os/ossrv/genericopenlibs/cppstdlib/inc/libstdcppwsd.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     3
* All rights reserved.
sl@0
     4
* This component and the accompanying materials are made available
sl@0
     5
* under the terms of "Eclipse Public License v1.0"
sl@0
     6
* which accompanies this distribution, and is available
sl@0
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
*
sl@0
     9
* Initial Contributors:
sl@0
    10
* Nokia Corporation - initial contribution.
sl@0
    11
*
sl@0
    12
* Contributors:
sl@0
    13
*
sl@0
    14
* Description:
sl@0
    15
* Name        : libcppwsd.h
sl@0
    16
* Part of     : standard c++ library (wsd definitions)
sl@0
    17
* 
sl@0
    18
*
sl@0
    19
*/
sl@0
    20
sl@0
    21
sl@0
    22
sl@0
    23
#ifndef LIBSTDCPPWSD_H_
sl@0
    24
#define LIBSTDCPPWSD_H_
sl@0
    25
sl@0
    26
#ifdef __SYMBIAN32__WSD__   //stuff for WSD
sl@0
    27
sl@0
    28
sl@0
    29
// ******************************  WSD RELATED ************************//
sl@0
    30
#include <e32std.h>
sl@0
    31
#include <pls.h> // For emulator WSD API
sl@0
    32
#include <typeinfo>
sl@0
    33
#include <locale>
sl@0
    34
#include <clocale>             
sl@0
    35
#include <vector>
sl@0
    36
#include <string>
sl@0
    37
#include <hash_map>
sl@0
    38
#include <cfloat>
sl@0
    39
#include <cmath>
sl@0
    40
#include <assert.h>
sl@0
    41
#include <stl/_new.h>
sl@0
    42
#include <stl/_map.h>
sl@0
    43
#include <stl/_locale.h>
sl@0
    44
#include <stl/_numpunct.h>
sl@0
    45
#include <stl/_alloc.h>
sl@0
    46
#include <stl/_fstream.h>
sl@0
    47
#include <stl/_codecvt.h>
sl@0
    48
#include <stl/_collate.h>
sl@0
    49
#include <stl/_ctype.h>
sl@0
    50
#include <stl/_pthread_alloc.h>
sl@0
    51
#include <stl/_monetary.h>
sl@0
    52
#include <stl/_threads.h>
sl@0
    53
sl@0
    54
sl@0
    55
// Global hash tables for category objects.
sl@0
    56
typedef std::hash_map<std::string, std::pair<void*, size_t>, std::hash<std::string>, std::equal_to<std::string> > Category_Map;
sl@0
    57
sl@0
    58
#define LOCALE_ID_MAX		39
sl@0
    59
/*
sl@0
    60
 * The following functions are used to make allocations internal to the 
sl@0
    61
 * C++ library.These are only required on the emulator as these are 
sl@0
    62
 * static variables in the actual STLPort implementation but in order to
sl@0
    63
 * save them on the ewsd, they need to allocated on heap.
sl@0
    64
 */
sl@0
    65
IMPORT_C void* WSDAlloc(unsigned int size);
sl@0
    66
IMPORT_C int   WSDFree(void*);
sl@0
    67
sl@0
    68
// ******************************************************//
sl@0
    69
//  ***   all WSD definitions here
sl@0
    70
// ******************************************************//
sl@0
    71
class _Libcpp_wsd
sl@0
    72
{
sl@0
    73
public:
sl@0
    74
	//_locale.h
sl@0
    75
	size_t locale_id_S_max;
sl@0
    76
	
sl@0
    77
	//locale_impl.h
sl@0
    78
	std::locale *_Stl_classic_locale;	
sl@0
    79
	std::locale *_Stl_global_locale;
sl@0
    80
	
sl@0
    81
	void* __Loc_init_buf;
sl@0
    82
	
sl@0
    83
	std::_Refcount_Base *_Loc_init_S_count;
sl@0
    84
	
sl@0
    85
	//locale.cpp
sl@0
    86
	__stl_atomic_t _S_index;
sl@0
    87
	std::_STLP_STATIC_MUTEX locale_Index_lock;
sl@0
    88
sl@0
    89
	//_ios_base.h
sl@0
    90
	bool ios_base_S_was_synced;
sl@0
    91
	long ios_base_Init_S_count; 	//ios_base::Init class	
sl@0
    92
	std::ios_base::Init *_IosInit;
sl@0
    93
	
sl@0
    94
	//ios.cpp
sl@0
    95
	int ios_base_xalloc_S_index;
sl@0
    96
	std::_STLP_STATIC_MUTEX ios_base_xalloc_lock; 
sl@0
    97
sl@0
    98
	//locale_catalog.cpp
sl@0
    99
	Category_Map *_S_ctype_hash;
sl@0
   100
	Category_Map *_S_numeric_hash;
sl@0
   101
	Category_Map *_S_time_hash;
sl@0
   102
	Category_Map *_S_collate_hash;
sl@0
   103
	Category_Map *_S_monetary_hash;
sl@0
   104
	Category_Map *_S_messages_hash;
sl@0
   105
	
sl@0
   106
	std::_STLP_STATIC_MUTEX locale_catalog_category_hash_lock;
sl@0
   107
sl@0
   108
	//iostream.cpp
sl@0
   109
	std::istream  *wsd_cin;
sl@0
   110
	std::ostream  *wsd_cout;
sl@0
   111
	std::ostream  *wsd_cerr;
sl@0
   112
	std::ostream  *wsd_clog;
sl@0
   113
#ifndef _STLP_NO_WCHAR_T
sl@0
   114
	std::wistream *wsd_wcin;
sl@0
   115
	std::wostream *wsd_wcout;
sl@0
   116
	std::wostream *wsd_wcerr;
sl@0
   117
	std::wostream *wsd_wclog;
sl@0
   118
#endif
sl@0
   119
sl@0
   120
	//numpunct.cpp
sl@0
   121
	std::string numpunct_char_m_truename;
sl@0
   122
	std::string numpunct_char_m_falsename;
sl@0
   123
	std::string numpunct_char_m_grouping;
sl@0
   124
# ifndef _STLP_NO_WCHAR_T
sl@0
   125
	std::wstring numpunct_wchar_m_truename;
sl@0
   126
	std::wstring numpunct_wchar_m_falsename;
sl@0
   127
	std::string  numpunct_wchar_m_grouping;
sl@0
   128
# endif
sl@0
   129
	
sl@0
   130
	//monetary.cpp
sl@0
   131
	std::string monetary_S_empty_string;	
sl@0
   132
# ifndef _STLP_NO_WCHAR_T
sl@0
   133
	std::wstring monetary_S_empty_wstring;
sl@0
   134
# endif //_STLP_NO_WCHAR_T
sl@0
   135
sl@0
   136
	//_fstream.h
sl@0
   137
	size_t fstream_Filebuf_base_M_page_size;
sl@0
   138
	
sl@0
   139
	//allocators.cpp
sl@0
   140
	std::__oom_handler_type wsd__oom_handler;
sl@0
   141
	std::_STLP_STATIC_MUTEX wsd_allocator_S_lock;
sl@0
   142
	size_t wsd__node_alloc_impl_S_heap_size;
sl@0
   143
	char* wsd_S_start_free;
sl@0
   144
	char* wsd_S_end_free;
sl@0
   145
	void* wsd_S_free_list[16];	
sl@0
   146
	
sl@0
   147
	std::_STLP_STATIC_MUTEX wsd_pt_S_chunk_allocator_lock;
sl@0
   148
	char *wsd_pt_S_start_free;
sl@0
   149
	char *wsd_pt_S_end_free;
sl@0
   150
	size_t wsd_pt_S_heap_size;
sl@0
   151
	stlp_priv::_Pthread_alloc::__state_type *wsd_pt_S_free_per_thread_states;
sl@0
   152
	pthread_key_t wsd_pt_S_key;
sl@0
   153
	bool wsd_pt_S_key_initialized;
sl@0
   154
	
sl@0
   155
	//_threads.h
sl@0
   156
	std::_STLP_STATIC_MUTEX _threads_S_swap_lock;
sl@0
   157
	std::_STLP_STATIC_MUTEX _threads_0_S_swap_lock;
sl@0
   158
	unsigned _mutex_max;
sl@0
   159
	unsigned _mutex_last;
sl@0
   160
	
sl@0
   161
# ifndef _STLP_NO_MBSTATE_T
sl@0
   162
	std::locale::id codecvt_char_char_mbstate_id;
sl@0
   163
# ifndef _STLP_NO_WCHAR_T
sl@0
   164
	std::locale::id codecvt_wchar_char_mbstate_id;
sl@0
   165
# endif
sl@0
   166
# endif		//_STLP_NO_MBSTATE_T
sl@0
   167
	std::locale::id collate_char_id;
sl@0
   168
sl@0
   169
	std::locale::id ctype_char_id;
sl@0
   170
sl@0
   171
	std::locale::id moneypunct_char_true_id;
sl@0
   172
sl@0
   173
	std::locale::id moneypunct_char_false_id;
sl@0
   174
sl@0
   175
	std::locale::id messages_char_id;
sl@0
   176
sl@0
   177
	std::locale::id numpunct_char_id;
sl@0
   178
sl@0
   179
# ifndef _STLP_NO_WCHAR_T
sl@0
   180
	std::locale::id collate_wchar_id;
sl@0
   181
sl@0
   182
	std::locale::id ctype_wchar_id;
sl@0
   183
sl@0
   184
	std::locale::id moneypunct_wchar_true_id;
sl@0
   185
sl@0
   186
	std::locale::id moneypunct_wchar_false_id;
sl@0
   187
sl@0
   188
	std::locale::id numpunct_wchar_id;
sl@0
   189
sl@0
   190
	std::locale::id messages_wchar_id;
sl@0
   191
sl@0
   192
	std::locale::id num_get_wchar_istreambuf_iterator_id;
sl@0
   193
sl@0
   194
	std::locale::id num_get_wchar_wchar_const_id;
sl@0
   195
sl@0
   196
	std::locale::id num_put_wchar_ostreambuf_iterator_id;
sl@0
   197
sl@0
   198
	std::locale::id num_put_wchar_wchar_id;
sl@0
   199
sl@0
   200
	std::locale::id time_get_wchar_istreambuf_iterator_id;
sl@0
   201
sl@0
   202
	std::locale::id time_get_wchar_wchar_const_id;
sl@0
   203
sl@0
   204
	std::locale::id time_put_wchar_ostreambuf_iterator_id;
sl@0
   205
sl@0
   206
	std::locale::id time_put_wchar_wchar_id;
sl@0
   207
sl@0
   208
	std::locale::id money_get_wchar_istreambuf_iterator_id;
sl@0
   209
sl@0
   210
	std::locale::id money_get_wchar_wchar_const_id;
sl@0
   211
sl@0
   212
	std::locale::id money_put_wchar_ostreambuf_iterator_id;
sl@0
   213
sl@0
   214
	std::locale::id money_put_wchar_wchar_id;
sl@0
   215
#endif
sl@0
   216
sl@0
   217
	std::locale::id time_get_char_istreambuf_iterator_id;
sl@0
   218
sl@0
   219
	std::locale::id time_get_char_char_const_id;
sl@0
   220
sl@0
   221
	std::locale::id time_put_char_ostreambuf_iterator_id;
sl@0
   222
sl@0
   223
	std::locale::id time_put_char_char_id;
sl@0
   224
sl@0
   225
	std::locale::id num_get_char_istreambuf_iterator_id;
sl@0
   226
sl@0
   227
	std::locale::id num_get_char_char_const_id;
sl@0
   228
sl@0
   229
	std::locale::id num_put_char_ostreambuf_iterator_id;
sl@0
   230
sl@0
   231
	std::locale::id num_put_char_char_id;
sl@0
   232
sl@0
   233
	std::locale::id num_put_char_back_insert_iterator_id;
sl@0
   234
sl@0
   235
	std::locale::id money_get_char_istreambuf_iterator_id;
sl@0
   236
sl@0
   237
	std::locale::id money_get_char_char_const_id;
sl@0
   238
sl@0
   239
	std::locale::id money_put_char_ostreambuf_iterator_id;
sl@0
   240
sl@0
   241
	std::locale::id money_put_char_char_id;
sl@0
   242
sl@0
   243
	std::map<std::string, std::locale::id> ctype_charT_ids; 		//for ctype<charT>
sl@0
   244
	std::map<std::string, std::locale::id> numpunct_charT_ids; 	//for numpunct<charT>
sl@0
   245
	std::map<std::string, std::locale::id> moneypunct_charT_ids;	//for moneypunct<charT>
sl@0
   246
		
sl@0
   247
#ifdef _STLP_DEBUG
sl@0
   248
	std::string *_Nameless;
sl@0
   249
#endif	
sl@0
   250
	// ****** end of static var definition
sl@0
   251
	
sl@0
   252
    bool is_Initialized;
sl@0
   253
    
sl@0
   254
    //constructor
sl@0
   255
    _Libcpp_wsd();
sl@0
   256
    
sl@0
   257
    //destructor	
sl@0
   258
    ~_Libcpp_wsd();
sl@0
   259
sl@0
   260
};
sl@0
   261
sl@0
   262
sl@0
   263
//declaraions for wsd initialization functions
sl@0
   264
void locale_impl_init();
sl@0
   265
void locale_index_lock_init();
sl@0
   266
void monetary_empty_string_init();
sl@0
   267
void global_iostream_init();
sl@0
   268
void stdcpp_allocators_init();
sl@0
   269
void filebuf_page_size_init();
sl@0
   270
sl@0
   271
#ifdef _STLP_DEBUG
sl@0
   272
inline std::string*& get_Nameless();
sl@0
   273
#endif
sl@0
   274
sl@0
   275
namespace _STLP_PRIV_NAME {
sl@0
   276
void locale_catalog_category_hash_lock_init();
sl@0
   277
void Category_Map_Init();
sl@0
   278
_STLP_END_NAMESPACE
sl@0
   279
sl@0
   280
sl@0
   281
const TUid KLibstdcppUID = {0x20017610};
sl@0
   282
sl@0
   283
//cleanup all the WSD allocations
sl@0
   284
IMPORT_C void CleanupWSD();
sl@0
   285
sl@0
   286
//return the global class pointer
sl@0
   287
IMPORT_C _Libcpp_wsd& get_libcpp_wsd();
sl@0
   288
sl@0
   289
#ifdef _STLP_DEBUG
sl@0
   290
inline std::string*& get_Nameless()
sl@0
   291
	{
sl@0
   292
	return get_libcpp_wsd()._Nameless;
sl@0
   293
	}
sl@0
   294
#endif
sl@0
   295
sl@0
   296
sl@0
   297
// ******************************************************//
sl@0
   298
sl@0
   299
//locale wsd functions
sl@0
   300
#include "wsd_locales.h"
sl@0
   301
sl@0
   302
//streams wsd functions
sl@0
   303
#include "wsd_streams.h"
sl@0
   304
sl@0
   305
// ******************************************************//
sl@0
   306
#endif
sl@0
   307
sl@0
   308
#endif /*LIBSTDCPPWSD_H_*/