|
ActiveLib
|
#include <BufferIn.h>


Public Member Functions | |
| BufferIn (const file::File &sourceFile, DataFormat::Option format=DataFormat{}) | |
| BufferIn (const Memory &sourceMem, DataFormat::Option format=DataFormat{}) | |
| BufferIn (const String &sourceString, DataFormat::Option format=DataFormat{}) | |
| BufferIn (BufferIn &&source) noexcept | |
| BufferIn (const BufferIn &)=delete | |
| No copy constructor. | |
| BufferIn & | operator= (BufferIn &&source) noexcept |
| BufferIn & | operator= (const BufferIn &)=delete |
| operator bool () const | |
| const BufferIn & | operator>> (String &str) const |
| const BufferIn & | operator>> (int16_t &val) const |
| const BufferIn & | operator>> (int32_t &val) const |
| const BufferIn & | operator>> (uint32_t &val) const |
| const BufferIn & | operator>> (int64_t &val) const |
| const BufferIn & | operator>> (uint64_t &val) const |
| const BufferIn & | operator>> (double &val) const |
| const char * | data () const |
| Memory::size_type | dataSize () const |
| Memory::size_type | sourceSize () const |
| Memory::size_type | getLastRow () const |
| Memory::size_type | getLastColumn () const |
| Memory::size_type | getPosition () const |
| TextEncoding | textEncoding () const |
| void | forEach (const String::Function &func, String *pool=nullptr) const |
| bool | findIf (const String::Filter &filter, String *pool=nullptr, bool isFoundSkipped=false) const |
| bool | find (char32_t toFind, String *pool=nullptr, bool isFoundSkipped=false) const |
| bool | find (const String &toFind, String *pool=nullptr, bool isFoundSkipped=false) const |
| bool | findFirstOf (const String &toFind, String *pool=nullptr, bool isContiguousMatch=false, bool isRepeatMatch=false, bool isFoundSkipped=false, bool isFoundPooled=false, std::optional< char32_t > escapeChar=std::nullopt) const |
| bool | findFirstNotOf (const String &toFind, String *pool=nullptr, std::optional< char32_t > escapeChar=std::nullopt) const |
| const BufferIn & | get (unsigned char &dest) const |
| Memory::size_type | getEncodedChar (String &encodedChar, bool isConsumed=true) const |
| std::pair< char32_t, String::size_type > | getEncodedChar (bool isConsumed=true) const |
| const BufferIn & | get (String &dest) const |
| const BufferIn & | read (char *dest, Memory::size_type &howMany) const |
| String | readWord (const String &division=String::allWhiteSpace) const |
| std::vector< String > | readWords (Memory::sizeOption howMany=std::nullopt, const String &division=String::allWhiteSpace) const |
| template<class T > | |
| const BufferIn & | getValue (T &val) const |
| const BufferIn & | getString (String &dest, String::sizeOption howMany=std::nullopt) const |
| const BufferIn & | getLine (String &line, bool keepStop=true) const |
| const BufferIn & | skip (Memory::size_type howMany) const |
| const BufferIn & | rewind (Memory::size_type howMany) const |
| void | setPosition (Memory::size_type pos) const |
| void | swap (BufferIn &other) |
| void | setFormat (DataFormat format) |
| void | setSourceEncoding (TextEncoding encoding) |
| void | setSource (const file::File &sourceFile, DataFormat::Option format=DataFormat{}) |
| void | setSource (const Memory &sourceMem, DataFormat::Option format=DataFormat{}) |
| void | setSource (const String &sourceString, DataFormat::Option format=DataFormat{}) |
Public Member Functions inherited from active::file::IOBase | |
| IOBase () noexcept | |
| IOBase (const IOBase &source) noexcept | |
| virtual | ~IOBase () noexcept=default |
| bool | operator! () const noexcept |
| operator void * () const noexcept | |
| virtual bool | good () const noexcept |
| virtual bool | eof () const noexcept |
| virtual bool | fail () const noexcept |
| virtual bool | bad () const noexcept |
| virtual flag_type | state () const noexcept |
| virtual void | clear (flag_type f=std::ios_base::goodbit) |
| virtual void | setState (flag_type f) |
| virtual void | unsetState (flag_type f) |
Additional Inherited Members | |
Public Types inherited from active::file::IOBase | |
| using | flag_type = std::ios_base::iostate |
| The state flag representation type. | |
Protected Member Functions inherited from active::file::IOBase | |
| void | setCompleteState (flag_type state) |
| void | clear (flag_type f=std::ios_base::goodbit) const |
| void | setState (flag_type f) const |
| virtual void | unsetState (flag_type f) const |
Class to buffer incoming data from a specified source
| BufferIn::BufferIn | ( | const file::File & | sourceFile, |
| DataFormat::Option | format = DataFormat{} ) |
Constructor
| sourceFile | The source data file. NB: The buffer does not take ownership of this object - must be maintained for the buffer |
| format | The source data format (nullopt = attempt to discover format from source) |

| BufferIn::BufferIn | ( | const Memory & | sourceMem, |
| DataFormat::Option | format = DataFormat{} ) |
Constructor
| sourceMem | A source block of memory. NB: The buffer does not take ownership of this object - must be maintained for the buffer |
| format | The source data format (nullopt = attempt to discover format from source) |

| BufferIn::BufferIn | ( | const String & | sourceString, |
| DataFormat::Option | format = DataFormat{} ) |
Constructor
| sourceString | The source data string. NB: The buffer does not take ownership of this object - must be maintained for the buffer |
| format | The source data format (nullopt = attempt to discover format from source) |

|
noexcept |
Move constructor
| source | The object to move |
|
inline |
Get a pointer to the raw buffer data (NB: only intended for low-level APIs that require pointer/length buffering - avoid otherwise)

|
inline |
Get the number of bytes remaining in the buffer


| bool BufferIn::find | ( | char32_t | toFind, |
| String * | pool = nullptr, | ||
| bool | isFoundSkipped = false ) const |
Find a specified character in the buffered content (skipping over all all non-matching data)
| toFind | The character to find (UTF-32) |
| pool | Optional string to collect the skipped characters (nullptr = discard) |
| isFoundSkipped | True if the buffer read position should skip over the found byte |


|
inline |
Find a specified string in the buffered content (skipping over all all non-matching data)
| toFind | The string to find (UTF-32) |
| pool | Optional string to collect the skipped characters (nullptr = discard) |
| isFoundSkipped | True if the buffer read position should skip over the found string |
|
inline |
Find the first character not matching a specified set (so it will be the next character read)
| toFind | A string containing the character(s) to skip |
| pool | Optional string to collect the skipped characters (nullptr = discard) |
| escapeChar | An optional escape char signifying the next character is escaped |

|
inline |
Find the first character from a specified string in the buffered content (skipping over all all non-matching data)
| toFind | A string containing the character(s) to find |
| pool | Optional pool string to collect the skipped characters (nullptr = discard) |
| isContiguousMatch | True if contiguous matching characters should be found, e.g. any grouping of CR and LF chars |
| isRepeatMatch | Used when isContiguousMatch = true; true to match found chars multiple times (e.g. all contiguous white-chars) |
| isFoundSkipped | True if the buffer read position should skip over the found character |
| isFoundPooled | True to add found character(s) to the pool string (ignored if isFoundSkipped = false) |
| escapeChar | An optional escape char signifying the next character is escaped |

| bool BufferIn::findIf | ( | const String::Filter & | filter, |
| String * | pool = nullptr, | ||
| bool | isFoundSkipped = false ) const |
Find the specified string within this using a filter
| filter | The string filter |
| pool | Optional string to collect the skipped characters (nullptr = discard) |
| isFoundSkipped | True if the buffer read position should skip over the found byte |


| void BufferIn::forEach | ( | const String::Function & | func, |
| String * | pool = nullptr ) const |
Apply a function to the buffered characters
| func | The character function |
| pool | Optional string to collect the values returned from the function (nullptr = discard) |


Get a single char in a string (supporting multi-byte chars)
| dest | The incoming char (supporting unicode) |

| const BufferIn & BufferIn::get | ( | unsigned char & | dest | ) | const |
Get a single char
| dest | The incoming char |

| std::pair< char32_t, Memory::size_type > BufferIn::getEncodedChar | ( | bool | isConsumed = true | ) | const |
Get the next character from the buffer as a UTF32 char
| isConsumed | True to consume the character bytes from the buffer |

