📄 vospserverdata.hxx
字号:
#ifndef VOSP_SERVER_DATA_H#define VOSP_SERVER_DATA_H/* ==================================================================== * The Vovida Software License, Version 1.0 * * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The names "VOCAL", "Vovida Open Communication Application Library", * and "Vovida Open Communication Application Library (VOCAL)" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact vocal@vovida.org. * * 4. Products derived from this software may not be called "VOCAL", nor * may "VOCAL" appear in their name, without prior written * permission of Vovida Networks, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. * * ==================================================================== * * This software consists of voluntary contributions made by Vovida * Networks, Inc. and many individuals on behalf of Vovida Networks, * Inc. For more information on Vovida Networks, Inc., please see * <http://www.vovida.org/>. * */static const char* const VOspServerData_hxx_Version = "$Id: VOspServerData.hxx,v 1.12 2001/06/29 05:41:00 bko Exp $";#include <stdio.h>#include <string>#include <iostream>#include "VXmlParser.hxx"#include "VException.hxx"/// OSP server data container classclass VOspServerData{ public: /// VOspServerData (void) {} /// constructor from an XML input string of data VOspServerData (string &xml) throw (VException&) { parse(xml); } /// Copy constructor VOspServerData (const VOspServerData& copy) { deepCopy(copy); } /// parse the XML input string void parse (string &xml) throw (VException&) { VXmlParser parser(xml); xmlNode *theNode = parser.findNode(NULL, "localValidation"); _localVal = atoi(parser.getAttribute(theNode, "value").c_str()); theNode = parser.findNode(NULL, "sslLifetime"); _sslLife = atoi(parser.getAttribute(theNode, "value").c_str()); theNode = parser.findNode(NULL, "ospExtension"); _ospExt = atoi(parser.getAttribute(theNode, "value").c_str()); theNode = parser.findNode(NULL, "customerID"); _custID = parser.getAttribute(theNode, "value"); theNode = parser.findNode(NULL, "deviceID"); _devID = parser.getAttribute(theNode, "value"); theNode = parser.findNode(NULL, "auditURL"); _auditURL = parser.getAttribute(theNode, "value"); // http stuff theNode = parser.findNode(NULL, "maxConnections"); _httpMaxConn = atoi(parser.getAttribute(theNode, "value").c_str()); theNode = parser.findNode(NULL, "persistence"); _httpPersist = atoi(parser.getAttribute(theNode, "value").c_str()); theNode = parser.findNode(NULL, "retryDelay"); _httpRetryDelay = atoi(parser.getAttribute(theNode, "value").c_str()); theNode = parser.findNode(NULL, "retryLimit"); _httpRetryLimit = atoi(parser.getAttribute(theNode, "value").c_str()); theNode = parser.findNode(NULL, "timeout"); _httpTimeout = atoi(parser.getAttribute(theNode, "value").c_str()); list < xmlNodePtr > listOfSvcPoints; parser.findNode(NULL, "servicePoint", listOfSvcPoints); _svcPoints.clear(); for (list < xmlNodePtr > ::iterator itr = listOfSvcPoints.begin(); itr != listOfSvcPoints.end(); itr++) { xmlNodePtr svcPointNode = (*itr); // get value attribute from node string val = parser.getAttribute(svcPointNode, "url"); _svcPoints.push_back(val); } _nSvcPoints = _svcPoints.size(); } /// Assignment operator VOspServerData operator= (const VOspServerData& copy) { if (this != ©) { deepCopy(copy); } return *this; } /// int getlocalValidation() const { return _localVal; } /// int getSslLifetime() const { return _sslLife; } /// int getHttpMaxConnections() const { return _httpMaxConn; } /// int getHttpPersistence() const { return _httpPersist; } /// int getHttpRetryDelay() const { return _httpRetryDelay; } /// int getHttpRetryLimit() const { return _httpRetryLimit; } /// int getHttpTimeout() const { return _httpTimeout; } /// int getOspExtension() const { return _ospExt; } /// int getNSvcPoints() const { return _nSvcPoints; } /// const string &getCustomerID() const { return _custID; } /// const string &getDeviceID() const { return _devID; } /// const string &getAuditURL() const { return _auditURL; } /// void getSvcPoints(list < string > &retVal) const { retVal.clear(); for (list < string > ::const_iterator itr = _svcPoints.begin(); itr != _svcPoints.end(); itr++) { retVal.push_back(*itr); } } // this one matches the signature of the original class (back compat so no doc++) const list < string > getSvcPoints( void ) const { return _svcPoints; }; /// friend ostream& operator<< (ostream &os, const VOspServerData &elem); private: /// copy operation to copy all elements (used by copy constructor and assign) void deepCopy(const VOspServerData ©) { _localVal = copy._localVal; _sslLife = copy._sslLife; _httpMaxConn = copy._httpMaxConn; _httpPersist = copy._httpPersist; _httpRetryDelay = copy._httpRetryDelay; _httpRetryLimit = copy._httpRetryLimit; _httpTimeout = copy._httpTimeout; _ospExt = copy._ospExt; _custID = copy._custID; _devID = copy._devID; _auditURL = copy._auditURL; _svcPoints = copy._svcPoints; _nSvcPoints = copy._nSvcPoints; }; int _localVal; int _sslLife; int _httpMaxConn; int _httpPersist; int _httpRetryDelay; int _httpRetryLimit; int _httpTimeout; int _ospExt; string _custID; string _devID; string _auditURL; list < string > _svcPoints; int _nSvcPoints;};///inline ostream& operator<<(ostream &os, const VOspServerData &elem){ os << "Local Validation: " << elem._localVal << endl; os << "SSL Lifetime: " << elem._sslLife << endl; os << "HTTP Max Conn: " << elem._httpMaxConn << endl; os << "HTTP Persistence: " << elem._httpPersist << endl; os << "HTTP Retry Delay: " << elem._httpRetryDelay << endl; os << "HTTP Retry Limit: " << elem._httpRetryLimit << endl; os << "HTTP Timeout: " << elem._httpTimeout << endl; os << "OSP Extension: " << elem._ospExt << endl; os << "Customer ID: " << elem._custID << endl; os << "Device ID: " << elem._devID << endl; os << "Audit URL: " << elem._auditURL << endl; os << "# of Svc Points: " << elem._nSvcPoints << endl; list < string > svcPoints; elem.getSvcPoints(svcPoints); for (list < string > ::const_iterator itr = svcPoints.begin(); itr != svcPoints.end(); itr++) { std::cout << " " << *itr << std::endl; } return os;}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -