Type Definitions

The Standard C++ Library defines a type string, which is no more than a typedef for a basic_string<char>; however, it is much more convenient and natural to use just the name string than the entire templatized symbol. In a similar fashion, SFL defines some short names for the most commonly used string types. However, the Standard C++ Library doesn’t take into account the possibility of applications using the Unicode character set, string is always defined to use 1 byte characters. SFL goes one step beyond, taking into account the standard way for a Windows application to define the character set it will use. The definition of string varies depending on whether the _UNICODE preprocessor macro is defined or not. For applications that need string processing for char or wchar_t types independently of the _UNICODE symbol, two permanent definitions are also included: cstring and wstring. The definition of each of these types is as follows:

  • cstring: String of ANSI characters. Always defined as basic_string_ex<char, wchar_t>.

  • wstring: String of wide (Unicode) characters. Always defined as basic_string_ex<wchar_t, char_t>

  • string: Defined as synonym of cstring if the _UNICODE preprocessor flag is not defined; otherwise is defined to wstring.

Remember that the string symbol we refer to here should not conflict with the string type in the Standard C++ Library: the former is within the stingray::foundation:: namespace, whereas the latter is in the std:: namespace. If you flatten those namespaces using the using statement, a name ambiguity will occur.

A similar naming trick is included for string streams. SFL does not provide an enhanced string stream; however, it does define some convenient names depending on the _UNICODE symbol, just as explained before. Thus, we have:

  • cstringstream: Stream of ANSI characters. Always defined as basic_stringstream<char>.

  • wstringstream: String of wide (Unicode) characters. Always defined as basic_stringstream<wchar_t>

  • stringstream: Defined as synonym of cstringstream if the _UNICODE preprocessor flag is not defined; otherwise is defined to wstringstream.

These streams use the char_traits_ex classes as their traits parameters, so they are compatible with SFL’s string types.