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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
#include <fstream>
#include <string>
#include <vector>
#include <iostream>
//LINES
class Lines
{
std::vector<std::string> d_line;
public:
class Proxy;
Proxy operator[](size_t idx);
class Proxy
{
friend Proxy Lines::operator[](size_t idx);
std::string &d_str;
Proxy(std::string &str);
public:
std::string &operator=(std::string const &rhs);
operator std::string const &() const;
};
Lines(std::istream &in);
};
//=
//MEMBERS
inline Lines::Proxy::Proxy(std::string &str)
:
d_str(str)
{}
inline std::string &Lines::Proxy::operator=(std::string const &rhs)
{
return d_str = rhs;
}
inline Lines::Proxy::operator std::string const &() const
{
return d_str;
}
//=
//INSERT
inline std::ostream &operator<<(std::ostream &out, Lines::Proxy const &proxy)
{
return out << static_cast<std::string const &>(proxy);
}
//=
//OPIDX
inline Lines::Proxy Lines::operator[](size_t idx)
{
Proxy ret(d_line[idx]);
return ret;
}
//=
|