forked from sourcesimian/uICAL
-
Notifications
You must be signed in to change notification settings - Fork 1
/
vobject.cpp
77 lines (69 loc) · 1.74 KB
/
vobject.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
/*############################################################################
# Copyright (c) 2020 Source Simian : https://github.com/sourcesimian/uICAL #
############################################################################*/
#include "uICAL/cppstl.h"
#include "uICAL/types.h"
#include "uICAL/error.h"
#include "uICAL/util.h"
#include "uICAL/logging.h"
#include "uICAL/vline.h"
#include "uICAL/vobject.h"
namespace uICAL
{
VObject::VObject()
{
}
const string &VObject::getName() const
{
return this->name;
}
VLine_ptr VObject::getPropertyByName(const string &name) const
{
for (auto line : this->lines)
{
if (line->name == name)
{
return line;
}
}
return nullptr;
}
VObject::line_vector VObject::getPropertysByName(const string &name) const
{
VObject::line_vector ret;
for (auto line : this->lines)
{
if (line->name == name)
{
ret.push_back(line);
}
}
return ret;
}
VObject::vector VObject::listObjects(const string &name) const
{
VObject::vector ret;
for (auto child : this->children)
{
if (child->name == name)
{
ret.push_back(child);
}
}
return ret;
}
void VObject::str(ostream &out) const
{
out << "BEGIN:" << this->name << uICAL::endl;
for (auto line : this->lines)
{
line->str(out);
out << uICAL::endl;
}
for (auto child : this->children)
{
child->str(out);
}
out << "END:" << this->name << uICAL::endl;
}
}