cosmopolitan/ctl/istringstream.h

42 lines
1 KiB
C
Raw Normal View History

2024-06-29 22:45:09 +00:00
// -*-mode:c++;indent-tabs-mode:nil;c-basic-offset:4;tab-width:8;coding:utf-8-*-
// vi: set et ft=cpp ts=4 sts=4 sw=4 fenc=utf-8 :vi
#ifndef CTL_ISTRINGSTREAM_H_
#define CTL_ISTRINGSTREAM_H_
#include "ios_base.h"
#include "string.h"
namespace ctl {
class istringstream : public ios_base
{
public:
istringstream();
2024-07-01 10:48:28 +00:00
explicit istringstream(const ctl::string_view&);
2024-06-29 22:45:09 +00:00
string str() const;
void str(const string&);
istringstream& operator>>(char&);
istringstream& operator>>(char*);
2024-07-01 10:48:28 +00:00
istringstream& operator>>(ctl::string&);
2024-06-29 22:45:09 +00:00
istringstream& operator>>(short&);
istringstream& operator>>(unsigned short&);
istringstream& operator>>(int&);
istringstream& operator>>(unsigned int&);
istringstream& operator>>(long&);
istringstream& operator>>(unsigned long&);
istringstream& operator>>(float&);
istringstream& operator>>(double&);
private:
2024-07-01 10:48:28 +00:00
ctl::string buffer_;
2024-06-29 22:45:09 +00:00
size_t read_pos_;
template<typename T>
istringstream& read_numeric(T&);
};
} // namespace ctl
#endif // CTL_ISTRINGSTREAM_H_