oaString Class Reference


Public Methods

 oaString ()
 oaString (oaUInt4 length)
 oaString (const oaChar *initialValue)
 oaString (const oaChar *initialValue, oaUInt4 length)
 oaString (const oaString &s)
 ~oaString ()
oaString & operator= (oaChar c)
oaString & operator= (const oaChar *str)
oaString & operator= (const oaString &str)
oaString & operator+= (oaChar c)
oaString & operator+= (const oaChar *str)
oaString & operator+= (const oaString &str)
oaBoolean operator< (const oaString &str) const
oaBoolean operator> (const oaString &str) const
oaBoolean operator== (const oaString &str) const
oaBoolean operator<= (const oaString &str) const
oaBoolean operator>= (const oaString &str) const
oaBoolean operator!= (const oaString &str) const
 operator const oaChar * () const
oaUInt4 getLength () const
oaBoolean isEmpty () const
oaDouble toDouble () const
int toInt () const
void toUpper ()
void toLower ()
void resize (oaUInt4 size)
oaUInt4 getSize () const
char & operator[] (oaUInt4 i)
const oaCharoperator[] (oaUInt4 i) const
oaUInt4 index (oaChar c, oaUInt4 offset=0) const
oaUInt4 substr (const oaString &sub, oaUInt4 offset=0) const
oaBoolean isEqual (const oaString &str, oaBoolean ignoreCase) const
void format (oaUInt4 size, const oaChar *formatStr,...)
void format (const oaChar *formatStr,...)
void format (const oaChar *formatStr, va_list args)

Friends

OA_BASE_DLL_API oaString operator+ (const oaString &s1, const oaString &s2)
OA_BASE_DLL_API oaBoolean operator< (const oaString &s1, const oaChar *s2)
OA_BASE_DLL_API oaBoolean operator< (const oaChar *s1, const oaString &s2)
OA_BASE_DLL_API oaBoolean operator> (const oaString &s1, const oaChar *s2)
OA_BASE_DLL_API oaBoolean operator> (const oaChar *s1, const oaString &s2)
OA_BASE_DLL_API oaBoolean operator== (const oaString &s1, const oaChar *s2)
OA_BASE_DLL_API oaBoolean operator== (const oaChar *s1, const oaString &s2)
OA_BASE_DLL_API oaBoolean operator<= (const oaString &s1, const oaChar *s2)
OA_BASE_DLL_API oaBoolean operator<= (const oaChar *s1, const oaString &s2)
OA_BASE_DLL_API oaBoolean operator>= (const oaString &s1, const oaChar *s2)
OA_BASE_DLL_API oaBoolean operator>= (const oaChar *s1, const oaString &s2)
OA_BASE_DLL_API oaBoolean operator!= (const oaString &s1, const oaChar *s2)
OA_BASE_DLL_API oaBoolean operator!= (const oaChar *s1, const oaString &s2)

Detailed Description

The oaString class is a utility class that is used to pass string arguments to and from OpenAccess functions. The oaString class is always constructed and destroyed by the caller and is passed by reference to OpenAccess functions. This calling style means that the lifetime of the string is determined by the caller. Callers are never given pointers to strings stored in an OpenAccess database.

An oaString supports many common operations one may need to do on a string:


Constructor & Destructor Documentation

oaString::oaString   [inline]
 

This function constructs an empty oaString object, containing only the NULL character.

oaString::oaString oaUInt4    length [inline, explicit]
 

This function creates an empty oaString of the specified length. The empty oaString contains only the NULL character.

Parameters:
length The initial size to allocate for this oaString

oaString::oaString const oaChar *    initialValue [inline]
 

This function constructs an oaString object by copying the string specified in initialValue. It is assumed that initialValue is pointing at a NULL terminated string. The oaString is sized accordingly to fit the initialvalue. If initialValue is NULL, an empty oaString object is constructed.

Parameters:
initialValue A pointer to a character buffer whose contents are used to initialize this oaString

oaString::oaString const oaChar *    initialValue,
oaUInt4    length
[inline]
 

This function constructs an oaString instance by copying the string specified in initialValue up to length characters. A terminating NULL character is placed at the length character. If initialValue is NULL, an empty oaString object is constructed.

Parameters:
initialValue A pointer to a character buffer whose contents are used to initialize this oaString
length The number of characters to copy from initialValue

