00001 // -*- C++ -*- $Id: InputSource.cpp 77257 2007-02-20 17:27:00Z johnnyw $ 00002 00003 #include "ACEXML/common/InputSource.h" 00004 #include "ACEXML/common/StreamFactory.h" 00005 #include "ace/ACE.h" 00006 00007 ACEXML_InputSource::ACEXML_InputSource (void) 00008 : charStream_ (0), 00009 encoding_ (0), 00010 publicId_ (0), 00011 systemId_ (0) 00012 { 00013 } 00014 00015 ACEXML_InputSource::ACEXML_InputSource (ACEXML_CharStream *stm) 00016 : charStream_ (stm), 00017 encoding_ (ACE::strnew (stm->getEncoding())), 00018 publicId_ (0), 00019 systemId_ (stm->getSystemId() ? ACE::strnew (stm->getSystemId()): 0) 00020 { 00021 } 00022 00023 /* 00024 * Create a new input source with a character stream. 00025 * 00026 */ 00027 00028 ACEXML_InputSource::ACEXML_InputSource (const ACEXML_Char *systemId) 00029 : charStream_ (0), 00030 encoding_ (0), 00031 publicId_ (0), 00032 systemId_ (ACE::strnew (systemId)) 00033 { 00034 ACEXML_StreamFactory factory; 00035 ACEXML_CharStream* stm = factory.create_stream (this->systemId_); 00036 if (stm) 00037 { 00038 this->setCharStream (stm); 00039 this->setEncoding (this->charStream_->getEncoding()); 00040 } 00041 } 00042 00043 ACEXML_InputSource::~ACEXML_InputSource (void) 00044 { 00045 delete[] this->publicId_; 00046 this->publicId_ = 0; 00047 delete[] this->systemId_; 00048 this->systemId_ = 0; 00049 delete this->charStream_; 00050 this->charStream_ = 0; 00051 delete[] this->encoding_; 00052 this->encoding_ = 0; 00053 } 00054 00055 ACEXML_CharStream * 00056 ACEXML_InputSource::getCharStream (void) const 00057 { 00058 return this->charStream_; 00059 } 00060 00061 const ACEXML_Char * 00062 ACEXML_InputSource::getEncoding (void) const 00063 { 00064 return this->encoding_; 00065 } 00066 00067 const ACEXML_Char * 00068 ACEXML_InputSource::getPublicId (void) const 00069 { 00070 return this->publicId_; 00071 } 00072 00073 const ACEXML_Char * 00074 ACEXML_InputSource::getSystemId (void) const 00075 { 00076 return this->systemId_; 00077 } 00078 00079 void 00080 ACEXML_InputSource::setCharStream (ACEXML_CharStream *stm) 00081 { 00082 delete this->charStream_; 00083 this->charStream_ = stm; 00084 } 00085 00086 void 00087 ACEXML_InputSource::setEncoding (const ACEXML_Char *encoding) 00088 { 00089 delete[] this->encoding_; 00090 this->encoding_ = ACE::strnew (encoding); 00091 } 00092 00093 void 00094 ACEXML_InputSource::setPublicId (const ACEXML_Char *publicId) 00095 { 00096 delete[] this->publicId_; 00097 this->publicId_ = ACE::strnew (publicId); 00098 } 00099 00100 void 00101 ACEXML_InputSource::setSystemId (const ACEXML_Char *systemId) 00102 { 00103 delete[] this->systemId_; 00104 this->systemId_ = ACE::strnew (systemId); 00105 }