Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Class template string_t

boost::asn1::string_t —

Synopsis

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() ;
};

Description

ASN1 string template

Strings

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 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/destruct

  1. string_t();
  2. string_t(const asn_base_ptr & asn_object);

    Copy constructor

    Copies an string_t being pass by a asn_base_ptr.

    Parameters:
    asn_object

    ASN1 object to copy from

  3. string_t(const string_t & object);

    Copy constructor

    Copies an string_t object

    Parameters:
    object

    string_t to copy from

  4. string_t(const n_string & s);

    Copy constructor

    Copies a basic_string<char> object

    Parameters:
    s

    basic_string<> object to copy from

  5. string_t(const w_string & s);

    Copy constructor

    Copies a basic_string<wchar_t> object

    Parameters:
    s

    basic_string<> object to copy from

  6. string_t(const charT * s);

    Copy constructor

    Copies a charT* object

    Parameters:
    s

    Character pointer to copy from

  7. string_t(charT c);

    Copy constructor

    Copies a charT object

    Parameters:
    c

    Character to copy from

  8. string_t& operator=(const n_string & s);
  9. string_t& operator=(const w_string & s);
  10. string_t& operator=(const charT * s);
  11. string_t& operator=(charT c);
  12. string_t& operator=(const string_t & v);
  13. ~string_t();

string_t public member functions

  1. string_t & operator+=(const string_type v) ;
  2. const string_type operator()() ;
  3. operator string_type() const;
  4. void assign(const asn_base_t * asn_object) ;

    Parameters:
    asn_object

    Value to assign

  5. 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:
    str

    A basic_string<charT> whose content is entirely copied as the new content for the string.

  6. void assign(const w_string & str) ;
  7. 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:
    n

    Number of characters to use for the content (i.e., its length).

    pos

    Starting position of the substring of the string object str that forms the new content.

    str

    A basic_string<charT> whose content is partially copied as the new content for the string.

    Notes:

    If the position passed is past the end of str, an out_of_range exception is thrown.

  8. 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:
    n

    Number of characters to use for the content

    s

    An array characters of type charT

    Notes:

    If the position passed is past the end of str, an out_of_range exception is thrown.

  9. void assign(const charT * s) ;
  10. 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:
    c

    Character value to be repeated n times to form the new content.

    n

    Number of characters to use for the content

  11. string_t & append(const string_type & str) ;

    Adds new content to the end of the current content

    Appends a copy of str.

    Parameters:
    str

    A basic_string<charT> whose content is completely appended to the contents for the string.

  12. 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:
    n

    Number of characters to append.

    pos

    Starting position of the substring of the string object str that is appended.

    str

    A basic_string<charT> whose content is completely appended to the contents for the string.

  13. 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:
    n

    Number of characters to append.

    s

    An array characters of type charT.

  14. 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:
    s

    An array characters of type charT.

  15. 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:
    c

    Character to append.

    n

    Number of characters to append.

  16. const charT * c_str() const;
  17. asn_base_ptr clone() const;
  18. uint32_t encode(asn_visitor_t & visitor) ;

    Writes the string_t's data to the stream.

    Parameters:
    visitor

    asn_visitor_t used for the encoding.

    Returns:

    The number of bytes used to encode the string_t's data

  19. uint32_t decode(asn_visitor_t & visitor) ;

    Reads the string_t's data from the stream.

    Parameters:
    visitor

    asn_visitor_t used for the decoding.

    Returns:

    The number of bytes used to decode the string_t's data

  20. size_t size_of() ;

    Gets the size of the ASN1 object

    Returns the size of the ASN1 class object sizeof(ASN1)

string_t public static functions

  1. static asn_base_ptr create() ;
Copyright © 2007 Andreas Haberstroh

PrevUpHomeNext