sptk2 logo
SPTK Home Page
WSFieldIndex.h
1/*
2╔══════════════════════════════════════════════════════════════════════════════╗
3║ SIMPLY POWERFUL TOOLKIT (SPTK) ║
4╟──────────────────────────────────────────────────────────────────────────────╢
5║ copyright © 1999-2022 Alexey Parshin. All rights reserved. ║
6║ email alexeyp@gmail.com ║
7╚══════════════════════════════════════════════════════════════════════════════╝
8┌──────────────────────────────────────────────────────────────────────────────┐
9│ This library is free software; you can redistribute it and/or modify it │
10│ under the terms of the GNU Library General Public License as published by │
11│ the Free Software Foundation; either version 2 of the License, or (at your │
12│ option) any later version. │
13│ │
14│ This library is distributed in the hope that it will be useful, but │
15│ WITHOUT ANY WARRANTY; without even the implied warranty of │
16│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library │
17│ General Public License for more details. │
18│ │
19│ You should have received a copy of the GNU Library General Public License │
20│ along with this library; if not, write to the Free Software Foundation, │
21│ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. │
22│ │
23│ Please report all bugs and problems to alexeyp@gmail.com. │
24└──────────────────────────────────────────────────────────────────────────────┘
25*/
26
27#pragma once
28
29#include <functional>
30#include <sptk5/wsdl/WSType.h>
31
32namespace sptk {
33
37class SP_EXPORT WSFieldIndex
38{
39public:
43 enum class Group : uint8_t
44 {
45 ELEMENTS = 1,
46 ATTRIBUTES = 2,
47 ELEMENTS_AND_ATTRIBUTES = 3
48 };
49
55 WSFieldIndex() = default;
56
60 ~WSFieldIndex() = default;
61
66 {
67 }
68
73 {
74 }
75
80 {
81 return *this;
82 }
83
88 {
89 return *this;
90 }
91
97 void setElements(const Strings& fieldNames, std::initializer_list<WSType*> fieldList);
98
104 void setAttributes(const Strings& fieldNames, std::initializer_list<WSType*> fieldList);
105
110 const std::map<String, WSType*>& elements() const
111 {
112 return m_elementIndex;
113 }
114
119 const std::map<String, WSType*>& attributes() const
120 {
121 return m_attributeIndex;
122 }
123
129 WSType* find(const String& name) const;
130
135 void forEach(const std::function<bool(WSType*)>& method, Group fieldType = Group::ELEMENTS_AND_ATTRIBUTES);
136
141 void forEach(const std::function<bool(const WSType*)>& method, Group fieldType = Group::ELEMENTS_AND_ATTRIBUTES) const;
142
143 bool hasElements() const;
144
145 bool hasAttributes() const;
146
147private:
148 std::vector<WSType*> m_elements;
149 std::vector<WSType*> m_attributes;
150
151 std::map<String, WSType*> m_elementIndex;
152 std::map<String, WSType*> m_attributeIndex;
153};
154
155using SWSFieldIndex = std::shared_ptr<WSFieldIndex>;
156
157} // namespace sptk
Definition: String.h:49
Definition: Strings.h:52
Definition: WSFieldIndex.h:38
WSFieldIndex(WSFieldIndex &&) noexcept
Definition: WSFieldIndex.h:72
void setElements(const Strings &fieldNames, std::initializer_list< WSType * > fieldList)
const std::map< String, WSType * > & elements() const
Definition: WSFieldIndex.h:110
WSType * find(const String &name) const
void setAttributes(const Strings &fieldNames, std::initializer_list< WSType * > fieldList)
WSFieldIndex()=default
WSFieldIndex & operator=(WSFieldIndex &&) noexcept
Definition: WSFieldIndex.h:87
void forEach(const std::function< bool(const WSType *)> &method, Group fieldType=Group::ELEMENTS_AND_ATTRIBUTES) const
void forEach(const std::function< bool(WSType *)> &method, Group fieldType=Group::ELEMENTS_AND_ATTRIBUTES)
WSFieldIndex(const WSFieldIndex &)
Definition: WSFieldIndex.h:65
WSFieldIndex & operator=(const WSFieldIndex &)
Definition: WSFieldIndex.h:79
~WSFieldIndex()=default
Group
Definition: WSFieldIndex.h:44
const std::map< String, WSType * > & attributes() const
Definition: WSFieldIndex.h:119
Definition: WSType.h:42

Fri Oct 14 2022 09:58:32: SPTK 5.4.1