13 #include <type_traits>
23 tResult visit_property(
const ant::IProperties& oProperties,
24 const char* strPropertyName,
25 const std::function<
tResult(
const IProperty& oProperty)>& fnCallback);
27 tResult visit_property_by_path(
const ant::IProperties& oProperties,
28 const char* strPropertyPathAndName,
29 const std::function<
tResult(
const IProperty& oProperty)>& fnCallback);
49 template<
typename VALUETYPE>
69 return set_property<std::string>(oProperties, strNameOfValue, poValue);
112 template<
typename VALUETYPE>
115 return get_property<VALUETYPE>(oProperties, strNameOfValue, VALUETYPE());
137 template <
typename VALUETYPE>
138 tResult set_property_by_path(
IProperties& oProperties,
const char* strPathAndName, VALUETYPE oValue)
141 size_t nLastSlashPosition = strHelper.RFind(
'/');
142 if (nLastSlashPosition == util::cString::InvalidPos)
144 return ant::set_property<VALUETYPE>(oProperties, strPathAndName, oValue);
148 return oProperties.SetPropertyByPath(strParent, property<VALUETYPE>(strHelper.Mid(nLastSlashPosition + 1), oValue));
151 template <
typename T>
152 T get_property_by_path(
const IProperties& oProperties,
const char* strPathAndName,
const T& oDefaultValue)
156 if (
IS_FAILED(spider::visit_property_by_path(oProperties, strPathAndName, [&](
const IProperty& oProperty) ->
tResult
162 return oDefaultValue;
168 template <
typename VALUETYPE>
169 VALUETYPE get_property_by_path(
const IProperties& oProperties,
const char* strPathAndName)
171 return get_property_by_path(oProperties, strPathAndName, VALUETYPE());
203 template <
typename PropertyType>
204 void call_callback(
const ant::IProperty& oProperty,
const std::function<
void(
const char*, PropertyType)>& fnCallback)
208 fnCallback(strName.
Get(), get_property_value<std::decay_t<PropertyType>>(*oProperty.GetValue()));
215 using tPropertyVisitorCallback = std::function<void(
const ant::IProperty& oProperty)>;
223 tPropertyVisitorCallback fnCallback);
231 template <
typename SubPropertyType>
233 std::function<
void(
const char*, SubPropertyType)> fnCallback)
235 visit_properties(oProperties, std::bind(detail::call_callback<SubPropertyType>, std::placeholders::_1, fnCallback));
244 tPropertyVisitorCallback fnCallback);
252 template <
typename SubPropertyType>
254 std::function<
void(
const char*, SubPropertyType)> fnCallback)
256 visit_sub_properties(oProperty, std::bind(detail::call_callback<SubPropertyType>, std::placeholders::_1, fnCallback));
266 const char* strPropertyName,
267 tPropertyVisitorCallback fnCallback);
276 template <
typename SubPropertyType>
278 const char* strPropertyName,
279 std::function<
void(
const char*, SubPropertyType)> fnCallback)
283 std::bind(detail::call_callback<SubPropertyType>, std::placeholders::_1, fnCallback));
291 using lucky::tPropertyVisitorCallback;
299 const tPropertyVisitorCallback& fnCallback);
307 template <
typename SubPropertyType>
309 const std::function<
void(
const char*, SubPropertyType)>& fnCallback)
311 visit_properties(oProperties, std::bind(lucky::detail::call_callback<SubPropertyType>, std::placeholders::_1, fnCallback));
320 const tPropertyVisitorCallback& fnCallback);
328 template <
typename SubPropertyType>
330 const std::function<
void(
const char*, SubPropertyType)>& fnCallback)
332 visit_sub_properties(oProperty, std::bind(lucky::detail::call_callback<SubPropertyType>, std::placeholders::_1, fnCallback));
342 const char* strPropertyName,
343 const tPropertyVisitorCallback& fnCallback);
352 template <
typename SubPropertyType>
354 const char* strPropertyName,
355 const std::function<
void(
const char*, SubPropertyType)>& fnCallback)
359 std::bind(lucky::detail::call_callback<SubPropertyType>, std::placeholders::_1, fnCallback));
367 using catwo::set_property_by_path;
368 using catwo::get_property_by_path;
374 using spider::visit_property;
375 using spider::visit_property_by_path;
Copyright © Audi Electronics Venture GmbH.
A_UTILS_NS::cResult tResult
For backwards compatibility and to bring latest version into scope.
#define IS_FAILED(s)
Check if result is failed.
#define RETURN_IF_FAILED(s)
Return if expression is failed, which requires the calling function's return type to be tResult.
#define RETURN_NOERROR
Return status ERR_NOERROR, which requires the calling function's return type to be tResult.
A common result class usable as return value throughout.
_myType Mid(tSize nPos, tSize nLength=InvalidPos) const
This function extracts a substring of length nLength characters from the cStringA object,...
Defintion of a property set container interface.
The IProperty interface provides methods for getting and setting property values, name of the propert...
The IString interface provides methods for getting and setting strings through abstract interfaces.
virtual const char * Get() const =0
Gets the pointer to the current associated nullterminated-string.
string_base< cStackString > cString
cString implementation for a stack string which works on stack if string is lower than A_UTILS_DEFAUL...
VALUETYPE get_property(const IConfiguration &oConfiguration, const char *strNameOfValue, VALUETYPE oDefaultValue)
Get the property content converted to the VALUETYPE.
tResult set_property(IConfiguration &oConfiguration, const char *strNameOfValue, VALUETYPE oValue)
Set the property.
tResult create_property_tree(ant::IProperties &oProperties, const char *strPath)
Creates a property tree structure.
std::pair< std::string, std::string > split_parents_and_leaf(const char *strPropertyPathAndName)
Splits a property path into the parent path and the property name.
tResult get_property_object_by_path(const ant::IConfiguration &oConfiguration, const char *strPropertyPathAndName, ant::IProperty &oProperty)
Retrieves a property reference under the given oConfiguration by path.
void visit_sub_properties(const ant::IProperty &oProperty, tPropertyVisitorCallback fnCallback)
Utility function to visit all sub-properties of a given property.
void visit_properties(const ant::IProperties &oProperties, tPropertyVisitorCallback fnCallback)
Utility function to visit all properties of a properties object.
void visit_properties(const ant::IProperties &oProperties, const tPropertyVisitorCallback &fnCallback)
Utility function to visit all properties of a properties object.
void visit_sub_properties(const ant::IProperty &oProperty, const tPropertyVisitorCallback &fnCallback)
Utility function to visit all sub-properties of a given property.
Namespace for entire ADTF SDK.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.