summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ParserClass/FileManContainer/Website.cpp37
-rw-r--r--ParserClass/FileManContainer/Website.hpp55
-rw-r--r--ParserClass/FileManParser.cpp92
-rw-r--r--ParserClass/FileManParser.hpp35
-rw-r--r--main.cpp31
5 files changed, 243 insertions, 7 deletions
diff --git a/ParserClass/FileManContainer/Website.cpp b/ParserClass/FileManContainer/Website.cpp
index 94fbc04..0d25344 100644
--- a/ParserClass/FileManContainer/Website.cpp
+++ b/ParserClass/FileManContainer/Website.cpp
@@ -7,3 +7,40 @@
* Contain all implementations of Website class.
*
*/
+
+
+#include "Website.hpp"
+
+std::string Website::getTitle(){
+ return this->title;
+}
+std::string Website::getUrl(){
+ return this->url;
+}
+std::string Website::getUsername(){
+ return this->username;
+}
+std::string Website::getPassword(){
+ return this->password;
+}
+std::string Website::getDescription(){
+ return this->description;
+}
+
+
+
+void Website::setTitle(std::string title){
+ this->title = title;
+}
+void Website::setUrl(std::string url){
+ this->url = url;
+}
+void Website::setUsername(std::string username){
+ this->username = username;
+}
+void Website::setPassword(std::string password){
+ this->password = password;
+}
+void Website::setDescription(std::string description){
+ this->description = description;
+}
diff --git a/ParserClass/FileManContainer/Website.hpp b/ParserClass/FileManContainer/Website.hpp
index 2e76df3..01c41f9 100644
--- a/ParserClass/FileManContainer/Website.hpp
+++ b/ParserClass/FileManContainer/Website.hpp
@@ -8,17 +8,70 @@
*
*/
+#ifndef __WEBSITE__
+#define __WEBSITE__
+#include <string>
+
+
+/**
+ * @class FileManIOFile FileManIOFile.hpp "/CryptClass/FileManIOFile.hpp"
+ * @brief Class for quick open and close encrypted file.
+ * @author manzerbredes
+ *
+ * -----File organisation-----
+ *
+ * 16 first bytes : md5 of decrypted file
+ * rest of the file : data encrypted (ASE for now)
+ *
+ */
+
+#include <string>
+
+
+
+/**
+ * @class Website Website.hpp "/ParserClass/FileManContainer/Website.hpp"
+ * @brief Class for quick open and close encrypted file.
+ * @author manzerbredes
+ *
+ * Container for website data.
+ *
+ */
class Website{
public:
+ /**
+ * @brief Containner getters.
+ */
+ std::string getTitle();
+ std::string getUrl();
+ std::string getUsername();
+ std::string getPassword();
+ std::string getDescription();
+ /**
+ * @brief Containner setters.
+ */
+ void setTitle(std::string title);
+ void setUrl(std::string url);
+ void setUsername(std::string username);
+ void setPassword(std::string password);
+ void setDescription(std::string description);
private:
-}
+ std::string title; ///< Title en the website
+ std::string url; ///< Url of the website
+ std::string username; ///< username of the account
+ std::string password; ///< password of the account
+ std::string description; ///< Description of the website
+};
+
+
+#endif
diff --git a/ParserClass/FileManParser.cpp b/ParserClass/FileManParser.cpp
index 43b3302..00db891 100644
--- a/ParserClass/FileManParser.cpp
+++ b/ParserClass/FileManParser.cpp
@@ -7,3 +7,95 @@
* Contain all implementations of FileManParser class.
*
*/
+
+
+#include "FileManParser.hpp"
+
+
+FileManParser::FileManParser(std::string data){
+ this->data=data;
+
+ try {
+ xercesc::XMLPlatformUtils::Initialize();
+ }
+ catch (const xercesc::XMLException& toCatch) {
+ // Do your failure processing here
+
+ }
+
+
+ xercesc::XercesDOMParser *parser = new xercesc::XercesDOMParser();
+ xercesc::MemBufInputSource myxml_buf((const XMLByte*)this->data.c_str(), this->data.size(), "dummy",false);
+
+ parser->parse("Doxygen/doc.xml");
+
+
+ this->document=parser->getDocument();
+ this->root=this->document->getDocumentElement();
+
+ this->initWebsites();
+
+
+
+}
+
+
+
+std::vector<Website> FileManParser::getWebsites(){
+ return this->websites;
+}
+
+
+std::string FileManParser::getData(){ return this->data;};
+
+
+
+void FileManParser::initWebsites(){
+
+ xercesc::DOMElement* websitesElement=this->getChildByTagName(this->root, "websites");
+
+
+ xercesc::DOMNodeList* nodeList=websitesElement->getChildNodes();
+ XMLSize_t nodeCount = nodeList->getLength();
+
+ for(int i=0;i<nodeCount;i++){
+
+ xercesc::DOMNode* current=nodeList->item(i);
+ std::string TagName=xercesc::XMLString::transcode(current->getNodeName());
+
+ if( current->getNodeType() == xercesc::DOMNode::ELEMENT_NODE ) {
+
+ std::cout << this->getContentOfChild(dynamic_cast< xercesc::DOMElement* >( current ),"title");
+ std::cout << this->getContentOfChild(dynamic_cast< xercesc::DOMElement* >( current ),"url");
+
+ }
+ }
+}
+
+
+xercesc::DOMElement* FileManParser::getChildByTagName(xercesc::DOMElement* node, std::string TagName){
+ xercesc::DOMNodeList* nodeList=node->getChildNodes();
+ XMLSize_t nodeCount = nodeList->getLength();
+ xercesc::DOMElement* returnElement=NULL;
+
+ for(int i=0;i<nodeCount;i++){
+
+ xercesc::DOMNode* current=nodeList->item(i);
+ std::string currentTagName=xercesc::XMLString::transcode(current->getNodeName());
+
+ if( current->getNodeType() == xercesc::DOMNode::ELEMENT_NODE ) {
+ if(currentTagName.compare(TagName)==0){
+ returnElement=dynamic_cast< xercesc::DOMElement* >( current );
+ break;
+ }
+ }
+ }
+
+ return returnElement;
+}
+
+
+std::string FileManParser::getContentOfChild(xercesc::DOMElement* node,std::string TagName){
+ xercesc::DOMElement* child=this->getChildByTagName(node,TagName);
+ return xercesc::XMLString::transcode(child->getTextContent());
+}
diff --git a/ParserClass/FileManParser.hpp b/ParserClass/FileManParser.hpp
index 0b35e38..88c959e 100644
--- a/ParserClass/FileManParser.hpp
+++ b/ParserClass/FileManParser.hpp
@@ -8,17 +8,50 @@
*
*/
+//----- std -----
+#include <iostream>
+#include <string>
+#include <vector>
+
+//----- class -----
+#include "Website.hpp"
+
+//----- xerces -----
+#include <xercesc/parsers/XercesDOMParser.hpp>
+#include <xercesc/dom/DOM.hpp>
+#include <xercesc/framework/MemBufInputSource.hpp>
+#include <xercesc/sax/HandlerBase.hpp>
+#include <xercesc/util/XMLString.hpp>
+#include <xercesc/util/PlatformUtils.hpp>
+#include <xercesc/util/XercesDefs.hpp>
+
+
class FileManParser{
public:
+ FileManParser(std::string data);
+
+ std::vector<Website> getWebsites();
+ void initWebsites();
+ std::string getData();
+ xercesc::DOMElement* getChildByTagName(xercesc::DOMElement* node, std::string TagName);
+ std::string getContentOfChild(xercesc::DOMElement* node,std::string TagName);
private:
-}
+ xercesc::DOMDocument* document; ///< contain the document
+
+ xercesc::DOMElement* root;
+
+ std::vector<Website> websites; ///< contain all websites entries
+
+ std::string data; ///< contain data to parse
+
+};
diff --git a/main.cpp b/main.cpp
index 6b1bf23..9a3b3f1 100644
--- a/main.cpp
+++ b/main.cpp
@@ -17,10 +17,8 @@
#include <string>
//----- class -----
-#include "AESCrypt.hpp"
-#include "HASHCrypt.hpp"
#include "FileManIOFile.hpp"
-
+#include "FileManParser.hpp"
/**
@@ -33,7 +31,30 @@
*/
int main(int argc, char *argv[]){
- std::string chaine="It's work !";
+
+
+
+ std::string xml="<?xml version=\"1.0\" standalone=\"yes\" ?>\n\
+<forgetIt> \n\
+<websites> \n\
+ \n\
+ </websites> \n\
+</forgetIt> \n\
+ ";
+
+
+ FileManParser parser(xml);
+
+
+
+ //std::cout << std::endl << parser.getData() << std::endl;
+
+
+
+
+
+
+ /*std::string chaine="It's work !";
std::string key="loic";
AESCrypt aes;
@@ -45,7 +66,7 @@ int main(int argc, char *argv[]){
fichier.read(key);
if(fichier.isReadable())
- std::cout << fichier.getData();
+ std::cout << fichier.getData();*/
return 0;