Struct GenericInsituStringStream

Synopsis

#include <include/rapidjson/stream.h>

template <typename Encoding>
struct GenericInsituStringStream

Description

A read-write string stream.

This string stream is particularly designed for in-situ parsing.

Note
implements Stream concept

Methods

GenericInsituStringStream
Flush
Peek
Pop
Push
Put
PutBegin
PutEnd
Take
Tell

Source

Lines 187-211 in include/rapidjson/stream.h.

template <typename Encoding>
struct GenericInsituStringStream {
    typedef typename Encoding::Ch Ch;

    GenericInsituStringStream(Ch *src) : src_(src), dst_(0), head_(src) {}

    // Read
    Ch Peek() { return *src_; }
    Ch Take() { return *src_++; }
    size_t Tell() { return static_cast<size_t>(src_ - head_); }

    // Write
    void Put(Ch c) { RAPIDJSON_ASSERT(dst_ != 0); *dst_++ = c; }

    Ch* PutBegin() { return dst_ = src_; }
    size_t PutEnd(Ch* begin) { return static_cast<size_t>(dst_ - begin); }
    void Flush() {}

    Ch* Push(size_t count) { Ch* begin = dst_; dst_ += count; return begin; }
    void Pop(size_t count) { dst_ -= count; }

    Ch* src_;
    Ch* dst_;
    Ch* head_;
};





Add Discussion as Guest

Log in