VMS Help CXXLSTD, IOStreams, char_traits *Conan The Librarian |
Standard C++ Library Copyright 1996, Rogue Wave Software, Inc. NAME char_traits_ - A traits class providing types and operations to the basic_string container and iostream classes. SYNOPSIS #include <string> template <class charT> struct char_traits struct char_traits<char>; . struct char_traits<wchar_t>; DESCRIPTION The char_traits struct provides elementary operations to instantiations of basic_string and iostream classes. As with all traits classes, char_traits is used to specialize the behavior of a template. In this case, the traits class provides functions based on character type to the basic_string template and to the templates that are part of the iostreams library. Specializations of char_traits are provided for char and wchar_t. These are used to define, respectively, string and wstring, cout and wcout, etc. INTERFACE template <class charT> struct char_traits . { typedef charT char_type; typedef int int_type; typedef streampos pos_type; typedef streamoff off_type; typedef mbstate_t state_type; static void assign (char_type&, const char_type&); static char_type* assign (char_type*, size_t, const char_type&); static bool eq (const char_type&, const char_type&); static bool lt (const char_type&, const char_type&); static int compare (const char_type*, const char_type*, size_t); static size_t length (const char_type * s); static const char_type* find (const char_type*, int, const char_type&); static char_type* move (char_type*, const char_type*, size_t); static char_type* copy (char_type*, const char_type*, size_t); static int_type not_eof(const int_type& c); static char_type to_char_type(const int_type& c); static int_type to_int_type(const char_type& c); static bool eq_int_type(const int_type& c1, const int_type& c2); static int_type eof(); }; TYPE char_type The basic character type. Same as the template parameter. int_type A type that can represent all the character values of char_type as well as and end of file value. pos_type A type used to represent a position within a stream buffer. off_type A type used to represent an offset to a position within a stream buffer. state_type A type used to represent the state class or type that is applied to the codecvt facet. This type is only relevant for streams with a underlying character type that is multi-byte. OPERATIONS static void assign(char_type& c1, const char_type& c2) Assigns one character value to another. The value of c2 is assigned to c1. static char_type* assign(char_type* s, size_t n, const char_type& a) Assigns one character value to n elements of a character array. The value of a is assigned to n elements of s. static bool eq(const char_type& c1, const char_type& c2) Returns true if c1 equals c2. static bool lt(const char_type& c1, const char_type& c2) Returns true if c1 is less than c2. static int compare(const char_type* s1, const char_type* s2, size_t n) Compares n values from s1 with n values from s2. Return 1 if s1 is greater than s2, -1 if s1 is less than s2, or 0 if they are equal. static size_t length(const char_type * s) Returns the length of the null terminated character array s. The eos terminator is not counted. static const char_type* find(const char_type* s, int n, const char_type& a) Looks for the value of a in s. Only n elements of s are examined. Returns a pointer to the matched element if one is found. Otherwise returns s + n. static char_type* move(char_type* s1, const char_type* s2, size_t n) Moves n values from s1 to s2. The ranges of (s1,s1+n) and (s2,s2+n) may overlap. static char_type* copy(char_type* s1, const char_type* s2, size_t n) Copy n values from s1 to s2. The ranges of (s1,s1+n) and (s2,s2+n) may not overlap. static int_type not_eof(const int_type& c) Returns c if c is not equal to eof(), otherwise returns 0. static int_type to_char_type(const int_type& c) Returns the char_type representation of c. This value may not be useful if no such representation exists. static int_type to_int_type(const char_type& c) Returns the int_type representation of c. static bool eq_int_type(const int_type& c1, const int_type& c2) Returns true if c1 equals c2. static int_type eof() Returns EOF. SEE ALSO basic_string, traits, basic_ostream, basic_istream, cout, cin, wcout, wcin STANDARDS CONFORMANCE ANSI X3J16/ISO WG21 Joint C++ Committee
|