Generate VB Enum member list¶
This operation reads code/code_descr reference rows from a caller-supplied table and turns each row into a VB enum-member line with an inline comment. It can optionally prepend a leading Null member, derives a legal VB identifier for every row, and disambiguates any identifier that repeats before returning the completed member list.
| Field | Value |
|---|---|
| Operation ID | OP-CODEGEN-003 |
| Trigger | Caller invokes CreateEnumStatement(table, enumName, includeNull, ...) |
| Inputs | table, enumName (accepted but unused), includeNull, optional useDescriptionAsCode, optional tabIndex |
| Outputs | Generated VB source text containing enum-member lines and inline comments |
| Primary components | CodeTableMap.CreateEnumStatement, CodeTableMap.GetResult, CodeTableMap.GetEnumValue |
| Entry point | SAIF.Framework.CodeGen\CodeTableMap.vb |
Steps¶
CreateEnumStatementcallsGetResult(table), which executes SQL-001 against CODE_TABLE (caller-supplied) — the same unfilteredcode/code_descrlookup used byCreateCaseStatement.ResultSetQueryobtains a new portal request fromm_dpi.NewPortalRequest()and marks it as a result-set request.Execute(sql)assigns the formatted SQL text toDataRequest.SQLStatement.Execute()callsm_dpi.ProcessPortalRequest(...)and returns the resultingclsResultSet.
Origin: Steps 1.1-1.3 are implemented in
SAIF.Framework.Core's data-portal pipeline and execute on behalf of this operation; see SAIF.Framework.Core interaction model. 2. The method initializes an empty output buffer. 3. WhenincludeNull = True, the method writes a single tab-indentedNullmember as the first line, before any database-driven entries are emitted. 4. The method initializes aDictionary(Of String, Boolean)that tracks which identifiers have already been emitted. 5. For each row returned by the query,GetEnumValuederives a candidate member identifier. - WhenuseDescriptionAsCode = True(the default), it strips every non-alphabetic character fromrow("code_descr")and uses what remains as the identifier (BR-003). - If the resulting candidate is purely numeric, it is prefixed with the literalCodeso the emitted member name stays legal VB syntax (BR-002). 6. Before writing the line, the method checks whether the candidate identifier is already present in the dictionary. - If it is, the method appends the row's rawcodevalue so the emitted member name becomes unique (BR-001). - It then records the final identifier in the dictionary, so subsequent rows are compared against every name emitted so far (BR-001). 7. The method appends one tab-indented enum-member line in the form{enumValue} ' {code}: {code_descr}. 8. Once every row has been processed, the method returns the accumulated buffer as the finished member list. - If SQL-001 returns zero rows from CODE_TABLE (caller-supplied), the result contains only the optional leadingNullline, if requested. - TheenumNameparameter is accepted by the method signature but is never read inside this implementation, so it has no effect on the generated output. - No local exception handling surrounds query execution or string assembly, so any failure in either stage propagates directly to the caller.
Process flow¶
The following diagram visualizes this operation's control flow.
flowchart TD
Start([Caller invokes CreateEnumStatement]) --> Query[Read code-table rows]
Query --> NullOpt{includeNull?}
NullOpt -->|Yes| AddNull[Emit Null member]
NullOpt -->|No| Loop[For each row derive identifier]
AddNull --> Loop
Loop --> Dup{Identifier already used?}
Dup -->|Yes| Disambiguate[Append raw code value]
Dup -->|No| Emit[Emit enum-member line]
Disambiguate --> Emit
Emit --> More{More rows?}
More -->|Yes| Loop
More -->|No| EndOk([Return generated enum list])
Failure and edge-case behavior¶
- Duplicate computed identifiers are disambiguated by appending the row's raw
codevalue before the line is emitted, guaranteeing every member name in the generated list is unique (BR-001). - Description-derived identifiers have non-alphabetic characters stripped and are then prefixed with
Codewhen the stripped result is purely numeric (BR-003, BR-002). includeNullonly controls whether the optional leadingNullline is written; theenumNameargument has no effect on the output because the method never reads it.- Query failures bubble up unhandled, because neither
GetResultnorCreateEnumStatementwraps or catches exceptions raised while executing SQL-001.
Related documentation¶
Sources¶
- SAIF.Framework.CodeGen\CodeTableMap.vb
- SAIF.Framework.Core\V1\DataAccessLayer\SqlHelper.vb
- SAIF.Framework.Core\V1\Interfaces\iDataPortalInfo.vb