This commit is contained in:
Ren RenJuan 2014-01-25 17:30:04 +00:00
parent 2f1e7252fd
commit b2163785a7
6 changed files with 419 additions and 0 deletions

View File

@ -0,0 +1,20 @@
/*
* Drafttanepplaunchphase.cpp
*
* Created on: Jan 25, 2014
* Author: jdaugherty
*/
#include <map>
#include <string>
#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
}

View File

@ -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<std::string, std::string> KeyValueList;
typedef std::map<std::string, KeyValueList> ExtensionList;
class Draft_tan_epp_launchphase {
public:
Draft_tan_epp_launchphase();
virtual ~Draft_tan_epp_launchphase();
};
#endif /* DRAFTTANEPPLAUNCHPHASE_H_ */

View File

@ -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<std::string> LPChkRespExtension::getLists() const
{
std::set<std::string> kvListNames;
ExtensionList::const_iterator extensionListIterator;
for (extensionListIterator = kvLists.begin();
extensionListIterator != kvLists.end();
extensionListIterator++)
{
kvListNames.insert(extensionListIterator->first);
}
return kvListNames;
}
const std::set<std::string> LPChkRespExtension::getListItems(
const std::string &listName) const
{
std::set<std::string> 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;
}

View File

@ -0,0 +1,66 @@
#ifndef LPCK_RESPONSE_EXTENSION_H_
#define LPCK_RESPONSE_EXTENSION_H_
#include <set>
#include <string>
#include <se/ResponseExtension.hpp>
#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<std::string> 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<std::string> 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_ */

View File

@ -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<std::string> LPCrtRespExtension::getLists() const
{
std::set<std::string> kvListNames;
ExtensionList::const_iterator extensionListIterator;
for (extensionListIterator = kvLists.begin();
extensionListIterator != kvLists.end();
extensionListIterator++)
{
kvListNames.insert(extensionListIterator->first);
}
return kvListNames;
}
const std::set<std::string> LPCrtRespExtension::getListItems(
const std::string &listName) const
{
std::set<std::string> 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;
}

View File

@ -0,0 +1,66 @@
#ifndef LPCR_RESPONSE_EXTENSION_H_
#define LPCR_RESPONSE_EXTENSION_H_
#include <set>
#include <string>
#include <se/ResponseExtension.hpp>
#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<std::string> 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<std::string> 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_ */