RWDBMBString RWCString
Member Functions | |
operator=() |
#include <rw/db/mbstring.h> RWDBMBString a;
Class RWDBMBString is a simple wrapper around the Tools.h++ class RWCString. Some databases require different handling of single byte character sets (SBCS), like ASCII or ISO Latin-1, and multibyte character sets (MBCS). Writing applications using class RWDBMBString for MBCS strings and class RWCString for SBCS strings allows DBTools.h++ to make the critical differentiation.
Since RWDBMBString derives publicly from RWCString, all the facilities and functions of RWCString are available. For a complete description of those functions, see the Tools.h++ documentation for class RWCString.
Parameters of type const char* must not be passed a value of zero. This is detected in the debug version of the library.
Class RWDBMBString is implemented using a technique called copy on write. With this technique, the copy constructor and assignment operators still reference the old object and hence are very fast. An actual copy is made only when a write is performed, that is, if the object is about to be changed. The net result is excellent performance, but with easy-to-understand copy semantics.
A separate Tools.h++ class RWCSubString supports substring extraction and modification operations.
Simple
#include <iostream.h> #include <rw/db/mbstring.h> void outputTest(RWDBDatabase& aDB){ RWDBInserter ins = aDB.table("t1").inserter(); RWDBMBString mbstring("\346\202\250\345\245\275"); ins << mbstring; cout << ins.asString() << endl; }
Oracle treats multibyte and single byte strings differently. If aDB represents an Oracle database and the proper character set is loaded on the machine, the output is:
INSERT INTO T1 VALUES (N'')
Sybase does not differentiate multibyte and single byte strings. If aDB represents a Sybase database and the proper character set is loaded on the machine, the output is:
INSERT INTO T1 VALUES ('')
RWDBMBString();
Creates a string of length zero (the null string).
RWDBMBString(const char* cs);
Conversion from the null-terminated character string cs. The created string copies the data pointed to by cs, up to the first terminating null. This function is incompatible with cs strings with embedded nulls. This function may be incompatible with cs MBCS strings.
RWDBMBString(const char* cs, size_t N);
Constructs a string from the character string cs. The created string copies the data pointed to by cs. Exactly N bytes are copied, including any embedded nulls. Hence, the buffer pointed to by cs must be at least N bytes long.
RWDBMBString(RWSize_T ic);
Creates a string of length zero, the null string. The string's capacity, that is, the size it can grow to without resizing, is given by the parameter ic. We recommend creating an RWSize_T value from a numerical constant to pass into this constructor. While RWSize_T knows how to convert a size_t to itself, conforming compilers will choose the conversion to char instead.
RWDBMBString(const RWDBMBString& str);
Copy constructor. The created string copies str's data.
RWDBMBString(const RWCString& str);
Copy-like constructor. The created string copies str's data.
RWDBMBString(const RWCSubString& ss);
Conversion from substring. The created string copies the substring represented by ss.
RWDBMBString(char c);
Constructs a string containing the single character c.
RWDBMBString(char c, size_t N);
Constructs a string containing the character c repeated N times.
RWDBMBString& operator=(const char* cs);
Assignment operator. Copies the null-terminated character string pointed to by cs into self. Returns a reference to self. This function is incompatible with cs strings with embedded nulls. This function may be incompatible with cs MBCS strings.
RWDBMBString& operator=(const RWCString& str);
Assignment operator. The string copies str's data. Returns a reference to self.
RWDBMBString& operator=(const RWDBMBString& str);
Assignment operator. The string copies str's data. Returns a reference to self.
©Copyright 1999, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.