![]() |
Home | Libraries | People | FAQ | More |
The strings of the ASN1 specification are support in the Boost.ASN1 library
through a templated class called string_t.
This template is specialized for ten of the ASN1 string data types. The
exception to this rule is the BIT STRING data type, which is covered else
where.
| ASN1 Type | C++ Equiv |
|---|---|
| NUMERIC STRING | numericstring_t |
| PRINTABLE STRING | printablestring_t |
| T61 STRING | t61string_t |
| VIDEOTEXT STRING | videotextstring_t |
| IA5 STRING | ia5string_t |
| GRAPHIC STRING | graphicstring_t |
| ISO646 STRING | iso646string_t |
| GENERAL STRING | generalstring_t |
| UTF8 STRING | utf8string_t |
| OCTET STRING | octetstring_t |
The internal storage for the string_t
class is 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 assignment, appending 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
| Copyright © 2007 Andreas Haberstroh |