// Setting up file based container
// Read Only File class
#include
#include
#include
#include
class ro_file {
public:
ro_file(const std::string& name);
ro_file(const ro_file&);
ro_file& operator=(const ro_file&);
~ro_file();
public:
typedef char value_type;
typedef const char* pointer;
typedef const char* const_pointer;
typedef const char& reference;
typedef const char& const_reference;
typedef std::ptrdiff_t difference_type;
typedef std::size_t size_type;
typedef const char* iterator;
typedef const char* const_iterator;
typedef std::reverse_iterator
reverse_iterator;
typedef std::reverse_iterator
const_reverse_iterator;
const_iterator begin() const { return base; }
const_iterator end() const { return base + length; }
const_reverse_iterator rbegin() const
{ return const_reverse_iterator(end()); }
const_reverse_iterator rend() const
{ return const_reverse_iterator(begin()); }
const_reference operator[](size_type n) const {
return base[n];
}
const_reference at(size_type n) const {
if (n >= size())
// throw std::out_of_range("ro_file");
throw "out of range in ro_file";
return base[n];
}
size_type size() const { return length; }
size_type max_size() const { return length; }
bool empty() const { return size() != 0; }
void swap(ro_file&);
private:
std::string file;
char* base;
size_type length;
};
bool operator==(const ro_file&, const ro_file&);
bool operator<(const ro_file&, const ro_file&);
inline bool operator!=(const ro_file& x, const ro_file& y)
{ return !(x == y); }
inline bool operator> (const ro_file& x, const ro_file& y)
{ return y < x; }
inline bool operator<=(const ro_file& x, const ro_file& y)
{ return !(y < x); }
inline bool operator>=(const ro_file& x, const ro_file& y)
{ return !(x < y); }