-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.hpp
More file actions
37 lines (37 loc) · 973 Bytes
/
utils.hpp
File metadata and controls
37 lines (37 loc) · 973 Bytes
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
#pragma once
#include <string>
#include <google/protobuf/compiler/importer.h>
class PBHelper
{
public:
static std::string ClassName(const google::protobuf::Descriptor *descriptor)
{
using namespace google::protobuf;
const Descriptor *parent = descriptor->containing_type();
std::string res;
if (parent)
res += ClassName(parent) + "_";
res += descriptor->name();
return res;
}
static std::string QualifiedClassName(const google::protobuf::Descriptor *d)
{
auto pFile = d->file();
std::string name = ClassName(d);
if (pFile->package().empty())
{
return "::" + name;
}
return "::" + pFile->package() + "::" + name;
}
static std::string QualifiedServiceName(const google::protobuf::ServiceDescriptor *d)
{
auto pFile = d->file();
std::string name = d->name();
if (pFile->package().empty())
{
return "::" + name;
}
return "::" + pFile->package() + "::" + name;
}
};