| Memory::size_type BufferIn::getEncodedChar | ( | String & | encodedChar, |
| bool | isConsumed = true ) const |
Get the next character from the buffer, encoding as necessary
| encodedChar | The next encoded character (empty on failure) |
| isConsumed | True to consume the character bytes from the buffer |


|
inline |
Get the current column position
|
inline |
Get the current row position
Get a single line (terminating at any known line ending)
| line | The incoming line |
| keepStop | True to keep the line terminator(s) |
| Memory::size_type BufferIn::getPosition | ( | ) | const |
Get the current read position in the source data (not the read position in the buffer)


| const BufferIn & BufferIn::getString | ( | String & | dest, |
| String::sizeOption | howMany = std::nullopt ) const |
Get a string of a specified number of characters
| dest | The incoming string |
| howMany | The number of whole characters to get (nullopt to read all) |

|
inline |
Get a value of a specified type from a buffer
| val | The value to read |


|
inline |
Bool operator

Assignment with move operator
| source | The object to move |
| const BufferIn & BufferIn::operator>> | ( | double & | val | ) | const |
Read operator
| val | A double to read |

|
inline |
Read operator
| val | A 16-bit integer to read |

|
inline |
Read operator
| val | A 32-bit integer to read |

|
inline |
Read operator
| val | A 64-bit integer to read |

Read operator (the next word)
| str | A string to read |

|
inline |
Read operator
| val | An unsigned 32-bit integer to read |

|
inline |
Read operator
| val | An unsigned 64-bit integer to read |

| const BufferIn & BufferIn::read | ( | char * | dest, |
| Memory::size_type & | howMany ) const |
Read a stream of bytes
| dest | The data destination |
| howMany | The number of bytes to read (contains the number of bytes actually read on return) |


| String BufferIn::readWord | ( | const String & | division = String::allWhiteSpace | ) | const |
Read a word (starting from the first non-dividing character and up to next dividing character)
| division | The dividing character(s) |


| std::vector< String > BufferIn::readWords | ( | Memory::sizeOption | howMany = std::nullopt, |
| const String & | division = String::allWhiteSpace ) const |
Read multiple words from the buffer
| howMany | Optional limit on the number of words to read (nullopt = to end of buffer) |
| division | The dividing character(s) |


| const BufferIn & BufferIn::rewind | ( | Memory::size_type | howMany | ) | const |
Rewind a specified number of bytes backward in the input source
| howMany | The number of bytes to rewind back |


|
inline |
Set The source text encoding
| format | The source data format |
| void BufferIn::setPosition | ( | Memory::size_type | pos | ) | const |
Set the current read position in the source data (not the read position in the buffer)
| pos | The read position (e.g. the read position in a source file) |


| void BufferIn::setSource | ( | const file::File & | sourceFile, |
| DataFormat::Option | format = DataFormat{} ) |
Set the data source
| sourceFile | The source data file. NB: The buffer does not take ownership of this object - must be maintained for the buffer |
| format | The source data format (nullopt = discover format from source) |

| void BufferIn::setSource | ( | const Memory & | sourceMem, |
| DataFormat::Option | format = DataFormat{} ) |
Set the data source
| sourceMem | A source block of memory. NB: The buffer does not take ownership of this object - must be maintained for the buffer |
| format | The source data format (nullopt = discover format from source) |

| void BufferIn::setSource | ( | const String & | sourceString, |
| DataFormat::Option | format = DataFormat{} ) |
Set the data source
| sourceString | The source data string. NB: The buffer does not take ownership of this object - must be maintained for the buffer |
| format | The source data format (nullopt = discover format from source) |

|
inline |
Set the source encoding type
| encoding | The source encoding type |
| const BufferIn & BufferIn::skip | ( | Memory::size_type | howMany | ) | const |
Skip a specified number of bytes forward in the input source
| howMany | The number of bytes to skip forward |

| Memory::size_type BufferIn::sourceSize | ( | ) | const |
Get the total number of bytes in the source, e.g. the source file/string/memory


| void BufferIn::swap | ( | BufferIn & | other | ) |
Swap this buffer with another
| other | The buffer to swap with this |
|
inline |
Get The source text encoding (NB: for text input functionality only)