string_utils.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright (C) 2013-2014 by Alexander Rykovanov *
3  * rykovanov.as@gmail.com *
4  * *
5  * This library is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU Lesser General Public License as *
7  * published by the Free Software Foundation; version 3 of the License. *
8  * *
9  * This library is distributed in the hope that it will be useful, *
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12  * GNU Lesser General Public License for more details. *
13  * *
14  * You should have received a copy of the GNU Lesser General Public License *
15  * along with this library; if not, write to the *
16  * Free Software Foundation, Inc., *
17  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
18  ******************************************************************************/
19 
20 #pragma once
21 
24 #include <opc/ua/protocol/types.h>
25 #include <opc/ua/protocol/utils.h>
27 #include <opc/ua/protocol/view.h>
28 #include <ostream>
29 #include <limits>
30 
31 namespace OpcUa
32 {
33 
34 class Event;
35 
36 std::string ToString(const AttributeId & value);
37 std::string ToString(const BrowseDirection & direction);
38 std::string ToString(const DateTime & t);
40 std::string ToString(const DeadbandType & value);
41 std::string ToString(const Event & value, bool showAll = false);
43 std::string ToString(const FilterOperator & value);
44 std::string ToString(const Guid & guid);
45 std::string ToString(const LocalizedText & code);
46 std::string ToString(const MonitoringMode & value);
47 std::string ToString(const NodeId & id, bool addObjectIdName = false);
48 std::string ToString(const ObjectId & value);
49 std::string ToString(const StatusCode & code);
51 std::string ToString(const VariantType & value);
52 
53 std::ostream & indent(std::ostream & os, int level, bool noSeparator = false);
54 std::ostream & ToStream(std::ostream & os, const AggregateFilter & value, int indentLevel = 0);
55 std::ostream & ToStream(std::ostream & os, const ContentFilterElement & value, int indentLevel = 0);
56 std::ostream & ToStream(std::ostream & os, const DataChangeFilter & value, int indentLevel = 0);
57 std::ostream & ToStream(std::ostream & os, const ExtensionObjectHeader & value, int indentLevel = 0);
58 std::ostream & ToStream(std::ostream & os, const Event & value, int indentLevel = 0, bool showAll = false);
59 std::ostream & ToStream(std::ostream & os, const EventFilter & value, int indentLevel = 0);
60 std::ostream & ToStream(std::ostream & os, const FilterOperand & value, int indentLevel = 0);
61 std::ostream & ToStream(std::ostream & os, const MonitoringFilter & value, int indentLevel = 0);
62 std::ostream & ToStream(std::ostream & os, const MonitoringParameters & value, int indentLevel = 0);
63 std::ostream & ToStream(std::ostream & os, const MonitoredItemCreateRequest & value, int indentLevel = 0);
64 std::ostream & ToStream(std::ostream & os, const MonitoredItemsParameters & value, int indentLevel = 0);
65 std::ostream & ToStream(std::ostream & os, const NodeId & value, bool addObjectIdName = false);
66 std::ostream & ToStream(std::ostream & os, const std::string & value, int indentLevel = 0);
67 std::ostream & ToStream(std::ostream & os, const std::vector<QualifiedName> & value);
68 std::ostream & ToStream(std::ostream & os, const ReadValueId & value, int indentLevel = 0);
69 std::ostream & ToStream(std::ostream & os, const SimpleAttributeOperand & value, int indentLevel = 0);
70 
71 template <typename T>
72 std::ostream & ToStream(std::ostream & os, const std::vector<T> & value, int indentLevel = 0)
73 {
74  os << "{";
75  int subIndentLevel = (indentLevel < 0)
76  ? indentLevel
77  : indentLevel + 1;
78  bool isFirst = true;
79  for (auto & element : value)
80  {
81  indent(os, subIndentLevel, isFirst);
82  ToStream(os, element, subIndentLevel);
83  isFirst = false;
84  }
85  indent(os, indentLevel, true);
86  os << "}";
87  return os;
88 }
89 
90 template <typename T>
91 std::string ToString(const T & value)
92 {
93  std::stringstream result;
94  ToStream(result, value);
95  return result.str();
96 }
97 
98 Guid ToGuid(const std::string & str);
99 NodeId ToNodeId(const std::string & str, uint32_t defaultNamespace = 0);
100 QualifiedName ToQualifiedName(const std::string & str, uint32_t default_ns = 0);
101 
102 inline std::ostream & operator<<(std::ostream & os, const OpcUa::AggregateFilter & value)
103 {
104  return OpcUa::ToStream(os, value);
105 }
106 
107 inline std::ostream & operator<<(std::ostream & os, const OpcUa::AttributeId & value)
108 {
109  os << OpcUa::ToString(value);
110  return os;
111 }
112 
113 inline std::ostream & operator<<(std::ostream & os, const OpcUa::BrowseDirection & direction)
114 {
115  os << OpcUa::ToString(direction);
116  return os;
117 }
118 
119 inline std::ostream & operator<<(std::ostream & os, const OpcUa::ByteString & value)
120 {
121  return ToHexDump(os, value.Data);
122 }
123 
124 inline std::ostream & operator<<(std::ostream & os, const OpcUa::ContentFilterElement & value)
125 {
126  return OpcUa::ToStream(os, value);
127 }
128 
129 inline std::ostream & operator<<(std::ostream & os, const OpcUa::DataChangeTrigger & value)
130 {
131  os << OpcUa::ToString(value);
132  return os;
133 }
134 
135 inline std::ostream & operator<<(std::ostream & os, const OpcUa::DataChangeFilter & value)
136 {
137  return OpcUa::ToStream(os, value);
138 }
139 
140 inline std::ostream & operator<<(std::ostream & os, const OpcUa::DateTime & value)
141 {
142  os << OpcUa::ToString(value);
143  return os;
144 }
145 
146 inline std::ostream & operator<<(std::ostream & os, const OpcUa::DeadbandType & value)
147 {
148  os << OpcUa::ToString(value);
149  return os;
150 }
151 
152 inline std::ostream & operator<<(std::ostream & os, const OpcUa::ExtensionObjectEncoding & value)
153 {
154  os << OpcUa::ToString(value);
155  return os;
156 }
157 
158 inline std::ostream & operator<<(std::ostream & os, const OpcUa::ExtensionObjectHeader & value)
159 {
160  return OpcUa::ToStream(os, value);
161 }
162 
163 inline std::ostream & operator<<(std::ostream & os, const Event & value)
164 {
165  return OpcUa::ToStream(os, value, -1, false);
166 }
167 
168 inline std::ostream & operator<<(std::ostream & os, const OpcUa::EventFilter & value)
169 {
170  return OpcUa::ToStream(os, value);
171 }
172 
173 inline std::ostream & operator<<(std::ostream & os, const OpcUa::FilterOperand & value)
174 {
175  return OpcUa::ToStream(os, value);
176 }
177 
178 inline std::ostream & operator<<(std::ostream & os, const OpcUa::FilterOperator & value)
179 {
180  os << OpcUa::ToString(value);
181  return os;
182 }
183 
184 inline std::ostream & operator<<(std::ostream & os, const OpcUa::Guid & guid)
185 {
186  os << "{" << ToString(guid) << "}";
187  return os;
188 }
189 
190 inline std::ostream & operator<<(std::ostream & os, const OpcUa::LocalizedText & t)
191 {
192  os << OpcUa::ToString(t).c_str();
193  return os;
194 }
195 
196 inline std::ostream & operator<<(std::ostream & os, const OpcUa::MonitoringFilter & value)
197 {
198  return ToStream(os, value);
199 }
200 
201 inline std::ostream & operator<<(std::ostream & os, const OpcUa::MonitoringMode & value)
202 {
203  os << OpcUa::ToString(value);
204  return os;
205 }
206 
207 inline std::ostream & operator<<(std::ostream & os, const OpcUa::MonitoringParameters & value)
208 {
209  return ToStream(os, value);
210 }
211 
212 inline std::ostream & operator<<(std::ostream & os, const OpcUa::MonitoredItemCreateRequest & value)
213 {
214  return ToStream(os, value);
215 }
216 
217 inline std::ostream & operator<<(std::ostream & os, const OpcUa::MonitoredItemsParameters & value)
218 {
219  return ToStream(os, value);
220 }
221 
222 inline std::ostream & operator<<(std::ostream & os, const OpcUa::NodeId & nodeid)
223 {
224  os << OpcUa::ToString(nodeid).c_str();
225  return os;
226 }
227 
228 inline std::ostream & operator<<(std::ostream & os, const OpcUa::ObjectId & value)
229 {
230  os << OpcUa::ToString(value);
231  return os;
232 }
233 
234 inline std::ostream & operator<<(std::ostream & os, const OpcUa::QualifiedName & qn)
235 {
236  os << "QualifiedName(" << qn.NamespaceIndex << ":" << qn.Name.c_str() << ")";
237  return os;
238 }
239 
240 inline std::ostream & operator<<(std::ostream & os, const std::vector<OpcUa::QualifiedName> & value)
241 {
242  return ToStream(os, value);
243 }
244 
245 inline std::ostream & operator<<(std::ostream & os, const OpcUa::ReadValueId & value)
246 {
247  return ToStream(os, value);
248 }
249 
250 inline std::ostream & operator<<(std::ostream & os, const OpcUa::SimpleAttributeOperand & value)
251 {
252  return ToStream(os, value);
253 }
254 
255 inline std::ostream & operator<<(std::ostream & os, const OpcUa::StatusCode & value)
256 {
257  os << OpcUa::ToString(value);
258  return os;
259 }
260 
261 inline std::ostream & operator<<(std::ostream & os, const OpcUa::TimestampsToReturn & value)
262 {
263  os << OpcUa::ToString(value);
264  return os;
265 }
266 
267 inline std::ostream & operator<<(std::ostream & os, const OpcUa::VariantType & value)
268 {
269  os << OpcUa::ToString(value);
270  return os;
271 }
272 }
273 
const char LocalizedText[]
Definition: strings.h:96
ExtensionObjectEncoding
Definition: types.h:276
std::vector< uint8_t > Data
Definition: types.h:37
DeadbandType
Definition: enums.h:290
const char NodeId[]
Definition: strings.h:116
uint16_t NamespaceIndex
Definition: types.h:73
TimestampsToReturn
Definition: enums.h:237
VariantType
Definition: variant.h:27
ObjectId
Definition: object_ids.h:12
BrowseDirection
Definition: enums.h:173
std::ostream & indent(std::ostream &os, int level, bool noSeparator=false)
const char Guid[]
Definition: strings.h:65
OPC UA Address space part. GNU LGPL.
MonitoringMode
Definition: enums.h:270
std::ostream & ToStream(std::ostream &os, const AggregateFilter &value, int indentLevel=0)
Guid ToGuid(const std::string &str)
std::string ToHexDump(const char *buf, std::size_t size)
Definition: utils.h:29
QualifiedName ToQualifiedName(const std::string &str, uint32_t default_ns=0)
std::string Name
Definition: types.h:74
NodeId ToNodeId(const std::string &str, uint32_t defaultNamespace=0)
std::string ToString(const AttributeId &value)
FilterOperator
Definition: enums.h:212
std::ostream & operator<<(std::ostream &os, const Node &node)
Definition: node.cpp:566
DataChangeTrigger
Definition: enums.h:280
const char DateTime[]
Definition: strings.h:46


ros_opcua_impl_freeopcua
Author(s): Denis Štogl
autogenerated on Tue Jan 19 2021 03:12:08