--- parser3/src/main/pa_charsets.C 2001/12/26 08:46:13 1.3 +++ parser3/src/main/pa_charsets.C 2012/03/16 09:24:13 1.19 @@ -1,51 +1,43 @@ /** @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.3 2001/12/26 08:46:13 paf Exp $ + Copyright (c) 2001-2012 Art. Lebedev Studio (http://www.artlebedev.com) + Author: Alexandr Petrosian (http://paf.design.ru) */ #include "pa_charsets.h" -#include "pa_charset.h" -// globals +volatile const char * IDENT_PA_CHARSETS_C="$Id: pa_charsets.C,v 1.19 2012/03/16 09:24:13 moko Exp $" IDENT_PA_CHARSETS_H; -Charsets *charsets; +// defines for globals -// +#define CHARSET_UTF8_NAME "UTF-8" -Charsets::Charsets(Pool& apool) : Hash(apool) { -} +// globals -static void destroy_charset(const Hash::Key& , Hash::Val *& value, void *) { - static_cast(value)->~Charset(); -} +Charset UTF8_charset(0, *new String(CHARSET_UTF8_NAME), 0/*no file=system*/); + +Charsets charsets; -Charsets::~Charsets() { - for_each(destroy_charset); +// methods + +Charsets::Charsets() { + put(UTF8_charset.NAME(), &UTF8_charset); } -Charset& Charsets::get_charset(const String& name) { - if(Charset *result=(Charset *)get(name)) +Charset& Charsets::get(const String::Body ANAME) { + if(Charset* result=HashString::get(ANAME)) return *result; else - throw Exception(0, 0, - &name, + throw Exception(PARSER_RUNTIME, + new String(ANAME, String::L_TAINTED), "unknown charset"); } -void Charsets::load_charset(const String& request_name, const String& request_file_spec) { +void Charsets::load_charset(Request_charsets& charsets, const String::Body ANAME, const String& afile_spec) { //we know that charset? - if(get(request_name)) + if(HashString::get(ANAME)) return; // don't load it then - const char *name_cstr=request_name.cstr(); - char *global_name_cstr=(char *)malloc(strlen(name_cstr)+1); - strcpy(global_name_cstr, name_cstr); - // make global_name string on global pool - String& global_name=*NEW String(pool(), global_name_cstr); - - put(request_name, NEW Charset(pool(), global_name, &request_file_spec)); -} \ No newline at end of file + put(ANAME, new Charset(&charsets, ANAME, &afile_spec)); +}