Update parser
This commit is contained in:
parent
1f12bca33f
commit
84c669f82a
5 changed files with 94 additions and 91 deletions
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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(){
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue