Skip to content

Commit 3c5c94a

Browse files
author
Martin D. Weinberg
committed
Added more comments/documentation only
1 parent 21a6ea3 commit 3c5c94a

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

expui/UnitValidator.H

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,29 @@
66
can be extended as needed by adding new names and aliases to
77
UnitValidator::createAllowedUnitTypes() and
88
UnitValidator::createAllowedUnitNames() in UnitValidator.cc
9+
10+
Strategy:
11+
-------
12+
- Types and their aliases are stored in an std::unordered_map
13+
- Units and their aliases are stored in an std::map of
14+
std::unordered_maps
15+
- The operator()(type, unit, value) first checks if the provided
16+
type exists in the allowed types map. If it does, it retrieves
17+
the canonical type string which is used to look up the allowed
18+
units for that type in the std::map. Then, the unit type is
19+
checked against the allowed units for that type. If both type
20+
and unit are valid, the canonical strings are returned.
21+
22+
Usage:
23+
-----
24+
- Create an instance of UnitValidator. Currently, this is done in
25+
the Coefficients class by default.
26+
- Call the operator() on an instance with the type and unit
27+
strings to be validated
28+
- The operator() returns a tuple with:
29+
+ a boolean indicating if the type and unit are valid
30+
+ the canonical type string, or "unknown" if invalid
31+
+ the canonical unit string, or "unknown" if invalid
932
*/
1033
class UnitValidator
1134
{

0 commit comments

Comments
 (0)