79 lines
1.6 KiB
C++
79 lines
1.6 KiB
C++
#pragma once
|
|
|
|
namespace google
|
|
{
|
|
namespace protobuf
|
|
{
|
|
class Descriptor;
|
|
class Message;
|
|
}
|
|
}
|
|
|
|
namespace a8
|
|
{
|
|
namespace mysql
|
|
{
|
|
class Query;
|
|
}
|
|
}
|
|
|
|
bool ReadCsvMetaFile(const std::string& filename,
|
|
google::protobuf::Message* prototype,
|
|
std::function<void (google::protobuf::Message*)> push_back_func);
|
|
|
|
template <typename T>
|
|
bool ReadCsvMetaFile(const std::string& filename, std::list<T>& meta_list)
|
|
{
|
|
T dummy;
|
|
return ReadCsvMetaFile(filename,
|
|
&dummy,
|
|
[&meta_list] (google::protobuf::Message* msg)
|
|
{
|
|
T t;
|
|
t.CopyFrom(*msg);
|
|
meta_list.emplace_back(t);
|
|
});
|
|
}
|
|
|
|
template <typename T1,
|
|
typename T2>
|
|
static void RepeatedFieldToVector(const T1& t1, T2& t2)
|
|
{
|
|
t2.clear();
|
|
for (auto& val : t1) {
|
|
t2.push_back(val);
|
|
}
|
|
}
|
|
|
|
template <typename T1,
|
|
typename T2>
|
|
static void RepeatedFieldToSet(const T1& t1, T2& t2)
|
|
{
|
|
t2.clear();
|
|
for (auto& val : t1) {
|
|
t2.insert(val);
|
|
}
|
|
}
|
|
|
|
template <typename T1,
|
|
typename T2>
|
|
static void VectorToRepeatedField(const T1& t1, T2& t2)
|
|
{
|
|
t2.Clear();
|
|
for (auto& val : t1) {
|
|
*t2.Add() = val;
|
|
}
|
|
}
|
|
|
|
template <typename T1,
|
|
typename T2>
|
|
static void SetToRepeatedField(const T1& t1, T2& t2)
|
|
{
|
|
t2.Clear();
|
|
for (auto& val : t1) {
|
|
*t2.Add() = val;
|
|
}
|
|
}
|
|
|
|
void InitMysqlConnection(a8::mysql::Query* query);
|