XMLWriter.hh
1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
* XMLWriter.hh
*
* Created on: 7 août 2013
* Author: CS
*/
#ifndef XMLWRITER_HH_
#define XMLWRITER_HH_
#include "AbstractWriter.hh"
#include <libxml/xmlwriter.h>
namespace TimeTableCatalog {
class XMLWriter: public TimeTableCatalog::AbstractWriter {
public:
XMLWriter(const std::string& pPath, const std::string& pName = NULL);
virtual ~XMLWriter();
/**
* Writes TimeTable into an InternalXML formated file.
*/
std::string write(const TimeTable& pTT, const char* pEncoding);
protected:
/**
* Writes <?xml introduction line.
*/
void writeHeader(const TimeTable& pTT, xmlTextWriterPtr& pWriter, const char* pEncoding);
/**
* Writes XML content (except header).
*/
virtual void writeContent(const TimeTable& pTT,
xmlTextWriterPtr& pWriter) = 0;
/**
* Writes a simple element as <starttag>value<endtag>.
*/
void writeElement(const TimeTable& pTT, xmlTextWriterPtr& pWriter, std::string pTag,
const std::string &pValue, const char* pEncoding = "UTF-8");
/**
* Writes a start tag.
*/
void openTag(const TimeTable& pTT, xmlTextWriterPtr& pWriter, std::string pTag);
/**
* Adds an attribute to the current tag.
*/
void addAttribute(const TimeTable& pTT, xmlTextWriterPtr& pWriter, std::string pTag,
const std::string &pValue, const char* pEncoding = "UTF-8");
/**
* Writes a stop tag.
*/
void closeTag(const TimeTable& pTT, xmlTextWriterPtr& pWriter, std::string pTag);
/**
* Converts, just in case, input into UTF-8.
*/
xmlChar * convertInput(const TimeTable& pTT, const char* pIn, const char* pEncoding);
void logEndTagError(const std::string& ptag, const std::string& pTTPath);
void logStartTagError(const std::string& ptag, const std::string& pTTPath);
void logTagError(const std::string& ptag, const std::string& pTTPath);
void logAttributeError(const std::string& pAttribute,
const std::string& pTTPath);
};
} /* namespace TimeTableCatalog */
#endif /* XMLWRITER_HH_ */