--- parser3/src/main/pa_charsets.C 2001/12/17 18:44:51 1.2 +++ parser3/src/main/pa_charsets.C 2003/01/28 11:46:45 1.11.2.3 @@ -1,37 +1,42 @@ /** @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.2 2001/12/17 18:44:51 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/01/28 11:46:45 $"; + #include "pa_charsets.h" -#include "pa_charset.h" + +// statics // globals -Charsets *charsets; +Charsets charsets; // -Charsets::Charsets(Pool& apool) : Hash(apool) { -} - -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_charset(const String& name) { - if(Charset *result=(Charset *)get(name)) - return *result; +CharsetPtr Charsets::get(ConstStringPtr aname) { + if(CharsetPtr result=Hash::get(aname)) + return result; else - throw Exception(0, 0, - &name, + throw Exception("parser.runtime", + aname, "unknown charset"); } + +void Charsets::load_charset(ConstStringPtr arequest_name, ConstStringPtr arequest_file_spec) { + //we know that charset? + if(get(arequest_name)) + return; // don't load it then + + // make global_name string on cache_pool pool + StringPtr global_name(new String(arequest_name->cstr(charsets_pool))); + + put(global_name, value_type(new Charset(global_name, arequest_file_spec))); +}