change clang-format
Signed-off-by: Folling <mail@folling.io>
This commit is contained in:
parent
497f96a574
commit
f925d90d6b
33 changed files with 217 additions and 254 deletions
|
|
@ -15,8 +15,8 @@ AlignEscapedNewlines: Left
|
||||||
AlignOperands: Align
|
AlignOperands: Align
|
||||||
AlignTrailingComments: true
|
AlignTrailingComments: true
|
||||||
|
|
||||||
AllowAllArgumentsOnNextLine: true
|
AllowAllArgumentsOnNextLine: false
|
||||||
AllowAllParametersOfDeclarationOnNextLine: true
|
AllowAllParametersOfDeclarationOnNextLine: false
|
||||||
AllowShortBlocksOnASingleLine: Empty
|
AllowShortBlocksOnASingleLine: Empty
|
||||||
AllowShortCaseLabelsOnASingleLine: true
|
AllowShortCaseLabelsOnASingleLine: true
|
||||||
AllowShortEnumsOnASingleLine: true
|
AllowShortEnumsOnASingleLine: true
|
||||||
|
|
@ -35,36 +35,38 @@ BinPackParameters: false
|
||||||
BitFieldColonSpacing: Both
|
BitFieldColonSpacing: Both
|
||||||
|
|
||||||
BraceWrapping:
|
BraceWrapping:
|
||||||
|
AfterCaseLabel: false
|
||||||
|
AfterClass: false
|
||||||
|
AfterControlStatement: Never
|
||||||
|
AfterEnum: false
|
||||||
|
AfterFunction: false
|
||||||
|
AfterNamespace: false
|
||||||
|
AfterStruct: false
|
||||||
|
AfterUnion: false
|
||||||
|
AfterExternBlock: false
|
||||||
BeforeCatch: false
|
BeforeCatch: false
|
||||||
BeforeElse: false
|
BeforeElse: false
|
||||||
BeforeLambdaBody: false
|
BeforeLambdaBody: false
|
||||||
BeforeWhile: false
|
BeforeWhile: false
|
||||||
AfterCaseLabel: false
|
|
||||||
AfterClass: false
|
|
||||||
AfterControlStatement: MultiLine
|
|
||||||
AfterEnum: false
|
|
||||||
AfterExternBlock: false
|
|
||||||
AfterFunction: false
|
|
||||||
AfterNamespace: false
|
|
||||||
AfterObjCDeclaration: false
|
|
||||||
AfterStruct: false
|
|
||||||
AfterUnion: false
|
|
||||||
IndentBraces: false
|
IndentBraces: false
|
||||||
SplitEmptyFunction: false
|
SplitEmptyFunction: false
|
||||||
SplitEmptyNamespace: false
|
SplitEmptyNamespace: false
|
||||||
SplitEmptyRecord: false
|
SplitEmptyRecord: false
|
||||||
|
|
||||||
|
BracedInitializerIndentWidth: 4
|
||||||
|
|
||||||
|
# BreakAdjacentStringLiterals: true
|
||||||
BreakAfterAttributes: Never
|
BreakAfterAttributes: Never
|
||||||
BreakBeforeBinaryOperators: None
|
BreakBeforeBinaryOperators: None
|
||||||
BreakBeforeBraces: Attach
|
BreakBeforeBraces: Custom
|
||||||
BreakBeforeConceptDeclarations: Always
|
BreakBeforeConceptDeclarations: Always
|
||||||
# BreakBeforeInlineASMColon: OnlyMultiline
|
BreakBeforeInlineASMColon: OnlyMultiline
|
||||||
BreakBeforeTernaryOperators: false
|
BreakBeforeTernaryOperators: false
|
||||||
BreakConstructorInitializers: AfterColon
|
BreakConstructorInitializers: AfterColon
|
||||||
BreakInheritanceList: AfterColon
|
BreakInheritanceList: AfterColon
|
||||||
BreakStringLiterals: false
|
BreakStringLiterals: false
|
||||||
|
|
||||||
ColumnLimit: 128
|
ColumnLimit: 140
|
||||||
|
|
||||||
CompactNamespaces: false
|
CompactNamespaces: false
|
||||||
ConstructorInitializerIndentWidth: 4
|
ConstructorInitializerIndentWidth: 4
|
||||||
|
|
@ -77,7 +79,9 @@ DerivePointerAlignment: false
|
||||||
EmptyLineAfterAccessModifier: Never
|
EmptyLineAfterAccessModifier: Never
|
||||||
EmptyLineBeforeAccessModifier: Always
|
EmptyLineBeforeAccessModifier: Always
|
||||||
|
|
||||||
FixNamespaceComments: false
|
ExperimentalAutoDetectBinPacking: true
|
||||||
|
|
||||||
|
FixNamespaceComments: true
|
||||||
|
|
||||||
IncludeBlocks: Regroup
|
IncludeBlocks: Regroup
|
||||||
IncludeCategories:
|
IncludeCategories:
|
||||||
|
|
@ -112,54 +116,59 @@ IndentAccessModifiers: false
|
||||||
IndentCaseBlocks: false
|
IndentCaseBlocks: false
|
||||||
IndentCaseLabels: false
|
IndentCaseLabels: false
|
||||||
IndentExternBlock: NoIndent
|
IndentExternBlock: NoIndent
|
||||||
IndentGotoLabels: true
|
IndentGotoLabels: false
|
||||||
IndentPPDirectives: None
|
IndentPPDirectives: None
|
||||||
IndentRequiresClause: true
|
IndentRequiresClause: true
|
||||||
IndentWidth: 4
|
IndentWidth: 4
|
||||||
IndentWrappedFunctionNames: false
|
IndentWrappedFunctionNames: false
|
||||||
InsertBraces: true
|
InsertBraces: true
|
||||||
InsertNewlineAtEOF: true
|
InsertNewlineAtEOF: true
|
||||||
|
InsertTrailingCommas: Wrapped
|
||||||
|
|
||||||
# InsertNewlineAtEOF: true
|
IntegerLiteralSeparator:
|
||||||
# IntegerLiteralSeparator:
|
Binary: -1
|
||||||
# Binary: 0
|
Decimal: 3
|
||||||
# Decimal: 3
|
Hex: -1
|
||||||
# Hex: -1
|
|
||||||
|
|
||||||
|
KeepEmptyLinesAtEOF: false
|
||||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||||
|
|
||||||
LambdaBodyIndentation: Signature
|
LambdaBodyIndentation: Signature
|
||||||
Language: Cpp
|
Language: Cpp
|
||||||
|
|
||||||
# LineEnding: LF
|
LineEnding: LF
|
||||||
|
|
||||||
MaxEmptyLinesToKeep: 1
|
MaxEmptyLinesToKeep: 1
|
||||||
|
|
||||||
NamespaceIndentation: None
|
NamespaceIndentation: None
|
||||||
|
|
||||||
|
PPIndentWidth: -1
|
||||||
PackConstructorInitializers: Never
|
PackConstructorInitializers: Never
|
||||||
|
|
||||||
PointerAlignment: Middle
|
PointerAlignment: Middle
|
||||||
QualifierAlignment: Right
|
QualifierAlignment: Right
|
||||||
# QualifierOrder: [ 'friend', 'constexpr', 'inline', 'static', 'type', 'const', 'volatile' ]
|
# QualifierOrder: [ 'friend', 'constexpr', 'inline', 'static', 'type', 'const', 'volatile' ]
|
||||||
ReferenceAlignment: Left
|
ReferenceAlignment: Middle
|
||||||
|
|
||||||
ReflowComments: true
|
ReflowComments: true
|
||||||
# RemoveSemicolon: true
|
RemoveBracesLLVM: false
|
||||||
|
RemoveParentheses: MultipleParentheses
|
||||||
|
RemoveSemicolon: true
|
||||||
|
|
||||||
RequiresClausePosition: OwnLine
|
RequiresClausePosition: OwnLine
|
||||||
# RequiresExpressionIndentation: OuterScope
|
RequiresExpressionIndentation: OuterScope
|
||||||
|
|
||||||
SeparateDefinitionBlocks: Always
|
SeparateDefinitionBlocks: Always
|
||||||
|
|
||||||
SortIncludes: CaseInsensitive
|
SortIncludes: CaseInsensitive
|
||||||
SortUsingDeclarations: true
|
SortUsingDeclarations: LexicographicNumeric
|
||||||
|
|
||||||
SpaceAfterCStyleCast: false
|
SpaceAfterCStyleCast: false
|
||||||
SpaceAfterLogicalNot: false
|
SpaceAfterLogicalNot: false
|
||||||
SpaceAfterTemplateKeyword: false
|
SpaceAfterTemplateKeyword: false
|
||||||
|
SpaceAroundPointerQualifiers: Both
|
||||||
SpaceBeforeAssignmentOperators: true
|
SpaceBeforeAssignmentOperators: true
|
||||||
|
SpaceBeforeCaseColon: false
|
||||||
SpaceBeforeCpp11BracedList: false
|
SpaceBeforeCpp11BracedList: false
|
||||||
SpaceBeforeCtorInitializerColon: false
|
SpaceBeforeCtorInitializerColon: false
|
||||||
SpaceBeforeInheritanceColon: true
|
SpaceBeforeInheritanceColon: true
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,10 @@
|
||||||
IKARUS_BEGIN_HEADER
|
IKARUS_BEGIN_HEADER
|
||||||
|
|
||||||
/// \brief Delineates what caused an error.
|
/// \brief Delineates what caused an error.
|
||||||
/// \details First 2 bytes delineate the major type, next 2 bytes delineate the minor type, next 4 bytes delineate the detail
|
/// \details First 2 bytes delineate the major type, next 2 bytes delineate the minor type, next 4 bytes delineate the
|
||||||
/// type.
|
/// detail type.
|
||||||
/// \remark Note that this doesn't show responsibility. An error with source "SubSystem" could still be the fault of
|
/// \remark Note that this doesn't show responsibility. An error with source "SubSystem" could still be the
|
||||||
/// libikarus.
|
/// fault of libikarus.
|
||||||
enum IkarusErrorInfo {
|
enum IkarusErrorInfo {
|
||||||
/// \brief No error occurred.
|
/// \brief No error occurred.
|
||||||
IkarusErrorInfo_Source_None = 0x0001000000000000,
|
IkarusErrorInfo_Source_None = 0x0001000000000000,
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,8 @@
|
||||||
|
|
||||||
IKARUS_BEGIN_HEADER
|
IKARUS_BEGIN_HEADER
|
||||||
|
|
||||||
/// \brief Frees a pointer allocated by ikarus. Every pointer returned by a function must be freed using this function unless
|
/// \brief Frees a pointer allocated by ikarus. Every pointer returned by a function must be freed using this function
|
||||||
/// explicitly stated otherwise.
|
/// unless explicitly stated otherwise.
|
||||||
IKA_API void ikarus_free(void * ptr);
|
IKA_API void ikarus_free(void * ptr);
|
||||||
|
|
||||||
IKARUS_END_HEADER
|
IKARUS_END_HEADER
|
||||||
|
|
|
||||||
|
|
@ -43,9 +43,8 @@ IKA_API void ikarus_blueprint_delete(IkarusBlueprint * blueprint);
|
||||||
/// \pre \li Must not be null.
|
/// \pre \li Must not be null.
|
||||||
/// \param properties_out_size The size of the buffer.
|
/// \param properties_out_size The size of the buffer.
|
||||||
/// \see ikarus_blueprint_get_property_count
|
/// \see ikarus_blueprint_get_property_count
|
||||||
IKA_API void ikarus_blueprint_get_properties(
|
IKA_API void
|
||||||
IkarusBlueprint const * blueprint, struct IkarusProperty ** properties_out, size_t properties_out_size
|
ikarus_blueprint_get_properties(IkarusBlueprint const * blueprint, struct IkarusProperty ** properties_out, size_t properties_out_size);
|
||||||
);
|
|
||||||
|
|
||||||
/// \brief Gets the number of properties of a blueprint.
|
/// \brief Gets the number of properties of a blueprint.
|
||||||
/// \param blueprint The blueprint to get the number of properties of.
|
/// \param blueprint The blueprint to get the number of properties of.
|
||||||
|
|
@ -62,9 +61,8 @@ IKA_API size_t ikarus_blueprint_get_property_count(IkarusBlueprint const * bluep
|
||||||
/// \pre \li Must not be null.
|
/// \pre \li Must not be null.
|
||||||
/// \param entities_out_size The size of the buffer.
|
/// \param entities_out_size The size of the buffer.
|
||||||
/// \see ikarus_blueprint_get_linked_entity_count
|
/// \see ikarus_blueprint_get_linked_entity_count
|
||||||
IKA_API void ikarus_blueprint_get_linked_entities(
|
IKA_API void
|
||||||
IkarusBlueprint const * blueprint, struct IkarusEntity ** entities_out, size_t entities_out_size
|
ikarus_blueprint_get_linked_entities(IkarusBlueprint const * blueprint, struct IkarusEntity ** entities_out, size_t entities_out_size);
|
||||||
);
|
|
||||||
|
|
||||||
/// \brief Gets the number of entities linked to a blueprint.
|
/// \brief Gets the number of entities linked to a blueprint.
|
||||||
/// \param blueprint The blueprint to get the number of linked entities of.
|
/// \param blueprint The blueprint to get the number of linked entities of.
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,14 @@ IKA_API IkarusEntity * ikarus_entity_create(struct IkarusProject * project, char
|
||||||
/// \remark The entity must not be accessed after deletion.
|
/// \remark The entity must not be accessed after deletion.
|
||||||
IKA_API void ikarus_entity_delete(IkarusEntity * entity);
|
IKA_API void ikarus_entity_delete(IkarusEntity * entity);
|
||||||
|
|
||||||
|
/// \brief Checks if an entity is linked to a blueprint.
|
||||||
|
/// \param entity The entity to check.
|
||||||
|
/// \pre \li Must not be null.
|
||||||
|
/// \pre \li Must exist.
|
||||||
|
/// \param blueprint The blueprint to check.
|
||||||
|
/// \pre \li Must not be null.
|
||||||
|
/// \pre \li Must exist.
|
||||||
|
/// \return True if the entity is linked to the blueprint, false otherwise.
|
||||||
IKA_API bool ikarus_entity_is_linked_to_blueprint(IkarusEntity const * entity, struct IkarusBlueprint const * blueprint);
|
IKA_API bool ikarus_entity_is_linked_to_blueprint(IkarusEntity const * entity, struct IkarusBlueprint const * blueprint);
|
||||||
|
|
||||||
/// \brief Links an entity to a blueprint.
|
/// \brief Links an entity to a blueprint.
|
||||||
|
|
@ -68,8 +76,8 @@ IKA_API bool ikarus_entity_is_linked_to_blueprint(IkarusEntity const * entity, s
|
||||||
/// \remark No-op if the entity is already linked to the blueprint.
|
/// \remark No-op if the entity is already linked to the blueprint.
|
||||||
IKA_API void ikarus_entity_link_to_blueprint(IkarusEntity * entity, struct IkarusBlueprint * blueprint);
|
IKA_API void ikarus_entity_link_to_blueprint(IkarusEntity * entity, struct IkarusBlueprint * blueprint);
|
||||||
|
|
||||||
/// \brief Unlinks an entity from a blueprint. All values of the properties of the blueprint the entity is linked with will be
|
/// \brief Unlinks an entity from a blueprint. All values of the properties of the blueprint the entity is linked with
|
||||||
/// deleted.
|
/// will be deleted.
|
||||||
/// \param entity The entity to unlink.
|
/// \param entity The entity to unlink.
|
||||||
/// \pre \li Must not be null.
|
/// \pre \li Must not be null.
|
||||||
/// \pre \li Must exist.
|
/// \pre \li Must exist.
|
||||||
|
|
@ -103,12 +111,11 @@ IKA_API size_t ikarus_entity_get_property_count(IkarusEntity const * entity);
|
||||||
/// \param properties_out The buffer to write the properties to.
|
/// \param properties_out The buffer to write the properties to.
|
||||||
/// \pre \li Must not be null.
|
/// \pre \li Must not be null.
|
||||||
/// \param properties_out_size The size of the buffer.
|
/// \param properties_out_size The size of the buffer.
|
||||||
IKA_API void ikarus_entity_get_properties(
|
IKA_API void ikarus_entity_get_properties(IkarusEntity const * entity, struct IkarusProperty ** properties_out, size_t properties_out_size);
|
||||||
IkarusEntity const * entity, struct IkarusProperty ** properties_out, size_t properties_out_size
|
|
||||||
);
|
|
||||||
|
|
||||||
/// \brief Gets the value of a property of an entity.
|
/// \brief Gets the value of a property of an entity.
|
||||||
/// \details If the entity has never set the value of the property, the default value is returned (which may be undefined).
|
/// \details If the entity has never set the value of the property, the default value is returned (which may be
|
||||||
|
/// undefined).
|
||||||
/// \param entity The entity to get the value of.
|
/// \param entity The entity to get the value of.
|
||||||
/// \pre \li Must not be null.
|
/// \pre \li Must not be null.
|
||||||
/// \pre \li Must exist.
|
/// \pre \li Must exist.
|
||||||
|
|
@ -116,7 +123,8 @@ IKA_API void ikarus_entity_get_properties(
|
||||||
/// \pre \li Must not be null.
|
/// \pre \li Must not be null.
|
||||||
/// \pre \li Must exist.
|
/// \pre \li Must exist.
|
||||||
/// \return The value of the property or null if the entity does not have the property or an error occurs.
|
/// \return The value of the property or null if the entity does not have the property or an error occurs.
|
||||||
/// \remark Must be freed using #ikarus_free.
|
/// \remark Must be freed using
|
||||||
|
/// #ikarus_free.
|
||||||
IKA_API struct IkarusEntityValue * ikarus_entity_get_value(IkarusEntity const * entity, struct IkarusProperty const * property);
|
IKA_API struct IkarusEntityValue * ikarus_entity_get_value(IkarusEntity const * entity, struct IkarusProperty const * property);
|
||||||
|
|
||||||
/// \brief Sets the value of a property of an entity.
|
/// \brief Sets the value of a property of an entity.
|
||||||
|
|
@ -131,9 +139,7 @@ IKA_API struct IkarusEntityValue * ikarus_entity_get_value(IkarusEntity const *
|
||||||
/// \pre \li Must be of the same type as the property.
|
/// \pre \li Must be of the same type as the property.
|
||||||
/// \pre \li Must be valid for the property's settings.
|
/// \pre \li Must be valid for the property's settings.
|
||||||
/// \remark If the entity does not have the property, this function fails.
|
/// \remark If the entity does not have the property, this function fails.
|
||||||
IKA_API void ikarus_entity_set_value(
|
IKA_API void ikarus_entity_set_value(IkarusEntity * entity, struct IkarusProperty const * property, struct IkarusValue const * value);
|
||||||
IkarusEntity * entity, struct IkarusProperty const * property, struct IkarusValue const * value
|
|
||||||
);
|
|
||||||
|
|
||||||
/// \brief Casts an entity to an object.
|
/// \brief Casts an entity to an object.
|
||||||
/// \param entity The entity to cast.
|
/// \param entity The entity to cast.
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,8 @@ IKARUS_BEGIN_HEADER
|
||||||
struct IkarusObject;
|
struct IkarusObject;
|
||||||
|
|
||||||
/// \brief Compares two objects for equality.
|
/// \brief Compares two objects for equality.
|
||||||
/// \details This neither compares the pointers nor does a deep copy. Instead it figures out if the objects _are_ the same
|
/// \details This neither compares the pointers nor does a deep copy. Instead it figures out if the objects _are_ the
|
||||||
/// object.
|
/// same object. \param lhs The left hand side object. \pre \li Must not be null. \param rhs The right hand side object.
|
||||||
/// \param lhs The left hand side object.
|
|
||||||
/// \pre \li Must not be null.
|
|
||||||
/// \param rhs The right hand side object.
|
|
||||||
/// \pre \li Must not be null.
|
/// \pre \li Must not be null.
|
||||||
/// \return True if the objects are equal, false otherwise.
|
/// \return True if the objects are equal, false otherwise.
|
||||||
IKA_API bool ikarus_object_is_equal(IkarusObject const * lhs, IkarusObject const * rhs);
|
IKA_API bool ikarus_object_is_equal(IkarusObject const * lhs, IkarusObject const * rhs);
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,8 @@ IKARUS_BEGIN_HEADER
|
||||||
|
|
||||||
struct IkarusNumberProperty;
|
struct IkarusNumberProperty;
|
||||||
|
|
||||||
IKA_API IkarusNumberProperty * ikarus_number_property_create(
|
IKA_API IkarusNumberProperty *
|
||||||
struct IkarusProject * project, char const * name, struct IkarusPropertySource * property_source
|
ikarus_number_property_create(struct IkarusProject * project, char const * name, struct IkarusPropertySource * property_source);
|
||||||
);
|
|
||||||
|
|
||||||
/// \brief Sets the default value for a number property.
|
/// \brief Sets the default value for a number property.
|
||||||
/// \param property The number property.
|
/// \param property The number property.
|
||||||
|
|
@ -30,11 +29,9 @@ IKA_API struct IkarusNumberValue * ikarus_number_property_get_default_value(stru
|
||||||
/// \param default_value The default value.
|
/// \param default_value The default value.
|
||||||
/// \pre \li Must not be null.
|
/// \pre \li Must not be null.
|
||||||
/// \pre \li Must be a valid value for the property.
|
/// \pre \li Must be a valid value for the property.
|
||||||
/// \remark Please see \ref property.h "the property documentation" for more information on the interplay between default values
|
/// \remark Please see \ref property.h "the property documentation" for more information on the interplay between
|
||||||
/// and other settings.
|
/// default values and other settings.
|
||||||
IKA_API void ikarus_number_property_set_default_value(
|
IKA_API void ikarus_number_property_set_default_value(struct IkarusNumberProperty * property, struct IkarusNumberValue * default_value);
|
||||||
struct IkarusNumberProperty * property, struct IkarusNumberValue * default_value
|
|
||||||
);
|
|
||||||
|
|
||||||
IKARUS_END_HEADER
|
IKARUS_END_HEADER
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,8 +33,8 @@ IKARUS_BEGIN_HEADER
|
||||||
/// - May be undefined
|
/// - May be undefined
|
||||||
///
|
///
|
||||||
/// Additionally, each property has a default value. If no default value is provided, a sensible default is chosen.
|
/// Additionally, each property has a default value. If no default value is provided, a sensible default is chosen.
|
||||||
/// Setting a default value that isn't valid for the property is an error. Changing settings so that the current default value
|
/// Setting a default value that isn't valid for the property is an error. Changing settings so that the current default
|
||||||
/// becomes invalid is valid but unsets the custom default value.
|
/// value becomes invalid is valid but unsets the custom default value.
|
||||||
///
|
///
|
||||||
/// The former transforms a property into a list. Instead of one number, you could then specify a series of numbers.
|
/// The former transforms a property into a list. Instead of one number, you could then specify a series of numbers.
|
||||||
/// The latter allows you to specify an "unknown" value for a property.
|
/// The latter allows you to specify an "unknown" value for a property.
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,8 @@ IKARUS_BEGIN_HEADER
|
||||||
|
|
||||||
struct IkarusTextProperty;
|
struct IkarusTextProperty;
|
||||||
|
|
||||||
IKA_API IkarusTextProperty * ikarus_text_property_create(
|
IKA_API IkarusTextProperty *
|
||||||
struct IkarusProject * project, char const * name, struct IkarusPropertySource * property_source
|
ikarus_text_property_create(struct IkarusProject * project, char const * name, struct IkarusPropertySource * property_source);
|
||||||
);
|
|
||||||
|
|
||||||
/// \brief Sets the default value for a text property.
|
/// \brief Sets the default value for a text property.
|
||||||
/// \param property The text property.
|
/// \param property The text property.
|
||||||
|
|
@ -30,11 +29,9 @@ IKA_API struct IkarusTextValue * ikarus_text_property_get_default_value(struct I
|
||||||
/// \param default_value The default value.
|
/// \param default_value The default value.
|
||||||
/// \pre \li Must not be null.
|
/// \pre \li Must not be null.
|
||||||
/// \pre \li Must be a valid value for the property.
|
/// \pre \li Must be a valid value for the property.
|
||||||
/// \remark Please see \ref property.h "the property documentation" for more information on the interplay between default values
|
/// \remark Please see \ref property.h "the property documentation" for more information on the interplay between
|
||||||
/// and other settings.
|
/// default values and other settings.
|
||||||
IKA_API void ikarus_text_property_set_default_value(
|
IKA_API void ikarus_text_property_set_default_value(struct IkarusTextProperty * property, struct IkarusTextValue * default_value);
|
||||||
struct IkarusTextProperty * property, struct IkarusTextValue * default_value
|
|
||||||
);
|
|
||||||
|
|
||||||
IKARUS_END_HEADER
|
IKARUS_END_HEADER
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,8 @@ IKARUS_BEGIN_HEADER
|
||||||
|
|
||||||
struct IkarusToggleProperty;
|
struct IkarusToggleProperty;
|
||||||
|
|
||||||
IKA_API IkarusToggleProperty * ikarus_toggle_property_create(
|
IKA_API IkarusToggleProperty *
|
||||||
struct IkarusProject * project, char const * name, struct IkarusPropertySource * property_source
|
ikarus_toggle_property_create(struct IkarusProject * project, char const * name, struct IkarusPropertySource * property_source);
|
||||||
);
|
|
||||||
|
|
||||||
/// \brief Sets the default value for a toggle property.
|
/// \brief Sets the default value for a toggle property.
|
||||||
/// \param property The toggle property.
|
/// \param property The toggle property.
|
||||||
|
|
@ -30,11 +29,9 @@ IKA_API struct IkarusToggleValue * ikarus_toggle_property_get_default_value(stru
|
||||||
/// \param default_value The default value.
|
/// \param default_value The default value.
|
||||||
/// \pre \li Must not be null.
|
/// \pre \li Must not be null.
|
||||||
/// \pre \li Must be a valid value for the property.
|
/// \pre \li Must be a valid value for the property.
|
||||||
/// \remark Please see \ref property.h "the property documentation" for more information on the interplay between default values
|
/// \remark Please see \ref property.h "the property documentation" for more information on the interplay between
|
||||||
/// and other settings.
|
/// default values and other settings.
|
||||||
IKA_API void ikarus_toggle_property_set_default_value(
|
IKA_API void ikarus_toggle_property_set_default_value(struct IkarusToggleProperty * property, struct IkarusToggleValue * default_value);
|
||||||
struct IkarusToggleProperty * property, struct IkarusToggleValue * default_value
|
|
||||||
);
|
|
||||||
|
|
||||||
IKARUS_END_HEADER
|
IKARUS_END_HEADER
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -144,9 +144,8 @@ IKA_API size_t ikarus_project_get_blueprint_count(IkarusProject const * project)
|
||||||
/// \param blueprints_out The buffer to write the blueprints to.
|
/// \param blueprints_out The buffer to write the blueprints to.
|
||||||
/// \pre \li Must not be null.
|
/// \pre \li Must not be null.
|
||||||
/// \param blueprints_out_size The size of the buffer.
|
/// \param blueprints_out_size The size of the buffer.
|
||||||
IKA_API void ikarus_project_get_blueprints(
|
IKA_API void
|
||||||
IkarusProject const * project, struct IkarusBlueprint ** blueprints_out, size_t blueprints_out_size
|
ikarus_project_get_blueprints(IkarusProject const * project, struct IkarusBlueprint ** blueprints_out, size_t blueprints_out_size);
|
||||||
);
|
|
||||||
|
|
||||||
/// \brief Gets the entity root folder of a project.
|
/// \brief Gets the entity root folder of a project.
|
||||||
/// \param project The project to get the entity root folder of.
|
/// \param project The project to get the entity root folder of.
|
||||||
|
|
@ -170,9 +169,7 @@ IKA_API size_t ikarus_project_get_entity_count(IkarusProject const * project);
|
||||||
/// \param entities_out The buffer to write the entities to.
|
/// \param entities_out The buffer to write the entities to.
|
||||||
/// \pre \li Must not be null.
|
/// \pre \li Must not be null.
|
||||||
/// \param entities_out_size The size of the buffer.
|
/// \param entities_out_size The size of the buffer.
|
||||||
IKA_API void ikarus_project_get_entities(
|
IKA_API void ikarus_project_get_entities(IkarusProject const * project, struct IkarusEntity ** entities_out, size_t entities_out_size);
|
||||||
IkarusProject const * project, struct IkarusEntity ** entities_out, size_t entities_out_size
|
|
||||||
);
|
|
||||||
|
|
||||||
IKARUS_END_HEADER
|
IKARUS_END_HEADER
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,8 @@
|
||||||
/// Each value may be undefined. \see IkarusProperty
|
/// Each value may be undefined. \see IkarusProperty
|
||||||
/// Values are stored as lists. If a property is "singular" then its value is a list of size 1.
|
/// Values are stored as lists. If a property is "singular" then its value is a list of size 1.
|
||||||
/// Values are typed, with types existing for each of the corresponding property types.
|
/// Values are typed, with types existing for each of the corresponding property types.
|
||||||
/// When setting values for a property the type must match the property type and the value must be valid under the property's
|
/// When setting values for a property the type must match the property type and the value must be valid under the
|
||||||
/// settings. \see PropertyType
|
/// property's settings. \see PropertyType
|
||||||
/// @{
|
/// @{
|
||||||
|
|
||||||
IKARUS_BEGIN_HEADER
|
IKARUS_BEGIN_HEADER
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,9 @@ void ikarus_blueprint_delete(IkarusBlueprint * blueprint) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ikarus_blueprint_get_properties(
|
void ikarus_blueprint_get_properties(
|
||||||
IkarusBlueprint const * blueprint, struct IkarusProperty ** properties_out, size_t properties_out_size
|
IkarusBlueprint const * blueprint,
|
||||||
|
struct IkarusProperty ** properties_out,
|
||||||
|
size_t properties_out_size
|
||||||
) {
|
) {
|
||||||
ikarus::util::fetch_multiple_buffered<IkarusId>(
|
ikarus::util::fetch_multiple_buffered<IkarusId>(
|
||||||
blueprint,
|
blueprint,
|
||||||
|
|
@ -43,18 +45,15 @@ void ikarus_blueprint_get_properties(
|
||||||
},
|
},
|
||||||
properties_out,
|
properties_out,
|
||||||
properties_out_size,
|
properties_out_size,
|
||||||
[&](IkarusProject * project, IkarusFunctionContext * ctx, IkarusId id
|
[&](IkarusProject * project, IkarusFunctionContext * ctx, IkarusId id) -> cppbase::Result<IkarusProperty *, sqlitecpp::QueryError> {
|
||||||
) -> cppbase::Result<IkarusProperty *, sqlitecpp::QueryError> {
|
VTRY(auto const type, IkarusProperty::get_property_type(blueprint->project, id).on_error([ctx, id](auto const & err) {
|
||||||
VTRY(
|
ctx->set_error(
|
||||||
auto const type, IkarusProperty::get_property_type(blueprint->project, id).on_error([ctx, id](auto const& err) {
|
fmt::format("failed to fetch property {}'s type: {}", id, err),
|
||||||
ctx->set_error(
|
true,
|
||||||
fmt::format("failed to fetch property {}'s type: {}", id, err),
|
IkarusErrorInfo_Source_SubSystem,
|
||||||
true,
|
IkarusErrorInfo_Type_SubSystem_Database
|
||||||
IkarusErrorInfo_Source_SubSystem,
|
);
|
||||||
IkarusErrorInfo_Type_SubSystem_Database
|
}));
|
||||||
);
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
return cppbase::ok(project->get_property(id, type));
|
return cppbase::ok(project->get_property(id, type));
|
||||||
}
|
}
|
||||||
|
|
@ -75,7 +74,9 @@ size_t ikarus_blueprint_get_property_count(IkarusBlueprint const * blueprint) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ikarus_blueprint_get_linked_entities(
|
void ikarus_blueprint_get_linked_entities(
|
||||||
IkarusBlueprint const * blueprint, struct IkarusEntity ** entities_out, size_t entities_out_size
|
IkarusBlueprint const * blueprint,
|
||||||
|
struct IkarusEntity ** entities_out,
|
||||||
|
size_t entities_out_size
|
||||||
) {
|
) {
|
||||||
ikarus::util::fetch_multiple_buffered<IkarusId>(
|
ikarus::util::fetch_multiple_buffered<IkarusId>(
|
||||||
blueprint,
|
blueprint,
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,11 @@
|
||||||
struct IkarusBlueprint : IkarusObject {
|
struct IkarusBlueprint : IkarusObject {
|
||||||
IkarusBlueprint(struct IkarusProject * project, IkarusId id);
|
IkarusBlueprint(struct IkarusProject * project, IkarusId id);
|
||||||
|
|
||||||
IkarusBlueprint(IkarusBlueprint const&) = default;
|
IkarusBlueprint(IkarusBlueprint const &) = default;
|
||||||
IkarusBlueprint(IkarusBlueprint&&) = default;
|
IkarusBlueprint(IkarusBlueprint &&) = default;
|
||||||
|
|
||||||
IkarusBlueprint& operator=(IkarusBlueprint const&) = default;
|
IkarusBlueprint & operator=(IkarusBlueprint const &) = default;
|
||||||
IkarusBlueprint& operator=(IkarusBlueprint&&) = default;
|
IkarusBlueprint & operator=(IkarusBlueprint &&) = default;
|
||||||
|
|
||||||
~IkarusBlueprint() override = default;
|
~IkarusBlueprint() override = default;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,11 @@ struct IkarusEntity : IkarusObject {
|
||||||
inline IkarusEntity(struct IkarusProject * project, IkarusId id):
|
inline IkarusEntity(struct IkarusProject * project, IkarusId id):
|
||||||
IkarusObject{project, id} {}
|
IkarusObject{project, id} {}
|
||||||
|
|
||||||
IkarusEntity(IkarusEntity const&) = default;
|
IkarusEntity(IkarusEntity const &) = default;
|
||||||
IkarusEntity(IkarusEntity&&) = default;
|
IkarusEntity(IkarusEntity &&) = default;
|
||||||
|
|
||||||
IkarusEntity& operator=(IkarusEntity const&) = default;
|
IkarusEntity & operator=(IkarusEntity const &) = default;
|
||||||
IkarusEntity& operator=(IkarusEntity&&) = default;
|
IkarusEntity & operator=(IkarusEntity &&) = default;
|
||||||
|
|
||||||
~IkarusEntity() override = default;
|
~IkarusEntity() override = default;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,11 @@ struct IkarusObject {
|
||||||
public:
|
public:
|
||||||
IkarusObject(struct IkarusProject * project, IkarusId id);
|
IkarusObject(struct IkarusProject * project, IkarusId id);
|
||||||
|
|
||||||
IkarusObject(IkarusObject const&) = default;
|
IkarusObject(IkarusObject const &) = default;
|
||||||
IkarusObject(IkarusObject&&) = default;
|
IkarusObject(IkarusObject &&) = default;
|
||||||
|
|
||||||
IkarusObject& operator=(IkarusObject const&) = default;
|
IkarusObject & operator=(IkarusObject const &) = default;
|
||||||
IkarusObject& operator=(IkarusObject&&) = default;
|
IkarusObject & operator=(IkarusObject &&) = default;
|
||||||
|
|
||||||
virtual ~IkarusObject() = default;
|
virtual ~IkarusObject() = default;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,17 +14,15 @@ IkarusProperty::IkarusProperty(IkarusProject * project, IkarusId id, Data data):
|
||||||
IkarusObject{project, id},
|
IkarusObject{project, id},
|
||||||
_data{data} {}
|
_data{data} {}
|
||||||
|
|
||||||
IkarusProperty::Data& IkarusProperty::get_data() {
|
IkarusProperty::Data & IkarusProperty::get_data() {
|
||||||
return _data;
|
return _data;
|
||||||
}
|
}
|
||||||
|
|
||||||
IkarusProperty::Data const& IkarusProperty::get_data() const {
|
IkarusProperty::Data const & IkarusProperty::get_data() const {
|
||||||
return _data;
|
return _data;
|
||||||
}
|
}
|
||||||
|
|
||||||
cppbase::Result<IkarusPropertyType, sqlitecpp::SingleQueryError> IkarusProperty::get_property_type(
|
cppbase::Result<IkarusPropertyType, sqlitecpp::SingleQueryError> IkarusProperty::get_property_type(IkarusProject * project, IkarusId id) {
|
||||||
IkarusProject * project, IkarusId id
|
|
||||||
) {
|
|
||||||
LOG_DEBUG("fetching unboxed property type");
|
LOG_DEBUG("fetching unboxed property type");
|
||||||
|
|
||||||
LOG_VERBOSE("project={};property={}", project->get_path().c_str(), id);
|
LOG_VERBOSE("project={};property={}", project->get_path().c_str(), id);
|
||||||
|
|
@ -33,16 +31,14 @@ cppbase::Result<IkarusPropertyType, sqlitecpp::SingleQueryError> IkarusProperty:
|
||||||
|
|
||||||
VTRY(
|
VTRY(
|
||||||
auto const type,
|
auto const type,
|
||||||
project->get_db()
|
project->get_db()->query_one<int>("SELECT `type` FROM `properties` WHERE `id` = ?", id).on_error([ctx](auto const & err) {
|
||||||
->query_one<int>("SELECT `type` FROM `properties` WHERE `id` = ?", id)
|
ctx->set_error(
|
||||||
.on_error([ctx](auto const& err) {
|
fmt::format("failed to fetch unboxed property type: {}", err),
|
||||||
ctx->set_error(
|
true,
|
||||||
fmt::format("failed to fetch unboxed property type: {}", err),
|
IkarusErrorInfo_Source_SubSystem,
|
||||||
true,
|
IkarusErrorInfo_Type_SubSystem_Database
|
||||||
IkarusErrorInfo_Source_SubSystem,
|
);
|
||||||
IkarusErrorInfo_Type_SubSystem_Database
|
})
|
||||||
);
|
|
||||||
})
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return cppbase::ok(static_cast<IkarusPropertyType>(type));
|
return cppbase::ok(static_cast<IkarusPropertyType>(type));
|
||||||
|
|
@ -55,20 +51,14 @@ IKA_API void ikarus_property_delete(IkarusProperty * property) {
|
||||||
|
|
||||||
auto * ctx = property->project->get_function_context();
|
auto * ctx = property->project->get_function_context();
|
||||||
|
|
||||||
TRYRV(
|
TRYRV(, property->project->get_db()->execute("DELETE FROM `objects` WHERE `id` = ?", property->id).on_error([ctx](auto const & err) {
|
||||||
,
|
ctx->set_error(
|
||||||
property->project
|
fmt::format("failed to delete property from objects table: {}", err),
|
||||||
->get_db()
|
true,
|
||||||
->execute("DELETE FROM `objects` WHERE `id` = ?", property->id)
|
IkarusErrorInfo_Source_SubSystem,
|
||||||
.on_error([ctx](auto const& err) {
|
IkarusErrorInfo_Type_SubSystem_Database
|
||||||
ctx->set_error(
|
);
|
||||||
fmt::format("failed to delete property from objects table: {}", err),
|
}));
|
||||||
true,
|
|
||||||
IkarusErrorInfo_Source_SubSystem,
|
|
||||||
IkarusErrorInfo_Type_SubSystem_Database
|
|
||||||
);
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
LOG_VERBOSE("property was successfully deleted from database, freeing");
|
LOG_VERBOSE("property was successfully deleted from database, freeing");
|
||||||
|
|
||||||
|
|
@ -80,8 +70,7 @@ IKA_API void ikarus_property_delete(IkarusProperty * property) {
|
||||||
IkarusPropertyType ikarus_property_get_type(IkarusProperty const * property) {
|
IkarusPropertyType ikarus_property_get_type(IkarusProperty const * property) {
|
||||||
LOG_VERBOSE("fetching property type");
|
LOG_VERBOSE("fetching property type");
|
||||||
|
|
||||||
return IkarusProperty::get_property_type(property->project, property->id)
|
return IkarusProperty::get_property_type(property->project, property->id).unwrap_value_or(IkarusPropertyType_Toggle);
|
||||||
.unwrap_value_or(IkarusPropertyType_Toggle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IkarusPropertySource const * ikarus_property_get_source(IkarusProperty const * property) {
|
IkarusPropertySource const * ikarus_property_get_source(IkarusProperty const * property) {
|
||||||
|
|
@ -94,10 +83,9 @@ IkarusPropertySource const * ikarus_property_get_source(IkarusProperty const * p
|
||||||
VTRYRV(
|
VTRYRV(
|
||||||
auto const source,
|
auto const source,
|
||||||
nullptr,
|
nullptr,
|
||||||
property->project
|
property->project->get_db()
|
||||||
->get_db()
|
|
||||||
->query_one<int>("SELECT `source` FROM `properties` WHERE `id` = ?", property->id)
|
->query_one<int>("SELECT `source` FROM `properties` WHERE `id` = ?", property->id)
|
||||||
.on_error([ctx](auto const& err) {
|
.on_error([ctx](auto const & err) {
|
||||||
ctx->set_error(
|
ctx->set_error(
|
||||||
fmt::format("failed to fetch property's source: {}", err),
|
fmt::format("failed to fetch property's source: {}", err),
|
||||||
true,
|
true,
|
||||||
|
|
@ -133,10 +121,9 @@ IkarusValue * ikarus_property_get_default_value(IkarusProperty const * property)
|
||||||
VTRYRV(
|
VTRYRV(
|
||||||
auto const value,
|
auto const value,
|
||||||
nullptr,
|
nullptr,
|
||||||
property->project
|
property->project->get_db()
|
||||||
->get_db()
|
|
||||||
->query_one<int>("SELECT `default_value` FROM `properties` WHERE `id` = ?", property->id)
|
->query_one<int>("SELECT `default_value` FROM `properties` WHERE `id` = ?", property->id)
|
||||||
.on_error([ctx](auto const& err) {
|
.on_error([ctx](auto const & err) {
|
||||||
ctx->set_error(
|
ctx->set_error(
|
||||||
fmt::format("failed to fetch property's default value: {}", err),
|
fmt::format("failed to fetch property's default value: {}", err),
|
||||||
true,
|
true,
|
||||||
|
|
|
||||||
|
|
@ -16,24 +16,23 @@ public:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// \brief Helper to fetch a type for a property that isn't yet wrapped in an object
|
/// \brief Helper to fetch a type for a property that isn't yet wrapped in an object
|
||||||
[[nodiscard]] static cppbase::Result<IkarusPropertyType, sqlitecpp::SingleQueryError> get_property_type(
|
[[nodiscard]] static cppbase::Result<IkarusPropertyType, sqlitecpp::SingleQueryError>
|
||||||
struct IkarusProject * project, IkarusId id
|
get_property_type(struct IkarusProject * project, IkarusId id);
|
||||||
);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IkarusProperty(struct IkarusProject * project, IkarusId id, Data data);
|
IkarusProperty(struct IkarusProject * project, IkarusId id, Data data);
|
||||||
|
|
||||||
IkarusProperty(IkarusProperty const&) = default;
|
IkarusProperty(IkarusProperty const &) = default;
|
||||||
IkarusProperty(IkarusProperty&&) = default;
|
IkarusProperty(IkarusProperty &&) = default;
|
||||||
|
|
||||||
IkarusProperty& operator=(IkarusProperty const&) = default;
|
IkarusProperty & operator=(IkarusProperty const &) = default;
|
||||||
IkarusProperty& operator=(IkarusProperty&&) = default;
|
IkarusProperty & operator=(IkarusProperty &&) = default;
|
||||||
|
|
||||||
~IkarusProperty() override = default;
|
~IkarusProperty() override = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
[[nodiscard]] Data& get_data();
|
[[nodiscard]] Data & get_data();
|
||||||
[[nodiscard]] Data const& get_data() const;
|
[[nodiscard]] Data const & get_data() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Data _data;
|
Data _data;
|
||||||
|
|
|
||||||
|
|
@ -11,11 +11,11 @@ public:
|
||||||
public:
|
public:
|
||||||
explicit IkarusPropertySource(Data data);
|
explicit IkarusPropertySource(Data data);
|
||||||
|
|
||||||
IkarusPropertySource(IkarusPropertySource const&) = default;
|
IkarusPropertySource(IkarusPropertySource const &) = default;
|
||||||
IkarusPropertySource(IkarusPropertySource&&) = default;
|
IkarusPropertySource(IkarusPropertySource &&) = default;
|
||||||
|
|
||||||
IkarusPropertySource& operator=(IkarusPropertySource const&) = default;
|
IkarusPropertySource & operator=(IkarusPropertySource const &) = default;
|
||||||
IkarusPropertySource& operator=(IkarusPropertySource&&) = default;
|
IkarusPropertySource & operator=(IkarusPropertySource &&) = default;
|
||||||
|
|
||||||
virtual ~IkarusPropertySource() = default;
|
virtual ~IkarusPropertySource() = default;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,5 @@
|
||||||
IkarusToggleProperty::IkarusToggleProperty(IkarusProject * project, IkarusId id):
|
IkarusToggleProperty::IkarusToggleProperty(IkarusProject * project, IkarusId id):
|
||||||
IkarusProperty{project, id, this} {}
|
IkarusProperty{project, id, this} {}
|
||||||
|
|
||||||
IkarusToggleProperty * ikarus_toggle_property_create(
|
IkarusToggleProperty *
|
||||||
struct IkarusProject * project, char const * name, struct IkarusPropertySource * property_source
|
ikarus_toggle_property_create(struct IkarusProject * project, char const * name, struct IkarusPropertySource * property_source) {}
|
||||||
) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ template<typename InsertFunction, typename ObjectFactory>
|
||||||
|
|
||||||
return cppbase::ok(id);
|
return cppbase::ok(id);
|
||||||
})
|
})
|
||||||
.on_error([&](auto const& err) {
|
.on_error([&](auto const & err) {
|
||||||
ctx->set_error(
|
ctx->set_error(
|
||||||
fmt::format("unable to insert {} into database: {}", object_type_str, err),
|
fmt::format("unable to insert {} into database: {}", object_type_str, err),
|
||||||
true,
|
true,
|
||||||
|
|
@ -81,7 +81,7 @@ void delete_object(IkarusProject * project, Object * object) {
|
||||||
|
|
||||||
auto * ctx = object->project->get_function_context();
|
auto * ctx = object->project->get_function_context();
|
||||||
|
|
||||||
TRYRV(, project->get_db()->execute("DELETE FROM `objects` WHERE `id` = ?", object->id).on_error([&](auto const& err) {
|
TRYRV(, project->get_db()->execute("DELETE FROM `objects` WHERE `id` = ?", object->id).on_error([&](auto const & err) {
|
||||||
ctx->set_error(
|
ctx->set_error(
|
||||||
fmt::format("failed to delete {} from objects table: {}", object_type_str, err),
|
fmt::format("failed to delete {} from objects table: {}", object_type_str, err),
|
||||||
true,
|
true,
|
||||||
|
|
@ -104,7 +104,7 @@ struct SingleQueryData {
|
||||||
|
|
||||||
template<typename T, typename Object>
|
template<typename T, typename Object>
|
||||||
requires std::derived_from<Object, IkarusObject>
|
requires std::derived_from<Object, IkarusObject>
|
||||||
cppbase::Result<T, sqlitecpp::SingleQueryError> fetch_single_field(Object const * object, SingleQueryData const& query_data) {
|
cppbase::Result<T, sqlitecpp::SingleQueryError> fetch_single_field(Object const * object, SingleQueryData const & query_data) {
|
||||||
auto object_type_str = ikarus_object_type_to_string(ikarus_id_get_object_type(object->id));
|
auto object_type_str = ikarus_object_type_to_string(ikarus_id_get_object_type(object->id));
|
||||||
|
|
||||||
LOG_VERBOSE("fetching property default value");
|
LOG_VERBOSE("fetching property default value");
|
||||||
|
|
@ -120,7 +120,7 @@ cppbase::Result<T, sqlitecpp::SingleQueryError> fetch_single_field(Object const
|
||||||
fmt::format("SELECT `{}` FROM `{}` WHERE `id` = ?", query_data.select_field_name, query_data.table_name),
|
fmt::format("SELECT `{}` FROM `{}` WHERE `id` = ?", query_data.select_field_name, query_data.table_name),
|
||||||
object->id
|
object->id
|
||||||
)
|
)
|
||||||
.on_error([&](auto const& err) {
|
.on_error([&](auto const & err) {
|
||||||
ctx->set_error(
|
ctx->set_error(
|
||||||
fmt::format("failed to fetch {} {} from database: {}", object_type_str, query_data.select_field_name, err),
|
fmt::format("failed to fetch {} {} from database: {}", object_type_str, query_data.select_field_name, err),
|
||||||
true,
|
true,
|
||||||
|
|
@ -143,10 +143,13 @@ struct MultipleBufferQueryData {
|
||||||
template<typename Selected, typename Mapped, typename Object, typename F>
|
template<typename Selected, typename Mapped, typename Object, typename F>
|
||||||
requires std::derived_from<Object, IkarusObject>
|
requires std::derived_from<Object, IkarusObject>
|
||||||
void fetch_multiple_buffered(
|
void fetch_multiple_buffered(
|
||||||
Object const * object, MultipleBufferQueryData const& query_data, Mapped * mapped_buffer, size_t buffer_size, F transformer
|
Object const * object,
|
||||||
|
MultipleBufferQueryData const & query_data,
|
||||||
|
Mapped * mapped_buffer,
|
||||||
|
size_t buffer_size,
|
||||||
|
F transformer
|
||||||
)
|
)
|
||||||
requires cppbase::
|
requires cppbase::is_result_with_value_type_v<Mapped, std::invoke_result_t<F, IkarusProject *, IkarusFunctionContext *, Selected>>
|
||||||
is_result_with_value_type_v<Mapped, std::invoke_result_t<F, IkarusProject *, IkarusFunctionContext *, Selected>>
|
|
||||||
{
|
{
|
||||||
auto * ctx = object->project->get_function_context();
|
auto * ctx = object->project->get_function_context();
|
||||||
|
|
||||||
|
|
@ -172,7 +175,7 @@ void fetch_multiple_buffered(
|
||||||
buffer_size,
|
buffer_size,
|
||||||
object->id
|
object->id
|
||||||
)
|
)
|
||||||
.on_error([&](auto const& err) {
|
.on_error([&](auto const & err) {
|
||||||
ctx->set_error(
|
ctx->set_error(
|
||||||
fmt::format("failed to fetch {} {} from database: {}", object_type_str, query_data.relation_desc, err),
|
fmt::format("failed to fetch {} {} from database: {}", object_type_str, query_data.relation_desc, err),
|
||||||
true,
|
true,
|
||||||
|
|
@ -182,9 +185,7 @@ void fetch_multiple_buffered(
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
LOG_DEBUG(
|
LOG_DEBUG("{} {}: [{}]", object_type_str, query_data.relation_desc, fmt::join(select_buffer, select_buffer + buffer_size, ", "));
|
||||||
"{} {}: [{}]", object_type_str, query_data.relation_desc, fmt::join(select_buffer, select_buffer + buffer_size, ", ")
|
|
||||||
);
|
|
||||||
|
|
||||||
for (size_t i = 0; i < buffer_size; ++i) {
|
for (size_t i = 0; i < buffer_size; ++i) {
|
||||||
VTRYRV(mapped_buffer[i], , transformer(object->project, ctx, select_buffer[i]));
|
VTRYRV(mapped_buffer[i], , transformer(object->project, ctx, select_buffer[i]));
|
||||||
|
|
@ -200,7 +201,7 @@ struct CountQueryData {
|
||||||
|
|
||||||
template<typename Object>
|
template<typename Object>
|
||||||
requires std::derived_from<Object, IkarusObject>
|
requires std::derived_from<Object, IkarusObject>
|
||||||
cppbase::Result<cppbase::usize, sqlitecpp::QueryError> fetch_count(Object const * object, CountQueryData const& query_data) {
|
cppbase::Result<cppbase::usize, sqlitecpp::QueryError> fetch_count(Object const * object, CountQueryData const & query_data) {
|
||||||
auto * object_type_str = ikarus_object_type_to_string(ikarus_id_get_object_type(object->id));
|
auto * object_type_str = ikarus_object_type_to_string(ikarus_id_get_object_type(object->id));
|
||||||
|
|
||||||
LOG_VERBOSE("fetching {} {} count", object_type_str, query_data.relation_desc);
|
LOG_VERBOSE("fetching {} {} count", object_type_str, query_data.relation_desc);
|
||||||
|
|
@ -221,7 +222,7 @@ cppbase::Result<cppbase::usize, sqlitecpp::QueryError> fetch_count(Object const
|
||||||
),
|
),
|
||||||
object->id
|
object->id
|
||||||
)
|
)
|
||||||
.on_error([&](auto const& err) {
|
.on_error([&](auto const & err) {
|
||||||
ctx->set_error(
|
ctx->set_error(
|
||||||
fmt::format("failed to fetch {} {} count: {}", object_type_str, query_data.relation_desc, err),
|
fmt::format("failed to fetch {} {} count: {}", object_type_str, query_data.relation_desc, err),
|
||||||
true,
|
true,
|
||||||
|
|
@ -238,4 +239,4 @@ cppbase::Result<cppbase::usize, sqlitecpp::QueryError> fetch_count(Object const
|
||||||
return cppbase::ok(static_cast<size_t>(count));
|
return cppbase::ok(static_cast<size_t>(count));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace ikarus::util
|
||||||
|
|
|
||||||
|
|
@ -16,11 +16,11 @@ struct IkarusFunctionContext {
|
||||||
public:
|
public:
|
||||||
explicit IkarusFunctionContext(struct IkarusProject * project);
|
explicit IkarusFunctionContext(struct IkarusProject * project);
|
||||||
|
|
||||||
IkarusFunctionContext(IkarusFunctionContext const&) noexcept = default;
|
IkarusFunctionContext(IkarusFunctionContext const &) noexcept = default;
|
||||||
IkarusFunctionContext(IkarusFunctionContext&&) noexcept = default;
|
IkarusFunctionContext(IkarusFunctionContext &&) noexcept = default;
|
||||||
|
|
||||||
auto operator=(IkarusFunctionContext const&) noexcept -> IkarusFunctionContext& = default;
|
auto operator=(IkarusFunctionContext const &) noexcept -> IkarusFunctionContext & = default;
|
||||||
auto operator=(IkarusFunctionContext&&) noexcept -> IkarusFunctionContext& = default;
|
auto operator=(IkarusFunctionContext &&) noexcept -> IkarusFunctionContext & = default;
|
||||||
|
|
||||||
~IkarusFunctionContext();
|
~IkarusFunctionContext();
|
||||||
|
|
||||||
|
|
@ -40,11 +40,7 @@ public:
|
||||||
_project->error_infos = {infos...};
|
_project->error_infos = {infos...};
|
||||||
|
|
||||||
if (log_error) {
|
if (log_error) {
|
||||||
LOG_ERROR(
|
LOG_ERROR("Error({}): {}", fmt::join(_project->error_infos | std::views::transform(get_error_info_name), ", "), error_message);
|
||||||
"Error({}): {}",
|
|
||||||
fmt::join(_project->error_infos | std::views::transform(get_error_info_name), ", "),
|
|
||||||
error_message
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ auto IkarusProject::get_name() const -> std::string_view {
|
||||||
return _name;
|
return _name;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto IkarusProject::get_path() const -> std::filesystem::path const& {
|
auto IkarusProject::get_path() const -> std::filesystem::path const & {
|
||||||
return _path;
|
return _path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -55,8 +55,7 @@ auto IkarusProject::get_property(IkarusId id, IkarusPropertyType type) -> Ikarus
|
||||||
return _properties.emplace(id, std::make_unique<IkarusToggleProperty>(this, id)).first->second.get();
|
return _properties.emplace(id, std::make_unique<IkarusToggleProperty>(this, id)).first->second.get();
|
||||||
case IkarusPropertyType_Number:
|
case IkarusPropertyType_Number:
|
||||||
return _properties.emplace(id, std::make_unique<IkarusNumberProperty>(this, id)).first->second.get();
|
return _properties.emplace(id, std::make_unique<IkarusNumberProperty>(this, id)).first->second.get();
|
||||||
case IkarusPropertyType_Text:
|
case IkarusPropertyType_Text: return _properties.emplace(id, std::make_unique<IkarusTextProperty>(this, id)).first->second.get();
|
||||||
return _properties.emplace(id, std::make_unique<IkarusTextProperty>(this, id)).first->second.get();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ struct IkarusProject {
|
||||||
public:
|
public:
|
||||||
[[nodiscard]] auto get_name() const -> std::string_view;
|
[[nodiscard]] auto get_name() const -> std::string_view;
|
||||||
|
|
||||||
[[nodiscard]] auto get_path() const -> std::filesystem::path const&;
|
[[nodiscard]] auto get_path() const -> std::filesystem::path const &;
|
||||||
|
|
||||||
[[nodiscard]] auto get_db() -> sqlitecpp::Connection *;
|
[[nodiscard]] auto get_db() -> sqlitecpp::Connection *;
|
||||||
[[nodiscard]] auto get_db() const -> sqlitecpp::Connection const *;
|
[[nodiscard]] auto get_db() const -> sqlitecpp::Connection const *;
|
||||||
|
|
@ -38,7 +38,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template<typename T>
|
template<typename T>
|
||||||
[[nodiscard]] T * get_cached_object(IkarusId id, auto& cache) {
|
[[nodiscard]] T * get_cached_object(IkarusId id, auto & cache) {
|
||||||
auto const iter = cache.find(id);
|
auto const iter = cache.find(id);
|
||||||
|
|
||||||
if (iter == cache.cend()) {
|
if (iter == cache.cend()) {
|
||||||
|
|
@ -49,7 +49,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void remove_cached_object(T * object, std::unordered_map<IkarusId, std::unique_ptr<T>>& cache) {
|
void remove_cached_object(T * object, std::unordered_map<IkarusId, std::unique_ptr<T>> & cache) {
|
||||||
cache.erase(object->id);
|
cache.erase(object->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ void ikarus_number_value_set_undefined(IkarusNumberValue * value, bool undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
char const * ikarus_number_value_to_string(IkarusNumberValue const * value) {
|
char const * ikarus_number_value_to_string(IkarusNumberValue const * value) {
|
||||||
return ikarus_value_base_to_string(value, [](auto const& value) { return value; });
|
return ikarus_value_base_to_string(value, [](auto const & value) { return value; });
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ikarus_number_value_is_equal(IkarusNumberValue const * lhs, IkarusNumberValue const * rhs) {
|
bool ikarus_number_value_is_equal(IkarusNumberValue const * lhs, IkarusNumberValue const * rhs) {
|
||||||
|
|
|
||||||
|
|
@ -12,15 +12,14 @@ public:
|
||||||
public:
|
public:
|
||||||
explicit IkarusNumberValue();
|
explicit IkarusNumberValue();
|
||||||
|
|
||||||
IkarusNumberValue(IkarusNumberValue const&) = default;
|
IkarusNumberValue(IkarusNumberValue const &) = default;
|
||||||
IkarusNumberValue(IkarusNumberValue&&) = default;
|
IkarusNumberValue(IkarusNumberValue &&) = default;
|
||||||
|
|
||||||
IkarusNumberValue& operator=(IkarusNumberValue const&) = default;
|
IkarusNumberValue & operator=(IkarusNumberValue const &) = default;
|
||||||
IkarusNumberValue& operator=(IkarusNumberValue&&) = default;
|
IkarusNumberValue & operator=(IkarusNumberValue &&) = default;
|
||||||
|
|
||||||
~IkarusNumberValue() override = default;
|
~IkarusNumberValue() override = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
boost::variant2::variant<boost::variant2::monostate, boost::container::small_vector<DataType, SMALL_VEC_VALUE_SIZE>> data{
|
boost::variant2::variant<boost::variant2::monostate, boost::container::small_vector<DataType, SMALL_VEC_VALUE_SIZE>> data{};
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ void ikarus_text_value_set_undefined(IkarusTextValue * value, bool undefined) {
|
||||||
}
|
}
|
||||||
|
|
||||||
char const * ikarus_text_value_to_string(IkarusTextValue const * value) {
|
char const * ikarus_text_value_to_string(IkarusTextValue const * value) {
|
||||||
return ikarus_value_base_to_string(value, [](auto const& value) { return value; });
|
return ikarus_value_base_to_string(value, [](auto const & value) { return value; });
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ikarus_text_value_is_equal(IkarusTextValue const * lhs, IkarusTextValue const * rhs) {
|
bool ikarus_text_value_is_equal(IkarusTextValue const * lhs, IkarusTextValue const * rhs) {
|
||||||
|
|
|
||||||
|
|
@ -11,15 +11,14 @@ public:
|
||||||
public:
|
public:
|
||||||
explicit IkarusTextValue();
|
explicit IkarusTextValue();
|
||||||
|
|
||||||
IkarusTextValue(IkarusTextValue const&) = default;
|
IkarusTextValue(IkarusTextValue const &) = default;
|
||||||
IkarusTextValue(IkarusTextValue&&) = default;
|
IkarusTextValue(IkarusTextValue &&) = default;
|
||||||
|
|
||||||
IkarusTextValue& operator=(IkarusTextValue const&) = default;
|
IkarusTextValue & operator=(IkarusTextValue const &) = default;
|
||||||
IkarusTextValue& operator=(IkarusTextValue&&) = default;
|
IkarusTextValue & operator=(IkarusTextValue &&) = default;
|
||||||
|
|
||||||
~IkarusTextValue() override = default;
|
~IkarusTextValue() override = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
boost::variant2::variant<boost::variant2::monostate, boost::container::small_vector<DataType, SMALL_VEC_VALUE_SIZE>> data{
|
boost::variant2::variant<boost::variant2::monostate, boost::container::small_vector<DataType, SMALL_VEC_VALUE_SIZE>> data{};
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ void ikarus_toggle_value_set_undefined(IkarusToggleValue * value, bool undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
char const * ikarus_toggle_value_to_string(IkarusToggleValue const * value) {
|
char const * ikarus_toggle_value_to_string(IkarusToggleValue const * value) {
|
||||||
return ikarus_value_base_to_string(value, [](auto const& value) { return value ? "✓" : "✗"; });
|
return ikarus_value_base_to_string(value, [](auto const & value) { return value ? "✓" : "✗"; });
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ikarus_toggle_value_is_equal(IkarusToggleValue const * lhs, IkarusToggleValue const * rhs) {
|
bool ikarus_toggle_value_is_equal(IkarusToggleValue const * lhs, IkarusToggleValue const * rhs) {
|
||||||
|
|
|
||||||
|
|
@ -11,15 +11,14 @@ public:
|
||||||
public:
|
public:
|
||||||
explicit IkarusToggleValue();
|
explicit IkarusToggleValue();
|
||||||
|
|
||||||
IkarusToggleValue(IkarusToggleValue const&) = default;
|
IkarusToggleValue(IkarusToggleValue const &) = default;
|
||||||
IkarusToggleValue(IkarusToggleValue&&) = default;
|
IkarusToggleValue(IkarusToggleValue &&) = default;
|
||||||
|
|
||||||
IkarusToggleValue& operator=(IkarusToggleValue const&) = default;
|
IkarusToggleValue & operator=(IkarusToggleValue const &) = default;
|
||||||
IkarusToggleValue& operator=(IkarusToggleValue&&) = default;
|
IkarusToggleValue & operator=(IkarusToggleValue &&) = default;
|
||||||
|
|
||||||
~IkarusToggleValue() override = default;
|
~IkarusToggleValue() override = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
boost::variant2::variant<boost::variant2::monostate, boost::container::small_vector<DataType, SMALL_VEC_VALUE_SIZE>> data{
|
boost::variant2::variant<boost::variant2::monostate, boost::container::small_vector<DataType, SMALL_VEC_VALUE_SIZE>> data{};
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
IkarusValue::IkarusValue(Data data):
|
IkarusValue::IkarusValue(Data data):
|
||||||
data(data) {}
|
data(data) {}
|
||||||
|
|
||||||
cppbase::Result<IkarusValue *, IkarusValue::FromJsonError> IkarusValue::from_json(boost::json::value const& json) {
|
cppbase::Result<IkarusValue *, IkarusValue::FromJsonError> IkarusValue::from_json(boost::json::value const & json) {
|
||||||
if (auto const * obj = json.if_object(); obj == nullptr) {
|
if (auto const * obj = json.if_object(); obj == nullptr) {
|
||||||
return cppbase::err(FromJsonError{});
|
return cppbase::err(FromJsonError{});
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -43,8 +43,9 @@ cppbase::Result<IkarusValue *, IkarusValue::FromJsonError> IkarusValue::from_jso
|
||||||
ret = new T{};
|
ret = new T{};
|
||||||
ret->data = boost::variant2::monostate{};
|
ret->data = boost::variant2::monostate{};
|
||||||
} else {
|
} else {
|
||||||
auto res = boost::json::try_value_to<
|
auto res =
|
||||||
boost::container::small_vector<typename T::DataType, IkarusValue::SMALL_VEC_VALUE_SIZE>>(*data);
|
boost::json::try_value_to<boost::container::small_vector<typename T::DataType, IkarusValue::SMALL_VEC_VALUE_SIZE>>(*data
|
||||||
|
);
|
||||||
|
|
||||||
if (res.has_error()) {
|
if (res.has_error()) {
|
||||||
return cppbase::err(FromJsonError{});
|
return cppbase::err(FromJsonError{});
|
||||||
|
|
@ -88,8 +89,8 @@ boost::json::value IkarusValue::to_json() const {
|
||||||
[]<typename T>(T const * value) -> boost::json::value {
|
[]<typename T>(T const * value) -> boost::json::value {
|
||||||
return boost::variant2::visit(
|
return boost::variant2::visit(
|
||||||
cppbase::overloaded{
|
cppbase::overloaded{
|
||||||
[]([[maybe_unused]] boost::variant2::monostate const& data) -> boost::json::value { return nullptr; },
|
[]([[maybe_unused]] boost::variant2::monostate const & data) -> boost::json::value { return nullptr; },
|
||||||
[](auto const& data) -> boost::json::value { return boost::json::value_from(data); }
|
[](auto const & data) -> boost::json::value { return boost::json::value_from(data); }
|
||||||
},
|
},
|
||||||
value->data
|
value->data
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -13,18 +13,18 @@ public:
|
||||||
public:
|
public:
|
||||||
explicit IkarusValue(Data data);
|
explicit IkarusValue(Data data);
|
||||||
|
|
||||||
IkarusValue(IkarusValue const&) = default;
|
IkarusValue(IkarusValue const &) = default;
|
||||||
IkarusValue(IkarusValue&&) noexcept = default;
|
IkarusValue(IkarusValue &&) noexcept = default;
|
||||||
|
|
||||||
IkarusValue& operator=(IkarusValue const&) = default;
|
IkarusValue & operator=(IkarusValue const &) = default;
|
||||||
IkarusValue& operator=(IkarusValue&&) noexcept = default;
|
IkarusValue & operator=(IkarusValue &&) noexcept = default;
|
||||||
|
|
||||||
virtual ~IkarusValue() = default;
|
virtual ~IkarusValue() = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
struct FromJsonError {};
|
struct FromJsonError {};
|
||||||
|
|
||||||
[[nodiscard]] static cppbase::Result<IkarusValue *, FromJsonError> from_json(boost::json::value const& json);
|
[[nodiscard]] static cppbase::Result<IkarusValue *, FromJsonError> from_json(boost::json::value const & json);
|
||||||
[[nodiscard]] boost::json::value to_json() const;
|
[[nodiscard]] boost::json::value to_json() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -2,16 +2,14 @@
|
||||||
|
|
||||||
#include <ranges>
|
#include <ranges>
|
||||||
|
|
||||||
#include <cppbase/templates.hpp>
|
|
||||||
|
|
||||||
#include <boost/container/small_vector.hpp>
|
#include <boost/container/small_vector.hpp>
|
||||||
|
|
||||||
|
#include <cppbase/templates.hpp>
|
||||||
|
|
||||||
template<typename V>
|
template<typename V>
|
||||||
typename V::DataType const * ikarus_value_base_get(V * value, size_t idx) {
|
typename V::DataType const * ikarus_value_base_get(V * value, size_t idx) {
|
||||||
if (auto * data =
|
if (auto * data =
|
||||||
boost::variant2::get_if<boost::container::small_vector<typename V::DataType, IkarusValue::SMALL_VEC_VALUE_SIZE>>(
|
boost::variant2::get_if<boost::container::small_vector<typename V::DataType, IkarusValue::SMALL_VEC_VALUE_SIZE>>(&value->data);
|
||||||
&value->data
|
|
||||||
);
|
|
||||||
data != nullptr) {
|
data != nullptr) {
|
||||||
return &(*data)[idx];
|
return &(*data)[idx];
|
||||||
}
|
}
|
||||||
|
|
@ -22,9 +20,7 @@ typename V::DataType const * ikarus_value_base_get(V * value, size_t idx) {
|
||||||
template<typename V>
|
template<typename V>
|
||||||
size_t ikarus_value_base_get_size(V const * value) {
|
size_t ikarus_value_base_get_size(V const * value) {
|
||||||
if (auto * data =
|
if (auto * data =
|
||||||
boost::variant2::get_if<boost::container::small_vector<typename V::DataType, IkarusValue::SMALL_VEC_VALUE_SIZE>>(
|
boost::variant2::get_if<boost::container::small_vector<typename V::DataType, IkarusValue::SMALL_VEC_VALUE_SIZE>>(&value->data);
|
||||||
&value->data
|
|
||||||
);
|
|
||||||
data != nullptr) {
|
data != nullptr) {
|
||||||
return data->size();
|
return data->size();
|
||||||
}
|
}
|
||||||
|
|
@ -35,9 +31,7 @@ size_t ikarus_value_base_get_size(V const * value) {
|
||||||
template<typename V>
|
template<typename V>
|
||||||
void ikarus_value_base_set(V * value, size_t idx, typename V::DataType new_data) {
|
void ikarus_value_base_set(V * value, size_t idx, typename V::DataType new_data) {
|
||||||
if (auto * data =
|
if (auto * data =
|
||||||
boost::variant2::get_if<boost::container::small_vector<typename V::DataType, IkarusValue::SMALL_VEC_VALUE_SIZE>>(
|
boost::variant2::get_if<boost::container::small_vector<typename V::DataType, IkarusValue::SMALL_VEC_VALUE_SIZE>>(&value->data);
|
||||||
&value->data
|
|
||||||
);
|
|
||||||
data != nullptr) {
|
data != nullptr) {
|
||||||
(*data)[idx] = new_data;
|
(*data)[idx] = new_data;
|
||||||
}
|
}
|
||||||
|
|
@ -46,9 +40,7 @@ void ikarus_value_base_set(V * value, size_t idx, typename V::DataType new_data)
|
||||||
template<typename V>
|
template<typename V>
|
||||||
void ikarus_value_base_remove(V * value, size_t idx) {
|
void ikarus_value_base_remove(V * value, size_t idx) {
|
||||||
if (auto * data =
|
if (auto * data =
|
||||||
boost::variant2::get_if<boost::container::small_vector<typename V::DataType, IkarusValue::SMALL_VEC_VALUE_SIZE>>(
|
boost::variant2::get_if<boost::container::small_vector<typename V::DataType, IkarusValue::SMALL_VEC_VALUE_SIZE>>(&value->data);
|
||||||
&value->data
|
|
||||||
);
|
|
||||||
data != nullptr) {
|
data != nullptr) {
|
||||||
data->erase(data->begin() + idx);
|
data->erase(data->begin() + idx);
|
||||||
}
|
}
|
||||||
|
|
@ -57,9 +49,7 @@ void ikarus_value_base_remove(V * value, size_t idx) {
|
||||||
template<typename V>
|
template<typename V>
|
||||||
void ikarus_value_base_insert(V * value, size_t idx, typename V::DataType new_data) {
|
void ikarus_value_base_insert(V * value, size_t idx, typename V::DataType new_data) {
|
||||||
if (auto * data =
|
if (auto * data =
|
||||||
boost::variant2::get_if<boost::container::small_vector<typename V::DataType, IkarusValue::SMALL_VEC_VALUE_SIZE>>(
|
boost::variant2::get_if<boost::container::small_vector<typename V::DataType, IkarusValue::SMALL_VEC_VALUE_SIZE>>(&value->data);
|
||||||
&value->data
|
|
||||||
);
|
|
||||||
data != nullptr) {
|
data != nullptr) {
|
||||||
data->insert(data->begin() + idx, new_data);
|
data->insert(data->begin() + idx, new_data);
|
||||||
}
|
}
|
||||||
|
|
@ -68,9 +58,7 @@ void ikarus_value_base_insert(V * value, size_t idx, typename V::DataType new_da
|
||||||
template<typename V>
|
template<typename V>
|
||||||
void ikarus_value_base_clear(V * value) {
|
void ikarus_value_base_clear(V * value) {
|
||||||
if (auto * data =
|
if (auto * data =
|
||||||
boost::variant2::get_if<boost::container::small_vector<typename V::DataType, IkarusValue::SMALL_VEC_VALUE_SIZE>>(
|
boost::variant2::get_if<boost::container::small_vector<typename V::DataType, IkarusValue::SMALL_VEC_VALUE_SIZE>>(&value->data);
|
||||||
&value->data
|
|
||||||
);
|
|
||||||
data != nullptr) {
|
data != nullptr) {
|
||||||
data->clear();
|
data->clear();
|
||||||
}
|
}
|
||||||
|
|
@ -93,10 +81,9 @@ void ikarus_value_base_set_undefined(V * value, bool undefined) {
|
||||||
template<typename V, std::invocable<typename V::DataType> F>
|
template<typename V, std::invocable<typename V::DataType> F>
|
||||||
char const * ikarus_value_base_to_string(V const * value, F transformer) {
|
char const * ikarus_value_base_to_string(V const * value, F transformer) {
|
||||||
return boost::variant2::visit(
|
return boost::variant2::visit(
|
||||||
cppbase::overloaded {
|
cppbase::overloaded{
|
||||||
[](boost::variant2::monostate const&) -> char const * { return nullptr; },
|
[](boost::variant2::monostate const &) -> char const * { return nullptr; },
|
||||||
[&transformer](auto const& data
|
[&transformer](auto const & data) -> char const * {
|
||||||
) -> char const * {
|
|
||||||
auto buffer = fmt::memory_buffer{};
|
auto buffer = fmt::memory_buffer{};
|
||||||
|
|
||||||
fmt::format_to(
|
fmt::format_to(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue