![]() |
Home | Libraries | People | FAQ | More |
boost::asn1::string_t —
template<typename charT, primitives_t P, typename predT> class string_t : public boost::asn1::asn_base_t { public: // types typedef std::basic_string< charT, std::char_traits< charT > > string_type; // std::string representation of the internal data typedef std::basic_string< char, std::char_traits< char > > n_string; typedef std::basic_string< wchar_t, std::char_traits< wchar_t > > w_string; // construct/copy/destruct string_t(); string_t(const asn_base_ptr &); string_t(const string_t &); string_t(const n_string &); string_t(const w_string &); string_t(const charT *); string_t(charT); string_t& operator=(const n_string &); string_t& operator=(const w_string &); string_t& operator=(const charT *); string_t& operator=(charT); string_t& operator=(const string_t &); ~string_t(); // public member functions string_t & operator+=(const string_type) ; const string_type operator()() ; operator string_type() const; void assign(const asn_base_t *) ; void assign(const n_string &) ; void assign(const w_string &) ; void assign(const string_type &, size_t, size_t) ; void assign(const charT *, size_t) ; void assign(const charT *) ; void assign(size_t, charT) ; string_t & append(const string_type &) ; string_t & append(const string_type &, size_t, size_t) ; string_t & append(const charT *, size_t) ; string_t & append(const charT *) ; string_t & append(size_t, charT) ; const charT * c_str() const; asn_base_ptr clone() const; uint32_t encode(asn_visitor_t &) ; uint32_t decode(asn_visitor_t &) ; size_t size_of() ; // public static functions static asn_base_ptr create() ; };
ASN1 string template
StringsThe strings of the ASN1 specification are support in the Boost.ASN1 library through a templated class called string_t. This template is specialized for the ten of the ASN1 string data types. The exception to this rule is the BIT STRING data type, which is covered else where.
| OCTET STRING | octetstring_t |
| NUMERIC STRING | numericstring_t |
| PRINTABLE STRING | printablestring_t |
| TELETEX STRING | t61string_t |
| VIDEO STRING | videotextstring_t |
| IA5 STRING | ia5string_t |
| GRAPHIC STRING | graphicstring_t |
| ISO646 STRING | iso646string_t |
| GENERAL STRING | generalstring_t |
| UTF8 STRING | utf8string_t |
The actual string representation for these types is encapsulate in a basic_string<> object of type char or wchar_t. This template class differs from the integral_t template class in that it allows only assign, append and retrieval of the internal data. No other basic_string<> functionality is exposed.
With the exception of strings of type OCTET, these string types have restricted character sets. For instance, the NUMERIC string only allows digit characters and spaces. Punctuation (ie, periods, dashes) is not allowed in a NUMERIC string.
numericstring_t legalNumeric("12 34");
numericstring_t illegalNumeric("12.34");
Assigning illegal characters to a restricted string type will cause the string to be blank and invalid.
As with the integral_t, assigning between string types is allowed if the strings are from within the same classification and meet the restricted requirements.
ia5string_t ia5string;
numericstring_t legalNumeric = "1234";
ia5string = legalNumeric; // Allowable assignment
ia5string("regular string");
numericstring_t illegalNumeric(ia5string); // Not allowable assignment
string_t construct/copy/destructstring_t();
string_t(const asn_base_ptr & asn_object);
Copy constructor
Copies an string_t being pass by a asn_base_ptr.
| Parameters: |
|
string_t(const string_t & object);
Copy constructor
Copies an string_t object
| Parameters: |
|
string_t(const n_string & s);
Copy constructor
Copies a basic_string<char> object
| Parameters: |
|
string_t(const w_string & s);
Copy constructor
Copies a basic_string<wchar_t> object
| Parameters: |
|
string_t(const charT * s);
Copy constructor
Copies a charT* object
| Parameters: |
|
string_t(charT c);
Copy constructor
Copies a charT object
| Parameters: |
|
string_t& operator=(const n_string & s);
string_t& operator=(const w_string & s);
string_t& operator=(const charT * s);
string_t& operator=(charT c);
string_t& operator=(const string_t & v);
~string_t();
string_t public member functionsstring_t & operator+=(const string_type v) ;
const string_type operator()() ;
operator string_type() const;
void assign(const asn_base_t * asn_object) ;
| Parameters: |
|
void assign(const n_string & str) ;
Assigns new content to the string_t replacing its current content
Sets a copy of str as the new content.
| Parameters: |
|
void assign(const w_string & str) ;
void assign(const string_type & str, size_t pos, size_t n) ;
Assigns new content to the string_t replacing its current content
Sets a copy of a substring of str as the new content. The substring is the portion of str that begins at the character position pos and takes up to n characters (it takes less than n if the end of str is reached before).
| Parameters: |
|
||||||
| Notes: | If the position passed is past the end of str, an out_of_range exception is thrown. |
void assign(const charT * s, size_t n) ;
Assigns new content to the string_t replacing its current content
Sets as the new content a copy of the string formed by the first n characters of the array pointed by s.
| Parameters: |
|
||||
| Notes: | If the position passed is past the end of str, an out_of_range exception is thrown. |
void assign(const charT * s) ;
void assign(size_t n, charT c) ;
Assigns new content to the string_t replacing its current content
Sets a string formed by a repetition of character c, n times, as the new content.
| Parameters: |
|
string_t & append(const string_type & str) ;
Adds new content to the end of the current content
Appends a copy of str.
| Parameters: |
|
string_t & append(const string_type & str, size_t pos, size_t n) ;
Adds new content to the end of the current content
Appends a copy of a substring of str.
| Parameters: |
|
string_t & append(const charT * s, size_t n) ;
Adds new content to the end of the current content
Appends a copy of the string formed by by the first n characters of the array pointed by s.
| Parameters: |
|
string_t & append(const charT * s) ;
Adds new content to the end of the current content
Appends a copy of the string formed by the null-terminated C string pointed by s to the content.
| Parameters: |
|
string_t & append(size_t n, charT c) ;
Adds new content to the end of the current content
Appends a string formed by the repetition n times of character c.
| Parameters: |
|
const charT * c_str() const;
asn_base_ptr clone() const;
uint32_t encode(asn_visitor_t & visitor) ;
Writes the string_t's data to the stream.
| Parameters: |
|
||
| Returns: | The number of bytes used to encode the string_t's data |
uint32_t decode(asn_visitor_t & visitor) ;
Reads the string_t's data from the stream.
| Parameters: |
|
||
| Returns: | The number of bytes used to decode the string_t's data |
size_t size_of() ;
Gets the size of the ASN1 object
Returns the size of the ASN1 class object sizeof(ASN1)
| Copyright © 2007 Andreas Haberstroh |