Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | OFINISection: Add unsigned long long Otherwise, no values > LLONG_MAX could be stored in / read from an INI file. |
|---|---|
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
d65bd089c5cbf333e021a06dd810dea8 |
| User & Date: | js 2025-03-21 02:47:20.515 |
Context
|
2025-03-21
| ||
| 02:54 | OFSettings: Add unsigned long long check-in: b6dd9f61af user: js tags: trunk | |
| 02:47 | OFINISection: Add unsigned long long check-in: d65bd089c5 user: js tags: trunk | |
| 02:33 | OFXMLNode: Deprecate number parsing methods check-in: 0ddf9671df user: js tags: trunk | |
Changes
Changes to src/OFINISection.h.
| ︙ | ︙ | |||
68 69 70 71 72 73 74 | * @return The string for the specified key or the specified default value if * it does not exist */ - (nullable OFString *)stringValueForKey: (OFString *)key defaultValue: (nullable OFString *)defaultValue; /** | | > > > > > > > > > > > > > > > > > > | 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
* @return The string for the specified key or the specified default value if
* it does not exist
*/
- (nullable OFString *)stringValueForKey: (OFString *)key
defaultValue: (nullable OFString *)defaultValue;
/**
* @brief Returns the `long long` value for the specified key or the specified
* default value if it does not exist.
*
* If the specified key is a multi-key (see @ref arrayValueForKey:), the value
* of the first key/value pair found is returned.
*
* @param key The key for which the long long should be returned
* @param defaultValue The value to return if the key does not exist
* @return The long long for the specified key or the specified default value
* if it does not exist
* @throw OFInvalidFormatException The specified key is not in the correct
* format for a long long
*/
- (long long)longLongValueForKey: (OFString *)key
defaultValue: (long long)defaultValue;
/**
* @brief Returns the `unsigned long long` value for the specified key or the
* specified default value if it does not exist.
*
* If the specified key is a multi-key (see @ref arrayValueForKey:), the value
* of the first key/value pair found is returned.
*
* @param key The key for which the long long should be returned
* @param defaultValue The value to return if the key does not exist
* @return The long long for the specified key or the specified default value
* if it does not exist
* @throw OFInvalidFormatException The specified key is not in the correct
* format for a long long
*/
- (unsigned long long)
unsignedLongLongValueForKey: (OFString *)key
defaultValue: (unsigned long long)defaultValue;
/**
* @brief Returns the bool value for the specified key or the specified default
* value if it does not exist.
*
* If the specified key is a multi-key (see @ref arrayValueForKey:), the value
* of the first key/value pair found is returned.
*
|
| ︙ | ︙ | |||
157 158 159 160 161 162 163 | * * @param stringValue The string to which the key should be set * @param key The key for which the new value should be set */ - (void)setStringValue: (OFString *)stringValue forKey: (OFString *)key; /** | | > > > > > > > > > > > > > | > | | 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | * * @param stringValue The string to which the key should be set * @param key The key for which the new value should be set */ - (void)setStringValue: (OFString *)stringValue forKey: (OFString *)key; /** * @brief Sets the value of the specified key to the specified `long long`. * * If the specified key is a multi-key (see @ref arrayValueForKey:), the value * of the first key/value pair found is changed. * * @param longLongValue The `long long` to which the key should be set * @param key The key for which the new value should be set */ - (void)setLongLongValue: (long long)longLongValue forKey: (OFString *)key; /** * @brief Sets the value of the specified key to the specified * `unsigned long long`. * * If the specified key is a multi-key (see @ref arrayValueForKey:), the value * of the first key/value pair found is changed. * * @param unsignedLongLongValue The `unsigned long long` to which the key * should be set * @param key The key for which the new value should be set */ - (void)setUnsignedLongLongValue: (unsigned long long)unsignedLongLongValue forKey: (OFString *)key; /** * @brief Sets the value of the specified key to the specified bool. * * If the specified key is a multi-key (see @ref arrayValueForKey:), the value * of the first key/value pair found is changed. * |
| ︙ | ︙ |
Changes to src/OFINISection.m.
| ︙ | ︙ | |||
300 301 302 303 304 305 306 307 308 309 310 311 312 313 |
else
ret = defaultValue;
objc_autoreleasePoolPop(pool);
return ret;
}
- (bool)boolValueForKey: (OFString *)key defaultValue: (bool)defaultValue
{
void *pool = objc_autoreleasePoolPush();
OFString *value = [self stringValueForKey: key defaultValue: nil];
bool ret;
| > > > > > > > > > > > > > > > > > > | 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 |
else
ret = defaultValue;
objc_autoreleasePoolPop(pool);
return ret;
}
- (unsigned long long)
unsignedLongLongValueForKey: (OFString *)key
defaultValue: (unsigned long long)defaultValue
{
void *pool = objc_autoreleasePoolPush();
OFString *value = [self stringValueForKey: key defaultValue: nil];
unsigned long long ret;
if (value != nil)
ret = [value unsignedLongLongValueWithBase: 0];
else
ret = defaultValue;
objc_autoreleasePoolPop(pool);
return ret;
}
- (bool)boolValueForKey: (OFString *)key defaultValue: (bool)defaultValue
{
void *pool = objc_autoreleasePoolPush();
OFString *value = [self stringValueForKey: key defaultValue: nil];
bool ret;
|
| ︙ | ︙ | |||
425 426 427 428 429 430 431 432 433 434 435 436 437 438 |
- (void)setLongLongValue: (long long)longLongValue forKey: (OFString *)key
{
void *pool = objc_autoreleasePoolPush();
[self setStringValue: [OFString stringWithFormat:
@"%lld", longLongValue]
forKey: key];
objc_autoreleasePoolPop(pool);
}
- (void)setBoolValue: (bool)boolValue forKey: (OFString *)key
{
[self setStringValue: (boolValue ? @"true" : @"false") forKey: key];
| > > > > > > > > > > > > | 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 |
- (void)setLongLongValue: (long long)longLongValue forKey: (OFString *)key
{
void *pool = objc_autoreleasePoolPush();
[self setStringValue: [OFString stringWithFormat:
@"%lld", longLongValue]
forKey: key];
objc_autoreleasePoolPop(pool);
}
- (void)setUnsignedLongLongValue: (unsigned long long)unsignedLongLongValue
forKey: (OFString *)key
{
void *pool = objc_autoreleasePoolPush();
[self setStringValue: [OFString stringWithFormat:
@"%llu", unsignedLongLongValue]
forKey: key];
objc_autoreleasePoolPop(pool);
}
- (void)setBoolValue: (bool)boolValue forKey: (OFString *)key
{
[self setStringValue: (boolValue ? @"true" : @"false") forKey: key];
|
| ︙ | ︙ |
Changes to src/OFString.m.
| ︙ | ︙ | |||
2544 2545 2546 2547 2548 2549 2550 |
unsigned long long value = 0;
while (OFASCIIIsSpace(*UTF8String))
UTF8String++;
switch (*UTF8String) {
case '-':
| | | 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 |
unsigned long long value = 0;
while (OFASCIIIsSpace(*UTF8String))
UTF8String++;
switch (*UTF8String) {
case '-':
@throw [OFOutOfRangeException exception];
case '+':
UTF8String++;
}
if (UTF8String[0] == '0') {
if (UTF8String[1] == 'x') {
if (base == 0)
|
| ︙ | ︙ |
Changes to tests/OFINIFileTests.m.
| ︙ | ︙ | |||
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
}
- (void)testLongLongValueForKeyDefaultValue
{
OTAssertEqual([[_file sectionForName: @"types"]
longLongValueForKey: @"integer"
defaultValue: 2],
0x20);
}
- (void)testBoolValueForKeyDefaultValue
{
OTAssertTrue([[_file sectionForName: @"types"]
boolValueForKey: @"bool"
defaultValue: false]);
}
| > > > > > > > > > > > > > > > > | 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
}
- (void)testLongLongValueForKeyDefaultValue
{
OTAssertEqual([[_file sectionForName: @"types"]
longLongValueForKey: @"integer"
defaultValue: 2],
-0x20);
}
- (void)testUnsignedLongLongValueForKeyDefaultValue
{
OTAssertEqual([[_file sectionForName: @"types"]
unsignedLongLongValueForKey: @"unsigned"
defaultValue: 2],
0x20);
}
- (void)testUnsignedLongLongValueThrowsForNegative
{
OTAssertThrowsSpecific([[_file sectionForName: @"types"]
unsignedLongLongValueForKey: @"integer"
defaultValue: 2],
OFOutOfRangeException);
}
- (void)testBoolValueForKeyDefaultValue
{
OTAssertTrue([[_file sectionForName: @"types"]
boolValueForKey: @"bool"
defaultValue: false]);
}
|
| ︙ | ︙ | |||
126 127 128 129 130 131 132 | @"qux=\" asd\"\r\n" @"quxquxqux=\"hello\\\"wörld\"\r\n" @"qux2=\"a\\n\"\r\n" @"\"asd=asd\"=foobar\r\n" @"qux3=\"a\\fb\"\r\n" @"\r\n" @"[types]\r\n" | | > > | | 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | @"qux=\" asd\"\r\n" @"quxquxqux=\"hello\\\"wörld\"\r\n" @"qux2=\"a\\n\"\r\n" @"\"asd=asd\"=foobar\r\n" @"qux3=\"a\\fb\"\r\n" @"\r\n" @"[types]\r\n" @"integer=-16\r\n" @"unsigned=16\r\n" @"bool=false\r\n" @"float=0.25\r\n" @"array1=foo\r\n" @"array1=bar\r\n" @"double=0.75\r\n"; OFINISection *tests = [_file sectionForName: @"tests"]; OFINISection *foobar = [_file sectionForName: @"foobar"]; OFINISection *types = [_file sectionForName: @"types"]; OFArray *array = [OFArray arrayWithObjects: @"foo", @"bar", nil]; #if defined(OF_HAVE_FILES) && !defined(OF_NINTENDO_DS) OFIRI *writeIRI; #endif [tests setStringValue: @"baz" forKey: @"foo"]; [tests setStringValue: @"new" forKey: @"new"]; [tests setStringValue: @";comment" forKey: @"#quoted"]; [foobar setStringValue: @"a\fb" forKey: @"qux3"]; [types setLongLongValue: -0x10 forKey: @"integer"]; [types setUnsignedLongLongValue: 0x10 forKey: @"unsigned"]; [types setBoolValue: false forKey: @"bool"]; [types setFloatValue: 0.25f forKey: @"float"]; [types setDoubleValue: 0.75 forKey: @"double"]; [types setArrayValue: array forKey: @"array1"]; [foobar removeValueForKey: @"quxqux "]; [types removeValueForKey: @"array2"]; |
| ︙ | ︙ |
Changes to tests/testfile.ini.
| ︙ | ︙ | |||
11 12 13 14 15 16 17 | qux=" asd" "quxqux " = asd quxquxqux="hello\"wörld" qux2="a\n" "asd=asd"=foobar [types] | | > | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | qux=" asd" "quxqux " = asd quxquxqux="hello\"wörld" qux2="a\n" "asd=asd"=foobar [types] integer = -0x20 unsigned = 0x20 bool = true float = 0.5 array1 = 1 array2 = 1 double = 0.25 array1 = 2 array2 = 2 |