Conscience Core
Classes | Namespaces | Macros | Typedefs | Enumerations | Functions | Variables
CommandParamsSpec.h File Reference
#include "CscCommon.h"
#include "Util/json.h"
#include <any>
#include <concepts>
#include <functional>
#include <type_traits>
#include <typeinfo>
#include <shared_mutex>
#include <Util/shared_recursive_mutex.h>
#include <Configuration/CscKeyDirectories.h>

Go to the source code of this file.

Classes

class  conscience_core::bridging::commands::MissingCommandDataTypeException
 
class  conscience_core::bridging::commands::MissingCommandMetadataException
 
class  conscience_core::bridging::commands::WrongCommandDataTypeDuringParseException
 
class  conscience_core::bridging::commands::WrongCommandParamsSizeDuringParseException
 
class  conscience_core::bridging::commands::CscCommandDataTypeBase
 
struct  conscience_core::bridging::commands::CscEnumInfos
 
class  conscience_core::bridging::commands::CscCommandDataTypeNodeMetadata
 
struct  conscience_core::bridging::commands::CommandTypesMetadataByTypeNameMutexUniqueType
 
struct  conscience_core::bridging::commands::CommandsMetadataByIdMutexUniqueType
 
class  conscience_core::bridging::commands::CscCommandDataTypeMetadata
 
struct  conscience_core::bridging::commands::CommandDataJsonSerializersMutexUniqueType
 
class  conscience_core::bridging::commands::BaseCommandParams
 

Namespaces

 conscience_core
 
 conscience_core::bridging
 
 conscience_core::bridging::commands
 

Macros

#define FOR_EACH_PAIR(macro, ...)   __VA_OPT__(MACRO_EXPAND(FOR_EACH_PAIR_HELPER(macro, __VA_ARGS__)))
 
#define FOR_EACH_PAIR_HELPER(macro, a1, a2, ...)
 
#define FOR_EACH_PAIR_AGAIN()   FOR_EACH_PAIR_HELPER
 
#define FIELDS_PAIR_PRINT(type, name)   type name;
 
#define FIELDS_ASSIGN_FROM_MAP_PRINT(FIELD_type, FIELD_name)
 
#define FIELDS_ASSIGN_INTO_JSONMAP_PRINT(FIELD_type, FIELD_name)
 
#define FIELDS_ASSIGN_INTO_JSONMAP_PRINT_NOTYPE(FIELD_name)   FIELDS_ASSIGN_INTO_JSONMAP_PRINT(UnspecifiedType, FIELD_name)
 

Typedefs

template<class TValue >
using map_by_string = std::map< string, TValue >
 
template<class TValue >
using map_by_int = std::map< int, TValue >
 
using conscience_core::bridging::commands::CommandTypesMetadataByTypeNameMutex = shared_recursive_mutex_t< CommandTypesMetadataByTypeNameMutexUniqueType >
 
using conscience_core::bridging::commands::CommandsMetadataByIdMutex = shared_recursive_mutex_t< CommandsMetadataByIdMutexUniqueType >
 
using conscience_core::bridging::commands::CommandDataJsonSerializersMutex = shared_recursive_mutex_t< CommandDataJsonSerializersMutexUniqueType >
 

Enumerations

enum  conscience_core::bridging::commands::CscCommandPtrType { conscience_core::bridging::commands::CommandPtrType_STAR, conscience_core::bridging::commands::CommandPtrType_SHARED, conscience_core::bridging::commands::CommandPtrType_REF, conscience_core::bridging::commands::CommandPtrType_PLAIN }
 

Functions

template<typename TClass >
const TClass * anyToPointer (const any &objectAny)
 
 conscience_core::bridging::commands::ENUM (CommandParamMetaType, CommandParamMetaType_double, CommandParamMetaType_float, CommandParamMetaType_int, CommandParamMetaType_long, CommandParamMetaType_unsigned_long_long, CommandParamMetaType_bool, CommandParamMetaType_string, CommandParamMetaType_list, CommandParamMetaType_map, CommandParamMetaType_object, CommandParamMetaType_optional, CommandParamMetaType_enum, CommandParamMetaType_entityReflexion, CommandParamMetaType_entityModel, CommandParamMetaType_placeModel, CommandParamMetaType_objectModel)
 
bool conscience_core::bridging::commands::isNullableObjectType (CscCommandPtrType refType)
 
CommandTypesMetadataByTypeNameMutex & conscience_core::bridging::commands::commandTypesMetadataByTypeNameMutex ()
 
map< string, CscCommandDataTypeMetadata * > & conscience_core::bridging::commands::commandTypesMetadataByTypeName ()
 
CommandsMetadataByIdMutex & conscience_core::bridging::commands::commandsMetadataByIdMutex ()
 
map< string, const CscCommandDataTypeMetadata * > & conscience_core::bridging::commands::commandsMetadataById ()
 
bool conscience_core::bridging::commands::hasCommandTypeMetadataForName (const string &qualifiedTypeName)
 
const CscCommandDataTypeMetadata * conscience_core::bridging::commands::getCommandTypeMetadataByName (const string &qualifiedTypeName)
 
const CscCommandDataTypeMetadata * conscience_core::bridging::commands::updateCommandTypeMetadataByName (const string &headerFileRelativePath, const string &classQualifiedName, const string &classSimpleName, const string &doc, const vector< const CscCommandDataTypeNodeMetadata * > &paramsMetadata, optional< string > commandId)
 
void conscience_core::bridging::commands::registerCommandTypeMetadata (CscCommandDataTypeMetadata *typeMetadata)
 
void conscience_core::bridging::commands::registerCommandMetadataTypeById (const CscCommandDataTypeMetadata *typeMetadata)
 
const CscCommandDataTypeNodeMetadata * conscience_core::bridging::commands::parseMetadataTypeNode (const string &name, const string &typeString)
 
CommandDataJsonSerializersMutex & conscience_core::bridging::commands::commandDataJsonSerializersMutex ()
 
map< const type_info *, function< optional< JsonSerializableData >const any &object)> > & conscience_core::bridging::commands::getCommandDataJsonSerializers ()
 
bool conscience_core::bridging::commands::registerCommandDataJsonSerializer (const type_info &typeInfo, function< optional< JsonSerializableData >(const any &object)> serializer)
 
template<typename TData >
function< optional< JsonSerializableData >const any &object)> conscience_core::bridging::commands::getCommandDataJsonSerializer ()
 
template<typename T >
conscience_core::bridging::commands::field_value_any_cast (any anyValue)
 
template<IsMap TMap>
TMap conscience_core::bridging::commands::field_value_any_cast (any anyValue)
 
template<IsOptional TOptional>
TOptional conscience_core::bridging::commands::field_value_any_cast (any anyValue)
 
template<IsVector TVector>
TVector conscience_core::bridging::commands::field_value_any_cast (any anyValue)
 
template<typename T >
 conscience_core::bridging::commands::requires (IsSharedPointer< std::remove_cvref_t< T >>) JsonSerializableData field_value_to_json_serializable(T value)
 
template<typename T >
 conscience_core::bridging::commands::requires (IsStarPointer< std::remove_cvref_t< T >>) JsonSerializableData field_value_to_json_serializable(T value)
 
template<typename T >
JsonSerializableData conscience_core::bridging::commands::field_value_to_json_serializable (optional< T > value)
 
template<IsVector TVector>
JsonSerializableData conscience_core::bridging::commands::field_value_to_json_serializable (TVector value)
 
template<IsMap TMap>
JsonSerializableData conscience_core::bridging::commands::field_value_to_json_serializable (TMap value)
 
template<typename T >
JsonSerializableData conscience_core::bridging::commands::field_value_to_json_serializable (T value)
 
map< string, any > conscience_core::bridging::commands::parseCommandParametersAsMap (const string &commandId, const vector< string > &commandStringArguments, optional< int > knowledgeId, bool objectsAsMap, bool resolveObjects, bool permissive)
 
void conscience_core::bridging::commands::listCommandsWithDocumentedParams ()
 
bool conscience_core::bridging::commands::isUserCommand (const string &commandId)
 
fs::path conscience_core::bridging::commands::resolveCommandFileAbsolutePathFromRelative (const fs::path &headerFileRelativePath, const string &forCommandId)
 

Variables

template<typename T >
concept conscience_core::bridging::commands::IsCommandParams = std::is_base_of<BaseCommandParams, T>::value
 

Macro Definition Documentation

◆ FIELDS_ASSIGN_FROM_MAP_PRINT

#define FIELDS_ASSIGN_FROM_MAP_PRINT (   FIELD_type,
  FIELD_name 
)
Value:
try { \
if (fieldsValues.find(#FIELD_name) != fieldsValues.end()) { \
any actualValue = fieldsValues.at(#FIELD_name); \
if (string(#FIELD_type) == "string" && typeid(const char *) == actualValue.type()) { \
actualValue = string(any_cast<const char *>(actualValue)); \
} \
LOGGER_TRACE("set " + string(#FIELD_name)); \
actualValue = field_value_any_cast<FIELD_type>(actualValue); \
targetObject->FIELD_name = any_cast<FIELD_type>(actualValue); \
} else { \
LOGGER_WARN(string("cannot find ") + #FIELD_name) \
} \
} catch (const std::bad_any_cast &e) { \
LOGGER_INFO(string("cannot set ") + #FIELD_type + " " + #FIELD_name + ": " + e.what()); \
throw e; \
}

◆ FIELDS_ASSIGN_INTO_JSONMAP_PRINT

#define FIELDS_ASSIGN_INTO_JSONMAP_PRINT (   FIELD_type,
  FIELD_name 
)
Value:
try { \
JsonSerializableData jsonSerializableValue = field_value_to_json_serializable(object->FIELD_name); \
jsonMap[#FIELD_name] = jsonSerializableValue; \
} catch (const exception &e) { \
LOGGER_INFO(string("cannot set ") + #FIELD_type + " " + #FIELD_name + " into map: " + e.what()); \
throw e; \
}

◆ FIELDS_ASSIGN_INTO_JSONMAP_PRINT_NOTYPE

#define FIELDS_ASSIGN_INTO_JSONMAP_PRINT_NOTYPE (   FIELD_name)    FIELDS_ASSIGN_INTO_JSONMAP_PRINT(UnspecifiedType, FIELD_name)

◆ FIELDS_PAIR_PRINT

#define FIELDS_PAIR_PRINT (   type,
  name 
)    type name;

◆ FOR_EACH_PAIR

#define FOR_EACH_PAIR (   macro,
  ... 
)    __VA_OPT__(MACRO_EXPAND(FOR_EACH_PAIR_HELPER(macro, __VA_ARGS__)))

◆ FOR_EACH_PAIR_AGAIN

#define FOR_EACH_PAIR_AGAIN ( )    FOR_EACH_PAIR_HELPER

◆ FOR_EACH_PAIR_HELPER

#define FOR_EACH_PAIR_HELPER (   macro,
  a1,
  a2,
  ... 
)
Value:
macro(a1, a2) \
__VA_OPT__(FOR_EACH_PAIR_AGAIN MACRO_PARENS(macro, __VA_ARGS__))

Typedef Documentation

◆ map_by_int

template<class TValue >
using map_by_int = std::map<int, TValue>

◆ map_by_string

template<class TValue >
using map_by_string = std::map<string, TValue>

Function Documentation

◆ anyToPointer()

template<typename TClass >
const TClass* anyToPointer ( const any &  objectAny)
conscience_core::bridging::commands::field_value_to_json_serializable
JsonSerializableData field_value_to_json_serializable(T value)
Definition: CommandParamsSpec.h:619
nlohmann::detail::value_t::string
@ string
string value
picojson::object
value::object object
Definition: picojson.h:210
FOR_EACH_PAIR_AGAIN
#define FOR_EACH_PAIR_AGAIN()
Definition: CommandParamsSpec.h:25
MACRO_PARENS
#define MACRO_PARENS
Definition: conscience_util.h:47