From b2163785a7bba2cb2962ab0af5a0e919b0899f7d Mon Sep 17 00:00:00 2001 From: Ren RenJuan Date: Sat, 25 Jan 2014 17:30:04 +0000 Subject: [PATCH] * --- ACTK1_0/se/LPE/Drafttanepplaunchphase.cpp | 20 ++++ ACTK1_0/se/LPE/Drafttanepplaunchphase.hpp | 25 +++++ ACTK1_0/se/LPE/LPChkRespExtension.cpp | 121 ++++++++++++++++++++++ ACTK1_0/se/LPE/LPChkRespExtension.hpp | 66 ++++++++++++ ACTK1_0/se/LPE/LPCrtRespExtension.cpp | 121 ++++++++++++++++++++++ ACTK1_0/se/LPE/LPCrtRespExtension.hpp | 66 ++++++++++++ 6 files changed, 419 insertions(+) create mode 100644 ACTK1_0/se/LPE/Drafttanepplaunchphase.cpp create mode 100644 ACTK1_0/se/LPE/Drafttanepplaunchphase.hpp create mode 100644 ACTK1_0/se/LPE/LPChkRespExtension.cpp create mode 100644 ACTK1_0/se/LPE/LPChkRespExtension.hpp create mode 100644 ACTK1_0/se/LPE/LPCrtRespExtension.cpp create mode 100644 ACTK1_0/se/LPE/LPCrtRespExtension.hpp diff --git a/ACTK1_0/se/LPE/Drafttanepplaunchphase.cpp b/ACTK1_0/se/LPE/Drafttanepplaunchphase.cpp new file mode 100644 index 0000000..e9bdade --- /dev/null +++ b/ACTK1_0/se/LPE/Drafttanepplaunchphase.cpp @@ -0,0 +1,20 @@ +/* + * Drafttanepplaunchphase.cpp + * + * Created on: Jan 25, 2014 + * Author: jdaugherty + */ + +#include +#include +#include "Drafttanepplaunchphase.hpp" + +Draft_tan_epp_launchphase::Draft_tan_epp_launchphase() { + // TODO Auto-generated constructor stub + +} + +Draft_tan_epp_launchphase::~Draft_tan_epp_launchphase() { + // TODO Auto-generated destructor stub +} + diff --git a/ACTK1_0/se/LPE/Drafttanepplaunchphase.hpp b/ACTK1_0/se/LPE/Drafttanepplaunchphase.hpp new file mode 100644 index 0000000..f627aed --- /dev/null +++ b/ACTK1_0/se/LPE/Drafttanepplaunchphase.hpp @@ -0,0 +1,25 @@ +/* + * Drafttanepplaunchphase.h + * + * Created on: Jan 25, 2014 + * Author: jdaugherty + */ + +#ifndef DRAFTTANEPPLAUNCHPHASE_H_ +#define DRAFTTANEPPLAUNCHPHASE_H_ + // + // The root user data object of the extensiong + // http://tools.ietf.org/html/draft-tan-epp-launchphase-12 + // + + +typedef std::map KeyValueList; +typedef std::map ExtensionList; + +class Draft_tan_epp_launchphase { +public: + Draft_tan_epp_launchphase(); + virtual ~Draft_tan_epp_launchphase(); +}; + +#endif /* DRAFTTANEPPLAUNCHPHASE_H_ */ diff --git a/ACTK1_0/se/LPE/LPChkRespExtension.cpp b/ACTK1_0/se/LPE/LPChkRespExtension.cpp new file mode 100644 index 0000000..9caf9fe --- /dev/null +++ b/ACTK1_0/se/LPE/LPChkRespExtension.cpp @@ -0,0 +1,121 @@ +#include "xml/XMLDocument.hpp" +#include "se/Response.hpp" +#include "se/ResponseExtension.hpp" +#include "se/LPE/LPChkRespExtension.hpp" + +/* + * Have to use static funcion instead of static variable + * since there is not guarantee about the construct/destruct + * order of a static instance of any types + */ +const std::string LPChkRespExtension::KVLIST_EXPR() +{ + return EXTENSION_EXPR() + "/launch:claims"; +} + +LPChkRespExtension::LPChkRespExtension() : + initialised(false), + kvLists() +{ +} + +void LPChkRespExtension::fromXML(XMLDocument *xmlDoc) +{ + int kvListCount = xmlDoc->getNodeCount("count(" + KVLIST_EXPR() + ")"); + + if (kvListCount == 0) + { + initialised = false; + } + else + { + for (int i = 1; i <= kvListCount; i++) + { + const std::string currentKVListXPath = + ReceiveSE::replaceIndex(KVLIST_EXPR() + "[IDX]", i); + const std::string kvListName = + xmlDoc->getNodeValue(currentKVListXPath + "/@name"); + + kvLists[kvListName] = createKVList(xmlDoc, currentKVListXPath); + } + + initialised = true; + } +} + +const std::set LPChkRespExtension::getLists() const +{ + std::set kvListNames; + + ExtensionList::const_iterator extensionListIterator; + + for (extensionListIterator = kvLists.begin(); + extensionListIterator != kvLists.end(); + extensionListIterator++) + { + kvListNames.insert(extensionListIterator->first); + } + + return kvListNames; +} + +const std::set LPChkRespExtension::getListItems( + const std::string &listName) const +{ + std::set itemNames; + ExtensionList::const_iterator extensionListIterator = kvLists.find(listName); + + if (extensionListIterator != kvLists.end()) + { + KeyValueList::const_iterator keyValueListIterator; + + for (keyValueListIterator = extensionListIterator->second.begin(); + keyValueListIterator != extensionListIterator->second.end(); + keyValueListIterator++) + { + itemNames.insert(keyValueListIterator->first); + } + } + + return itemNames; +} + +const std::string LPChkRespExtension::getItem( + const std::string &listName, + const std::string &key) const +{ + std::string itemValue; + ExtensionList::const_iterator extensionListIterator = kvLists.find(listName); + + if (extensionListIterator != kvLists.end()) + { + KeyValueList::const_iterator keyValueListIterator = + extensionListIterator->second.find(key); + + if (keyValueListIterator != extensionListIterator->second.end()) + { + itemValue = keyValueListIterator->second; + } + } + + return itemValue; +} + +const KeyValueList LPChkRespExtension::createKVList( + XMLDocument *xmlDoc, + const std::string &kvListXPath) +{ + int kvItemCount = xmlDoc->getNodeCount("count(" + kvListXPath + "/kv:item)"); + + KeyValueList kvList; + + for (int i = 1; i <= kvItemCount; i++) + { + std::string itemXPath = ReceiveSE::replaceIndex(kvListXPath + "/kv:item[IDX]", i); + std::string key = xmlDoc->getNodeValue(itemXPath + "/@key"); + std::string value = xmlDoc->getNodeValue(itemXPath); + kvList[key] = value; + } + + return kvList; +} diff --git a/ACTK1_0/se/LPE/LPChkRespExtension.hpp b/ACTK1_0/se/LPE/LPChkRespExtension.hpp new file mode 100644 index 0000000..93794d0 --- /dev/null +++ b/ACTK1_0/se/LPE/LPChkRespExtension.hpp @@ -0,0 +1,66 @@ +#ifndef LPCK_RESPONSE_EXTENSION_H_ +#define LPCK_RESPONSE_EXTENSION_H_ + +#include +#include + +#include +#include "Drafttanepplaunchphase.hpp" + +class XMLDocument; + +class LPChkRespExtension : public ResponseExtension +{ + public: + LPChkRespExtension(); + + virtual void fromXML(XMLDocument *xmlDoc); + virtual bool isInitialised() const; + + /** + * Retrieves the names of all key-value lists that have been added to the + * object. + * + * @return the set of list names + */ + const std::set getLists() const; + + /** + * Retrieves the names of all item keys, for a specified key-value list + * name. + * + * @param listName + * the name of the key-value list + * + * @return the set of item keys + */ + const std::set getListItems(const std::string &listName) const; + + /** + * Retrieves the value of a given key-value item. + * + * @param listName + * the name of the key-value list + * @param key + * the key of the item + * + * @return the value of the item + */ + const std::string getItem(const std::string &listName, const std::string &key) const; + private: + const KeyValueList createKVList( + XMLDocument *xmlDoc, + const std::string &kvListXPath); + + bool initialised; + ExtensionList kvLists; + + static const std::string KVLIST_EXPR(); +}; + +inline bool LPChkRespExtension::isInitialised() const +{ + return initialised; +} + +#endif /* LPCK_RESPONSE_EXTENSION_H_ */ diff --git a/ACTK1_0/se/LPE/LPCrtRespExtension.cpp b/ACTK1_0/se/LPE/LPCrtRespExtension.cpp new file mode 100644 index 0000000..4335ea9 --- /dev/null +++ b/ACTK1_0/se/LPE/LPCrtRespExtension.cpp @@ -0,0 +1,121 @@ +#include "xml/XMLDocument.hpp" +#include "se/Response.hpp" +#include "se/ResponseExtension.hpp" +#include "se/LPE/LPCrtRespExtension.hpp" + +/* + * Have to use static funcion instead of static variable + * since there is not guarantee about the construct/destruct + * order of a static instance of any types + */ +const std::string LPCrtRespExtension::KVLIST_EXPR() +{ + return EXTENSION_EXPR() + "/launch:claims"; +} + +LPCrtRespExtension::LPCrtRespExtension() : + initialised(false), + kvLists() +{ +} + +void LPCrtRespExtension::fromXML(XMLDocument *xmlDoc) +{ + int kvListCount = xmlDoc->getNodeCount("count(" + KVLIST_EXPR() + ")"); + + if (kvListCount == 0) + { + initialised = false; + } + else + { + for (int i = 1; i <= kvListCount; i++) + { + const std::string currentKVListXPath = + ReceiveSE::replaceIndex(KVLIST_EXPR() + "[IDX]", i); + const std::string kvListName = + xmlDoc->getNodeValue(currentKVListXPath + "/@name"); + + kvLists[kvListName] = createKVList(xmlDoc, currentKVListXPath); + } + + initialised = true; + } +} + +const std::set LPCrtRespExtension::getLists() const +{ + std::set kvListNames; + + ExtensionList::const_iterator extensionListIterator; + + for (extensionListIterator = kvLists.begin(); + extensionListIterator != kvLists.end(); + extensionListIterator++) + { + kvListNames.insert(extensionListIterator->first); + } + + return kvListNames; +} + +const std::set LPCrtRespExtension::getListItems( + const std::string &listName) const +{ + std::set itemNames; + ExtensionList::const_iterator extensionListIterator = kvLists.find(listName); + + if (extensionListIterator != kvLists.end()) + { + KeyValueList::const_iterator keyValueListIterator; + + for (keyValueListIterator = extensionListIterator->second.begin(); + keyValueListIterator != extensionListIterator->second.end(); + keyValueListIterator++) + { + itemNames.insert(keyValueListIterator->first); + } + } + + return itemNames; +} + +const std::string LPCrtRespExtension::getItem( + const std::string &listName, + const std::string &key) const +{ + std::string itemValue; + ExtensionList::const_iterator extensionListIterator = kvLists.find(listName); + + if (extensionListIterator != kvLists.end()) + { + KeyValueList::const_iterator keyValueListIterator = + extensionListIterator->second.find(key); + + if (keyValueListIterator != extensionListIterator->second.end()) + { + itemValue = keyValueListIterator->second; + } + } + + return itemValue; +} + +const KeyValueList LPCrtRespExtension::createKVList( + XMLDocument *xmlDoc, + const std::string &kvListXPath) +{ + int kvItemCount = xmlDoc->getNodeCount("count(" + kvListXPath + "/kv:item)"); + + KeyValueList kvList; + + for (int i = 1; i <= kvItemCount; i++) + { + std::string itemXPath = ReceiveSE::replaceIndex(kvListXPath + "/kv:item[IDX]", i); + std::string key = xmlDoc->getNodeValue(itemXPath + "/@key"); + std::string value = xmlDoc->getNodeValue(itemXPath); + kvList[key] = value; + } + + return kvList; +} diff --git a/ACTK1_0/se/LPE/LPCrtRespExtension.hpp b/ACTK1_0/se/LPE/LPCrtRespExtension.hpp new file mode 100644 index 0000000..4fc1768 --- /dev/null +++ b/ACTK1_0/se/LPE/LPCrtRespExtension.hpp @@ -0,0 +1,66 @@ +#ifndef LPCR_RESPONSE_EXTENSION_H_ +#define LPCR_RESPONSE_EXTENSION_H_ + +#include +#include + +#include +#include "Drafttanepplaunchphase.hpp" + +class XMLDocument; + +class LPCrtRespExtension : public ResponseExtension +{ + public: + LPCrtRespExtension(); + + virtual void fromXML(XMLDocument *xmlDoc); + virtual bool isInitialised() const; + + /** + * Retrieves the names of all key-value lists that have been added to the + * object. + * + * @return the set of list names + */ + const std::set getLists() const; + + /** + * Retrieves the names of all item keys, for a specified key-value list + * name. + * + * @param listName + * the name of the key-value list + * + * @return the set of item keys + */ + const std::set getListItems(const std::string &listName) const; + + /** + * Retrieves the value of a given key-value item. + * + * @param listName + * the name of the key-value list + * @param key + * the key of the item + * + * @return the value of the item + */ + const std::string getItem(const std::string &listName, const std::string &key) const; + private: + const KeyValueList createKVList( + XMLDocument *xmlDoc, + const std::string &kvListXPath); + + bool initialised; + ExtensionList kvLists; + + static const std::string KVLIST_EXPR(); +}; + +inline bool LPCrtRespExtension::isInitialised() const +{ + return initialised; +} + +#endif /* LPCK_RESPONSE_EXTENSION_H_ */