forked from xR3b0rn/dbcppp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNodeImpl.cpp
More file actions
59 lines (57 loc) · 1.55 KB
/
NodeImpl.cpp
File metadata and controls
59 lines (57 loc) · 1.55 KB
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
#include "NodeImpl.h"
using namespace dbcppp;
std::unique_ptr<INode> INode::Create(
std::string&& name,
std::string&& comment,
std::vector<std::unique_ptr<IAttribute>>&& attribute_values)
{
std::vector<AttributeImpl> avs;
for (auto& av : attribute_values)
{
avs.push_back(std::move(static_cast<AttributeImpl&>(*av)));
av.reset(nullptr);
}
return std::make_unique<NodeImpl>(std::move(name), std::move(comment), std::move(avs));
}
NodeImpl::NodeImpl(std::string&& name, std::string&& comment, std::vector<AttributeImpl>&& attribute_values)
: _name(std::move(name))
, _comment(std::move(comment))
, _attribute_values(std::move(attribute_values))
{}
std::unique_ptr<INode> NodeImpl::Clone() const
{
return std::make_unique<NodeImpl>(*this);
}
const std::string& NodeImpl::Name() const
{
return _name;
}
const std::string& NodeImpl::Comment() const
{
return _comment;
}
const IAttribute& NodeImpl::AttributeValues_Get(std::size_t i) const
{
return _attribute_values[i];
}
uint64_t NodeImpl::AttributeValues_Size() const
{
return _attribute_values.size();
}
bool NodeImpl::operator==(const INode& rhs) const
{
bool equal = true;
equal &= _name == rhs.Name();
equal &= _comment == rhs.Comment();
for (const auto& attr : rhs.AttributeValues())
{
auto beg = _attribute_values.begin();
auto end = _attribute_values.end();
equal &= std::find(beg, end, attr) != end;
}
return equal;
}
bool NodeImpl::operator!=(const INode& rhs) const
{
return !(*this == rhs);
}