diff options
| author | manzerbredes <loic.guegan_secondary@yahoo.fr> | 2015-03-20 10:57:03 +0400 |
|---|---|---|
| committer | manzerbredes <loic.guegan_secondary@yahoo.fr> | 2015-03-20 10:57:03 +0400 |
| commit | 45f7cc5d27b338dae1d36c211cc5720c82f3de35 (patch) | |
| tree | 38c356a4e5ba77520e59964f25cde28527e552bd /ParserClass | |
| parent | eb267792cd70a763bf2dcbfce6e7a09251b3913f (diff) | |
Change file architecture
Diffstat (limited to 'ParserClass')
| -rw-r--r-- | ParserClass/AbstractIDManager.cpp | 39 | ||||
| -rw-r--r-- | ParserClass/AbstractIDManager.hpp | 59 | ||||
| -rw-r--r-- | ParserClass/FileManContainer/Website.cpp | 67 | ||||
| -rw-r--r-- | ParserClass/FileManContainer/Website.hpp | 83 | ||||
| -rw-r--r-- | ParserClass/FileManParser.cpp | 132 | ||||
| -rw-r--r-- | ParserClass/FileManParser.hpp | 114 |
6 files changed, 0 insertions, 494 deletions
diff --git a/ParserClass/AbstractIDManager.cpp b/ParserClass/AbstractIDManager.cpp deleted file mode 100644 index e1c5e13..0000000 --- a/ParserClass/AbstractIDManager.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @file AbstractIDManager.cpp - * @brief AbstractIDManager class definitions - * @author manzerbredes - * @date 11 Mars 2015 - * - * Contain all implémentations of AbstractIDManager class. - * - */ - -#include "AbstractIDManager.hpp" - -AbstractIDManager::AbstractIDManager(){ - this->id=this->generateId(); -} - -AbstractIDManager::AbstractIDManager(std::string id){ - this->id=id; -} -AbstractIDManager::~AbstractIDManager(){ - this->id=id; -} - - - -void AbstractIDManager::setId(std::string id){ - this->id = id; -} - -std::string AbstractIDManager::generateId(){ - boost::uuids::uuid uuid = boost::uuids::random_generator()(); - std::stringstream ss; - ss << uuid; - return ss.str(); -} - -std::string AbstractIDManager::getId() const{ - return this->id; -} diff --git a/ParserClass/AbstractIDManager.hpp b/ParserClass/AbstractIDManager.hpp deleted file mode 100644 index 67d5f6f..0000000 --- a/ParserClass/AbstractIDManager.hpp +++ /dev/null @@ -1,59 +0,0 @@ -/** - * @file AbstractIDManager.hpp - * @brief AbstractIDManager class definitions - * @author manzerbredes - * @date 11 Mars 2015 - * - * Contain all definitions of AbstractIDManager class. - * If you want to manage id in class (like container), use - * this class as superclass. - * - */ - -//----- std ----- -#include <string> -#include <sstream> - - -//----- boost ----- -#include <boost/uuid/uuid.hpp> // uuid class -#include <boost/uuid/uuid_generators.hpp> // generators -#include <boost/uuid/uuid_io.hpp> // streaming operators etc. - - - - -/** - * @class AbstractIDManager AbstractIDManager.hpp "/CryptClass/AbstractIDManager.hpp" - * @brief Managing ID - * @author manzerbredes - * - * This class should not be instantiate directly. - * - */ - class AbstractIDManager{ - - - public: - //Constructor - AbstractIDManager(); - - //Constructor, init with id - AbstractIDManager(std::string); - - //Destructor - ~AbstractIDManager(); - - - //Getters and setters - std::string getId() const; - void setId(std::string id); - - - private: - //Generate and random id - std::string generateId(); - - std::string id; ///< String id attribute - - }; diff --git a/ParserClass/FileManContainer/Website.cpp b/ParserClass/FileManContainer/Website.cpp deleted file mode 100644 index f65a66d..0000000 --- a/ParserClass/FileManContainer/Website.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/** - * @file Website.cpp - * @brief Website class definitions - * @author manzerbredes - * @date 11 Mars 2015 - * - * Contain all implementations of Website class. - * - */ - - -#include "Website.hpp" - - -//Constructor -Website::Website(){ - -} - - - -//----- Getters ----- -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; -} - - - -//----- Setters ----- -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; -} - - - -//Equality comparator -bool Website::operator==(const Website& website) const{ - if((this->getId()).compare(website.getId())==0){ - return true; - } - return false; -} - diff --git a/ParserClass/FileManContainer/Website.hpp b/ParserClass/FileManContainer/Website.hpp deleted file mode 100644 index cb293d4..0000000 --- a/ParserClass/FileManContainer/Website.hpp +++ /dev/null @@ -1,83 +0,0 @@ -/** - * @file Website.hpp - * @brief Website class definitions - * @author manzerbredes - * @date 11 Mars 2015 - * - * Contain all definitions of Website class. - * - */ - -#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> -#include "AbstractIDManager.hpp" - -/** - * @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 AbstractIDManager { - - - public: - - Website(); - - /** - * @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); - - - /** - * @brief Equality comparator - */ - bool operator==(const Website& website) const; - - private: - - std::string title; ///< Title of 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 deleted file mode 100644 index 57a485a..0000000 --- a/ParserClass/FileManParser.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/** - * @file FileManParser.cpp - * @brief FileManParser class definitions - * @author manzerbredes - * @date 11 Mars 2015 - * - * Contain all implementations of FileManParser class. - * - */ - - -#include "FileManParser.hpp" - - -FileManParser::FileManParser(std::string data){ - - //String to stringstream - (this->dataStream) << data; - - //Create parser - //parser.parse_stream(dataStream); - (this->parser).parse_file("Doxygen/doc.xml"); - - //Retrieve document - this->document=(this->parser).get_document(); - - //Init root Node - this->rootNode=(this->document)->get_root_node(); - - //Init container: - this->initWebsites(); - - - -} - - -std::string FileManParser::getDocument(){ - std::string data=(this->document)->write_to_string(); - return data; -} - - -std::vector<Website>* FileManParser::getWebsites(){ - return this->websites; -} - - - - -//----------------Container part------------------------ -void FileManParser::initWebsites(){ - this->websites=new std::vector<Website>; - - std::vector<xmlpp::Node*> websitesNodeSet=this->rootNode->find("//websites"); - this->websitesNode=websitesNodeSet.at(0); - - std::vector<xmlpp::Node*> websiteNodeSet=this->websitesNode->find("*"); - - for(int i=0;i<websiteNodeSet.size();i++){ - xmlpp::Node* current=websiteNodeSet.at(i); - xmlpp::Element* currentElement=(xmlpp::Element*)current; - - Website newWebsite; - newWebsite.setId(currentElement->get_attribute_value("id")); - - std::vector<xmlpp::Node*> websiteChildren=current->find("*"); - - for(int j=0;j<websiteChildren.size();j++){ - xmlpp::Element* currentChild=(xmlpp::Element*)websiteChildren.at(j); - - std::list<xmlpp::Node*> contentNodes=currentChild->get_children(); - xmlpp::CdataNode* cdataNode=(xmlpp::CdataNode*)contentNodes.front(); - std::string cdataContent=cdataNode->get_content(); - - - if(currentChild->get_name().compare("title")==0){ - newWebsite.setTitle(cdataContent); - } - else if(currentChild->get_name().compare("url")==0){ - newWebsite.setUrl(cdataContent); - } - else if(currentChild->get_name().compare("username")==0){ - newWebsite.setUsername(cdataContent); - } - else if(currentChild->get_name().compare("password")==0){ - newWebsite.setPassword(cdataContent); - } - else if(currentChild->get_name().compare("description")==0){ - newWebsite.setDescription(cdataContent); - } - } - this->websites->push_back(newWebsite); - } -} - - - - - - - - - -void FileManParser::updateParser(){ - this->rootNode->remove_child(this->websitesNode); - - xmlpp::Element* websitesNode=this->rootNode->add_child("websites"); - this->websitesNode=(xmlpp::Node*)websitesNode; - - for(int i=0;i<this->websites->size();i++){ - xmlpp::Element* current=this->websitesNode->add_child("website"); - Website currentWebsite=this->websites->at(i); - - current->set_attribute("id", currentWebsite.getId()); - xmlpp::Element* title=current->add_child("title"); - title->add_child_cdata(currentWebsite.getTitle()); - - xmlpp::Element* url=current->add_child("url"); - url->add_child_cdata(currentWebsite.getUrl()); - - xmlpp::Element* username=current->add_child("username"); - username->add_child_cdata(currentWebsite.getUsername()); - - xmlpp::Element* password=current->add_child("password"); - password->add_child_cdata(currentWebsite.getPassword()); - - xmlpp::Element* description=current->add_child("description"); - description->add_child_cdata(currentWebsite.getDescription()); - - } -} diff --git a/ParserClass/FileManParser.hpp b/ParserClass/FileManParser.hpp deleted file mode 100644 index f0d01e5..0000000 --- a/ParserClass/FileManParser.hpp +++ /dev/null @@ -1,114 +0,0 @@ -/** - * @file FileManParser.hpp - * @brief FileManParser class definitions - * @author manzerbredes - * @date 11 Mars 2015 - * - * Contain all definitions of FileManParser class. - * - */ - - - -#ifndef __FileManParser__ -#define __FileManParser__ - - - -//----- std ----- -#include <iostream> -#include <sstream> -#include <string> -#include <vector> - -//----- class ----- -#include "Website.hpp" - -//----- libxml++ ----- -#include <cstdlib> -#include <libxml++/libxml++.h> - - - -/** - * @class FileManParser FileManParser.hpp "/ParserClass/FileManContainer/FileManParser.hpp" - * @brief Class for parser un xml file in a string. - * @author manzerbredes - * - * Parse string using libxml++ library. - * - */ -class FileManParser{ - - - public: - - //Constructor - FileManParser(std::string data); - - - /** - * @brief Get document in string - * - * @return a string that contain the document - * - * Return current document. - * To have an up-to-date document, please run updateParser() before. - * - */ - std::string getDocument(); - - - /** - * @brief Write data in encrypted file. - * - * @return vector pointer that point to the vector of website in document - * - * You can modified this vector, and for apply change run updateParser() - * - */ - std::vector<Website>* getWebsites(); - - - - /** - * @brief Update the parser - * - * Apply all modifications you have made on the vector object (example std::vector<Website>* websites). - * - */ - void updateParser(); - - - private: - - - /** - * @brief Instanciate websites vector - * - * Read the document and create all Website object and put them into - * the websites vector attribute. - * - */ - void initWebsites(); - - - //Parser attributes - std::stringstream dataStream; ///< Contain the document you want to parse - xmlpp::DomParser parser; ///< Contain the parser - - - - //Document attributes - xmlpp::Document* document; ///< Contain the document (generate by the parser and dataStream) - xmlpp::Node* rootNode; ///< Contain the root node of the document - - - //Website attributes - xmlpp::Node* websitesNode; ///< Contain the websites node of the document - std::vector<Website> *websites; ///< Contain all website of the document (you can modify it and run updateParser to apply all modifications). - -}; - - -#endif |
