MistServer  2.5.3-Pro-19-gf5e75b1 ( Generic_64)
Public Member Functions | Private Attributes
DTSC::Scan Class Reference

This class allows scanning through raw binary format DTSC data. More...

#include <dtsc.h>

Public Member Functions

 Scan ()
 Create an invalid DTSC::Scan object by default. More...
 
 Scan ()
 
 Scan (char *pointer, size_t len)
 Create a DTSC::Scan object from memory pointer. More...
 
 Scan (char *pointer, size_t len)
 
bool asBool ()
 
bool asBool ()
 Returns the boolean value of this DTSC value. More...
 
long long asInt ()
 
long long asInt ()
 Returns the long long value of this DTSC number value. More...
 
JSON::Value asJSON ()
 Returns the DTSC scan object as a JSON value Returns an empty object on error. More...
 
JSON::Value asJSON ()
 
std::string asString ()
 
std::string asString ()
 Returns the string value of this DTSC string value. More...
 
Scan getIndice (unsigned int num)
 Returns an object representing the num-th indice of this array. More...
 
Scan getIndice (unsigned int num)
 
std::string getIndiceName (unsigned int num)
 Returns the name of the num-th member of this object. More...
 
std::string getIndiceName (unsigned int num)
 
Scan getMember (std::string indice)
 
Scan getMember (std::string indice)
 Returns an object representing the named indice of this object. More...
 
Scan getMember (const char *indice)
 Returns an object representing the named indice of this object. More...
 
Scan getMember (const char *indice)
 
Scan getMember (const char *indice, const unsigned int ind_len)
 
Scan getMember (const char *indice, const unsigned int ind_len)
 Returns an object representing the named indice of this object. More...
 
unsigned int getSize ()
 Returns the amount of indices if an array, the amount of members if an object, or zero otherwise. More...
 
unsigned int getSize ()
 
void getString (char *&result, unsigned int &len)
 Sets result to a pointer to the string, and strlen to the length of it. More...
 
void getString (char *&result, unsigned int &len)
 
char getType ()
 
char getType ()
 Returns the first byte of this DTSC value, or 0 on error. More...
 
bool hasMember (std::string indice)
 
bool hasMember (std::string indice)
 Returns an object representing the named indice of this object. More...
 
bool hasMember (const char *indice, const unsigned int ind_len)
 Returns whether an object representing the named indice of this object exists. More...
 
bool hasMember (const char *indice, const unsigned int ind_len)
 
 operator bool () const
 
 operator bool () const
 Returns whether the DTSC::Scan object contains valid data. More...
 
std::string toPrettyString (unsigned int indent=0)
 
std::string toPrettyString (unsigned int indent=0)
 

Private Attributes

size_t len
 
char * p
 

Detailed Description

This class allows scanning through raw binary format DTSC data.

It can be used as an iterator or as a direct accessor.

Constructor & Destructor Documentation

DTSC::Scan::Scan ( )

Create an invalid DTSC::Scan object by default.

DTSC::Scan::Scan ( char *  pointer,
size_t  len 
)

Create a DTSC::Scan object from memory pointer.

DTSC::Scan::Scan ( )
DTSC::Scan::Scan ( char *  pointer,
size_t  len 
)

Member Function Documentation

bool DTSC::Scan::asBool ( )

Returns the boolean value of this DTSC value.

Numbers are compared to 0. Strings are checked for non-zero length. Objects and arrays are checked for content. Returns false on error or in other cases.

bool DTSC::Scan::asBool ( )
long long DTSC::Scan::asInt ( )

Returns the long long value of this DTSC number value.

Will convert string values to numbers, taking octal and hexadecimal types into account. Illegal or invalid values return 0.

long long DTSC::Scan::asInt ( )
JSON::Value DTSC::Scan::asJSON ( )

Returns the DTSC scan object as a JSON value Returns an empty object on error.

JSON::Value DTSC::Scan::asJSON ( )
std::string DTSC::Scan::asString ( )

Returns the string value of this DTSC string value.

Uses getString internally, if a string. Converts integer values to strings. Returns an empty string on error.

std::string DTSC::Scan::asString ( )
Scan DTSC::Scan::getIndice ( unsigned int  num)

Returns an object representing the num-th indice of this array.

If not an array but an object, it returns the num-th member, instead. Returns an invalid object if this indice doesn't exist or this isn't an array or object type.

Scan DTSC::Scan::getIndice ( unsigned int  num)
std::string DTSC::Scan::getIndiceName ( unsigned int  num)

Returns the name of the num-th member of this object.

Returns an empty string on error or when not an object.

std::string DTSC::Scan::getIndiceName ( unsigned int  num)
Scan DTSC::Scan::getMember ( std::string  indice)

Returns an object representing the named indice of this object.

Returns an invalid object if this indice doesn't exist or this isn't an object type.

Scan DTSC::Scan::getMember ( std::string  indice)
Scan DTSC::Scan::getMember ( const char *  indice)
Scan DTSC::Scan::getMember ( const char *  indice)

Returns an object representing the named indice of this object.

Returns an invalid object if this indice doesn't exist or this isn't an object type.

Scan DTSC::Scan::getMember ( const char *  indice,
const unsigned int  ind_len 
)
Scan DTSC::Scan::getMember ( const char *  indice,
const unsigned int  ind_len 
)

Returns an object representing the named indice of this object.

Returns an invalid object if this indice doesn't exist or this isn't an object type.

unsigned int DTSC::Scan::getSize ( )

Returns the amount of indices if an array, the amount of members if an object, or zero otherwise.

unsigned int DTSC::Scan::getSize ( )
void DTSC::Scan::getString ( char *&  result,
unsigned int &  len 
)
void DTSC::Scan::getString ( char *&  result,
unsigned int &  strlen 
)

Sets result to a pointer to the string, and strlen to the length of it.

Sets both to zero if this isn't a DTSC string value. Attempts absolutely no conversion.

char DTSC::Scan::getType ( )

Returns the first byte of this DTSC value, or 0 on error.

char DTSC::Scan::getType ( )
bool DTSC::Scan::hasMember ( std::string  indice)
bool DTSC::Scan::hasMember ( std::string  indice)

Returns an object representing the named indice of this object.

Returns an invalid object if this indice doesn't exist or this isn't an object type.

bool DTSC::Scan::hasMember ( const char *  indice,
const unsigned int  ind_len 
)
bool DTSC::Scan::hasMember ( const char *  indice,
const unsigned int  ind_len 
)

Returns whether an object representing the named indice of this object exists.

Returns false if this indice doesn't exist or this isn't an object type.

DTSC::Scan::operator bool ( ) const
DTSC::Scan::operator bool ( ) const

Returns whether the DTSC::Scan object contains valid data.

std::string DTSC::Scan::toPrettyString ( unsigned int  indent = 0)
std::string DTSC::Scan::toPrettyString ( unsigned int  indent = 0)

Field Documentation

size_t DTSC::Scan::len
private
char * DTSC::Scan::p
private

The documentation for this class was generated from the following files: