MQLArticles/Utils/EnumsStr/README.md
Nique_372 656e26c5f8
2026-09-06 11:25:00 -05:00

1,1 KiB

← Utils

Utils/EnumsStr

Automatic enum-to-string / string-to-value conversion, backed by generated perfect-hash lookup tables instead of switch statements.

Main features

  • Code-generator macro that builds a lookup class from a set of keys, seeds and values (TSN_MQLARTICLES_ENUM_REG_TEM / TSN_MQLARTICLES_ENUM_REG_TEMF in Template.mqh).
  • Generated class exposes O(1) GetVal / GetValNoRef lookups by string key, with a default fallback value.
  • A dynamic variant (RunDinyamics) allows updating values at runtime, not just at generation time.
  • Table/seed generation tooling lives in Generate/ (CRecolect in Generate/Recolect.mqh).

Basic usage

// Generated once via the macro (seeds/hashes/values produced by the Generate/ tooling):
// You must have previously generated the perfect hash table with SimPHash; the macro helps to define a custom class.
TSN_MQLARTICLES_ENUM_REG_TEM(MyEnum, seeds, valores, hashes, BUCKETS_SIZE_L, FINAL_TABLE_SIZE_L)

// Then used as:
ENUM_MY_TYPE v = CEnumRegMyEnum::GetVal("SOME_KEY", ENUM_MY_TYPE_DEFAULT);

Only the most representative macros/classes are shown here.