VTK  9.3.20240329
Macros | Functions
vtkValueFromString.h File Reference
#include "vtkCommonCoreModule.h"
#include "vtkWrappingHints.h"
#include <cstdlib>
Include dependency graph for vtkValueFromString.h:

Go to the source code of this file.

Macros

#define DECLARE_FROMSTRING_EXTERN_TEMPLATE(type)
 

Functions

template<typename T >
VTK_WRAPEXCLUDE std::size_t vtkValueFromString (const char *begin, const char *end, T &output) noexcept
 Low-level function to convert a string to ints, floats or bools. More...
 
 DECLARE_FROMSTRING_EXTERN_TEMPLATE (signed char)
 
 DECLARE_FROMSTRING_EXTERN_TEMPLATE (unsigned char)
 
 DECLARE_FROMSTRING_EXTERN_TEMPLATE (short)
 
 DECLARE_FROMSTRING_EXTERN_TEMPLATE (unsigned short)
 
 DECLARE_FROMSTRING_EXTERN_TEMPLATE (int)
 
 DECLARE_FROMSTRING_EXTERN_TEMPLATE (unsigned int)
 
 DECLARE_FROMSTRING_EXTERN_TEMPLATE (long)
 
 DECLARE_FROMSTRING_EXTERN_TEMPLATE (unsigned long)
 
 DECLARE_FROMSTRING_EXTERN_TEMPLATE (long long)
 
 DECLARE_FROMSTRING_EXTERN_TEMPLATE (unsigned long long)
 
 DECLARE_FROMSTRING_EXTERN_TEMPLATE (float)
 
 DECLARE_FROMSTRING_EXTERN_TEMPLATE (double)
 
 DECLARE_FROMSTRING_EXTERN_TEMPLATE (bool)
 

Macro Definition Documentation

◆ DECLARE_FROMSTRING_EXTERN_TEMPLATE

#define DECLARE_FROMSTRING_EXTERN_TEMPLATE (   type)
Value:
extern template VTKCOMMONCORE_EXPORT std::size_t vtkValueFromString<type>( \
const char* begin, const char* end, type&) noexcept
@ type
Definition: vtkX3D.h:516

Definition at line 63 of file vtkValueFromString.h.

Function Documentation

◆ vtkValueFromString()

template<typename T >
VTK_WRAPEXCLUDE std::size_t vtkValueFromString ( const char *  begin,
const char *  end,
T &  output 
)
noexcept

Low-level function to convert a string to ints, floats or bools.

This function is the low-level high-performance parsing function. This function does not trim any data from input before parsing.

Supported types are signed char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, long long, unsigned long long, float, double, bool.


signed char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, long long and unsigned long long parsing support decimal, hexadecimal (0x{value} or 0X{value}), octal (0o{value} or 0O{value}) and binary (0b{value} or 0B{value}) integers. Overflow will return an error.

Limitations:

  • When parsing a hexadecimal, octal or binary number, if a leading - is parsed, it will return an error. When parsing a signed type, hexadecimal, octal or binary number parsing uses the unsigned variant of the type, then reinterpreted to the signed type. For example parsing "0xFF" to a int8_t will parse -1.
  • Octal old format (0{value}) is not supported.
  • When parsing a unsigned type, if a leading - is parsed, it will return an error.
  • Leading + is not supported and will return an error.

float, double parsing always uses '.' as separator of the integer and decimal part of a number. Scientific format is supported, both e and E are supported. nan and [-]inf are supported and case insensitive.

Limitations:

  • Leading + is not supported and will return an error.

bool parsing supports the following syntaxes: "0", "1", "false", "False", "true" and "True".

Parameters
beginBegin of the range to convert
endEnd of the range to convert
outputVariable to write output to. If parsing failed, output is left unmodified.
Returns
The number of consumed characters. 0 is returned to indicate failure, or empty range. If 0 is returned, output is not modified, otherwise it contains the parsed value.

◆ DECLARE_FROMSTRING_EXTERN_TEMPLATE() [1/13]

DECLARE_FROMSTRING_EXTERN_TEMPLATE ( signed char  )

◆ DECLARE_FROMSTRING_EXTERN_TEMPLATE() [2/13]

DECLARE_FROMSTRING_EXTERN_TEMPLATE ( unsigned char  )

◆ DECLARE_FROMSTRING_EXTERN_TEMPLATE() [3/13]

DECLARE_FROMSTRING_EXTERN_TEMPLATE ( short  )

◆ DECLARE_FROMSTRING_EXTERN_TEMPLATE() [4/13]

DECLARE_FROMSTRING_EXTERN_TEMPLATE ( unsigned short  )

◆ DECLARE_FROMSTRING_EXTERN_TEMPLATE() [5/13]

DECLARE_FROMSTRING_EXTERN_TEMPLATE ( int  )

◆ DECLARE_FROMSTRING_EXTERN_TEMPLATE() [6/13]

DECLARE_FROMSTRING_EXTERN_TEMPLATE ( unsigned int  )

◆ DECLARE_FROMSTRING_EXTERN_TEMPLATE() [7/13]

DECLARE_FROMSTRING_EXTERN_TEMPLATE ( long  )

◆ DECLARE_FROMSTRING_EXTERN_TEMPLATE() [8/13]

DECLARE_FROMSTRING_EXTERN_TEMPLATE ( unsigned long  )

◆ DECLARE_FROMSTRING_EXTERN_TEMPLATE() [9/13]

DECLARE_FROMSTRING_EXTERN_TEMPLATE ( long long  )

◆ DECLARE_FROMSTRING_EXTERN_TEMPLATE() [10/13]

DECLARE_FROMSTRING_EXTERN_TEMPLATE ( unsigned long long  )

◆ DECLARE_FROMSTRING_EXTERN_TEMPLATE() [11/13]

DECLARE_FROMSTRING_EXTERN_TEMPLATE ( float  )

◆ DECLARE_FROMSTRING_EXTERN_TEMPLATE() [12/13]

DECLARE_FROMSTRING_EXTERN_TEMPLATE ( double  )

◆ DECLARE_FROMSTRING_EXTERN_TEMPLATE() [13/13]

DECLARE_FROMSTRING_EXTERN_TEMPLATE ( bool  )