Debian Codegraph @

src/kj/parse/char.c++

raw symbols SCIP
1 // Copyright (c) 2013-2014 Sandstorm Development Group, Inc. and contributorscxx . . $ `<file>/src/kj/parse/char.c++`/
2 // Licensed under the MIT License:
3 //
4 // Permission is hereby granted, free of charge, to any person obtaining a copy
5 // of this software and associated documentation files (the "Software"), to deal
6 // in the Software without restriction, including without limitation the rights
7 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 // copies of the Software, and to permit persons to whom the Software is
9 // furnished to do so, subject to the following conditions:
10 //
11 // The above copyright notice and this permission notice shall be included in
12 // all copies or substantial portions of the Software.
13 //
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 // THE SOFTWARE.
21
22 #include "char.h"cxx . . $ `<file>/src/kj/parse/char.h`/
23 #include "../debug.h"cxx . . $ `<file>/src/kj/debug.h`/
24 #include <stdlib.h>
25
26 namespace kjcxx . . $ kj/ {
27 namespace parsecxx . . $ kj/parse/ {
28
29 namespace _cxx . . $ kj/parse/_/ { // private
30
31 double ParseFloatcxx . . $ kj/parse/_/ParseFloat#::operatorcxx . . $ kj/parse/_/ParseFloat#`operator()`(79d4433aeecf6f69).()(const Arraycxx . . $ kj/Array#<char>& digits,
32 const Maybecxx . . $ kj/Maybe#<Arraycxx . . $ kj/Array#<char>>& fraction,
33 const Maybecxx . . $ kj/Maybe#<Tuplecxx . . $ kj/Tuple#<Maybecxx . . $ kj/Maybe#<char>, Arraycxx . . $ kj/Array#<char>>>& exponent) const {
34 size_t bufSize = digits.sizecxx . . $ kj/Array#size(fe4d2d262d4164a8).();
35 KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(f, fraction) {
36 bufSize += 1 + f->sizecxx . . $ kj/Array#size(fe4d2d262d4164a8).();
37 }
38 KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(e, exponent) {
39 bufSize += 1 + (getcxx . . $ kj/get(66110fd16b6dabf3).<0>(*e) !=cxx . . $ kj/Maybe#`operator!=`(b102b25da64d45e5). nullptr) + getcxx . . $ kj/get(66110fd16b6dabf3).<1>(*e).sizecxx . . $ kj/Array#size(fe4d2d262d4164a8).();
40 }
41
42 KJ_STACK_ARRAYcxx . . $ `src/kj/common.h:406:9`!(char, buf, bufSize + 1, 128, 128);
43
44 char* pos = buf.begincxx . . $ kj/ArrayPtr#begin(155dc7f103cdb9db).();
45 memcpy(pos, digits.begincxx . . $ kj/Array#begin(1016ee5406d91ab9).(), digits.sizecxx . . $ kj/Array#size(fe4d2d262d4164a8).());
46 pos += digits.sizecxx . . $ kj/Array#size(fe4d2d262d4164a8).();
47 KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(f, fraction) {
48 *pos++ = '.';
49 memcpy(pos, f->begincxx . . $ kj/Array#begin(1016ee5406d91ab9).(), f->sizecxx . . $ kj/Array#size(fe4d2d262d4164a8).());
50 pos += f->sizecxx . . $ kj/Array#size(fe4d2d262d4164a8).();
51 }
52 KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(e, exponent) {
53 *pos++ = 'e';
54 KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(sign, get<0>(*e)) {
55 *pos++ = *sign;
56 }
57 memcpy(pos, getcxx . . $ kj/get(66110fd16b6dabf3).<1>(*e).begincxx . . $ kj/Array#begin(1016ee5406d91ab9).(), getcxx . . $ kj/get(66110fd16b6dabf3).<1>(*e).sizecxx . . $ kj/Array#size(fe4d2d262d4164a8).());
58 pos += getcxx . . $ kj/get(66110fd16b6dabf3).<1>(*e).sizecxx . . $ kj/Array#size(fe4d2d262d4164a8).();
59 }
60
61 *pos++ = '\0';
62 KJ_DASSERTcxx . . $ `src/kj/debug.h:372:9`!(pos == buf.end());
63
64 // The above construction should always produce a valid double, so this should never throw...
65 return StringPtrcxx . . $ kj/StringPtr#StringPtr(7cafb6e0818eff3b).(buf.begincxx . . $ kj/ArrayPtr#begin(155dc7f103cdb9db).(), bufSize).parseAscxx . . $ kj/StringPtr#parseAs(21b6c25e127938e2).<double>();
66 }
67
68 } // namespace _ (private)
69
70 } // namespace parse
71 } // namespace kj