diff options
author | Ben Longbons <b.r.longbons@gmail.com> | 2013-06-29 23:23:43 -0700 |
---|---|---|
committer | Ben Longbons <b.r.longbons@gmail.com> | 2013-08-01 15:19:45 -0700 |
commit | 3b98f3439e33b15bba2036c402f9925340fdb2b9 (patch) | |
tree | f6a59330bb747d9cc64f5f83d06e7f76dc01d540 /src/common/io.hpp | |
parent | 8d1480c1be7c9741876d89008277a2b3629a4d01 (diff) | |
download | tmwa-3b98f3439e33b15bba2036c402f9925340fdb2b9.tar.gz tmwa-3b98f3439e33b15bba2036c402f9925340fdb2b9.tar.bz2 tmwa-3b98f3439e33b15bba2036c402f9925340fdb2b9.tar.xz tmwa-3b98f3439e33b15bba2036c402f9925340fdb2b9.zip |
Poison std::string and use the various string classes
Diffstat (limited to 'src/common/io.hpp')
-rw-r--r-- | src/common/io.hpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/common/io.hpp b/src/common/io.hpp new file mode 100644 index 0000000..1831651 --- /dev/null +++ b/src/common/io.hpp @@ -0,0 +1,26 @@ +#ifndef TMWA_COMMON_IO_HPP +#define TMWA_COMMON_IO_HPP + +#include <istream> +#include <ostream> + +#include "strings.hpp" + +namespace io +{ + inline + std::istream& getline(std::istream& in, FString& line) + { + std::string s; + if (std::getline(in, s)) + { + std::string::const_iterator begin = s.cbegin(), end = s.cend(); + if (begin != end && end[-1] == '\r') + --end; + line = FString(begin, end); + } + return in; + } +} // namespace io + +#endif //TMWA_COMMON_IO_HPP |