| 91 | def add_object(config, var, value, type=None): |
| 92 | |
| 93 | def get_value(type, value): |
| 94 | |
| 95 | def have_multipliers(value, mps): |
| 96 | for m in mps: |
| 97 | if value.endswith(m): |
| 98 | return True |
| 99 | |
| 100 | return False |
| 101 | |
| 102 | if value is None or value == 'nullptr' or value == 'NULL': |
| 103 | return None |
| 104 | |
| 105 | # We want to make the type right when inserting the element into the dict. |
| 106 | if type == 'FLOAT': |
| 107 | return float(value) |
| 108 | elif type == 'INT': |
| 109 | # We need to make it YAML compliant as this will be an int, so if contains |
| 110 | # any special character like hex or a multiplier, then we make a string. ATS will |
| 111 | # parse it as string anyway. |
| 112 | if value.startswith('0x') or have_multipliers(value, ['K', 'M', 'G', 'T']): |
| 113 | return str(value) |
| 114 | else: |
| 115 | return int(value) |
| 116 | elif type == 'STRING': |
| 117 | return str(value) |
| 118 | |
| 119 | return None |
| 120 | |
| 121 | obj = {} |
| 122 | key = '' |