summaryrefslogtreecommitdiff
path: root/ParserClass
diff options
context:
space:
mode:
Diffstat (limited to 'ParserClass')
-rw-r--r--ParserClass/FileManContainer/Website.cpp8
-rw-r--r--ParserClass/FileManContainer/Website.hpp5
-rw-r--r--ParserClass/FileManParser.cpp27
-rw-r--r--ParserClass/FileManParser.hpp64
4 files changed, 74 insertions, 30 deletions
diff --git a/ParserClass/FileManContainer/Website.cpp b/ParserClass/FileManContainer/Website.cpp
index 2810d48..f65a66d 100644
--- a/ParserClass/FileManContainer/Website.cpp
+++ b/ParserClass/FileManContainer/Website.cpp
@@ -12,14 +12,14 @@
#include "Website.hpp"
+//Constructor
Website::Website(){
}
-
-
+//----- Getters -----
std::string Website::getTitle(){
return this->title;
}
@@ -38,7 +38,7 @@ std::string Website::getDescription(){
-
+//----- Setters -----
void Website::setTitle(std::string title){
this->title = title;
}
@@ -56,6 +56,8 @@ void Website::setDescription(std::string description){
}
+
+//Equality comparator
bool Website::operator==(const Website& website) const{
if((this->getId()).compare(website.getId())==0){
return true;
diff --git a/ParserClass/FileManContainer/Website.hpp b/ParserClass/FileManContainer/Website.hpp
index 7d68b91..cb293d4 100644
--- a/ParserClass/FileManContainer/Website.hpp
+++ b/ParserClass/FileManContainer/Website.hpp
@@ -64,9 +64,12 @@ class Website : public AbstractIDManager {
void setPassword(std::string password);
void setDescription(std::string description);
- //bool operator==(Website const& website1, Website const& website2) const;
+ /**
+ * @brief Equality comparator
+ */
bool operator==(const Website& website) const;
+
private:
std::string title; ///< Title of the website
diff --git a/ParserClass/FileManParser.cpp b/ParserClass/FileManParser.cpp
index 1434229..57a485a 100644
--- a/ParserClass/FileManParser.cpp
+++ b/ParserClass/FileManParser.cpp
@@ -35,8 +35,20 @@ FileManParser::FileManParser(std::string data){
}
+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>;
@@ -76,33 +88,18 @@ void FileManParser::initWebsites(){
}
else if(currentChild->get_name().compare("description")==0){
newWebsite.setDescription(cdataContent);
-
}
-
-
}
-
this->websites->push_back(newWebsite);
-
-
}
-
}
-std::string FileManParser::getDocument(){
- std::string data=(this->document)->write_to_string();
- return data;
-}
-
-std::vector<Website>* FileManParser::getWebsites(){
- return this->websites;
-}
void FileManParser::updateParser(){
diff --git a/ParserClass/FileManParser.hpp b/ParserClass/FileManParser.hpp
index 5c64708..f0d01e5 100644
--- a/ParserClass/FileManParser.hpp
+++ b/ParserClass/FileManParser.hpp
@@ -9,6 +9,12 @@
*/
+
+#ifndef __FileManParser__
+#define __FileManParser__
+
+
+
//----- std -----
#include <iostream>
#include <sstream>
@@ -24,7 +30,14 @@
-
+/**
+ * @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{
@@ -34,39 +47,68 @@ class FileManParser{
FileManParser(std::string data);
- //Get document in string
+ /**
+ * @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();
- //Get container vector pointer:
+ /**
+ * @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();
- //Apply change that have made on container
+ /**
+ * @brief Update the parser
+ *
+ * Apply all modifications you have made on the vector object (example std::vector<Website>* websites).
+ *
+ */
void updateParser();
private:
- //Instaciate all website container
+ /**
+ * @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;
- xmlpp::DomParser parser;
+ std::stringstream dataStream; ///< Contain the document you want to parse
+ xmlpp::DomParser parser; ///< Contain the parser
//Document attributes
- xmlpp::Document* document;
- xmlpp::Node* rootNode;
+ 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;
- std::vector<Website> *websites;
+ 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