Annotation of parser3/src/main/pa_charset_manager.C, revision 1.1
1.1 ! parser 1: /** @file
! 2: Parser: sql driver manager implementation.
! 3:
! 4: Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
! 5: Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
! 6:
! 7: $Id: pa_charset_manager.C,v 1.4 2001/09/26 10:32:26 parser Exp $
! 8: */
! 9: #include "pa_config_includes.h"
! 10: #ifdef XML
! 11:
! 12: #include "pa_charset_manager.h"
! 13: #include "pa_stylesheet_connection.h"
! 14: #include "ltdl.h"
! 15: #include "pa_exception.h"
! 16: #include "pa_common.h"
! 17: #include "pa_threads.h"
! 18:
! 19: // globals
! 20:
! 21: Charset_manager *charset_manager;
! 22:
! 23: // consts
! 24:
! 25:
! 26: // Charset_manager
! 27:
! 28: Charset_connection& Charset_manager::get_connection(const String& request_name, const String& request_file_spec) {
! 29: Pool& pool=request_name.pool(); // request pool
! 30:
! 31: // first trying to get cached
! 32: Charset_connection *result=get_connection_from_cache(request_file_spec);
! 33: if(!result) {
! 34: // then just construct it
! 35:
! 36: // make global_name C-string on global pool
! 37: const char *request_name_cstr=request_name.cstr(String::UL_FILE_SPEC);
! 38: char *global_name_cstr=(char *)malloc(strlen(request_name_cstr)+1);
! 39: strcpy(global_name_cstr, request_name_cstr);
! 40: // make global_name string on global pool
! 41: String& global_name=*new(this->pool()) String(this->pool(), global_name_cstr);
! 42:
! 43: // make global_file_spec C-string on global pool
! 44: const char *request_file_spec_cstr=request_file_spec.cstr(String::UL_FILE_SPEC);
! 45: char *global_file_spec_cstr=(char *)malloc(strlen(request_file_spec_cstr)+1);
! 46: strcpy(global_file_spec_cstr, request_file_spec_cstr);
! 47: // make global_file_spec string on global pool
! 48: String& global_file_spec=*new(this->pool()) String(this->pool(), global_file_spec_cstr);
! 49:
! 50: // construct result
! 51: result=new(this->pool()) Charset_connection(this->pool(), global_name, global_file_spec);
! 52: // cache it
! 53: put_connection_to_cache(global_file_spec, *result);
! 54: }
! 55: // preload file, need to make addEncoding for xml
! 56: result->up_to_date(pool);
! 57: // return it
! 58: return *result;
! 59: }
! 60:
! 61: // cache
! 62: Charset_connection *Charset_manager::get_connection_from_cache(const String& file_spec) {
! 63: SYNCHRONIZED;
! 64:
! 65: return (Charset_connection *)cache.get(file_spec);
! 66: }
! 67:
! 68: void Charset_manager::put_connection_to_cache(const String& file_spec,
! 69: Charset_connection& connection) {
! 70: SYNCHRONIZED;
! 71:
! 72: cache.put(file_spec, &connection);
! 73: }
! 74:
! 75: #endif
E-mail: