|
| Reader () |
| Default Constructor. More...
|
|
virtual | ~Reader () |
| Destructor. More...
|
|
bool | Open (FILE *file, unsigned int encoding=0, LineEndMode mode=Text) |
| Wrap ANSI C FILE pointer This service is used to allow a developer to access a file open with fopen but with the advantage to use the SDK API. More...
|
|
bool | Open (HANDLE fileHandle, unsigned int encoding=0, LineEndMode mode=Text) |
| Wrap a Win32 file handle. More...
|
|
bool | Open (const MCHAR *fileName, unsigned int encoding=0, LineEndMode mode=Text) |
| Open a file using a file name. More...
|
|
bool | Open (const MaxSDK::Util::MaxString &fileName, unsigned int encoding=0, LineEndMode mode=Text) |
| Open a file using a file name. More...
|
|
void | Close () |
| Close the underlying stream and free any intermediate data. More...
|
|
MaxString | LastError () const |
| Returns the last error return by the BinaryStream. More...
|
|
unsigned int | Encoding () const |
| Returns the current encoding of this file. More...
|
|
LineEndMode | Mode () const |
| Determine how this reader handles line ending. More...
|
|
void | SetReadBufferSize (size_t readSize) |
| Set the read buffer size. More...
|
|
size_t | GetReadBufferSize () const |
| Returns the read buffer size. More...
|
|
void | SetDetectSize (size_t detectSize) |
| Set the default size of the buffer used to validate encoding. More...
|
|
size_t | GetDetectSize () const |
| Returns the detect buffer size. More...
|
|
size_t | NumberOfChars () const |
| Return the number of characters in the file. More...
|
|
size_t | NumberOfLines () const |
| Calculate the total number of line feeds in the file. More...
|
|
void | SetEOFCharacterHandling (EOFCharacterHandling) |
| Set the EOF character handling method and refilter the buffer. More...
|
|
EOFCharacterHandling | GetEOFCharacterHandling () const |
| Get the EOF character handling method. More...
|
|
virtual Char | ReadChar (bool peek=false) const |
| Reads a single char. More...
|
|
virtual unsigned int | ReadCharUTF32 (bool peek=false) const |
| Reads a single char and returns it's UTF32 representation. More...
|
|
virtual MaxString | ReadChars (size_t nchars) const |
| Reads characters from the file. More...
|
|
virtual MaxString | ReadLine (size_t nchars=(size_t) -1, bool dontReturnEOL=false) const |
| Reads a line from the file (or nchars, depending on which one comes first.) More...
|
|
virtual MaxString | ReadChunk (size_t len, bool dontReturnLastEOL=false) const |
| Reads up to "len" bytes from the file and convert it to a unicode-compliant string. More...
|
|
virtual MaxString | ReadFull () const |
| Reads the file in a single operation and returns it in a single string object. More...
|
|
virtual size_t | PositionBytes () const |
| Get the number of bytes read so far. More...
|
|
size_t | Position () const |
| Get the number of characters read so far. More...
|
|
size_t | LineNumber () const |
| Get the current line number. More...
|
|
virtual size_t | Seek (long offset, int origin) |
| Seek inside the stream. More...
|
|
virtual bool | IsEndOfFile () const |
| Returns true if file at the end. More...
|
|
virtual bool | IsFileOpen () const |
| Returns true if file is open. More...
|
|
virtual size_t | UnreadChar (const Char &c) |
| Unread a character. More...
|
|
virtual | ~BaseTextReader () |
|
|
static bool | Detect (void *data, size_t len, unsigned int &encoding, size_t *ignoreBytes) |
| Detect the encoding of the passed buffer. More...
|
|
static size_t | NumberOfChars (const void *data, size_t len, unsigned int encoding=CP_ACP) |
| Determine the number of chars inside a buffer. More...
|
|
static size_t | NumberOfLines (const void *data, size_t length, unsigned int encoding=CP_ACP) |
| Determine the number of line feeds inside a buffer. More...
|
|
template<typename ChType , ChType ch> |
static size_t | RemoveCharacter (ChType *data, size_t len) |
| Remove ch character from the passed buffer. More...
|
|
template<typename ChType , ChType ch> |
static size_t | TruncateAtCharacter (ChType *data, size_t len) |
| Truncate buffer at ch character. More...
|
|
static UtilExport void * | operator new (size_t size) |
| Standard new operator used to allocate objects If there is insufficient memory, an exception will be thrown. More...
|
|
static UtilExport void * | operator new (size_t size, const std::nothrow_t &e) |
| Standard new operator used to allocate objects if there is insufficient memory, NULL will be returned. More...
|
|
static UtilExport void * | operator new (size_t size, const char *filename, int line) |
| New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
|
|
static UtilExport void * | operator new (size_t size, int block_type, const char *filename, int line) |
| New operator used to allocate objects that takes the type of memory, filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
|
|
static UtilExport void * | operator new (size_t size, const std::nothrow_t &e, const char *filename, int line) |
| New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, NULL will be returned. More...
|
|
static UtilExport void * | operator new (size_t size, unsigned long flags) |
| New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, an exception will be thrown. More...
|
|
static UtilExport void * | operator new (size_t size, const std::nothrow_t &e, unsigned long flags) |
| New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, NULL will be returned. More...
|
|
static UtilExport void * | operator new[] (size_t size) |
| New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
|
|
static UtilExport void * | operator new[] (size_t size, const std::nothrow_t &e) |
| New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
|
|
static UtilExport void * | operator new[] (size_t size, const char *filename, int line) |
| New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
|
|
static UtilExport void * | operator new[] (size_t size, int block_type, const char *filename, int line) |
| New operator used to allocate arrays of objects. More...
|
|
static UtilExport void * | operator new[] (size_t size, const std::nothrow_t &e, const char *filename, int line) |
| New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
|
|
static UtilExport void * | operator new[] (size_t size, unsigned long flags) |
| New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
|
|
static UtilExport void * | operator new[] (size_t size, const std::nothrow_t &e, unsigned long flags) |
| New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
|
|
static UtilExport void | operator delete (void *ptr) |
| Standard delete operator used to deallocate an object If the pointer is invalid, an exception will be thrown. More...
|
|
static UtilExport void | operator delete (void *ptr, const std::nothrow_t &e) |
| Standard delete operator used to deallocate an object If the pointer is invalid, nothing will happen. More...
|
|
static UtilExport void | operator delete (void *ptr, const char *filename, int line) |
| Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
|
|
static UtilExport void | operator delete (void *ptr, int block_type, const char *filename, int line) |
| Delete operator used to deallocate an object that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
|
|
static UtilExport void | operator delete (void *ptr, const std::nothrow_t &e, const char *filename, int line) |
| Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
|
|
static UtilExport void | operator delete (void *ptr, unsigned long flags) |
| Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
|
|
static UtilExport void | operator delete (void *ptr, const std::nothrow_t &e, unsigned long flags) |
| Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, nothing will happen. More...
|
|
static UtilExport void | operator delete[] (void *ptr) |
| Standard delete operator used to deallocate an array of objects If the pointer is invalid, an exception will be thrown. More...
|
|
static UtilExport void | operator delete[] (void *ptr, const std::nothrow_t &e) |
| Standard delete operator used to deallocate an array of objects If the pointer is invalid, nothing will happen. More...
|
|
static UtilExport void | operator delete[] (void *ptr, const char *filename, int line) |
| Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
|
|
static UtilExport void | operator delete[] (void *ptr, int block_type, const char *filename, int line) |
| Delete operator used to deallocate an array of objects that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
|
|
static UtilExport void | operator delete[] (void *ptr, const std::nothrow_t &e, const char *filename, int line) |
| Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
|
|
static UtilExport void | operator delete[] (void *ptr, unsigned long flags) |
| Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
|
|
static UtilExport void | operator delete[] (void *ptr, const std::nothrow_t &e, unsigned long flags) |
| Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
|
|
static UtilExport void * | operator new (size_t size, void *placement_ptr) |
| Placement new operator. More...
|
|
static UtilExport void | operator delete (void *ptr, void *placement_ptr) |
| Placement delete operator. More...
|
|
static UtilExport void * | aligned_malloc (size_t size, size_t alignment) |
| Allocates memory on a specified alignment boundary. More...
|
|
static UtilExport void * | aligned_realloc (void *ptr, size_t size, size_t alignment) |
| Reallocates memory on a specified alignment boundary. More...
|
|
static UtilExport void | aligned_free (void *ptr) |
| Frees a block of memory that was allocated with aligned_malloc/aligned_realloc. More...
|
|
|
void | Detect (size_t len) const |
| Detect the opened file encoding by analyzing the first "len" bytes of the file. More...
|
|
size_t | FillBuffer (size_t len, bool force=false, bool binary=false, bool detecting_encoding=false) const |
| Read and cache len bytes from stream. More...
|
|
size_t | Filter (size_t pos) const |
| Apply the selected open mode on the internal cache buffer up to position. More...
|
|
size_t | Filter (size_t pos, bool processBufferBoundaryCRLF) const |
| Apply the selected open mode on the internal cache buffer up to position. More...
|
|
size_t | EnsureBufferContains (size_t len) const |
| Ensure buffer size can contains the passed length. More...
|
|
size_t | NumberOfChars (const void *data, size_t size) const |
| Return the number of characters in the passed buffer depending on the current encoding. More...
|
|
size_t | ConvertNumUTF8CharsToNumBytes (const char *data, size_t num) |
| Return the number of bytes corresponding to the num of UTF8 chars in passed buffer. More...
|
|
size_t | ConvertNumUTF16CharsToNumBytes (const MCHAR *data, size_t num) |
| Return the number of bytes corresponding to the num of UTF16 chars in passed buffer. More...
|
|
size_t | ConvertNumCharsToNumBytes (const char *data, size_t num, unsigned int encoding) |
| Return the number of bytes corresponding to the num of chars in passed buffer depending on the encoding. More...
|
|
size_t | NumberOfLines (const void *data, size_t size) const |
| Calculate the total number of line feeds in the passed buffer. More...
|
|
template<typename ChType , typename CharLengthFunctor , int maxCharLength> |
ChType * | ReadChar (size_t &charLengthT, bool peek, const CharLengthFunctor &CharLengthFunction) const |
| INTERNAL FUNCTION. More...
|
|
template<typename ChType > |
MaxString | MakeString (const ChType *data, size_t length, bool dontReturnEndingCRLF) const |
|
size_t | Unread (const MaxString &string) |
| Unread String. More...
|
|
size_t | SeekToEnd (long offset=0) |
| INTERNAL FUNCTION. More...
|
|
size_t | SeekToAbsolute (long offset) |
| Seek to an absolute point inside the text stream. More...
|
|
size_t | SeekFromCurrent (long offset) |
| Advance "offset" characters. More...
|
|
bool | Open (BinaryStream *stream, unsigned int encoding=0, LineEndMode mode=Text, bool closeOnDelete=false) |
| Open an abstract BinaryStream. More...
|
|
Reads and interprets text files.
This class was designed to perform file and stream I/O in a code page neutral way.
It was designed to perform resolve the following problems:
- Reads and interprets correctly the BOM (an invisible character at the beginning of unicode files.)
- Detect correctly UTF-8 and UTF-16 files. (even if it's not signed.)
- Detect encoding cookies. XML files usually begins with "<?xml encoding='????'>". The detection algorithm will interpret this directive correctly.
- Prevent from splitting a character. In UTF-16, UTF-8 and some ANSI codepage, characters can be stored on 1 to 6 bytes. All the operations of this object are designed to avoid to returns a partial character.
Plugin developer should consider using this class to perform File I/O to ensure that the files they generate remain compatible to previous version of Max.
- See also
- ReaderWriter class when file IO requirements are for reading and writing.