Overview
Comment: | Add -[OFString octalValue] |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
6ea8c2f107d7951bda8dad4289e7dbea |
User & Date: | js on 2016-05-22 17:38:56 |
Other Links: | manifest | tags |
Context
2016-05-22
| ||
17:51 | objfw-config.in: Remove @NO_WARN_UNUSED@ check-in: 286c1afb46 user: js tags: trunk | |
17:38 | Add -[OFString octalValue] check-in: 6ea8c2f107 user: js tags: trunk | |
16:14 | OFHash: Remove method obsoleted by property check-in: 14117d73d7 user: js tags: trunk | |
Changes
Modified src/OFConstantString.m from [3401be807a] to [25ba828e39].
︙ | ︙ | |||
545 546 547 548 549 550 551 552 553 554 555 556 557 558 | - (uintmax_t)hexadecimalValue { [self finishInitialization]; return [self hexadecimalValue]; } - (float)floatValue { [self finishInitialization]; return [self floatValue]; } | > > > > > > > | 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 | - (uintmax_t)hexadecimalValue { [self finishInitialization]; return [self hexadecimalValue]; } - (uintmax_t)octalValue { [self finishInitialization]; return [self octalValue]; } - (float)floatValue { [self finishInitialization]; return [self floatValue]; } |
︙ | ︙ |
Modified src/OFString.h from [f6c039afa4] to [f7188a0160].
︙ | ︙ | |||
948 949 950 951 952 953 954 | * standardization of paths that are part of a URL. * * @return The URL path with relative sub paths resolved */ - (OFString*)stringByStandardizingURLPath; /*! | | | | | | | > > > > > > > > > > > > > > > | | | | | | 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 | * standardization of paths that are part of a URL. * * @return The URL path with relative sub paths resolved */ - (OFString*)stringByStandardizingURLPath; /*! * @brief Returns the decimal value of the string as an `intmax_t`. * * Leading and trailing whitespaces are ignored. * * If the string contains any non-number characters, an * @ref OFInvalidEncodingException is thrown. * * If the number is too big to fit into an `intmax_t`, an * @ref OFOutOfRangeException is thrown. * * @return An `intmax_t` with the value of the string */ - (intmax_t)decimalValue; /*! * @brief Returns the hexadecimal value of the string as an `uintmax_t`. * * Leading and trailing whitespaces are ignored. * * If the string contains any non-number characters, an * @ref OFInvalidEncodingException is thrown. * * If the number is too big to fit into an `uintmax_t`, an * @ref OFOutOfRangeException is thrown. * * @return A `uintmax_t` with the value of the string */ - (uintmax_t)hexadecimalValue; /*! * @brief Returns the octal value of the string as an `uintmax_t`. * * Leading and trailing whitespaces are ignored. * * If the string contains any non-number characters, an * @ref OFInvalidEncodingException is thrown. * * If the number is too big to fit into an `uintmax_t`, an * @ref OFOutOfRangeException is thrown. * * @return A `uintmax_t` with the value of the string */ - (uintmax_t)octalValue; /*! * @brief Returns the float value of the string as a float. * * If the string contains any non-number characters, an * OFInvalidEncodingException is thrown. * |
︙ | ︙ |
Modified src/OFString.m from [b978deee43] to [0f58946fa2].
︙ | ︙ | |||
2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 | @throw [OFOutOfRangeException exception]; value = newValue; } if (!foundValue) @throw [OFInvalidFormatException exception]; objc_autoreleasePoolPop(pool); return value; } - (float)floatValue | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 | @throw [OFOutOfRangeException exception]; value = newValue; } if (!foundValue) @throw [OFInvalidFormatException exception]; objc_autoreleasePoolPop(pool); return value; } - (uintmax_t)octalValue { void *pool = objc_autoreleasePoolPush(); const of_unichar_t *characters = [self characters]; size_t i = 0, length = [self length]; uintmax_t value = 0; bool expectWhitespace = false; while (length > 0 && (*characters == ' ' || *characters == '\t' || *characters == '\n' || *characters == '\r' || *characters == '\f')) { characters++; length--; } if (length == 0) { objc_autoreleasePoolPop(pool); return 0; } for (; i < length; i++) { uintmax_t newValue; if (expectWhitespace) { if (characters[i] != ' ' && characters[i] != '\t' && characters[i] != '\n' && characters[i] != '\r' && characters[i] != '\f') @throw [OFInvalidFormatException exception]; continue; } if (characters[i] >= '0' && characters[i] <= '7') newValue = (value << 3) | (characters[i] - '0'); else if (characters[i] == ' ' || characters[i] == '\t' || characters[i] == '\n' || characters[i] == '\r' || characters[i] == '\f') { expectWhitespace = true; continue; } else @throw [OFInvalidFormatException exception]; if (newValue < value) @throw [OFOutOfRangeException exception]; value = newValue; } objc_autoreleasePoolPop(pool); return value; } - (float)floatValue |
︙ | ︙ |
Modified tests/OFStringTests.m from [81aaac2175] to [a324e7bfdc].
︙ | ︙ | |||
440 441 442 443 444 445 446 447 448 449 450 451 452 453 | [@"123f" hexadecimalValue] == 0x123f && [@"\t\n0xABcd\r" hexadecimalValue] == 0xABCD && [@" xbCDE" hexadecimalValue] == 0xBCDE && [@"$CdEf" hexadecimalValue] == 0xCDEF && [@"\rFeh " hexadecimalValue] == 0xFE && [@"\r\t" hexadecimalValue] == 0) /* * These test numbers can be generated without rounding if we have IEEE * floating point numbers, thus we can use == on them. */ TEST(@"-[floatValue]", [@"\t-0.25 " floatValue] == -0.25 && [@"\r-INFINITY\n" floatValue] == -INFINITY && | > > > > > > | 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 | [@"123f" hexadecimalValue] == 0x123f && [@"\t\n0xABcd\r" hexadecimalValue] == 0xABCD && [@" xbCDE" hexadecimalValue] == 0xBCDE && [@"$CdEf" hexadecimalValue] == 0xCDEF && [@"\rFeh " hexadecimalValue] == 0xFE && [@"\r\t" hexadecimalValue] == 0) TEST(@"-[octalValue]", [@"1234567" octalValue] == 01234567 && [@"\r\n123" octalValue] == 0123 && [@"765\t" octalValue] == 0765 && [@"\t\t\r\n" octalValue] == 0) /* * These test numbers can be generated without rounding if we have IEEE * floating point numbers, thus we can use == on them. */ TEST(@"-[floatValue]", [@"\t-0.25 " floatValue] == -0.25 && [@"\r-INFINITY\n" floatValue] == -INFINITY && |
︙ | ︙ |