Update ParserClass files

This commit is contained in:
manzerbredes 2015-03-11 19:53:47 +04:00
parent 2166479d44
commit 41897f295f
7 changed files with 128 additions and 8 deletions

View file

@ -0,0 +1,25 @@
/**
* @file FileManContainer.cpp
* @brief FileManContainer class definitions
* @author manzerbredes
* @date 11 Mars 2015
*
* Contain all implementation of FileManContainer class.
*
*/
#include "FileManContainer.hpp"
FileManContainer::FileManContainer(){
}
void FileManContainer::addWebsite(Website website){
this->websites.push_back(website);
}
std::vector<Website> FileManContainer::getWebsites(){
return this->websites;
}

View file

@ -0,0 +1,46 @@
/**
* @file FileManContainer.hpp
* @brief FileManContainer class definitions
* @author manzerbredes
* @date 11 Mars 2015
*
* Contain all definitions of FileManContainer class.
*
*/
#ifndef __FileManContainer__
#define __FileManContainer__
//----- std -----
#include <string>
#include <vector>
//----- class -----
#include "Website.hpp"
/**
* @class Website Website.hpp "/ParserClass/FileManContainer/Website.hpp"
* @brief Class for manager all FileMan container (websites etc...)
* @author manzerbredes
*
*
*
*/
class FileManContainer{
public:
FileManContainer();
void addWebsite(Website website);
std::vector<Website> getWebsites();
private:
std::vector<Website> websites;
};
#endif

View file

@ -11,6 +11,20 @@
#include "Website.hpp"
Website::Website(){
boost::uuids::uuid uuid = boost::uuids::random_generator()();
std::stringstream ss;
ss << uuid;
this->id=ss.str();
}
std::string Website::getId(){
return this->id;
}
std::string Website::getTitle(){
return this->title;
}
@ -29,6 +43,9 @@ std::string Website::getDescription(){
void Website::setId(std::string id){
this->id = id;
}
void Website::setTitle(std::string title){
this->title = title;
}

View file

@ -27,6 +27,10 @@
*/
#include <string>
#include <sstream>
#include <boost/uuid/uuid.hpp> // uuid class
#include <boost/uuid/uuid_generators.hpp> // generators
#include <boost/uuid/uuid_io.hpp> // streaming operators etc.
@ -43,10 +47,13 @@ class Website{
public:
Website();
/**
* @brief Containner getters.
*/
std::string getId();
std::string getTitle();
std::string getUrl();
std::string getUsername();
@ -57,6 +64,7 @@ class Website{
/**
* @brief Containner setters.
*/
void setId(std::string title);
void setTitle(std::string title);
void setUrl(std::string url);
void setUsername(std::string username);
@ -66,7 +74,8 @@ class Website{
private:
std::string title; ///< Title en the website
std::string id; ///< id of the website
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

View file

@ -41,8 +41,8 @@ FileManParser::FileManParser(std::string data){
std::vector<Website> FileManParser::getWebsites(){
return this->websites;
FileManContainer FileManParser::getContainer(){
return this->container;
}
@ -64,9 +64,25 @@ void FileManParser::initWebsites(){
std::string TagName=xercesc::XMLString::transcode(current->getNodeName());
if( current->getNodeType() == xercesc::DOMNode::ELEMENT_NODE ) {
Website newWebsite;
std::cout << this->getContentOfChild(dynamic_cast< xercesc::DOMElement* >( current ),"title");
std::cout << this->getContentOfChild(dynamic_cast< xercesc::DOMElement* >( current ),"url");
newWebsite.setTitle(\
this->getContentOfChild(dynamic_cast< xercesc::DOMElement* >( current ),"title"));
newWebsite.setUrl(\
this->getContentOfChild(dynamic_cast< xercesc::DOMElement* >( current ),"url"));
newWebsite.setUsername(\
this->getContentOfChild(dynamic_cast< xercesc::DOMElement* >( current ),"username"));
newWebsite.setPassword(\
this->getContentOfChild(dynamic_cast< xercesc::DOMElement* >( current ),"password"));
newWebsite.setDescription(\
this->getContentOfChild(dynamic_cast< xercesc::DOMElement* >( current ),"description"));
this->container.addWebsite(newWebsite);
}
}

View file

@ -15,6 +15,7 @@
//----- class -----
#include "Website.hpp"
#include "FileManContainer.hpp"
//----- xerces -----
#include <xercesc/parsers/XercesDOMParser.hpp>
@ -35,7 +36,7 @@ class FileManParser{
std::vector<Website> getWebsites();
FileManContainer getContainer();
void initWebsites();
@ -50,7 +51,7 @@ class FileManParser{
xercesc::DOMElement* root;
std::vector<Website> websites; ///< contain all websites entries
FileManContainer container; ///< contain all container
std::string data; ///< contain data to parse

View file

@ -15,11 +15,13 @@
#include <iostream>
#include <string>
#include <vector>
//----- class -----
#include "FileManIOFile.hpp"
#include "FileManParser.hpp"
#include "FileManContainer.hpp"
#include "Website.hpp"
/**
* @fn int main(int argc, char *argv[])
@ -68,6 +70,10 @@ int main(int argc, char *argv[]){
if(fichier.isReadable())
std::cout << fichier.getData();*/
FileManContainer container= parser.getContainer();
std::vector<Website> websites= container.getWebsites();
std::cout << websites.at(1).getId();
return 0;
}