diff --git a/include/SAX/helpers/InputSourceResolver.cpp b/include/SAX/helpers/InputSourceResolver.cpp deleted file mode 100644 index 3d1a479d..00000000 --- a/include/SAX/helpers/InputSourceResolver.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/* - * $Id$ - */ - -#ifdef _MSC_VER -#pragma warning(disable: 4786) -#endif - -#include -#include -#include -#include - -InputSourceResolver::InputSourceResolver(const SAX::InputSource& inputSource) : - deleteStream_(false), - byteStream_(0) -{ - open(inputSource.getPublicId(), - inputSource.getSystemId(), - inputSource.getByteStream()); -} // InputSourceResolver - -void InputSourceResolver::open(const std::string& publicId, - const std::string& systemId, - std::istream* byteStream) -{ - if(byteStream != 0) - { - byteStream_ = byteStream; - return; - } - - // does it look like a URL? - std::string::size_type colonIndex = systemId.find("://"); - if(colonIndex != std::string::npos) - { - URIResolver res = findResolver(systemId.substr(0, colonIndex)); - if(res) - byteStream_ = res(systemId); - if(byteStream_) - { - deleteStream_ = true; - return; - } // if ... - } // if ... - - // try and open it as a file - std::ifstream* ifs = new std::ifstream(systemId.c_str()); - if(ifs->is_open()) - { - deleteStream_ = true; - byteStream_ = ifs; - } - else - delete ifs; -} // InputSourceResolver - -InputSourceResolver::~InputSourceResolver() -{ - if(deleteStream_) - delete byteStream_; -} // ~InputSourceResolver - -////////////////////////////////////////////////////// -// resolverMap register/unregister -bool InputSourceResolver::registerResolver(const std::string& method, URIResolver resolver) -{ - resolverMap()[method] = resolver; - return true; -} // registerResolver - -bool InputSourceResolver::unRegisterResolver(const std::string& method) -{ - resolverMapT::iterator i = resolverMap().find(method); - if(i != resolverMap().end()) - resolverMap().erase(i); - return true; -} // unRegisterResolver - -InputSourceResolver::URIResolver InputSourceResolver::findResolver(std::string method) -{ - resolverMapT::iterator i = resolverMap().find(method); - return (i != resolverMap().end()) ? i->second : 0; -} // findResolver - -namespace -{ - std::istream* fileResolver(const std::string& fileURL) - { - int colon = fileURL.find("://"); - std::string fileName = fileURL.substr(colon+3); - - std::ifstream* ifs = new std::ifstream(fileName.c_str()); - if(ifs->is_open()) - return ifs; - delete ifs; - - // WIN32 specific stuff - for(std::string::iterator i = fileName.begin(); i != fileName.end(); ++i) - if(*i == '/') - *i = '\\'; - - if((fileName[0] == '\\') && (fileName[2] == ':')) - fileName.erase(0, 1); - - ifs = new std::ifstream(fileName.c_str()); - if(ifs->is_open()) - return ifs; - delete ifs; - - return 0; - } // fileResolver - - static bool fileReg = InputSourceResolver::registerResolver("file", fileResolver); - - std::istream* httpResolver(const std::string& httpURL) - { -#ifdef ARABICA_WINDOWS - WORD wVersionRequested; - WSADATA wsaData; - int err; - - wVersionRequested = MAKEWORD(1, 1); - err = WSAStartup( wVersionRequested, &wsaData ); - if(err != 0) - return 0; -#endif - - int colon1 = httpURL.find("://"); - colon1 += 3; - //int colon2 = httpURL.find("://", colon1); - int slash1 = httpURL.find("/", colon1); - - std::string hostName = httpURL.substr(colon1, slash1 - (colon1)); - std::string path = httpURL.substr(slash1); - - Arabica::socketstream* ifs = new Arabica::socketstream(hostName.c_str(), 80); - if(!ifs->is_open()) - return 0; - *ifs << "GET " << path << " HTTP/1.0" << std::endl; - *ifs << "Host: " << hostName << std::endl; - *ifs << "Connection: close" << std::endl; - *ifs << std::endl; - - - char buffer[1024]; - do - { - ifs->getline(buffer, sizeof(buffer)); - } - while(buffer[0] != '\r'); - - return ifs; - } // httpResolver - - static bool httpReg = InputSourceResolver::registerResolver("http", httpResolver); -} // namespace - -// end of file diff --git a/include/XML b/include/XML new file mode 100644 index 00000000..a679041e --- /dev/null +++ b/include/XML @@ -0,0 +1,289 @@ +#ifndef ARABICA_XML_UNICODE_CHARACTERS_H +#define ARABICA_XML_UNICODE_CHARACTERS_H + +namespace Arabica +{ + +template +struct Unicode +{ + static const charT HORIZONTAL_TABULATION; + static const charT LINE_FEED; + static const charT CARRIAGE_RETURN; + static const charT SPACE; + static const charT EXCLAMATION_MARK; + static const charT QUOTATION_MARK; + static const charT NUMBER_SIGN; + static const charT PERCENT_SIGN; + static const charT AMPERSAND; + static const charT APOSTROPHE; + static const charT LEFT_PARENTHESIS; + static const charT RIGHT_PARENTHESIS; + static const charT ASTERISK; + static const charT PLUS_SIGN; + static const charT COMMA; + static const charT HYPHEN_MINUS; + static const charT FULL_STOP; + static const charT SLASH; + static const charT NUMBER_0; + static const charT NUMBER_1; + static const charT NUMBER_2; + static const charT NUMBER_3; + static const charT NUMBER_4; + static const charT NUMBER_5; + static const charT NUMBER_6; + static const charT NUMBER_7; + static const charT NUMBER_8; + static const charT NUMBER_9; + static const charT COLON; + static const charT SEMI_COLON; + static const charT LESS_THAN_SIGN; + static const charT EQUALS_SIGN; + static const charT GREATER_THAN_SIGN; + static const charT QUESTION_MARK; + static const charT CAPITAL_A; + static const charT CAPITAL_B; + static const charT CAPITAL_C; + static const charT CAPITAL_D; + static const charT CAPITAL_E; + static const charT CAPITAL_F; + static const charT CAPITAL_G; + static const charT CAPITAL_H; + static const charT CAPITAL_I; + static const charT CAPITAL_J; + static const charT CAPITAL_K; + static const charT CAPITAL_L; + static const charT CAPITAL_M; + static const charT CAPITAL_N; + static const charT CAPITAL_O; + static const charT CAPITAL_P; + static const charT CAPITAL_Q; + static const charT CAPITAL_R; + static const charT CAPITAL_S; + static const charT CAPITAL_T; + static const charT CAPITAL_U; + static const charT CAPITAL_V; + static const charT CAPITAL_W; + static const charT CAPITAL_X; + static const charT CAPITAL_Y; + static const charT CAPITAL_Z; + static const charT LEFT_SQUARE_BRACKET; + static const charT BACK_SLASH; + static const charT RIGHT_SQUARE_BRACKET; + static const charT LOW_LINE; + static const charT LOWERCASE_A; + static const charT LOWERCASE_B; + static const charT LOWERCASE_C; + static const charT LOWERCASE_D; + static const charT LOWERCASE_E; + static const charT LOWERCASE_F; + static const charT LOWERCASE_G; + static const charT LOWERCASE_H; + static const charT LOWERCASE_I; + static const charT LOWERCASE_J; + static const charT LOWERCASE_K; + static const charT LOWERCASE_L; + static const charT LOWERCASE_M; + static const charT LOWERCASE_N; + static const charT LOWERCASE_O; + static const charT LOWERCASE_P; + static const charT LOWERCASE_Q; + static const charT LOWERCASE_R; + static const charT LOWERCASE_S; + static const charT LOWERCASE_T; + static const charT LOWERCASE_U; + static const charT LOWERCASE_V; + static const charT LOWERCASE_W; + static const charT LOWERCASE_X; + static const charT LOWERCASE_Y; + static const charT LOWERCASE_Z; + static const charT VERTICAL_BAR; +}; // namespace XML + +template +const charT Unicode::HORIZONTAL_TABULATION = 0x09; +template +const charT Unicode::LINE_FEED = 0x0A; +template +const charT Unicode::CARRIAGE_RETURN = 0x0D; +template +const charT Unicode::SPACE = 0x20; +template +const charT Unicode::EXCLAMATION_MARK = 0x21; // ! +template +const charT Unicode::QUOTATION_MARK = 0x22; // " +template +const charT Unicode::NUMBER_SIGN = 0x23; // # +template +const charT Unicode::PERCENT_SIGN = 0x25; // % +template +const charT Unicode::AMPERSAND = 0x26; // & +template +const charT Unicode::APOSTROPHE = 0x27; // ' +template +const charT Unicode::LEFT_PARENTHESIS = 0x28; // ( +template +const charT Unicode::RIGHT_PARENTHESIS = 0x29; // ) +template +const charT Unicode::ASTERISK = 0x2A; // * +template +const charT Unicode::PLUS_SIGN = 0x2B; // + +template +const charT Unicode::COMMA = 0x2C; // , +template +const charT Unicode::HYPHEN_MINUS = 0x2D; // - +template +const charT Unicode::FULL_STOP = 0x2E; // . +template +const charT Unicode::SLASH = 0x2F; // / +template +const charT Unicode::NUMBER_0 = 0x30; +template +const charT Unicode::NUMBER_1 = 0x31; +template +const charT Unicode::NUMBER_2 = 0x32; +template +const charT Unicode::NUMBER_3 = 0x33; +template +const charT Unicode::NUMBER_4 = 0x34; +template +const charT Unicode::NUMBER_5 = 0x35; +template +const charT Unicode::NUMBER_6 = 0x36; +template +const charT Unicode::NUMBER_7 = 0x37; +template +const charT Unicode::NUMBER_8 = 0x38; +template +const charT Unicode::NUMBER_9 = 0x39; +template +const charT Unicode::COLON = 0x3A; // : +template +const charT Unicode::SEMI_COLON = 0x3B; // ; +template +const charT Unicode::LESS_THAN_SIGN = 0x3C; // < +template +const charT Unicode::EQUALS_SIGN = 0x3D; // = +template +const charT Unicode::GREATER_THAN_SIGN = 0x3E; // > +template +const charT Unicode::QUESTION_MARK = 0x3F; // ? +template +const charT Unicode::CAPITAL_A = 0x41; +template +const charT Unicode::CAPITAL_B = 0x42; +template +const charT Unicode::CAPITAL_C = 0x43; +template +const charT Unicode::CAPITAL_D = 0x44; +template +const charT Unicode::CAPITAL_E = 0x45; +template +const charT Unicode::CAPITAL_F = 0x46; +template +const charT Unicode::CAPITAL_G = 0x47; +template +const charT Unicode::CAPITAL_H = 0x48; +template +const charT Unicode::CAPITAL_I = 0x49; +template +const charT Unicode::CAPITAL_J = 0x4A; +template +const charT Unicode::CAPITAL_K = 0x4B; +template +const charT Unicode::CAPITAL_L = 0x4C; +template +const charT Unicode::CAPITAL_M = 0x4D; +template +const charT Unicode::CAPITAL_N = 0x4E; +template +const charT Unicode::CAPITAL_O = 0x4F; +template +const charT Unicode::CAPITAL_P = 0x50; +template +const charT Unicode::CAPITAL_Q = 0x51; +template +const charT Unicode::CAPITAL_R = 0x52; +template +const charT Unicode::CAPITAL_S = 0x53; +template +const charT Unicode::CAPITAL_T = 0x54; +template +const charT Unicode::CAPITAL_U = 0x55; +template +const charT Unicode::CAPITAL_V = 0x56; +template +const charT Unicode::CAPITAL_W = 0x57; +template +const charT Unicode::CAPITAL_X = 0x58; +template +const charT Unicode::CAPITAL_Y = 0x59; +template +const charT Unicode::CAPITAL_Z = 0x5A; +template +const charT Unicode::LEFT_SQUARE_BRACKET = 0x5B; // ] +template +const charT Unicode::BACK_SLASH = 0x5C; // +template +const charT Unicode::RIGHT_SQUARE_BRACKET = 0x5D; // [ +template +const charT Unicode::LOW_LINE = 0x5F; // _ +template +const charT Unicode::LOWERCASE_A = 0x61; +template +const charT Unicode::LOWERCASE_B = 0x62; +template +const charT Unicode::LOWERCASE_C = 0x63; +template +const charT Unicode::LOWERCASE_D = 0x64; +template +const charT Unicode::LOWERCASE_E = 0x65; +template +const charT Unicode::LOWERCASE_F = 0x66; +template +const charT Unicode::LOWERCASE_G = 0x67; +template +const charT Unicode::LOWERCASE_H = 0x68; +template +const charT Unicode::LOWERCASE_I = 0x69; +template +const charT Unicode::LOWERCASE_J = 0x6A; +template +const charT Unicode::LOWERCASE_K = 0x6B; +template +const charT Unicode::LOWERCASE_L = 0x6C; +template +const charT Unicode::LOWERCASE_M = 0x6D; +template +const charT Unicode::LOWERCASE_N = 0x6E; +template +const charT Unicode::LOWERCASE_O = 0x6F; +template +const charT Unicode::LOWERCASE_P = 0x70; +template +const charT Unicode::LOWERCASE_Q = 0x71; +template +const charT Unicode::LOWERCASE_R = 0x72; +template +const charT Unicode::LOWERCASE_S = 0x73; +template +const charT Unicode::LOWERCASE_T = 0x74; +template +const charT Unicode::LOWERCASE_U = 0x75; +template +const charT Unicode::LOWERCASE_V = 0x76; +template +const charT Unicode::LOWERCASE_W = 0x77; +template +const charT Unicode::LOWERCASE_X = 0x78; +template +const charT Unicode::LOWERCASE_Y = 0x79; +template +const charT Unicode::LOWERCASE_Z = 0x7A; +template +const charT Unicode::VERTICAL_BAR = 0x7C; // | + +} // namespace Arabica + +#endif +