summaryrefslogtreecommitdiff
path: root/xmlspec/XMLText.h
blob: 4b0f4dccf2756761ff3a70504f42a41f3c212d7c (plain)
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#ifndef _H_XMLTEXT_
#define _H_XMLTEXT_

// standard c++ includes
#include <string>

// our includes
#include "XMLBase.h"

using namespace std;

class XMLText : public XMLBase
{
//
// constructors/destructor
//
public:
	/**
	 * Default constructor
	 * .
	 * @param szText The text to add
	 * @param szLang The text's language
	 * @return none
	 **/
	XMLText(const char* szText,
			const char* szLang = NULL);

	/**
	 * Copy constructor
	 * .
	 * @param rText reference to the text to copy
	 * @return none
	 **/
	XMLText(const XMLText& rText);

	/**
	 * Default destructor
	 * .
	 * @param none
	 * @return none
	 **/
	~XMLText();

//
// get/set methods for internal variables
//
public:
	/**
	 * Sets the text
	 * .
	 * @param szText The text
	 * @return none
	 **/
	void setText(const char* szText)
	{
		if (szText)
			m_sText.assign(szText);
	}

	/**
	 * Gets the text
	 * .
	 * @param none
	 * @return string containing the text
	 **/
	const char* getText()
	{
		return m_sText.c_str();
	}

	/**
	 * Tests if we have a language for this description
	 * .
	 * @param none
	 * @return true if we have a language, false otherwise
	 **/
	bool hasLang()
	{
		return m_sLang.length() ? true : false;
	}

	/**
	 * Sets the language
	 * .
	 * @param szLang The language
	 * @return none
	 **/
	void setLang(const char* szLang)
	{
		if (szLang) {
			// FIXME: We need to get the actual default language as specified
			// in one of the RPM headers (which I cannot find now) and
			// substitute it here. (I know the value is "C", bu we should
			// use the define.)
			if (strcmp(szLang, "C") != 0)
				m_sLang.assign(szLang);
		}
	}

	/**
	 * Gets the language
	 * .
	 * @param none
	 * @return string containing the language
	 **/
	const char* getLang()
	{
		return m_sLang.c_str();
	}

//
// member variables
//
public:
	string m_sText;
	string m_sLang;
};

#endif