epoc32/include/stdapis/stlport/stl/_numpunct.h
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
permissions -rw-r--r--
Final list of Symbian^2 public API header files
     1 /*
     2  * © Portions copyright (c) 2006-2007 Nokia Corporation.  All rights reserved.
     3  *
     4  * Copyright (c) 1999
     5  * Silicon Graphics Computer Systems, Inc.
     6  *
     7  * Copyright (c) 1999 
     8  * Boris Fomitchev
     9  *
    10  * This material is provided "as is", with absolutely no warranty expressed
    11  * or implied. Any use is at your own risk.
    12  *
    13  * Permission to use or copy this software for any purpose is hereby granted 
    14  * without fee, provided the above notices are retained on all copies.
    15  * Permission to modify the code and to distribute modified code is granted,
    16  * provided the above notices are retained, and a notice that the code was
    17  * modified is included with the above copyright notice.
    18  *
    19  */ 
    20 // WARNING: This is an internal header file, included by other C++
    21 // standard library headers.  You should not attempt to use this header
    22 // file directly.
    23 
    24 
    25 #ifndef _STLP_INTERNAL_NUMPUNCT_H
    26 #define _STLP_INTERNAL_NUMPUNCT_H
    27 
    28 #ifndef _STLP_IOS_BASE_H
    29 # include <stl/_ios_base.h>
    30 #endif
    31 
    32 # ifndef _STLP_C_LOCALE_H
    33 #  include <stl/c_locale.h>
    34 # endif
    35 
    36 #ifndef _STLP_STRING_H
    37 # include <stl/_string.h>
    38 #endif
    39 
    40 _STLP_BEGIN_NAMESPACE
    41 
    42 //----------------------------------------------------------------------
    43 // numpunct facets
    44 
    45 #ifdef	__SYMBIAN32__
    46 extern locale::id& Numpunct_charT_GetFacetLocaleId(const char* type);
    47 
    48 template <class _CharT> class numpunct: public locale::facet
    49 {
    50 	friend class _Locale;
    51 public:
    52  	typedef char               		char_type;
    53   	typedef basic_string<_CharT>             string_type;
    54 	explicit numpunct(size_t __refs = 0) : _BaseFacet(__refs) {
    55 	_M_truename.append(1, (_CharT)'t');
    56 	_M_truename.append(1, (_CharT)'r');
    57 	_M_truename.append(1, (_CharT)'u');
    58 	_M_truename.append(1, (_CharT)'e');
    59 
    60 	_M_falsename.append(1, (_CharT)'f');
    61 	_M_falsename.append(1, (_CharT)'a');
    62 	_M_falsename.append(1, (_CharT)'l');
    63 	_M_falsename.append(1, (_CharT)'s');
    64 	_M_falsename.append(1, (_CharT)'e');
    65 	}
    66 	
    67   	_CharT decimal_point() const { return do_decimal_point(); }
    68   	_CharT thousands_sep() const { return do_thousands_sep(); }
    69   	string grouping() const { return do_grouping(); }
    70   	string_type truename() const { return do_truename(); }
    71   	string_type falsename() const { return do_falsename(); }
    72 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
    73 	static locale::id& GetFacetLocaleId(){return Numpunct_charT_GetFacetLocaleId(typeid(_CharT).name()); }
    74 #else
    75   	 static locale::id id;
    76 #endif
    77 
    78 # ifndef _STLP_NO_FRIEND_TEMPLATES
    79 protected:
    80 # endif
    81 	~numpunct();
    82 
    83 protected:
    84   	 static string_type  _M_truename;
    85   	static string_type  _M_falsename;
    86   	static string  _M_grouping;
    87 protected:
    88 
    89   	virtual _CharT do_decimal_point() const;
    90   	virtual _CharT do_thousands_sep() const;
    91   	virtual string do_grouping() const; 
    92   	virtual string_type do_truename() const;
    93   	virtual string_type do_falsename()  const;
    94 };
    95 
    96 template <class _CharT>
    97 basic_string<_CharT> numpunct<_CharT>::_M_truename;
    98 template <class _CharT>
    99 basic_string<_CharT> numpunct<_CharT>::_M_falsename;
   100 template <class _CharT>
   101 string numpunct<_CharT>::_M_grouping ;
   102 
   103 _STLP_DECLSPEC _Locale_numeric* __acquire_numericE(const char* );
   104 _STLP_DECLSPEC void __release_numericE(_Locale_numeric* );
   105 _STLP_DECLSPEC const char* _Locale_trueE(_Locale_numeric*);
   106 _STLP_DECLSPEC const char* _Locale_falseE(_Locale_numeric*);
   107 _STLP_DECLSPEC char _Locale_decimal_pointE(_Locale_numeric*);
   108 _STLP_DECLSPEC char _Locale_thousands_sepE(_Locale_numeric*);
   109 _STLP_DECLSPEC const char*_Locale_groupingE(_Locale_numeric*);
   110 
   111 template <class _CharT>
   112 class numpunct_byname : public numpunct<_CharT>{
   113 public:
   114 	typedef _CharT                char_type;
   115   	typedef basic_string<_CharT>              string_type;
   116 
   117   	explicit  numpunct_byname(const char* name, size_t refs = 0);	
   118 protected:
   119 
   120 	   ~numpunct_byname();
   121 
   122 	 virtual _CharT   do_decimal_point() const;
   123   	 virtual _CharT   do_thousands_sep() const;
   124 	  virtual string do_grouping()      const;
   125 
   126 private:
   127   	_Locale_numeric* _M_numeric;
   128 };
   129 
   130 #else
   131 template <class _CharT> class numpunct {};
   132 template <class _CharT> class numpunct_byname {};
   133 #endif
   134 template <class _Ch, class _InIt> class num_get;
   135 
   136 _STLP_TEMPLATE_NULL
   137 #ifdef __SYMBIAN32__
   138 class numpunct <char> : public locale::facet
   139 #else
   140 class _STLP_CLASS_DECLSPEC numpunct<char> : public locale::facet
   141 #endif
   142 {
   143   friend class _Locale;
   144 # ifndef _STLP_NO_FRIEND_TEMPLATES
   145   template <class _Ch, class _InIt> friend class num_get;
   146 # endif
   147 public:
   148   typedef char               char_type;
   149   typedef string             string_type;
   150 
   151   explicit numpunct(size_t __refs = 0) : _BaseFacet(__refs) {}
   152 
   153   char decimal_point() const { return do_decimal_point(); }
   154   char thousands_sep() const { return do_thousands_sep(); }
   155   string grouping() const { return do_grouping(); }
   156   string truename() const { return do_truename(); }
   157   string falsename() const { return do_falsename(); }
   158 
   159 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
   160 	_STLP_STATIC_MEMBER_DECLSPEC static locale::id& GetFacetLocaleId();
   161 #else
   162   	_STLP_STATIC_MEMBER_DECLSPEC static locale::id id;
   163 #endif
   164 
   165 # ifndef _STLP_NO_FRIEND_TEMPLATES
   166 protected:
   167 # endif
   168   ~numpunct(){};
   169 
   170 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
   171 public:
   172   _STLP_STATIC_MEMBER_DECLSPEC static string&  GetNumPunct_M_truename();
   173   _STLP_STATIC_MEMBER_DECLSPEC static string&  GetNumPunct_M_falsename();
   174   _STLP_STATIC_MEMBER_DECLSPEC static string&  GetNumPunct_M_grouping();
   175 #else
   176 protected:
   177   _STLP_STATIC_MEMBER_DECLSPEC static string  _M_truename;
   178   _STLP_STATIC_MEMBER_DECLSPEC static string  _M_falsename;
   179   _STLP_STATIC_MEMBER_DECLSPEC static string  _M_grouping;
   180 #endif
   181 
   182 protected:
   183 
   184   _STLP_DECLSPEC virtual char do_decimal_point() const;
   185   _STLP_DECLSPEC virtual char do_thousands_sep() const;
   186   _STLP_DECLSPEC virtual string do_grouping() const;
   187   _STLP_DECLSPEC virtual string do_truename() const;
   188   _STLP_DECLSPEC virtual string do_falsename()  const;
   189 };
   190 
   191 # if ! defined (_STLP_NO_WCHAR_T)
   192 
   193 _STLP_TEMPLATE_NULL
   194 #ifdef __SYMBIAN32__
   195 class numpunct<wchar_t> : public locale::facet
   196 #else
   197 class _STLP_CLASS_DECLSPEC numpunct<wchar_t> : public locale::facet
   198 #endif
   199 {
   200   friend class _Locale;
   201 public:
   202   typedef wchar_t               char_type;
   203   typedef wstring               string_type;
   204 
   205   explicit numpunct(size_t __refs = 0) : _BaseFacet(__refs) {}
   206 
   207   wchar_t decimal_point() const { return do_decimal_point(); }
   208   wchar_t thousands_sep() const { return do_thousands_sep(); }
   209   string grouping() const { return do_grouping(); }
   210   wstring truename() const { return do_truename(); }
   211   wstring falsename() const { return do_falsename(); }
   212 
   213 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
   214     _STLP_STATIC_MEMBER_DECLSPEC static locale::id& GetFacetLocaleId();
   215 #else
   216  	_STLP_STATIC_MEMBER_DECLSPEC static locale::id id;
   217 #endif
   218 
   219 #if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
   220 public:
   221   _STLP_STATIC_MEMBER_DECLSPEC static wstring&  GetNumPunct_M_Wchar_truename();
   222   _STLP_STATIC_MEMBER_DECLSPEC static wstring&  GetNumPunct_M_Wchar_falsename();
   223   _STLP_STATIC_MEMBER_DECLSPEC static string&  GetNumPunct_M_Wchar_grouping();
   224 #else
   225 protected:
   226   _STLP_STATIC_MEMBER_DECLSPEC static wstring _M_truename;
   227   _STLP_STATIC_MEMBER_DECLSPEC static wstring _M_falsename;
   228   _STLP_STATIC_MEMBER_DECLSPEC static string _M_grouping;
   229 #endif
   230 protected:
   231   ~numpunct() {}
   232 
   233   _STLP_DECLSPEC virtual wchar_t do_decimal_point() const;
   234   _STLP_DECLSPEC virtual wchar_t do_thousands_sep() const;
   235   _STLP_DECLSPEC virtual string do_grouping() const;
   236   _STLP_DECLSPEC virtual wstring do_truename() const;
   237   _STLP_DECLSPEC virtual wstring do_falsename()  const;
   238 };
   239 
   240 # endif /* WCHAR_T */
   241 
   242 _STLP_TEMPLATE_NULL
   243 class _STLP_CLASS_DECLSPEC numpunct_byname<char> : public numpunct<char> {
   244 public:
   245   typedef char                char_type;
   246   typedef string              string_type;
   247 
   248   explicit _STLP_DECLSPEC numpunct_byname(const char* __name, size_t __refs = 0);
   249 
   250 protected:
   251 
   252 _STLP_DECLSPEC   ~numpunct_byname();
   253 
   254 _STLP_DECLSPEC   virtual char   do_decimal_point() const;
   255   _STLP_DECLSPEC virtual char   do_thousands_sep() const;
   256 _STLP_DECLSPEC   virtual string do_grouping()      const;
   257 
   258 private:
   259   _Locale_numeric* _M_numeric;
   260 };
   261 
   262 # ifndef _STLP_NO_WCHAR_T
   263 _STLP_TEMPLATE_NULL
   264 class _STLP_CLASS_DECLSPEC numpunct_byname<wchar_t>: public numpunct<wchar_t> {
   265 public:
   266   typedef wchar_t               char_type;
   267   typedef wstring               string_type;
   268 
   269   explicit _STLP_DECLSPEC numpunct_byname(const char* __name, size_t __refs = 0);
   270 
   271 protected:
   272 
   273 _STLP_DECLSPEC   ~numpunct_byname();
   274 
   275 _STLP_DECLSPEC   virtual wchar_t   do_decimal_point() const;
   276   _STLP_DECLSPEC virtual wchar_t   do_thousands_sep() const;
   277 _STLP_DECLSPEC   virtual string do_grouping() const;
   278 
   279 private:
   280   _Locale_numeric* _M_numeric;
   281 };
   282 
   283 # endif /* WCHAR_T */
   284 
   285 #ifdef	__SYMBIAN32__
   286 #include<stl/_numpunct.c>
   287 #endif
   288 _STLP_END_NAMESPACE
   289 
   290 #endif /* _STLP_NUMPUNCT_H */
   291 
   292 // Local Variables:
   293 // mode:C++
   294 // End:
   295