-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQueryResponse.cpp
116 lines (100 loc) · 2.51 KB
/
QueryResponse.cpp
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
/******************************************************************************
** (C) Chris Oldwood
**
** MODULE: QUERYRESPONSE.CPP
** COMPONENT: The Application
** DESCRIPTION: CQueryResponse class definition.
**
*******************************************************************************
*/
#include "Common.hpp"
#include "QueryResponse.hpp"
/******************************************************************************
** Method: Constructor.
**
** Description: .
**
** Parameters: None.
**
** Returns: Nothing.
**
*******************************************************************************
*/
CQueryResponse::CQueryResponse()
{
}
/******************************************************************************
** Method: Destructor.
**
** Description: .
**
** Parameters: None.
**
** Returns: Nothing.
**
*******************************************************************************
*/
CQueryResponse::~CQueryResponse()
{
}
/******************************************************************************
** Method: FindField()
**
** Description: Finds the index of a field in the response.
**
** Parameters: pszField The field name.
**
** Returns: The index or -1 if not found.
**
*******************************************************************************
*/
int CQueryResponse::FindField(const tchar* pszField) const
{
ASSERT(pszField != nullptr);
// For all fields.
for (size_t i = 0; i < m_astrFields.Size(); ++i)
{
if (m_astrFields[i].Compare(pszField, true) == 0)
return i;
}
return -1;
}
/******************************************************************************
** Method: FieldValue()
**
** Description: Gets the value for a field, if it is set.
**
** Parameters: pszField The field name.
**
** Returns: The field value or "" if not found.
**
*******************************************************************************
*/
CString CQueryResponse::FieldValue(const tchar* pszField) const
{
ASSERT(pszField != nullptr);
int i = FindField(pszField);
if (i != -1)
return m_astrValues[i];
return TXT("");
}
/******************************************************************************
** Method: Dump()
**
** Description: Dumps the fields and values to the debug output.
**
** Parameters: None.
**
** Returns: Nothing.
**
*******************************************************************************
*/
void CQueryResponse::Dump()
{
#ifdef _DEBUG
for (size_t i = 0; i < m_astrFields.Size(); ++i)
{
TRACE2(TXT("%s:%s\n"), m_astrFields[i].c_str(), m_astrValues[i].c_str());
}
#endif
}