oaString::oaString const oaString &    str [inline]
 

This function constructs a copy of the specified oaString.

oaString::~oaString   [inline]
 

This function destroys this oaString object, freeing the memory associated with the it.


Member Function Documentation

void oaString::format const oaChar *    formatStr,
va_list    args
 

This function formats this string according to the format specification given in formatStr. The format specification has the same form as the format argument for printf.

Note: If the number of va_list args is 1 and the type of the argument is char *, compilers may call the wrong function, which can result in incorrect behavior or a crash. To avoid problems, the argument should be cast to (const char*).

void oaString::format const oaChar *    formatStr,
...   
 

This function formats this string according to the format specification given in formatStr. The format specification has the same form as the format argument for printf.

Note: If the number of variable arguments to this function is 1 and the type of the argument is char *, compilers may call the wrong function, which can result in incorrect behavior or a crash. To avoid problems, the argument should be cast to (const char*), for example,

     oaString mystring;
     char str[200]="Hello";
     mystring.format("%s", (const char*) str);
     

void oaString::format oaUInt4    size,
const oaChar *    formatStr,
...   
 

This function increases the size of this string to the specified size and formats it according to the format specification given in formatStr. The format specification has the same form as the format argument for printf. If the length of the formatted string is larger than the specified size, this function will not resize this string to fit the formatted string. This function should only be used when the size is known to be bounded.

oaUInt4 oaString::getLength   const [inline]
 

This function returns the length of this string. The value represents the number of characters in this string excluding the trailing NULL character.

oaUInt4 oaString::getSize   const [inline]
 

This function returns the size of the space allocated for this oaString.

oaUInt4 oaString::index oaChar    c,
oaUInt4    offset = 0
const
 

This function searches this string and returns an index to the first occurrence of the specified character. If the character is not found, the index to the terminating NULL character is returned. You can specify an optional initial offset into the string from where the search will begin.

Parameters:
c The character to find
offset The initial offset into the string
Returns:
An integer representing the position of the character in this string

oaBoolean oaString::isEmpty   const [inline]
 

This function returns a boolean that indicates whether this string is empty or not.

oaBoolean oaString::isEqual const oaString &    str,
oaBoolean    ignoreCase
const [inline]
 

This function compares this oaString with the oaString str, either with or without case sensitivity, and returns true if they are equal.

Parameters:
str The string to be compared
ignoreCase Ignore case or not when comparing

oaString::operator const oaChar *   const [inline]
 

This function implements an operator that returns a const oaChar* pointer to the contents of this string.

oaBoolean oaString::operator!= const oaString &    str const [inline]
 

This logical operator compares this oaString with the specified oaString str and returns true if their values are not alphanumerically equal.

oaString & oaString::operator+= const oaString &    str
 

This assignment operator for the oaString class concatenates the specified string str with this oaString. This oaString is resized accordingly to fit the new set of characters.

oaString & oaString::operator+= const oaChar *    str
 

This assignment operator for the oaString class concatenates the specified const character string str to this oaString. This oaString is resized accordingly to fit the new set of characters. It is assumed that the given str is NULL terminated.

oaString & oaString::operator+= oaChar    c
 

This assignment operator for the oaString class concatenates the specified character c to this oaString. This oaString is resized accordingly to fit the character.

oaBoolean oaString::operator< const oaString &    str const [inline]
 

This logical operator compares this oaString with the specified oaString str and returns true if this oaString is alphanumerically less than str.

oaBoolean oaString::operator<= const oaString &    str const [inline]
 

This logical operator compares this oaString with the specified oaString str and returns true if this oaString is alphanumerically less than or equal to str.

oaString & oaString::operator= const oaString &    str
 

This assignment operator for the oaString class copies the specified oaString str into this oaString. The contents of this oaString are overwritten.

oaString & oaString::operator= const oaChar *    str
 

This assignment operator for the oaString class copies the specified const char* string str into this oaString. The contents of this oaString are overwritten. This oaString will be resized accordingly in order to accommodate the given str value.

oaString & oaString::operator= oaChar    c
 

This assignment operator for the oaString class copies the specified character c into this oaString. The contents of this oaString are overwritten.

oaBoolean oaString::operator== const oaString &    str const [inline]
 

This logical operator compares this oaString with the specified oaString str and returns true if this oaString is alphanumerically equal to str.

oaBoolean oaString::operator> const oaString &    str const [inline]
 

This logical operator compares this oaString with the specified oaString str and returns true if this oaString is alphanumerically greater than str.

oaBoolean oaString::operator>= const oaString &    str const [inline]
 

This logical operator compares this oaString with the specified oaString str and returns true if this oaString is alphanumerically greater than or equal to str.

const char & oaString::operator[] oaUInt4    i const [inline]
 

This index operator for the oaString class returns the character at position i in the string. This const version does not allow you to modify the character.

Returns:
Undefined if i specifies a value greater than the number of characters in the string

char & oaString::operator[] oaUInt4    i [inline]
 

This index operator for the oaString class returns the character at position i in the string. This non-const version allows you to modify the character.

Returns:
Undefined if i specifies a value greater than the number of characters in the string

void oaString::resize oaUInt4    newSize [inline]
 

This function increases the amount of space allocated by this string to newSize. The contents of the string is retained.

oaUInt4 oaString::substr const oaString &    sub,
oaUInt4    offset = 0
const
 

This function searches this oaString and returns the index to the first occurrence of the specified substring sub. If the substring is not found, index of the terminating NULL character is returned. You can specify an optional initial offset into the string from which the search will begin.

Parameters:
sub The substring to find
offset The initial offset into the string

double oaString::toDouble   const [inline]
 

This function converts the contents of this oaString to a double value and returns it. See the system function atof for formatting details.

Returns:
0.0 if the conversion fails

int oaString::toInt   const [inline]
 

This function converts the contents of this oaString to an integer value and returns it. See the system function atoi for details.

Returns:
Zero if the conversion fails

void oaString::toLower  
 

This function changes the contents of this oaString so that all of the alphabetic characters are in lowercase.

void oaString::toUpper  
 

This function converts the contents of this oaString so that all of the alphabetic characters are in uppercase.


Friends And Related Function Documentation

oaBoolean oaString::operator!= const oaChar *    s1,
const oaString &    s2
[friend]
 

This logical operator compares an oaChar s1 against an oaString s2 and returns true if their values are not alphanumerically equal.

oaBoolean oaString::operator!= const oaString &    s1,
const oaChar *    s2
[friend]
 

This logical operator compares an oaString s1 against an oaChar s2 and returns true if their values are not alphanumerically equal.

OA_BASE_DLL_API oaString operator+ const oaString &    s1,
const oaString &    s2
[friend]
 

oaBoolean oaString::operator< const oaChar *    s1,
const oaString &    s2
[friend]
 

This logical operator compares an oaChar s1 against an oaString s2 and returns true if s1 is alphanumerically less than s2.

oaBoolean oaString::operator< const oaString &    s1,
const oaChar *    s2
[friend]
 

This logical operator compares an oaString s1 against an oaChar s2 and returns true if s1 is alphanumerically less than s2.

oaBoolean oaString::operator<= const oaChar *    s1,
const oaString &    s2
[friend]
 

This logical operator compares an oaChar s1 against an oaString s2 and returns true if s1 is alphanumerically less than or equal to s2.

OA_BASE_DLL_API oaBoolean operator<= const oaString &    s1,
const oaChar *    s2
[friend]
 

oaBoolean oaString::operator== const oaChar *    s1,
const oaString &    s2
[friend]
 

This logical operator compares an oaChar s1 against an oaString s2 and returns true if s1 is alphanumerically equal to s2.

oaBoolean oaString::operator== const oaString &    s1,
const oaChar *    s2
[friend]
 

This logical operator compares an oaString s1 against an oaChar s2 and returns true if s1 is alphanumerically equal to s2.

oaBoolean oaString::operator> const oaChar *    s1,
const oaString &    s2
[friend]
 

This logical operator compares an oaChar s1 against an oaString s2 and returns true if s1 is alphanumerically greater than s2.

OA_BASE_DLL_API oaBoolean operator> const oaString &    s1,
const oaChar *    s2
[friend]
 

oaBoolean oaString::operator>= const oaChar *    s1,
const oaString &    s2
[friend]
 

This logical operator compares an oaChar s1 against an oaString s2 and returns true if s1 is alphanumerically greater than or equal to s2.

OA_BASE_DLL_API oaBoolean operator>= const oaString &    s1,
const oaChar *    s2
[friend]
 


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

Return to top of page