| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* GATE PROJECT LICENSE: | ||
| 2 | +----------------------------------------------------------------------------+ | ||
| 3 | | Copyright(c) 2018-2025, Stefan Meislinger <sm@opengate.at> | | ||
| 4 | | All rights reserved. | | ||
| 5 | | | | ||
| 6 | | Redistribution and use in source and binary forms, with or without | | ||
| 7 | | modification, are permitted provided that the following conditions are met:| | ||
| 8 | | | | ||
| 9 | | 1. Redistributions of source code must retain the above copyright notice, | | ||
| 10 | | this list of conditions and the following disclaimer. | | ||
| 11 | | 2. Redistributions in binary form must reproduce the above copyright | | ||
| 12 | | notice, this list of conditions and the following disclaimer in the | | ||
| 13 | | documentation and/or other materials provided with the distribution. | | ||
| 14 | | | | ||
| 15 | | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"| | ||
| 16 | | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | | ||
| 17 | | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | ||
| 18 | | ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | | ||
| 19 | | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | ||
| 20 | | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | ||
| 21 | | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | ||
| 22 | | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | ||
| 23 | | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | ||
| 24 | | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | | ||
| 25 | | THE POSSIBILITY OF SUCH DAMAGE. | | ||
| 26 | +----------------------------------------------------------------------------+ | ||
| 27 | */ | ||
| 28 | |||
| 29 | #include "gate/numbers.hpp" | ||
| 30 | #include "gate/strings.h" | ||
| 31 | |||
| 32 | namespace gate | ||
| 33 | { | ||
| 34 | |||
| 35 | namespace numbers | ||
| 36 | { | ||
| 37 | 1 | String to_string(int8_t const& n) | |
| 38 | { | ||
| 39 | char buffer[16]; | ||
| 40 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | size_t len = gate_str_print_int16(buffer, sizeof(buffer), static_cast<int16_t>(n)); |
| 41 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | return String(buffer, len); |
| 42 | } | ||
| 43 | |||
| 44 | 1 | String to_string(int16_t const& n) | |
| 45 | { | ||
| 46 | char buffer[16]; | ||
| 47 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | size_t len = gate_str_print_int16(buffer, sizeof(buffer), n); |
| 48 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | return String(buffer, len); |
| 49 | } | ||
| 50 | |||
| 51 | 1 | String to_string(int32_t const& n) | |
| 52 | { | ||
| 53 | char buffer[32]; | ||
| 54 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | size_t len = gate_str_print_int32(buffer, sizeof(buffer), n); |
| 55 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | return String(buffer, len); |
| 56 | } | ||
| 57 | |||
| 58 | 1 | String to_string(int64_t const& n) | |
| 59 | { | ||
| 60 | char buffer[32]; | ||
| 61 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | size_t len = gate_str_print_int64(buffer, sizeof(buffer), n); |
| 62 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | return String(buffer, len); |
| 63 | } | ||
| 64 | |||
| 65 | 1 | String to_string(uint8_t const& n) | |
| 66 | { | ||
| 67 | char buffer[32]; | ||
| 68 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | size_t len = gate_str_print_uint16(buffer, sizeof(buffer), static_cast<uint16_t>(n)); |
| 69 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | return String(buffer, len); |
| 70 | } | ||
| 71 | |||
| 72 | 1 | String to_string(uint16_t const& n) | |
| 73 | { | ||
| 74 | char buffer[32]; | ||
| 75 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | size_t len = gate_str_print_uint16(buffer, sizeof(buffer), n); |
| 76 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | return String(buffer, len); |
| 77 | } | ||
| 78 | |||
| 79 | 76 | String to_string(uint32_t const& n) | |
| 80 | { | ||
| 81 | char buffer[32]; | ||
| 82 |
1/2✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
|
76 | size_t len = gate_str_print_uint32(buffer, sizeof(buffer), n); |
| 83 |
1/2✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
|
152 | return String(buffer, len); |
| 84 | } | ||
| 85 | |||
| 86 | 1 | String to_string(uint64_t const& n) | |
| 87 | { | ||
| 88 | char buffer[32]; | ||
| 89 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | size_t len = gate_str_print_uint64(buffer, sizeof(buffer), n); |
| 90 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | return String(buffer, len); |
| 91 | } | ||
| 92 | |||
| 93 | ✗ | String to_string(real32_t const& n, unsigned intlen, unsigned decimallen, unsigned grouplen) | |
| 94 | { | ||
| 95 | char buffer[64]; | ||
| 96 | ✗ | size_t len = gate_str_print_real(buffer, sizeof(buffer), n, intlen, decimallen, grouplen); | |
| 97 | ✗ | return String(buffer, len); | |
| 98 | } | ||
| 99 | |||
| 100 | 1 | String to_string(real64_t const& n, unsigned intlen, unsigned decimallen, unsigned grouplen) | |
| 101 | { | ||
| 102 | char buffer[64]; | ||
| 103 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | size_t len = gate_str_print_real(buffer, sizeof(buffer), n, intlen, decimallen, grouplen); |
| 104 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | return String(buffer, len); |
| 105 | } | ||
| 106 | } | ||
| 107 | |||
| 108 | |||
| 109 | } // end of namespace gate | ||
| 110 | |||
| 111 |