File: SimpleXMLUtils.hpp

package info (click to toggle)
pbseqlib 5.3.5%2Bdfsg-10
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 7,148 kB
  • sloc: cpp: 77,259; python: 331; sh: 103; makefile: 41
file content (104 lines) | stat: -rw-r--r-- 2,134 bytes parent folder | download | duplicates (4)
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#ifndef _BLASR_SIMPLE_XML_UTILS_HPP_
#define _BLASR_SIMPLE_XML_UTILS_HPP_

#include <sstream>
#include <string>

/*
 * WARNING !!! The functions here use TONS of temoprary variables and are
 * very slow. Do not use for high-throughput xml generation.
 */

/*
 * none of this is really used... just the keyword value pair items.
 */

template <typename T_String, typename T_Value>
int OutputKeywordValuePair(T_String title, T_Value value, std::ostream out)
{
    out << title << "=\"" << value << "\" ";
    return out.good();
}

template <typename T_String>
int OutputBeginElement(T_String title, std::ostream out)
{
    out << "<" << title << " ";
    return 1;
}

template <typename T_String>
int OutputEndElement(T_String title, std::ostream out)
{
    out << "/" << title;
    return 1;
}

template <typename T_String>
int OutputElement(T_String title, std::ostream out)
{
    out << "<" << title << " ";
    return 1;
}

inline void OutputEnd(std::ostream out) { out << "/>"; }

template <typename T_String, typename T_Value>
T_String CreateKeywordValuePair(T_String title, T_Value value)
{
    T_String keywordPair;
    std::stringstream sstrm;
    sstrm << title << "=\"" << value << "\"";
    keywordPair = sstrm.str();
    return keywordPair;
}

template <typename T_String>
T_String BeginDataEntry(T_String id, T_String data)
{
    T_String entry;
    entry += "<";
    entry += id;
    entry += " ";
    entry += data;
    entry += ">";
    return entry;
}

template <typename T_String>
T_String EndDataEntry(T_String id)
{
    T_String entry;
    entry = "<" + id + ">/";
    return entry;
}

template <typename T_String>
T_String CreateDataEntry(T_String id, T_String data)
{
    T_String entry;
    entry += "<";
    entry += id;
    entry += " ";
    entry += data;
    entry += " />";
    return entry;
}

template <typename T_String>
T_String CreateStartEntry(T_String id, T_String data)
{
    T_String entry;
    entry = "<" + id + " " + data + ">";
    return entry;
}

template <typename T_String>
T_String CreateEndEntry(T_String id)
{
    T_String entry;
    entry = "<" + id + "/>";
    return entry;
}

#endif