--- parser3/src/main/pa_charsets.C 2001/12/15 21:28:21 1.1 +++ parser3/src/main/pa_charsets.C 2003/03/21 13:42:31 1.11.2.10.2.2 @@ -1,29 +1,47 @@ /** @file Parser: sql driver manager implementation. - Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) - Author: Alexander Petrosyan (http://paf.design.ru) - - $Id: pa_charsets.C,v 1.1 2001/12/15 21:28:21 paf Exp $ + Copyright (c) 2001-2003 ArtLebedev Group (http://www.artlebedev.com) + Author: Alexandr Petrosian (http://paf.design.ru) */ +static const char* IDENT_CHARSETS_C="$Date: 2003/03/21 13:42:31 $"; + #include "pa_charsets.h" -#include "pa_charset.h" + +// defines for globals + +#define CHARSET_UTF8_NAME "UTF-8" // globals -Charsets *charsets; +CharsetPtr UTF8_charset(new Charset(String* (new String(CHARSET_UTF8_NAME)), + 0/*no file=system*/)); -// +Charsets charsets; -Charsets::Charsets(Pool& apool) : Hash(apool) { -} +// methods -static void destroy_charset(const Hash::Key& key, Hash::Val *& value, void *) { - static_cast(value)->~Charset(); +Charsets::Charsets() { + put(UTF8_charset->name(), UTF8_charset); } -Charsets::~Charsets() { - for_each(destroy_charset); +Charset& Charsets::get(const String& aname) { + if(CharsetPtr result=Hash::get(aname)) + return *result; + else + throw Exception("parser.runtime", + aname, + "unknown charset"); } +void Charsets::load_charset(const String& arequest_name, const String& arequest_file_spec) { + //we know that charset? + if(Hash::get(arequest_name)) + return; // don't load it then + + // make global_name string on cache_pool pool + const String& global_name(new String(arequest_name->cstr(charsets_pool))); + + put(global_name, value_type(new Charset(global_name, arequest_file_spec))); +}