Sese Framework  2.3.0
A cross-platform framework
Loading...
Searching...
No Matches
XmlTypes.h
Go to the documentation of this file.
1// Copyright 2024 libsese
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
22#pragma once
23#include <sese/Config.h>
24#include <vector>
25#include <map>
26
27#ifdef _WIN32
28#pragma warning(disable : 4251)
29#endif
30
31namespace sese::xml {
32
34class Element {
35public:
36 using Ptr = std::shared_ptr<Element>;
37 using AttrType = std::map<std::string, std::string>;
38 using SubType = std::vector<Element::Ptr>;
39
40 explicit Element(const std::string &name);
41 [[nodiscard]] const std::string &getName() const;
42 [[nodiscard]] const std::string &getValue() const;
43 void setValue(std::string var);
44 [[nodiscard]] const AttrType &getAttributes() const;
45 [[nodiscard]] const SubType &getElements() const;
46 void addElement(const Element::Ptr &element);
47 void setAttribute(const std::string &name, const std::string &value);
48 [[nodiscard]] const std::string &getAttribute(const std::string &name, const std::string &default_value) const;
49 void removeAttribute(const std::string &name);
50
52
53private:
54 std::string name;
55 std::string value;
57};
58} // namespace sese::xml