|
|
| version 1.4, 2001/12/27 19:57:09 | version 1.14, 2003/11/20 16:34:26 |
|---|---|
| Line 1 | Line 1 |
| /** @file | /** @file |
| Parser: sql driver manager implementation. | Parser: sql driver manager implementation. |
| Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) | Copyright (c) 2001-2003 ArtLebedev Group (http://www.artlebedev.com) |
| Author: Alexander Petrosyan <paf@design.ru> (http://paf.design.ru) | Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) |
| $Id$ | |
| */ | */ |
| static const char * const IDENT_CHARSETS_C="$Date$"; | |
| #include "pa_charsets.h" | #include "pa_charsets.h" |
| #include "pa_charset.h" | |
| // globals | // defines for globals |
| Charsets *charsets; | #define CHARSET_UTF8_NAME "UTF-8" |
| // | // globals |
| Charsets::Charsets(Pool& apool) : Hash(apool) { | Charset UTF8_charset(0, *new String(CHARSET_UTF8_NAME), 0/*no file=system*/); |
| } | |
| static void destroy_charset(const Hash::Key& , Hash::Val *& value, void *) { | Charsets charsets; |
| static_cast<Charset *>(value)->~Charset(); | |
| } | // methods |
| Charsets::~Charsets() { | Charsets::Charsets() { |
| for_each(destroy_charset); | put(UTF8_charset.NAME(), &UTF8_charset); |
| } | } |
| Charset& Charsets::get_charset(const String& name) { | Charset& Charsets::get(const String::Body ANAME) { |
| if(Charset *result=(Charset *)get(name)) | if(Charset* result=Hash<key_type, value_type>::get(ANAME)) |
| return *result; | return *result; |
| else | else |
| throw Exception(0, 0, | throw Exception("parser.runtime", |
| &name, | new String(ANAME, String::L_TAINTED), |
| "unknown charset"); | "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? | //we know that charset? |
| if(get(request_name)) | if(Hash<key_type, value_type>::get(ANAME)) |
| return; // don't load it then | return; // don't load it then |
| const char *name_cstr=request_name.cstr(); | put(ANAME, new Charset(&charsets, ANAME, &afile_spec)); |
| 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)); | |
| } | } |