class Core::Portable::TextReader

Overview

A simple text stream reader. More…

#include <coresimplereader.h>

class TextReader
{
public:
    // typedefs

    typedef CStringBuffer<kMaxLineLength> LineString;
    typedef CString64 ValueString;

    // fields

    static const int kMaxLineLength = STRING_STACK_SPACE_MAX;

    // construction

    TextReader(IO::Stream& stream, bool rewind = true);

    // methods

    bool skipBOM();
    bool getNextLine(LineString& lineString) const;
    bool advanceToNextWord(CStringPtr word) const;
    bool getNextWord(ValueString& wordString, char delimiter = '\t') const;
    bool advanceToNextChar(char test) const;
    bool getValueForKey(ValueString& value, CStringPtr key) const;
    bool findValueForKey(ValueString& value, CStringPtr key) const;
    int64 getPosition() const;
    void setPosition(int64 pos);

    static void getValueForKey(
        ValueString& value,
        CStringPtr key,
        CStringPtr fileName
    );
};

Detailed Documentation

A simple text stream reader.

Methods

bool findValueForKey(ValueString& value, CStringPtr key) const

Like getValueForKey() but it’ll search the entire file (stream).

static void getValueForKey(
    ValueString& value,
    CStringPtr key,
    CStringPtr fileName
)

Given a filename and a key (ie.

“KEY=VALUE”), return a value string.