summaryrefslogtreecommitdiff
path: root/src/common/io.hpp
blob: 1831651feff97122904db0a86c3af608952dad24 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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