8#ifndef Sawyer_Container_LineVector_H 
    9#define Sawyer_Container_LineVector_H 
   11#include <Sawyer/Buffer.h> 
   12#include <Sawyer/Sawyer.h> 
   15#include <boost/filesystem.hpp> 
   28    mutable std::vector<size_t> lineFeeds_;
 
   29    mutable size_t nextCharToScan_;
 
   33    LineVector(): charBuf_(NULL), bufSize_(0), nextCharToScan_(0) {}
 
   47    void load(
const boost::filesystem::path&);
 
   53    void load(
size_t nBytes, 
const char *buf);
 
   89        return charIdx >= 
nCharacters() ? EOF : (int)charBuf_[charIdx];
 
 
  137    std::pair<size_t, size_t> 
location(
size_t charIndex) 
const;
 
  154    void cacheLines(
size_t nLines) 
const;
 
 
SharedPointer< Buffer > Ptr
Reference counting smart pointer.
 
A buffer of characters indexed by line number.
 
size_t nCharacters() const
Number of characters.
 
std::string lineString(size_t lineIdx) const
Line as a string.
 
const char * lineChars(size_t lineIdx) const
Characters for a line.
 
int character(size_t lineIdx, size_t colIdx) const
Character at line offset.
 
void load(const Buffer< size_t, char >::Ptr &)
(Re)load a line vector from a buffer.)
 
const char * characters(size_t charIdx) const
Characters at file offset.
 
int character(size_t charIdx) const
Character at file offset.
 
LineVector(const boost::filesystem::path &)
Constructor that opens a file.
 
size_t nLines() const
Number of lines.
 
bool isEmpty() const
Determines whether the file is empty.
 
LineVector()
Constructor that creates an empty line vector.
 
std::string contentAsString(size_t begin, size_t end) const
Returns part of the buffer as a string.
 
std::pair< size_t, size_t > location(size_t charIndex) const
Convert a character index to a line and column index.
 
void load(size_t nBytes, const char *buf)
(Re)load a line vector from a string.)
 
size_t characterIndex(size_t lineIdx) const
Character index for start of line.
 
void load(const boost::filesystem::path &)
(Re)load a line vector from a file.
 
LineVector(const Buffer< size_t, char >::Ptr &)
Construct a line vector from a buffer.
 
size_t nCharacters(size_t lineIdx) const
Number of characters in a line.
 
LineVector(size_t nBytes, const char *buf)
Construct a line vector from a string.
 
bool isLastLineTerminated() const
Determines whether the file ends with line termination.
 
size_t lineIndex(size_t charIndex) const
Convert a character index to a line index.
 
Reference-counting intrusive smart pointer.