载入中...
搜索中...
未找到
eve::schema::Schema类 参考

Script-facing facade for runtime schema registration and validation. 更多...

#include <Schema.h>

类 eve::schema::Schema 继承关系图:
eve::Module

Public 成员函数

 Module_REG (Schema)
 
 Schema ()
 Creates an empty facade over the process schema registry.
 
eve::Result< void > registerJson (const std::string &json)
 Registers or replaces a schema encoded as JSON.
 
eve::Result< void > registerFromClass (const ssq::Object &classOrInstance)
 Registers a schema reflected from a script class or instance.
 
void clear ()
 Removes all registered schemas and cached validation errors.
 
bool has (const std::string &id) const
 Returns whether a stable schema id is registered.
 
bool hasVersion (const std::string &id, int version) const
 Returns whether an exact schema id and version is registered.
 
int getSchemaCount () const
 Returns the number of registered schema ids.
 
int getSchemaVersionCount (const std::string &id) const
 Returns the number of registered versions for one schema id.
 
int getSchemaVersionAt (const std::string &id, int index) const
 Returns a schema version at an ascending enumeration index.
 
std::string getSchemaId (int index) const
 Returns the id at a deterministic enumeration index.
 
int getSchemaVersion (const std::string &id) const
 Returns the highest registered schema version, or zero when absent.
 
std::string getSchemaTitle (const std::string &id) const
 Returns a schema title, or an empty string when absent.
 
std::string getSchemaDescription (const std::string &id) const
 Returns a schema description, or an empty string when absent.
 
bool getSchemaAdditionalProperties (const std::string &id) const
 Returns whether undeclared object members are accepted.
 
int getFieldCount (const std::string &id) const
 Returns the number of fields in a schema.
 
std::string getFieldName (const std::string &id, int index) const
 Returns a field's stable name.
 
std::string getFieldType (const std::string &id, int index) const
 Returns a field's stable value type name.
 
std::string getFieldElementType (const std::string &id, int index) const
 Returns the element type name for an array field.
 
bool getFieldRequired (const std::string &id, int index) const
 Returns whether a field must be present.
 
std::string getFieldTitle (const std::string &id, int index) const
 Returns the short editor-facing field title.
 
std::string getFieldDescription (const std::string &id, int index) const
 Returns the editor-facing field description.
 
std::string getFieldReference (const std::string &id, int index) const
 Returns the referenced definition/schema category.
 
std::string getFieldDefaultJson (const std::string &id, int index) const
 Returns the optional default value as JSON text.
 
bool getFieldHasMinimum (const std::string &id, int index) const
 Returns whether a numeric minimum constraint is present.
 
float getFieldMinimum (const std::string &id, int index) const
 Returns a numeric minimum, or zero when absent.
 
bool getFieldHasMaximum (const std::string &id, int index) const
 Returns whether a numeric maximum constraint is present.
 
float getFieldMaximum (const std::string &id, int index) const
 Returns a numeric maximum, or zero when absent.
 
int getFieldEnumCount (const std::string &id, int index) const
 Returns the number of allowed string values.
 
std::string getFieldEnumValue (const std::string &id, int fieldIndex, int valueIndex) const
 Returns one allowed string value.
 
eve::Result< void > validateJson (const std::string &schemaId, const std::string &json)
 Validates JSON against the highest registered version and caches failures.
 
eve::Result< void > validateJsonVersioned (const std::string &schemaId, int version, const std::string &json)
 Validates JSON against one exact schema version.
 
int getValidationErrorCount () const
 Returns cached validation failure count.
 
std::string getValidationErrorPath (int index) const
 Returns a failure's JSON Pointer-like path.
 
std::string getValidationErrorCode (int index) const
 Returns a stable machine-readable failure code.
 
std::string getValidationErrorMessage (int index) const
 Returns a human-readable failure description.
 
- Public 成员函数 继承自 eve::Module
virtual ~Module ()
 Module.
 
virtual std::string getName () const =0
 Returns the name.
 

详细描述

Script-facing facade for runtime schema registration and validation.

在文件 Schema.h 第 16 行定义.

构造及析构函数说明

◆ Schema()

eve::schema::Schema::Schema ( )
default

Creates an empty facade over the process schema registry.

成员函数说明

◆ clear()

void eve::schema::Schema::clear ( )

Removes all registered schemas and cached validation errors.

在文件 Schema.cpp 第 286 行定义.

引用了 eve::schema::SchemaRegistry::clear().

◆ getFieldCount()

int eve::schema::Schema::getFieldCount ( const std::string &  id) const

Returns the number of fields in a schema.

在文件 Schema.cpp 第 335 行定义.

引用了 eve::schema::SchemaRegistry::find() , 以及 value.

◆ getFieldDefaultJson()

std::string eve::schema::Schema::getFieldDefaultJson ( const std::string &  id,
int  index 
) const

Returns the optional default value as JSON text.

在文件 Schema.cpp 第 368 行定义.

引用了 index , 以及 value.

◆ getFieldDescription()

std::string eve::schema::Schema::getFieldDescription ( const std::string &  id,
int  index 
) const

Returns the editor-facing field description.

在文件 Schema.cpp 第 360 行定义.

引用了 index , 以及 value.

◆ getFieldElementType()

std::string eve::schema::Schema::getFieldElementType ( const std::string &  id,
int  index 
) const

Returns the element type name for an array field.

在文件 Schema.cpp 第 348 行定义.

引用了 index, value , 以及 eve::schema::valueTypeName().

◆ getFieldEnumCount()

int eve::schema::Schema::getFieldEnumCount ( const std::string &  id,
int  index 
) const

Returns the number of allowed string values.

在文件 Schema.cpp 第 388 行定义.

引用了 index , 以及 value.

◆ getFieldEnumValue()

std::string eve::schema::Schema::getFieldEnumValue ( const std::string &  id,
int  fieldIndex,
int  valueIndex 
) const

Returns one allowed string value.

在文件 Schema.cpp 第 392 行定义.

引用了 value.

◆ getFieldHasMaximum()

bool eve::schema::Schema::getFieldHasMaximum ( const std::string &  id,
int  index 
) const

Returns whether a numeric maximum constraint is present.

在文件 Schema.cpp 第 380 行定义.

引用了 index , 以及 value.

◆ getFieldHasMinimum()

bool eve::schema::Schema::getFieldHasMinimum ( const std::string &  id,
int  index 
) const

Returns whether a numeric minimum constraint is present.

在文件 Schema.cpp 第 372 行定义.

引用了 index , 以及 value.

◆ getFieldMaximum()

float eve::schema::Schema::getFieldMaximum ( const std::string &  id,
int  index 
) const

Returns a numeric maximum, or zero when absent.

在文件 Schema.cpp 第 384 行定义.

引用了 index , 以及 value.

◆ getFieldMinimum()

float eve::schema::Schema::getFieldMinimum ( const std::string &  id,
int  index 
) const

Returns a numeric minimum, or zero when absent.

在文件 Schema.cpp 第 376 行定义.

引用了 index , 以及 value.

◆ getFieldName()

std::string eve::schema::Schema::getFieldName ( const std::string &  id,
int  index 
) const

Returns a field's stable name.

在文件 Schema.cpp 第 340 行定义.

引用了 index , 以及 value.

◆ getFieldReference()

std::string eve::schema::Schema::getFieldReference ( const std::string &  id,
int  index 
) const

Returns the referenced definition/schema category.

在文件 Schema.cpp 第 364 行定义.

引用了 index , 以及 value.

◆ getFieldRequired()

bool eve::schema::Schema::getFieldRequired ( const std::string &  id,
int  index 
) const

Returns whether a field must be present.

在文件 Schema.cpp 第 352 行定义.

引用了 index , 以及 value.

◆ getFieldTitle()

std::string eve::schema::Schema::getFieldTitle ( const std::string &  id,
int  index 
) const

Returns the short editor-facing field title.

在文件 Schema.cpp 第 356 行定义.

引用了 index , 以及 value.

◆ getFieldType()

std::string eve::schema::Schema::getFieldType ( const std::string &  id,
int  index 
) const

Returns a field's stable value type name.

在文件 Schema.cpp 第 344 行定义.

引用了 index, value , 以及 eve::schema::valueTypeName().

◆ getSchemaAdditionalProperties()

bool eve::schema::Schema::getSchemaAdditionalProperties ( const std::string &  id) const

Returns whether undeclared object members are accepted.

在文件 Schema.cpp 第 324 行定义.

引用了 eve::schema::SchemaRegistry::find() , 以及 value.

◆ getSchemaCount()

int eve::schema::Schema::getSchemaCount ( ) const

Returns the number of registered schema ids.

在文件 Schema.cpp 第 295 行定义.

引用了 eve::schema::SchemaRegistry::count().

◆ getSchemaDescription()

std::string eve::schema::Schema::getSchemaDescription ( const std::string &  id) const

Returns a schema description, or an empty string when absent.

在文件 Schema.cpp 第 319 行定义.

引用了 eve::schema::SchemaRegistry::find() , 以及 value.

◆ getSchemaId()

std::string eve::schema::Schema::getSchemaId ( int  index) const

Returns the id at a deterministic enumeration index.

在文件 Schema.cpp 第 304 行定义.

引用了 eve::schema::SchemaRegistry::ids(), index , 以及 values.

◆ getSchemaTitle()

std::string eve::schema::Schema::getSchemaTitle ( const std::string &  id) const

Returns a schema title, or an empty string when absent.

在文件 Schema.cpp 第 314 行定义.

引用了 eve::schema::SchemaRegistry::find() , 以及 value.

◆ getSchemaVersion()

int eve::schema::Schema::getSchemaVersion ( const std::string &  id) const

Returns the highest registered schema version, or zero when absent.

在文件 Schema.cpp 第 309 行定义.

引用了 eve::schema::SchemaRegistry::find() , 以及 value.

◆ getSchemaVersionAt()

int eve::schema::Schema::getSchemaVersionAt ( const std::string &  id,
int  index 
) const

Returns a schema version at an ascending enumeration index.

参数
idStable schema id.
indexVersion enumeration index.
返回
Version, or zero when the index is out of range.

在文件 Schema.cpp 第 299 行定义.

引用了 index, values , 以及 eve::schema::SchemaRegistry::versions().

◆ getSchemaVersionCount()

int eve::schema::Schema::getSchemaVersionCount ( const std::string &  id) const

Returns the number of registered versions for one schema id.

参数
idStable schema id.

在文件 Schema.cpp 第 296 行定义.

引用了 eve::schema::SchemaRegistry::versions().

◆ getValidationErrorCode()

std::string eve::schema::Schema::getValidationErrorCode ( int  index) const

Returns a stable machine-readable failure code.

在文件 Schema.cpp 第 418 行定义.

引用了 code , 以及 index.

◆ getValidationErrorCount()

int eve::schema::Schema::getValidationErrorCount ( ) const

Returns cached validation failure count.

在文件 Schema.cpp 第 412 行定义.

◆ getValidationErrorMessage()

std::string eve::schema::Schema::getValidationErrorMessage ( int  index) const

Returns a human-readable failure description.

在文件 Schema.cpp 第 423 行定义.

引用了 index , 以及 message.

◆ getValidationErrorPath()

std::string eve::schema::Schema::getValidationErrorPath ( int  index) const

Returns a failure's JSON Pointer-like path.

在文件 Schema.cpp 第 413 行定义.

引用了 index , 以及 path.

◆ has()

bool eve::schema::Schema::has ( const std::string &  id) const

Returns whether a stable schema id is registered.

在文件 Schema.cpp 第 291 行定义.

引用了 eve::schema::SchemaRegistry::find().

◆ hasVersion()

bool eve::schema::Schema::hasVersion ( const std::string &  id,
int  version 
) const

Returns whether an exact schema id and version is registered.

参数
idStable schema id.
versionExact schema version.

在文件 Schema.cpp 第 292 行定义.

引用了 eve::schema::SchemaRegistry::resolve().

◆ Module_REG()

eve::schema::Schema::Module_REG ( Schema  )

◆ registerFromClass()

eve::Result< void > eve::schema::Schema::registerFromClass ( const ssq::Object &  classOrInstance)

Registers a schema reflected from a script class or instance.

Class-level </ ... /> attributes supply id, version, title, description and additionalProperties. Each non-method member becomes a field: its default value infers the type and the JSON default, and member-level </ ... /> attributes carry required, type, elementType, title, description, reference, defaultJson, values, minimum/min, maximum/max, minLength, maxLength.

返回
Success, or a structured reflection/registration failure.

在文件 Schema.cpp 第 196 行定义.

引用了 eve::Applied, eve::Diagnostic::error(), eve::Result< T >::failure(), eve::InvalidArgument, name, eve::schema::SchemaRegistry::registerSchema(), strict, eve::Status::success(), eve::Result< T >::success(), top, type, eve::editing::Value::type() , 以及 vm.

◆ registerJson()

eve::Result< void > eve::schema::Schema::registerJson ( const std::string &  json)

Registers or replaces a schema encoded as JSON.

返回
Success, or a structured parse/validation/conflict failure.

在文件 Schema.cpp 第 19 行定义.

引用了 eve::Applied, eve::Result< T >::failure(), eve::schema::SchemaRegistry::registerFromJson(), eve::Status::success() , 以及 eve::Result< T >::success().

◆ validateJson()

eve::Result< void > eve::schema::Schema::validateJson ( const std::string &  schemaId,
const std::string &  json 
)

Validates JSON against the highest registered version and caches failures.

返回
Success, or the first structured validation failure.

在文件 Schema.cpp 第 398 行定义.

引用了 eve::Applied, error, eve::Diagnostic::error(), eve::Result< T >::failure(), eve::InvalidArgument, eve::Status::success(), eve::Result< T >::success() , 以及 eve::schema::SchemaRegistry::validate().

◆ validateJsonVersioned()

eve::Result< void > eve::schema::Schema::validateJsonVersioned ( const std::string &  schemaId,
int  version,
const std::string &  json 
)

Validates JSON against one exact schema version.

参数
schemaIdStable schema id.
versionExact schema version.
jsonJSON value to validate.
返回
Success when validation succeeds; otherwise the first validation failure.

在文件 Schema.cpp 第 405 行定义.

引用了 eve::Applied, error, eve::Diagnostic::error(), eve::Result< T >::failure(), eve::InvalidArgument, eve::Status::success(), eve::Result< T >::success() , 以及 eve::schema::SchemaRegistry::validate().


该类的文档由以下文件生成: