Audacity 3.2.0
Namespaces | Functions
FromChars.cpp File Reference

Define functions to convert numeric types to string representation. More...

#include "FromChars.h"
#include "3party/fast_float.h"
#include <limits>
#include <algorithm>
Include dependency graph for FromChars.cpp:

Go to the source code of this file.

Namespaces

namespace  anonymous_namespace{FromChars.cpp}
 

Functions

unsigned anonymous_namespace{FromChars.cpp}::digitToInt (char c) noexcept
 
template<typename T >
bool anonymous_namespace{FromChars.cpp}::safeMul10Add (T &result, T a, T b)
 
template<typename ResultType >
FromCharsResult anonymous_namespace{FromChars.cpp}::FastStringToInt (const char *first, const char *last, ResultType &value, bool isNegative) noexcept
 
template<typename ResultType >
FromCharsResult anonymous_namespace{FromChars.cpp}::IntFromChars (const char *buffer, const char *last, ResultType &value) noexcept
 
FromCharsResult FromChars (const char *buffer, const char *last, float &value) noexcept
 Parse a string into a single precision floating point value, always uses the dot as decimal. More...
 
FromCharsResult FromChars (const char *buffer, const char *last, double &value) noexcept
 Parse a string into a single precision floating point value, always uses the dot as decimal. More...
 
FromCharsResult FromChars (const char *buffer, const char *last, short &value) noexcept
 Parse a string into a signed 16-bit integer value. More...
 
FromCharsResult FromChars (const char *buffer, const char *last, unsigned short &value) noexcept
 Parse a string into an unsigned 16-bit integer value. More...
 
FromCharsResult FromChars (const char *buffer, const char *last, int &value) noexcept
 Parse a string into a signed 32-bit integer value. More...
 
FromCharsResult FromChars (const char *buffer, const char *last, unsigned int &value) noexcept
 Parse a string into an unsigned 32-bit integer value. More...
 
FromCharsResult FromChars (const char *buffer, const char *last, long &value) noexcept
 Parse a string into a signed long integer value. More...
 
FromCharsResult FromChars (const char *buffer, const char *last, unsigned long &value) noexcept
 Parse a string into an unsigned long integer value. More...
 
FromCharsResult FromChars (const char *buffer, const char *last, long long &value) noexcept
 Parse a string into a signed 64-bit integer value. More...
 
FromCharsResult FromChars (const char *buffer, const char *last, unsigned long long &value) noexcept
 Parse a string into an unsigned 64-bit integer value. More...
 
FromCharsResult FromChars (const char *buffer, const char *last, bool &value) noexcept
 Parse a string into a boolean value. String must be "0" or "1". More...
 

Detailed Description

Define functions to convert numeric types to string representation.


Audacity: A Digital Audio Editor

Dmitry Vedenko

Definition in file FromChars.cpp.

Function Documentation

◆ FromChars() [1/11]

FromCharsResult FromChars ( const char *  buffer,
const char *  last,
bool &  value 
)
noexcept

Parse a string into a boolean value. String must be "0" or "1".

Definition at line 203 of file FromChars.cpp.

204{
205 if (buffer >= last)
206 return { buffer, std::errc::invalid_argument };
207
208 if (buffer[0] == '0')
209 {
210 value = false;
211 return { buffer + 1, std::errc() };
212 }
213 else if (buffer[0] == '1')
214 {
215 value = true;
216 return { buffer + 1, std::errc() };
217 }
218
219 return { buffer, std::errc::invalid_argument };
220}

◆ FromChars() [2/11]

FromCharsResult FromChars ( const char *  buffer,
const char *  last,
double &  value 
)
noexcept

Parse a string into a single precision floating point value, always uses the dot as decimal.

Definition at line 156 of file FromChars.cpp.

157{
158 const auto result = fast_float::from_chars(buffer, last, value);
159 return { result.ptr, result.ec };
160}
from_chars_result from_chars(const char *first, const char *last, T &value, chars_format fmt=chars_format::general) noexcept
Definition: fast_float.h:2900

