PLYwoot
Header-only C++17 library for parsing and writing PLY files
Loading...
Searching...
No Matches
std.hpp File Reference
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <iterator>
#include <sstream>
#include <string>

Go to the source code of this file.

Functions

template<typename Ptr >
constexpr Ptr plywoot::detail::align (Ptr ptr, std::size_t alignment)
 
template<>
constexpr std::size_t plywoot::detail::align (std::size_t ptr, std::size_t alignment)
 
template<typename Number >
Number plywoot::detail::to_number (const char *first, const char *last, const char **end)
 
template<>
float plywoot::detail::to_number (const char *first, const char *last, const char **end)
 
template<>
double plywoot::detail::to_number< double > (const char *first, const char *last, const char **end)
 
bool plywoot::detail::starts_with (const std::string &s, const char *prefix)
 
template<typename T >
std::string plywoot::detail::to_string (const T &t)
 

Function Documentation

◆ align() [1/2]

template<typename Ptr >
constexpr Ptr plywoot::detail::align ( Ptr  ptr,
std::size_t  alignment 
)
constexpr

Aligns the given input pointer. Implementation is taken from GCCs std::align implementation. The given alignment value should be a power of two.

Parameters
ptrpointer to align
alignmentalignment requirements of the given pointer
Returns
ptr aligned according to the given alignment requirements

Definition at line 50 of file std.hpp.

◆ align() [2/2]

template<>
constexpr std::size_t plywoot::detail::align ( std::size_t  ptr,
std::size_t  alignment 
)
constexpr

Aligns the given input pointer. Implementation is taken from GCCs std::align implementation. The given alignment value should be a power of two.

Parameters
ptrpointer to align
alignmentalignment requirements of the given pointer
Returns
ptr aligned according to the given alignment requirements

Definition at line 69 of file std.hpp.

◆ starts_with()

bool plywoot::detail::starts_with ( const std::string &  s,
const char *  prefix 
)
inline

Returns whether the given string starts with the given prefix.

Parameters
sstring to check for the given prefix
prefixprefix text to find
Returns
true in case the given string starts with the given prefix, false otherwise

Definition at line 151 of file std.hpp.

◆ to_number() [1/2]

template<typename Number >
Number plywoot::detail::to_number ( const char *  first,
const char *  last,
const char **  end 
)
inline

Converts a text to an integer number. The fast_int library will be used to perform the conversion in case it was found during the configuration stage.

Template Parameters
Numberinteger number type
Parameters
firststart of the text range
lastend of the text range
endposition in the text range that denotes the end of the number text
Returns
converted integer number

Definition at line 90 of file std.hpp.

◆ to_number() [2/2]

template<>
float plywoot::detail::to_number ( const char *  first,
const char *  last,
const char **  end 
)
inline

Converts a text to a single precision floating point number. The fast_float library will be used to perform the conversion in case it was found during the configuration stage.

Parameters
firststart of the text range
lastend of the text range
endposition in the text range that denotes the end of the number text
Returns
converted single precision floating point number

Definition at line 112 of file std.hpp.

◆ to_number< double >()

template<>
double plywoot::detail::to_number< double > ( const char *  first,
const char *  last,
const char **  end 
)
inline

Converts a text to a double precision floating point number. The fast_float library will be used to perform the conversion in case it was found during the configuration stage.

Parameters
firststart of the text range
lastend of the text range
endposition in the text range that denotes the end of the number text
Returns
converted double precision floating point number

Definition at line 134 of file std.hpp.

◆ to_string()

template<typename T >
std::string plywoot::detail::to_string ( const T &  t)

Generic type to string conversion functionality, requiring that an std::ostream << operator is defined for the type. This should only be used in contexts where performance does not matter.

Parameters
tobject to convert to string
Returns
t converted to string

Definition at line 160 of file std.hpp.