Base Framework
Public Member Functions | Protected Attributes | List of all members
StringInputStream Class Reference

Input stream with string source. More...

#include <base/string/StringInputStream.h>

Inherits InputStream, and String.

Public Member Functions

 StringInputStream (String &string)
 
unsigned int available () const
 
void close ()
 
unsigned int read (uint8 *buffer, unsigned int size, bool nonblocking)
 
unsigned int skip (unsigned int count)
 
 ~StringInputStream ()
 
- Public Member Functions inherited from InputStream
virtual void wait () const =0
 
virtual bool wait (unsigned int timeout) const =0
 
- Public Member Functions inherited from Stream
virtual ~Stream () noexcept(false)
 
- Public Member Functions inherited from ReferenceCountedObject
 ReferenceCountedObject () noexcept
 
 ReferenceCountedObject (const ReferenceCountedObject &copy) noexcept
 
 ReferenceCountedObject (ReferenceCountedObject &&move) noexcept
 
ReferenceCountedObjectoperator= (const ReferenceCountedObject &copy) noexcept
 
ReferenceCountedObjectoperator= (ReferenceCountedObject &&move) noexcept
 
MemorySize getNumberOfReferences_INTERNAL () const noexcept
 
virtual bool useGarbageCollector () const noexcept
 
- Public Member Functions inherited from DynamicObject
 DynamicObject () noexcept
 
bool isValidObject () const noexcept
 
virtual ~DynamicObject () noexcept(false)
 
 _COM_AZURE_DEV__BASE__OVERRIDE_ALLOC ()
 

Protected Attributes

Stringstring
 
unsigned int index = 0
 
bool eof = false
 
bool closed = false
 

Additional Inherited Members

- Protected Types inherited from String
typedef CharTraits Traits
 
typedef ReferenceCountedAllocator< char >::Iterator Iterator
 
typedef ReferenceCountedAllocator< char >::ReadIterator ReadIterator
 
typedef ReferenceCountedAllocator< char >::Enumerator Enumerator
 
typedef ReferenceCountedAllocator< char >::ReadEnumerator ReadEnumerator
 
- Protected Member Functions inherited from String
void initialize (const char *string, MemorySize length)
 
void initialize (const wchar *string, MemorySize length)
 
void initialize (const char16_t *string, MemorySize length)
 
void initialize (const ucs4 *string, MemorySize length)
 
char * getBuffer ()
 
char * getBuffer (MemorySize length)
 
const char * getBuffer () const noexcept
 
void setLength (MemorySize length)
 
 String () noexcept
 
 String (Reference< ReferenceCountedAllocator< char > > string)
 
 String (MemorySize capacity)
 
 String (Default d)
 
 String (const UTF8Stringify &stringify)
 
 String (const OwnedNativeString &string)
 
 String (const NativeString &string)
 
 String (const Literal &string)
 
 String (const char *string)
 
 String (const char *string, MemorySize length)
 
 String (const wchar *string)
 
 String (const wchar *string, MemorySize length)
 
 String (const char16_t *string)
 
 String (const char16_t *string, MemorySize length)
 
 String (const char32_t *string)
 
 String (const char32_t *string, MemorySize length)
 
 String (const WideString &string)
 
 String (const NativeString &string, MemorySize maximum)
 
 String (const String &copy) noexcept
 
 String (String &&move) noexcept
 
 String (StringOutputStream &stream)
 
 String (FormatOutputStream &stream)
 
Stringoperator= (const String &assign) noexcept
 
Stringoperator= (String &&move) noexcept
 
Stringoperator= (const Literal &assign)
 
Stringoperator= (const WideLiteral &assign)
 
Stringoperator= (const NativeString &assign)
 
Stringoperator= (const char *assign)
 
Stringoperator= (const wchar *assign)
 
Stringoperator= (const char16_t *assign)
 
Stringoperator= (const char32_t *assign)
 
Stringoperator= (const WideString &assign)
 
Stringoperator= (const StringOutputStream &assign)
 
template<MemorySize SIZE>
Stringoperator= (const char(&literal)[SIZE])
 
MemorySize getLength () const noexcept
 
bool isEmpty () const noexcept
 
bool isProper () const noexcept
 
bool isASCII () const noexcept
 
bool isMultiReferenced () const noexcept
 
MemorySize getCapacity () const noexcept
 
