Audacity 3.2.0
Classes | Functions
FromChars.h File Reference

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

#include <system_error>
Include dependency graph for FromChars.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  FromCharsResult
 Result of the conversion, similar to std::from_chars_result. More...
 

Functions

STRING_UTILS_API 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...
 
STRING_UTILS_API 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...
 
STRING_UTILS_API FromCharsResult FromChars (const char *buffer, const char *last, short &value) noexcept
 Parse a string into a signed 16-bit integer value. More...
 
STRING_UTILS_API FromCharsResult FromChars (const char *buffer, const char *last, unsigned short &value) noexcept
 Parse a string into an unsigned 16-bit integer value. More...
 
STRING_UTILS_API FromCharsResult FromChars (const char *buffer, const char *last, int &value) noexcept
 Parse a string into a signed 32-bit integer value. More...
 
STRING_UTILS_API FromCharsResult FromChars (const char *buffer, const char *last, unsigned int &value) noexcept
 Parse a string into an unsigned 32-bit integer value. More...
 
STRING_UTILS_API FromCharsResult FromChars (const char *buffer, const char *last, long &value) noexcept
 Parse a string into a signed long integer value. More...
 
STRING_UTILS_API FromCharsResult FromChars (const char *buffer, const char *last, unsigned long &value) noexcept
 Parse a string into an unsigned long integer value. More...
 
STRING_UTILS_API FromCharsResult FromChars (const char *buffer, const char *last, long long &value) noexcept
 Parse a string into a signed 64-bit integer value. More...
 
STRING_UTILS_API FromCharsResult FromChars (const char *buffer, const char *last, unsigned long long &value) noexcept
 Parse a string into an unsigned 64-bit integer value. More...
 
STRING_UTILS_API 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

Declare functions to convert numeric types to string representation.


Audacity: A Digital Audio Editor

Dmitry Vedenko

Definition in file FromChars.h.

Function Documentation

◆ FromChars() [1/11]

STRING_UTILS_API 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 206 of file FromChars.cpp.

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

◆ FromChars() [2/11]

STRING_UTILS_API 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 159 of file FromChars.cpp.

160{
161 const auto result = fast_float::from_chars(buffer, last, value);
162 return { result.ptr, result.ec };
163}
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]

STRING_UTILS_API 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 153 of file FromChars.cpp.

154{
155 const auto result = fast_float::from_chars(buffer, last, value);
156 return { result.ptr, result.ec };
157}

References fast_float::from_chars().

Referenced by anonymous_namespace{ImportMP3_MPG123.cpp}::GetId3v2Genre(), ProjectFileIO::GetValue(), audacity::cloud::audiocom::sync::anonymous_namespace{WavPackCompressor.cpp}::Importer::Importer(), audacity::cloud::audiocom::sync::anonymous_namespace{ResumedSnaphotUploadOperation.cpp}::IsUrlExpired(), XMLAttributeValueView::TryGet(), and XMLAttributeValueView::TryGetInteger().

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

◆ FromChars() [4/11]

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

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

Definition at line 175 of file FromChars.cpp.

176{
177 return IntFromChars(buffer, last, value);
178}
FromCharsResult IntFromChars(const char *buffer, const char *last, ResultType &value) noexcept
Definition: FromChars.cpp:126

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

Here is the call graph for this function:

◆ FromChars() [5/11]

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

Parse a string into a signed long integer value.

Definition at line 185 of file FromChars.cpp.

186{
187 return IntFromChars(buffer, last, value);
188}

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

Here is the call graph for this function:

◆ FromChars() [6/11]

STRING_UTILS_API 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 195 of file FromChars.cpp.

196{
197 return IntFromChars(buffer, last, value);
198}

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

Here is the call graph for this function:

◆ FromChars() [7/11]

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

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

Definition at line 165 of file FromChars.cpp.

166{
167 return IntFromChars(buffer, last, value);
168}

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

Here is the call graph for this function:

◆ FromChars() [8/11]

STRING_UTILS_API 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 180 of file FromChars.cpp.

181{
182 return IntFromChars(buffer, last, value);
183}

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

Here is the call graph for this function:

◆ FromChars() [9/11]

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

Parse a string into an unsigned long integer value.

Definition at line 190 of file FromChars.cpp.

191{
192 return IntFromChars(buffer, last, value);
193}

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

Here is the call graph for this function:

◆ FromChars() [10/11]

STRING_UTILS_API 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 200 of file FromChars.cpp.

201{
202 return IntFromChars(buffer, last, value);
203}

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

Here is the call graph for this function:

◆ FromChars() [11/11]

STRING_UTILS_API 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 170 of file FromChars.cpp.

171{
172 return IntFromChars(buffer, last, value);
173}

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

Here is the call graph for this function: