Main Page | Class Hierarchy | Compound List | File List | Compound Members

BxString Class Reference

Class implementing the BinX data type string. More...

#include <BxString.h>

Inheritance diagram for BxString:

BxDataObject BxObject List of all members.

Public Member Functions

 BxString ()
 BxString (const char *str, int size)
 BxString (const char *str, BxInteger *sizeObj)
 BxString (const char *str)
 BxString (const BxString &copy)
char * toString (bool xml)
bool toStream (FILE *)
bool toStreamBinary (FILE *)
void setDelimiter (const char *s)
char * getDelims () const

Detailed Description

Instances of this class hold and perform operations on the BinX XML Schema type <string>.

There are three types of strings.

  1. Fixed-length string
  2. Variable-length string
  3. Delimited string

Examples:

The size() function returns the number of bytes.


Since: BinX version 1.1.


Constructor & Destructor Documentation

BxString::BxString  ) 
 

Default constructor.

Constructs and initialises an instance of the class BxString.

BxString::BxString const char *  str,
int  size
 

Construct a fixed-length BxString instance and assign it a string.

Constructs and initialises an instance of the class BxString. The length of the new string is either, the size of the string str if it is less than the parameter size, or the string is truncated to the parameter size.

Parameters:
str A char* string to initialise the new BxString object.
size specifies the number of bytes for the fixed-length string.

BxString::BxString const char *  str,
BxInteger sizeObj
 

Construct a variable-length BxString instance and assign it a string.

Constructs and initialises an instance of the class BxString. The length of the new string is either, the size of the string str if it is less than the parameter sizeObj, or the string is truncated to the parameter sizeObj.

Parameters:
str A char* string to initialise the new BxString object.
sizeObj specifies the number data object to specify the length of the string.

BxString::BxString const char *  str  ) 
 

Construct a BxString instance and assign it a specified C string (ASCII).

Constructs and initialises an instance of the class BxString.

Parameters:
str A char* string to initialise the new BxString object.

BxString::BxString const BxString copy  ) 
 

Construct a BxString instance by copying a specified BxString instance.

Constructs and initialises an instance of the class BxString.

Parameters:
copy A reference to the BxString instance to copy.


Member Function Documentation

char * BxString::getDelims  )  const
 

Return the delimiter as a string.

The ASCII character that terminates the string can be specified in three ways:

  • By an escaped character (e.g. "\n").
  • By a number between 0 - 255 preceded by the '#' character representing an ASCII char.
  • By a XML escaped character representing an ASCII char (e.g. "&gt;" for the character '>').
The return string will be for example ' '..'~' or #0..#31, #128..#255. The returned string needs to be released by the caller.
Returns:
string allocated to hold the string.

void BxString::setDelimiter const char *  s  ) 
 

Set the delimiter for the delimited string.

The delimiter is a string representing one-character. The ASCII character that terminates the string can be specified in three ways:

  • By an escaped character (e.g. "\n").
  • By a number between 0 - 255 preceded by the '#' character representing an ASCII char.
  • By a XML escaped character representing an ASCII char (e.g. "&gt;" for the character '>').
Example:
       #0-#255, ' '..'~', '\0','\a','\b','\f','\t','\n','\r','\1'..'\255',
       (number values for these, same as #1-#255),
       '\a'..'\~' are the same as 'a'..'~'.
   

Parameters:
s contains the string for delimiter.

bool BxString::toStream FILE *  stream  )  [virtual]
 

Save the XML element containing the string in the given file.

Example:

       <string>aaaa</string>
   
Parameters:
stream the file to save the string
Returns:
true if successful

Reimplemented from BxDataObject.

bool BxString::toStreamBinary FILE *  stream  )  [virtual]
 

Save the string in a binary file.

A fixed-length string is saved in exactly the number of bytes given in sizeInBytes_. Variable-length strings are saved after the sizeObject is saved. Delimited strings are saved followed by the delimiter.

Parameters:
stream the file handler to save the string.
Returns:
true if successful

Reimplemented from BxDataObject.

char * BxString::toString bool  xml  )  [virtual]
 

Return a string containing the DataBinX XML element (or printable value only ) for the value of this BxString object.

The DataBinx representation of a BxString object value consists of:

  • The BinX XML tags, <string> and </string>
  • Attributes for the string element;
  • The string data value of this object

Example Return Result:
  • <string size="10">a c d b</string>
  • <string sizeType="byte-8">a c d b</string>
  • <string delim="#10">a c d b</string>

This method allocates memory to hold the returned string. The caller is responsible for releasing the memory when the string is no longer needed.
If the BinX XML tags are not required, then the input boolean flag can be used to request that only the converted binary data value be included in the result string.
Only BinX primitive data types implement this method.
Parameters:
xml A boolean indicating whether to include BinX XML tags or not.
Returns:
A string buffer containing the DataBinX representation of the value of this object, if the input flag is true,
A string buffer containing the printable representation of the value of this object, if the input flag is false.

Reimplemented from BxDataObject.


The documentation for this class was generated from the following files:
Generated on Fri May 6 13:36:19 2005 for edikt::BinX by doxygen 1.3.3