void ensureCapacity (MemorySize capacity)
 
void clear ()
 
String copy () const
 
void garbageCollect ()
 
void forceToLength (MemorySize length)
 
Iterator getBeginIterator () noexcept
 
Iterator getEndIterator () noexcept
 
ReadIterator getBeginReadIterator () const noexcept
 
ReadIterator getEndReadIterator () const noexcept
 
ReadIterator begin () const noexcept
 
ReadIterator end () const noexcept
 
Enumerator getEnumerator () noexcept
 
ReadEnumerator getReadEnumerator () const noexcept
 
String getValidUTF8 () const
 
UTF8Iterator getUTF8BeginReadIterator () const noexcept
 
UTF8Iterator getUTF8EndReadIterator () const noexcept
 
UTF8Enumerator getUTF8ReadEnumerator () const noexcept
 
UTF8String getUTF8String () const noexcept
 
char getAt (MemorySize index) const
 
void setAt (MemorySize index, char value)
 
Element operator[] (MemorySize index)
 
 operator bool () const noexcept
 
char operator[] (MemorySize index) const
 
Stringremove (MemorySize start, MemorySize end)
 
StringremoveFrom (MemorySize start)
 
StringremoveAt (MemorySize index)
 
Stringappend (char ch)
 
Stringappend (uint8 ch)
 
Stringappend (ucs4 ch)
 
Stringappend (const String &string)
 
Stringappend (const NativeString &string)
 
Stringappend (const char *string)
 
Stringappend (const Literal &string)
 
template<MemorySize SIZE>
Stringappend (const char(&literal)[SIZE])
 
Stringappend (const Literal &string, MemorySize maximum)
 
Stringappend (const NativeString &string, MemorySize maximum)
 
Stringappend (const ConstSpan< char > &buffer)
 
Stringprepend (char ch)
 
Stringprepend (const String &string)
 
Stringinsert (MemorySize index, const ConstSpan< char > &span)
 
Stringinsert (MemorySize index, char ch)
 
Stringinsert (MemorySize index, const String &string)
 
Stringinsert (MemorySize index, const Literal &string)
 
template<MemorySize SIZE>
Stringinsert (MemorySize index, const char(&literal)[SIZE])
 
Stringinsert (MemorySize index, const NativeString &string)
 
Stringreplace (MemorySize start, MemorySize end, const String &string)
 
MemorySize replaceAll (const String &fromStr, const String &toStr)
 
String substring (MemorySize start, MemorySize end) const
 
String substring (MemorySize start) const
 
Stringoperator+= (const String &suffix)
 
Stringoperator+= (const Literal &suffix)
 
Stringoperator+= (const char *suffix)
 
Stringoperator+= (char suffix)
 
Stringoperator-= (const String &suffix)
 
Stringreverse () noexcept
 
StringtoLowerCase () noexcept
 
StringtoUpperCase () noexcept
 
int compareTo (const String &string) const noexcept
 
int compareTo (const Literal &string) const noexcept
 
int compareTo (const NativeString &string) const noexcept
 
int compareToIgnoreCase (const String &string) const noexcept
 
int compareToIgnoreCase (const NativeString &string) const
 
template<MemorySize SIZE>
int compareToIgnoreCase (const char(&literal)[SIZE]) const noexcept
 
bool startsWith (const String &prefix) const noexcept
 
bool startsWith (const Literal &prefix) const noexcept
 
template<MemorySize SIZE>
bool startsWith (const char(&prefix)[SIZE]) const noexcept
 
bool endsWith (const String &suffix) const noexcept
 
bool endsWith (const Literal &suffix) const noexcept
 
template<MemorySize SIZE>
bool endsWith (const char(&suffix)[SIZE]) const noexcept
 
bool operator== (const String &string) const noexcept
 
bool operator== (const Literal &string) const noexcept
 
template<MemorySize SIZE>
bool operator== (const char(&literal)[SIZE]) const noexcept
 
bool operator!= (const String &string) const noexcept
 
bool operator!= (const Literal &string) const noexcept
 
template<MemorySize SIZE>
bool operator!= (const char(&literal)[SIZE]) const noexcept
 
bool operator< (const String &string) const noexcept
 
template<MemorySize SIZE>
bool operator< (const char(&literal)[SIZE]) const noexcept
 
bool operator<= (const String &string) const noexcept
 
template<MemorySize SIZE>
bool operator<= (const char(&literal)[SIZE]) const noexcept
 
bool operator>= (const String &string) const noexcept
 
template<MemorySize SIZE>
bool operator>= (const char(&literal)[SIZE]) const noexcept
 
bool operator> (const String &string) const noexcept
 
template<MemorySize SIZE>
bool operator> (const char(&literal)[SIZE]) const noexcept
 
bool operator== (const NativeString &string) const noexcept
 
bool operator!= (const NativeString &string) const noexcept
 
bool operator< (const NativeString &string) const noexcept
 
bool operator<= (const NativeString &string) const noexcept
 
bool operator>= (const NativeString &string) const noexcept
 
bool operator> (const NativeString &string) const noexcept
 
MemoryDiff indexOf (char ch, MemorySize start=0) const noexcept
 
MemoryDiff indexOf (const String &string, MemorySize start=0) const noexcept
 
MemoryDiff lastIndexOf (char ch, MemorySize start) const noexcept
 
MemoryDiff lastIndexOf (char ch) const noexcept
 
MemoryDiff lastIndexOf (const String &string, MemorySize start) const noexcept
 
MemoryDiff lastIndexOf (const String &string) const noexcept
 
MemorySize count (char ch, MemorySize start=0) const noexcept
 
MemorySize count (const String &string, MemorySize start=0) const noexcept
 
Stringtrim (char character=' ')
 
MemoryDiff search (const String &substring, MemorySize start=0) const noexcept
 
Array< Stringsplit (char separator, bool group=false) const
 
const Reference< ReferenceCountedAllocator< char > > & getContainer () const
 
char * getElements ()
 
bool invariant () const noexcept
 
const char * getElements () const noexcept
 
const char * getEnd () const noexcept
 
const uint8 * getBytes () const noexcept
 
bool hasNull () const noexcept
 
ConstSpan< char > getSpan () const noexcept
 
const char * native () const noexcept
 
template<typename... ARGS>
String operator() (ARGS &&... args)
 
- Static Protected Member Functions inherited from String
static int compareToIgnoreCase (const char *left, const char *right) noexcept
 
static String makeLength (MemorySize length)
 
static String makeCapacity (MemorySize capacity)
 
static ConstSpan< char > toSpan (const char *string) noexcept
 
static String substImpl (const UTF8Stringify &text, const UTF8Stringify *args, MemorySize numberOfArgs)
 
- Static Protected Attributes inherited from String
static const char TERMINATOR = '\0'
 
static const MemorySize MAXIMUM_LENGTH = PrimitiveTraits<int>::MAXIMUM - sizeof(TERMINATOR)
 

Detailed Description

Input stream with string source.

A string input stream is a input stream which receives its data from a string.

Version
1.0

Constructor & Destructor Documentation

◆ StringInputStream()

StringInputStream::StringInputStream ( String string)

Initializes the string input stream.

Parameters
stringThe string providing the data stream.

◆ ~StringInputStream()

StringInputStream::~StringInputStream ( )

Destroys the string input stream.

Member Function Documentation

◆ available()

unsigned int StringInputStream::available ( ) const
virtual

Returns the number of bytes that can be read or skipped over without blocking.

Returns
Available number of bytes in stream.

Implements InputStream.

◆ close()

void StringInputStream::close ( )
virtual

Closes the input stream and releases any system resources associated with the stream.

Implements Stream.

◆ read()

unsigned int StringInputStream::read ( uint8 *  buffer,
unsigned int  size,
bool  nonblocking 
)
virtual

Fills the buffer with bytes from the stream. Blocks if asked to read more bytes than available.

Parameters
bufferThe buffer.
sizeThe size of the buffer.

Implements InputStream.

◆ skip()

unsigned int StringInputStream::skip ( unsigned int  count)
virtual

Skips a specified number of bytes. Blocks if asked to skip more bytes than available.

Parameters
countThe number of bytes to skip.

Implements InputStream.

Member Data Documentation

◆ closed

bool StringInputStream::closed = false
protected

Specifies that the stream has been closed.

◆ eof

bool StringInputStream::eof = false
protected

Specifies that the end has been reached.

◆ index

unsigned int StringInputStream::index = 0
protected

The current position.

◆ string

String& StringInputStream::string
protected

String providing the data stream.