|
|
| version 1.8, 2002/03/27 15:30:36 | version 1.11.2.4, 2003/01/29 11:06:43 |
|---|---|
| Line 1 | Line 1 |
| /** @file | /** @file |
| Parser: sql driver manager implementation. | Parser: sql driver manager implementation. |
| Copyright (c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com) | Copyright (c) 2001, 2003 ArtLebedev Group (http://www.artlebedev.com) |
| Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) | Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) |
| $Id$ | |
| */ | */ |
| static const char* IDENT_CHARSETS_C="$Date$"; | |
| #include "pa_charsets.h" | #include "pa_charsets.h" |
| #include "pa_charset.h" | #include "pa_value_includes.h" |
| // globals | // globals |
| Charsets *charsets; | Charsets charsets; |
| // | |
| Charsets::Charsets(Pool& apool) : Hash(apool) { | // methods |
| } | |
| static void destroy_charset(const Hash::Key& , Hash::Val *& value, void *) { | |
| static_cast<Charset *>(value)->~Charset(); | |
| } | |
| Charsets::~Charsets() { | Charsets::Charsets() { |
| for_each(destroy_charset); | put(UTF8_charset->name(), UTF8_charset); |
| } | } |
| Charset& Charsets::get_charset(const String& name) { | Charset *Charsets::get(ConstStringPtr aname) { |
| if(Charset *result=(Charset *)get(name)) | if(CharsetPtr result=Hash<key_type, value_type>::get(aname)) |
| return *result; | return result.get(); |
| else | else |
| throw Exception("parser.runtime", | throw Exception("parser.runtime", |
| &name, | aname, |
| "unknown charset"); | "unknown charset"); |
| } | } |
| void Charsets::load_charset(const String& request_name, const String& request_file_spec) { | void Charsets::load_charset(ConstStringPtr arequest_name, ConstStringPtr arequest_file_spec) { |
| //we know that charset? | //we know that charset? |
| if(get(request_name)) | if(get(arequest_name)) |
| return; // don't load it then | return; // don't load it then |
| const char *name_cstr=request_name.cstr(); | // make global_name string on cache_pool pool |
| char *global_name_cstr=(char *)malloc(strlen(name_cstr)+1); | StringPtr global_name(new String(arequest_name->cstr(charsets_pool))); |
| strcpy(global_name_cstr, name_cstr); | |
| // make global_name string on global pool | |
| String& global_name=*NEW String(pool(), global_name_cstr); | |
| put(global_name, NEW Charset(pool(), global_name, &request_file_spec)); | put(global_name, value_type(new Charset(global_name, arequest_file_spec))); |
| } | } |