References fast_float::from_chars().

Here is the call graph for this function:

◆ FromChars() [3/11]

FromCharsResult FromChars ( const char *  buffer,
const char *  last,
float &  value 
)
noexcept

Parse a string into a single precision floating point value, always uses the dot as decimal.

Definition at line 150 of file FromChars.cpp.

151{
152 const auto result = fast_float::from_chars(buffer, last, value);
153 return { result.ptr, result.ec };
154}

References fast_float::from_chars().

Referenced by ProjectFileIO::GetValue(), XMLAttributeValueView::TryGet(), and XMLAttributeValueView::TryGetInteger().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FromChars() [4/11]

FromCharsResult FromChars ( const char *  buffer,
const char *  last,
int &  value 
)
noexcept

Parse a string into a signed 32-bit integer value.

Definition at line 172 of file FromChars.cpp.

173{
174 return IntFromChars(buffer, last, value);
175}
FromCharsResult IntFromChars(const char *buffer, const char *last, ResultType &value) noexcept
Definition: FromChars.cpp:123

References anonymous_namespace{FromChars.cpp}::IntFromChars().

Here is the call graph for this function:

◆ FromChars() [5/11]

FromCharsResult FromChars ( const char *  buffer,
const char *  last,
long &  value 
)
noexcept

Parse a string into a signed long integer value.

Definition at line 182 of file FromChars.cpp.

183{
184 return IntFromChars(buffer, last, value);
185}

References anonymous_namespace{FromChars.cpp}::IntFromChars().

Here is the call graph for this function:

◆ FromChars() [6/11]

FromCharsResult FromChars ( const char *  buffer,
const char *  last,
long long &  value 
)
noexcept

Parse a string into a signed 64-bit integer value.

Definition at line 192 of file FromChars.cpp.

193{
194 return IntFromChars(buffer, last, value);
195}

References anonymous_namespace{FromChars.cpp}::IntFromChars().

Here is the call graph for this function:

◆ FromChars() [7/11]

FromCharsResult FromChars ( const char *  buffer,
const char *  last,
short &  value 
)
noexcept

Parse a string into a signed 16-bit integer value.

Definition at line 162 of file FromChars.cpp.

163{
164 return IntFromChars(buffer, last, value);
165}

References anonymous_namespace{FromChars.cpp}::IntFromChars().

Here is the call graph for this function:

◆ FromChars() [8/11]

FromCharsResult FromChars ( const char *  buffer,
const char *  last,
unsigned int &  value 
)
noexcept

Parse a string into an unsigned 32-bit integer value.

Definition at line 177 of file FromChars.cpp.

178{
179 return IntFromChars(buffer, last, value);
180}

References anonymous_namespace{FromChars.cpp}::IntFromChars().

Here is the call graph for this function:

◆ FromChars() [9/11]

FromCharsResult FromChars ( const char *  buffer,
const char *  last,
unsigned long &  value 
)
noexcept

Parse a string into an unsigned long integer value.

Definition at line 187 of file FromChars.cpp.

188{
189 return IntFromChars(buffer, last, value);
190}

References anonymous_namespace{FromChars.cpp}::IntFromChars().

Here is the call graph for this function:

◆ FromChars() [10/11]

FromCharsResult FromChars ( const char *  buffer,
const char *  last,
unsigned long long &  value 
)
noexcept

Parse a string into an unsigned 64-bit integer value.

Definition at line 197 of file FromChars.cpp.

198{
199 return IntFromChars(buffer, last, value);
200}

References anonymous_namespace{FromChars.cpp}::IntFromChars().

Here is the call graph for this function:

◆ FromChars() [11/11]

FromCharsResult FromChars ( const char *  buffer,
const char *  last,
unsigned short &  value 
)
noexcept

Parse a string into an unsigned 16-bit integer value.

Definition at line 167 of file FromChars.cpp.

168{
169 return IntFromChars(buffer, last, value);
170}

References anonymous_namespace{FromChars.cpp}::IntFromChars().

Here is the call graph for this function: