Bicameral Engine
GPU-resident engine for a magic-research open-world game
Loading...
Searching...
No Matches
bicameral::script::anonymous_namespace{reaction_package.cpp} Namespace Reference

Classes

struct  ElementCount
struct  ElementDefinition
struct  ReactionTableDefinition
struct  RuleDefinition
struct  RuleTerm
struct  SpeciesDefinition

Functions

std::expected< void, std::string > CheckFields (const ScriptValue &table, std::span< const std::string_view > allowed, std::string_view path)
std::expected< const ScriptValue *, std::string > RequireField (const ScriptValue &table, std::string_view field, std::string_view path)
std::expected< void, std::string > RequireTable (const ScriptValue &value, std::string_view path)
std::expected< int64_t, std::string > ReadInteger (const ScriptValue &value, std::string_view path, int64_t minimum, int64_t maximum)
std::expected< int64_t, std::string > ReadIntegerField (const ScriptValue &table, std::string_view field, std::string_view path, int64_t minimum, int64_t maximum)
std::expected< void, std::string > CheckRecord (const ScriptValue &value, std::span< const std::string_view > allowed, std::string_view path)
std::expected< ElementDefinition, std::string > ReadElement (const std::string &name, const ScriptValue &value, const std::string &path)
std::expected< std::vector< ElementCount >, std::string > ReadComposition (const ScriptValue &value, const std::string &path)
std::expected< SpeciesDefinition, std::string > ReadSpecies (const std::string &name, const ScriptValue &value, const std::string &path)
std::expected< std::vector< RuleTerm >, std::string > ReadTerms (const ScriptValue &value, const std::string &path)
std::expected< void, std::string > ReadOrders (const ScriptValue *orders, std::vector< RuleTerm > &reactants, const std::string &path)
std::expected< DecimalNumber, std::string > ReadPreExponential (const ScriptValue &value, const std::string &path)
std::expected< sim::ArrheniusRate, std::string > ReadRate (const ScriptValue &value, const std::string &path)
std::expected< void, std::string > ReadRuleTerms (const ScriptValue &value, const std::string &path, RuleDefinition &rule)
std::expected< RuleDefinition, std::string > ReadRule (const std::string &name, const ScriptValue &value, const std::string &path)
template<typename Definition, typename Reader>
std::expected< void, std::string > ReadCategory (const PackageSetResult &packages, std::string_view category, Reader read, std::vector< Definition > &out)
std::expected< DecimalNumber, std::string > DigitsToDecimal (std::string digits, int64_t exponent10)
bool IsDigit (char character)
std::expected< int64_t, std::string > ParseExponent (std::string_view text)

Variables

constexpr int64_t EXACT_INTEGER_LIMIT = int64_t{1} << 53
constexpr int64_t UINT32_LIMIT = std::numeric_limits<uint32_t>::max()
constexpr size_t DECIMAL_DIGITS_MAX = 19
constexpr int64_t DECIMAL_EXPONENT_MAX = 999

Function Documentation

◆ CheckFields()

std::expected< void, std::string > bicameral::script::anonymous_namespace{reaction_package.cpp}::CheckFields ( const ScriptValue & table,
std::span< const std::string_view > allowed,
std::string_view path )

Definition at line 34 of file reaction_package.cpp.

References CheckFields(), bicameral::script::ScriptValue::fields, bicameral::script::ScriptValue::IsString(), bicameral::script::ScriptField::key, bicameral::script::ScriptValue::text, and bicameral::script::ToDebugText().

Referenced by CheckFields(), and CheckRecord().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CheckRecord()

std::expected< void, std::string > bicameral::script::anonymous_namespace{reaction_package.cpp}::CheckRecord ( const ScriptValue & value,
std::span< const std::string_view > allowed,
std::string_view path )

Definition at line 88 of file reaction_package.cpp.

References CheckFields(), CheckRecord(), and RequireTable().

Referenced by CheckRecord(), ReadElement(), ReadRate(), ReadRule(), and ReadSpecies().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DigitsToDecimal()

std::expected< DecimalNumber, std::string > bicameral::script::anonymous_namespace{reaction_package.cpp}::DigitsToDecimal ( std::string digits,
int64_t exponent10 )

Definition at line 337 of file reaction_package.cpp.

References DECIMAL_DIGITS_MAX, DECIMAL_EXPONENT_MAX, and DigitsToDecimal().

Referenced by DigitsToDecimal().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsDigit()

bool bicameral::script::anonymous_namespace{reaction_package.cpp}::IsDigit ( char character)

Definition at line 361 of file reaction_package.cpp.

References IsDigit().

Referenced by IsDigit(), and ParseExponent().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ParseExponent()

std::expected< int64_t, std::string > bicameral::script::anonymous_namespace{reaction_package.cpp}::ParseExponent ( std::string_view text)

Definition at line 366 of file reaction_package.cpp.

References IsDigit(), and ParseExponent().

Referenced by ParseExponent().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReadCategory()

template<typename Definition, typename Reader>
std::expected< void, std::string > bicameral::script::anonymous_namespace{reaction_package.cpp}::ReadCategory ( const PackageSetResult & packages,
std::string_view category,
Reader read,
std::vector< Definition > & out )

Definition at line 316 of file reaction_package.cpp.

References ReadCategory(), and bicameral::script::PackageSetResult::tables.

Referenced by ReadCategory().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReadComposition()

std::expected< std::vector< ElementCount >, std::string > bicameral::script::anonymous_namespace{reaction_package.cpp}::ReadComposition ( const ScriptValue & value,
const std::string & path )

Definition at line 113 of file reaction_package.cpp.

References bicameral::script::ScriptValue::fields, bicameral::script::ScriptValue::IsString(), bicameral::script::ScriptField::key, ReadComposition(), ReadInteger(), RequireTable(), bicameral::script::ScriptValue::text, UINT32_LIMIT, and bicameral::script::ScriptField::value.

Referenced by ReadComposition(), and ReadSpecies().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReadElement()

std::expected< ElementDefinition, std::string > bicameral::script::anonymous_namespace{reaction_package.cpp}::ReadElement ( const std::string & name,
const ScriptValue & value,
const std::string & path )

Definition at line 98 of file reaction_package.cpp.

References CheckRecord(), ReadElement(), ReadIntegerField(), and UINT32_LIMIT.

Referenced by ReadElement().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReadInteger()

std::expected< int64_t, std::string > bicameral::script::anonymous_namespace{reaction_package.cpp}::ReadInteger ( const ScriptValue & value,
std::string_view path,
int64_t minimum,
int64_t maximum )

Definition at line 63 of file reaction_package.cpp.

References EXACT_INTEGER_LIMIT, bicameral::script::ScriptValue::IsNumber(), bicameral::script::ScriptValue::number, and ReadInteger().

Referenced by ReadComposition(), ReadInteger(), ReadIntegerField(), ReadOrders(), ReadPreExponential(), ReadRule(), and ReadTerms().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReadIntegerField()

std::expected< int64_t, std::string > bicameral::script::anonymous_namespace{reaction_package.cpp}::ReadIntegerField ( const ScriptValue & table,
std::string_view field,
std::string_view path,
int64_t minimum,
int64_t maximum )

Definition at line 78 of file reaction_package.cpp.

References ReadInteger(), ReadIntegerField(), and RequireField().

Referenced by ReadElement(), ReadIntegerField(), ReadRate(), and ReadSpecies().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReadOrders()

std::expected< void, std::string > bicameral::script::anonymous_namespace{reaction_package.cpp}::ReadOrders ( const ScriptValue * orders,
std::vector< RuleTerm > & reactants,
const std::string & path )

Definition at line 192 of file reaction_package.cpp.

References bicameral::script::ScriptValue::fields, bicameral::script::ScriptField::key, ReadInteger(), ReadOrders(), RequireTable(), bicameral::script::ScriptValue::text, bicameral::script::ToDebugText(), and bicameral::script::ScriptField::value.

Referenced by ReadOrders(), and ReadRuleTerms().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReadPreExponential()

std::expected< DecimalNumber, std::string > bicameral::script::anonymous_namespace{reaction_package.cpp}::ReadPreExponential ( const ScriptValue & value,
const std::string & path )

Definition at line 222 of file reaction_package.cpp.

References EXACT_INTEGER_LIMIT, bicameral::script::ScriptValue::IsString(), bicameral::script::ParseDecimal(), ReadInteger(), ReadPreExponential(), and bicameral::script::ScriptValue::text.

Referenced by ReadPreExponential(), and ReadRate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReadRate()

std::expected< sim::ArrheniusRate, std::string > bicameral::script::anonymous_namespace{reaction_package.cpp}::ReadRate ( const ScriptValue & value,
const std::string & path )

Definition at line 239 of file reaction_package.cpp.

References CheckRecord(), EXACT_INTEGER_LIMIT, ReadIntegerField(), ReadPreExponential(), ReadRate(), and RequireField().

Referenced by ReadRate(), and ReadRule().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReadRule()

std::expected< RuleDefinition, std::string > bicameral::script::anonymous_namespace{reaction_package.cpp}::ReadRule ( const std::string & name,
const ScriptValue & value,
const std::string & path )

Definition at line 280 of file reaction_package.cpp.

References CheckRecord(), bicameral::sim::RuleDefinition::declaredReactionEnthalpy, EXACT_INTEGER_LIMIT, bicameral::script::ScriptValue::Find(), bicameral::sim::RuleDefinition::rate, ReadInteger(), ReadRate(), ReadRule(), ReadRuleTerms(), and RequireField().

Referenced by ReadRule().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReadRuleTerms()

std::expected< void, std::string > bicameral::script::anonymous_namespace{reaction_package.cpp}::ReadRuleTerms ( const ScriptValue & value,
const std::string & path,
RuleDefinition & rule )

Definition at line 263 of file reaction_package.cpp.

References bicameral::script::ScriptValue::Find(), bicameral::sim::RuleDefinition::products, bicameral::sim::RuleDefinition::reactants, ReadOrders(), ReadRuleTerms(), ReadTerms(), and RequireField().

Referenced by ReadRule(), and ReadRuleTerms().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReadSpecies()

std::expected< SpeciesDefinition, std::string > bicameral::script::anonymous_namespace{reaction_package.cpp}::ReadSpecies ( const std::string & name,
const ScriptValue & value,
const std::string & path )

Definition at line 134 of file reaction_package.cpp.

References CheckRecord(), EXACT_INTEGER_LIMIT, ReadComposition(), ReadIntegerField(), ReadSpecies(), RequireField(), and UINT32_LIMIT.

Referenced by ReadSpecies().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReadTerms()

std::expected< std::vector< RuleTerm >, std::string > bicameral::script::anonymous_namespace{reaction_package.cpp}::ReadTerms ( const ScriptValue & value,
const std::string & path )

Definition at line 169 of file reaction_package.cpp.

References bicameral::script::ScriptValue::fields, bicameral::script::ScriptValue::IsString(), bicameral::script::ScriptField::key, ReadInteger(), ReadTerms(), RequireTable(), bicameral::script::ScriptValue::text, UINT32_LIMIT, and bicameral::script::ScriptField::value.

Referenced by ReadRuleTerms(), and ReadTerms().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RequireField()

std::expected< const ScriptValue *, std::string > bicameral::script::anonymous_namespace{reaction_package.cpp}::RequireField ( const ScriptValue & table,
std::string_view field,
std::string_view path )

Definition at line 46 of file reaction_package.cpp.

References bicameral::script::ScriptValue::Find(), and RequireField().

Referenced by ReadIntegerField(), ReadRate(), ReadRule(), ReadRuleTerms(), ReadSpecies(), and RequireField().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RequireTable()

std::expected< void, std::string > bicameral::script::anonymous_namespace{reaction_package.cpp}::RequireTable ( const ScriptValue & value,
std::string_view path )

Definition at line 55 of file reaction_package.cpp.

References bicameral::script::ScriptValue::IsTable(), and RequireTable().

Referenced by CheckRecord(), ReadComposition(), ReadOrders(), ReadTerms(), and RequireTable().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ DECIMAL_DIGITS_MAX

size_t bicameral::script::anonymous_namespace{reaction_package.cpp}::DECIMAL_DIGITS_MAX = 19
constexpr

Definition at line 28 of file reaction_package.cpp.

Referenced by DigitsToDecimal().

◆ DECIMAL_EXPONENT_MAX

int64_t bicameral::script::anonymous_namespace{reaction_package.cpp}::DECIMAL_EXPONENT_MAX = 999
constexpr

Definition at line 29 of file reaction_package.cpp.

Referenced by DigitsToDecimal().

◆ EXACT_INTEGER_LIMIT

int64_t bicameral::script::anonymous_namespace{reaction_package.cpp}::EXACT_INTEGER_LIMIT = int64_t{1} << 53
constexpr

Definition at line 26 of file reaction_package.cpp.

Referenced by ReadInteger(), ReadPreExponential(), ReadRate(), ReadRule(), and ReadSpecies().

◆ UINT32_LIMIT

int64_t bicameral::script::anonymous_namespace{reaction_package.cpp}::UINT32_LIMIT = std::numeric_limits<uint32_t>::max()
constexpr

Definition at line 27 of file reaction_package.cpp.

Referenced by ReadComposition(), ReadElement(), ReadSpecies(), and ReadTerms().