| 1 |
#include <fstream> |
| 2 |
#include <string> |
| 3 |
#include <vector> |
| 4 |
#include <iostream> |
| 5 |
|
| 6 |
//LINES |
| 7 |
class Lines |
| 8 |
{ |
| 9 |
std::vector<std::string> d_line; |
| 10 |
|
| 11 |
public: |
| 12 |
class Proxy; |
| 13 |
Proxy operator[](size_t idx); |
| 14 |
class Proxy |
| 15 |
{ |
| 16 |
friend Proxy Lines::operator[](size_t idx); |
| 17 |
std::string &d_str; |
| 18 |
Proxy(std::string &str); |
| 19 |
public: |
| 20 |
std::string &operator=(std::string const &rhs); |
| 21 |
operator std::string const &() const; |
| 22 |
}; |
| 23 |
Lines(std::istream &in); |
| 24 |
}; |
| 25 |
//= |
| 26 |
|
| 27 |
//MEMBERS |
| 28 |
inline Lines::Proxy::Proxy(std::string &str) |
| 29 |
: |
| 30 |
d_str(str) |
| 31 |
{} |
| 32 |
inline std::string &Lines::Proxy::operator=(std::string const &rhs) |
| 33 |
{ |
| 34 |
return d_str = rhs; |
| 35 |
} |
| 36 |
inline Lines::Proxy::operator std::string const &() const |
| 37 |
{ |
| 38 |
return d_str; |
| 39 |
} |
| 40 |
//= |
| 41 |
|
| 42 |
//INSERT |
| 43 |
inline std::ostream &operator<<(std::ostream &out, Lines::Proxy const &proxy) |
| 44 |
{ |
| 45 |
return out << static_cast<std::string const &>(proxy); |
| 46 |
} |
| 47 |
//= |
| 48 |
|
| 49 |
//OPIDX |
| 50 |
inline Lines::Proxy Lines::operator[](size_t idx) |
| 51 |
{ |
| 52 |
Proxy ret(d_line[idx]); |
| 53 |
return ret; |
| 54 |
} |
| 55 |
//= |