blob: 19d45321831ec02dfec8e28250446215d2d7dc33 (
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
|
#ifndef RECORDS_PARAM_H
#define RECORDS_PARAM_H
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <QtCore>
class DicRecord;
using std::vector;
using std::string;
using std::ostream;
struct RecordsParam
{
public:
static vector<RecordsParam> createParams();
template <typename T>
static string vectorToStr(const vector<T>& v);
static vector<string> hashToStrVector(const QHash<QString, QString>& hash,
const vector<string>& keys);
public:
RecordsParam(vector<int> packFields, vector<vector<string> > records,
vector<string> questions, vector<vector<string> > answers);
vector<string> recordsToStr() const;
public:
static const vector<string> fieldNames;
public:
QList<DicRecord*> records;
vector<int> packFields;
vector<string> questions;
vector<vector<string> > answers;
};
ostream& operator<<(ostream& os, const RecordsParam& param);
template <typename T>
string RecordsParam::vectorToStr(const vector<T>& v)
{
std::stringstream ss;
for(unsigned i = 0; i < v.size(); i++)
{
if(i != 0)
ss << ", ";
ss << v[i];
}
return ss.str();
}
#endif
|