Stroika Library 3.0d25
 
Loading...
Searching...
No Matches
Action.inl
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2026. All rights reserved
3 */
4
6
7 /*
8 ********************************************************************************
9 ***************************** UPnP::SOAP::Argument *****************************
10 ********************************************************************************
11 */
12 template <DataTypes::IValue T>
13 inline Argument::Argument (const String& name, const T& value)
14 : Foundation::Common::KeyValuePair<String, String>{name, DataTypes::ToText (value)}
15 {
16 }
17 inline Argument::Argument (const String& name, const DataTypes::Value& value, DataTypes::DataType dataType)
18 : Foundation::Common::KeyValuePair<String, String>{name, DataTypes::ToText (value, dataType)}
19 {
20 }
21 inline Argument::Argument (const String& name, const String& text)
22 : Foundation::Common::KeyValuePair<String, String>{name, text}
23 {
24 }
26 : Foundation::Common::KeyValuePair<String, String>{nameAndText}
27 {
28 }
29
30 namespace Private_ {
31 // the text of the argument called name; nullopt if none is
32 inline optional<String> LookupText_ (const Arguments& arguments, const String& name)
33 {
34 for (const Argument& a : arguments) {
35 if (a.fKey == name) {
36 return a.fValue;
37 }
38 }
39 return nullopt;
40 }
41 }
42
43 /*
44 ********************************************************************************
45 ************************** UPnP::SOAP::ActionRequest ***************************
46 ********************************************************************************
47 */
48 template <DataTypes::IValue T>
49 inline optional<T> ActionRequest::LookupArgument (const String& name) const
50 {
51 return LookupArgument<T> (name, DataTypes::DefaultDataType<T> ());
52 }
53 template <DataTypes::IValue T>
54 inline optional<T> ActionRequest::LookupArgument (const String& name, DataTypes::DataType dataType) const
55 {
56 optional<String> text = Private_::LookupText_ (fArguments, name);
57 return text ? DataTypes::FromText<T> (*text, dataType) : nullopt;
58 }
59
60 /*
61 ********************************************************************************
62 ************************* UPnP::SOAP::ActionResponse ***************************
63 ********************************************************************************
64 */
65 template <DataTypes::IValue T>
66 inline optional<T> ActionResponse::LookupArgument (const String& name) const
67 {
68 return LookupArgument<T> (name, DataTypes::DefaultDataType<T> ());
69 }
70 template <DataTypes::IValue T>
71 inline optional<T> ActionResponse::LookupArgument (const String& name, DataTypes::DataType dataType) const
72 {
73 optional<String> text = Private_::LookupText_ (fArguments, name);
74 return text ? DataTypes::FromText<T> (*text, dataType) : nullopt;
75 }
76
77}
String is like std::u32string, except it is much easier to use, often much more space efficient,...
Definition String.h:201
variant< bool, uint8_t, uint16_t, uint32_t, uint64_t, int8_t, int16_t, int32_t, int64_t, float, double, Foundation::Characters::Character, String, Foundation::Time::Date, Foundation::Time::DateTime, Foundation::Time::TimeOfDay, Foundation::Memory::BLOB, Foundation::IO::Network::URI, Foundation::Common::GUID > Value
A value of any of UPnP's data types, as its C++ type (the table above) - for code that learns a value...
Definition DataTypes.h:111
DataType
UPnP's data types - each named, as a service's description names it (Common::DefaultNames): ui2,...
Definition DataTypes.h:69
String ToText(const T &v)
v, as UPnP writes it: as t, if given, else as its C++ type's default data type (the table above)
Foundation::Containers::Sequence< Argument > Arguments
Definition Action.h:94
nonvirtual optional< T > LookupArgument(const String &name) const
nonvirtual optional< T > LookupArgument(const String &name) const
Argument(const String &name, const T &value)
Definition Action.inl:13