Function from_chars

Summary

#include <src/c4/base64.hpp>

(1) size_t from_chars(csubstr buf, fmt::base64_wrapper *b)

#include <src/c4/charconv.hpp>

(2) C4_ALWAYS_INLINE bool from_chars(csubstr buf, uint8_t *C4_RESTRICT v)

(3) C4_ALWAYS_INLINE bool from_chars(csubstr buf, uint16_t *C4_RESTRICT v)

(4) C4_ALWAYS_INLINE bool from_chars(csubstr buf, uint32_t *C4_RESTRICT v)

(5) C4_ALWAYS_INLINE bool from_chars(csubstr buf, uint64_t *C4_RESTRICT v)

(6) C4_ALWAYS_INLINE bool from_chars(csubstr buf, int8_t *C4_RESTRICT v)

(7) C4_ALWAYS_INLINE bool from_chars(csubstr buf, int16_t *C4_RESTRICT v)

(8) C4_ALWAYS_INLINE bool from_chars(csubstr buf, int32_t *C4_RESTRICT v)

(9) C4_ALWAYS_INLINE bool from_chars(csubstr buf, int64_t *C4_RESTRICT v)

(10) C4_ALWAYS_INLINE bool from_chars(csubstr buf, float *C4_RESTRICT v)

(11) C4_ALWAYS_INLINE bool from_chars(csubstr buf, double *C4_RESTRICT v)

(12) template <class T>
     C4_ALWAYS_INLINE bool from_chars(csubstr buf, T **v)

(13) bool from_chars(csubstr buf, bool *C4_RESTRICT v)

(14) bool from_chars(csubstr buf, char *C4_RESTRICT v)

(15) bool from_chars(csubstr buf, csubstr *C4_RESTRICT v)

(16) bool from_chars(csubstr buf, substr *C4_RESTRICT v)

#include <src/c4/format.hpp>

(17) bool from_chars(csubstr buf, fmt::raw_wrapper *r)

(18) bool from_chars(csubstr buf, fmt::raw_wrapper r)

#include <src/c4/std/string.hpp>

(19) bool from_chars(c4::csubstr buf, std::string *s)

Function overload

Synopsis

#include <src/c4/base64.hpp>

size_t from_chars(csubstr buf, fmt::base64_wrapper *b)

Description

read a variable in base64 format

Mentioned in

Source

Lines 80-83 in src/c4/base64.hpp.

inline size_t from_chars(csubstr buf, fmt::base64_wrapper *b)
{
    return base64_decode(buf, b->data);
}

Synopsis

#include <src/c4/charconv.hpp>

C4_ALWAYS_INLINE bool from_chars(csubstr buf, uint8_t *C4_RESTRICT v)

Description

No description yet.

Mentioned in

Source

Lines 1289-1289 in src/c4/charconv.hpp.

C4_ALWAYS_INLINE bool from_chars(csubstr buf,  uint8_t *C4_RESTRICT v) { return atou(buf, v); }

Synopsis

#include <src/c4/charconv.hpp>

C4_ALWAYS_INLINE bool from_chars(csubstr buf, uint16_t *C4_RESTRICT v)

Description

No description yet.

Mentioned in

Source

Lines 1290-1290 in src/c4/charconv.hpp.

C4_ALWAYS_INLINE bool from_chars(csubstr buf, uint16_t *C4_RESTRICT v) { return atou(buf, v); }

Synopsis

#include <src/c4/charconv.hpp>

C4_ALWAYS_INLINE bool from_chars(csubstr buf, uint32_t *C4_RESTRICT v)

Description

No description yet.

Mentioned in

Source

Lines 1291-1291 in src/c4/charconv.hpp.

C4_ALWAYS_INLINE bool from_chars(csubstr buf, uint32_t *C4_RESTRICT v) { return atou(buf, v); }

Synopsis

#include <src/c4/charconv.hpp>

C4_ALWAYS_INLINE bool from_chars(csubstr buf, uint64_t *C4_RESTRICT v)

Description

No description yet.

Mentioned in

Source

Lines 1292-1292 in src/c4/charconv.hpp.

C4_ALWAYS_INLINE bool from_chars(csubstr buf, uint64_t *C4_RESTRICT v) { return atou(buf, v); }

Synopsis

#include <src/c4/charconv.hpp>

C4_ALWAYS_INLINE bool from_chars(csubstr buf, int8_t *C4_RESTRICT v)

Description

No description yet.

Mentioned in

Source

Lines 1293-1293 in src/c4/charconv.hpp.

C4_ALWAYS_INLINE bool from_chars(csubstr buf,   int8_t *C4_RESTRICT v) { return atoi(buf, v); }

Synopsis

#include <src/c4/charconv.hpp>

C4_ALWAYS_INLINE bool from_chars(csubstr buf, int16_t *C4_RESTRICT v)

Description

No description yet.

Mentioned in

Source

Lines 1294-1294 in src/c4/charconv.hpp.

C4_ALWAYS_INLINE bool from_chars(csubstr buf,  int16_t *C4_RESTRICT v) { return atoi(buf, v); }

Synopsis

#include <src/c4/charconv.hpp>

C4_ALWAYS_INLINE bool from_chars(csubstr buf, int32_t *C4_RESTRICT v)

Description

No description yet.

Mentioned in

Source

Lines 1295-1295 in src/c4/charconv.hpp.

C4_ALWAYS_INLINE bool from_chars(csubstr buf,  int32_t *C4_RESTRICT v) { return atoi(buf, v); }

Synopsis

#include <src/c4/charconv.hpp>

C4_ALWAYS_INLINE bool from_chars(csubstr buf, int64_t *C4_RESTRICT v)

Description

No description yet.

Mentioned in

Source

Lines 1296-1296 in src/c4/charconv.hpp.

C4_ALWAYS_INLINE bool from_chars(csubstr buf,  int64_t *C4_RESTRICT v) { return atoi(buf, v); }

Synopsis

#include <src/c4/charconv.hpp>

C4_ALWAYS_INLINE bool from_chars(csubstr buf, float *C4_RESTRICT v)

Description

No description yet.

Mentioned in

Source

Lines 1297-1297 in src/c4/charconv.hpp.

C4_ALWAYS_INLINE bool from_chars(csubstr buf,    float *C4_RESTRICT v) { return atof(buf, v); }

Synopsis

#include <src/c4/charconv.hpp>

C4_ALWAYS_INLINE bool from_chars(csubstr buf, double *C4_RESTRICT v)

Description

No description yet.

Mentioned in

Source

Lines 1298-1298 in src/c4/charconv.hpp.

C4_ALWAYS_INLINE bool from_chars(csubstr buf,   double *C4_RESTRICT v) { return atod(buf, v); }

Synopsis

#include <src/c4/charconv.hpp>

template <class T>
C4_ALWAYS_INLINE bool from_chars(csubstr buf, T **v)

Description

No description yet.

Mentioned in

Source

Lines 1344-1344 in src/c4/charconv.hpp.

template <class T> C4_ALWAYS_INLINE bool   from_chars(csubstr buf, T **v) { return from_chars(buf, *v); }

Synopsis

#include <src/c4/charconv.hpp>

bool from_chars(csubstr buf, bool *C4_RESTRICT v)

Description

No description yet.

Mentioned in

Source

Lines 1374-1392 in src/c4/charconv.hpp.

inline bool from_chars(csubstr buf, bool * C4_RESTRICT v)
{
    if(buf == '0') { *v = false; return true; }
    else if(buf == '1') { *v = true; return true; }
    else if(buf == "false") { *v = false; return true; }
    else if(buf == "true") { *v = true; return true; }
    else if(buf == "False") { *v = false; return true; }
    else if(buf == "True") { *v = true; return true; }
    else if(buf == "FALSE") { *v = false; return true; }
    else if(buf == "TRUE") { *v = true; return true; }
    // fallback to c-style int bools
    int val = 0;
    bool ret = from_chars(buf, &val);
    if(C4_LIKELY(ret))
    {
        *v = (val != 0);
    }
    return ret;
}

Synopsis

#include <src/c4/charconv.hpp>

bool from_chars(csubstr buf, char *C4_RESTRICT v)

Description

extract a single character from a substring

Note
to extract a string instead and not just a single character, use the csubstr overload

Mentioned in

Source

Lines 1416-1421 in src/c4/charconv.hpp.

inline bool from_chars(csubstr buf, char * C4_RESTRICT v)
{
    if(buf.len != 1) return false;
    *v = buf[0];
    return true;
}

Synopsis

#include <src/c4/charconv.hpp>

bool from_chars(csubstr buf, csubstr *C4_RESTRICT v)

Description

No description yet.

Mentioned in

Source

Lines 1442-1446 in src/c4/charconv.hpp.

inline bool from_chars(csubstr buf, csubstr *C4_RESTRICT v)
{
    *v = buf;
    return true;
}

Synopsis

#include <src/c4/charconv.hpp>

bool from_chars(csubstr buf, substr *C4_RESTRICT v)

Description

No description yet.

Mentioned in

Source

Lines 1468-1479 in src/c4/charconv.hpp.

inline bool from_chars(csubstr buf, substr * C4_RESTRICT v)
{
    C4_ASSERT(!buf.overlaps(*v));
    if(buf.len <= v->len)
    {
        memcpy(v->str, buf.str, buf.len);
        v->len = buf.len;
        return true;
    }
    memcpy(v->str, buf.str, v->len);
    return false;
}

Synopsis

#include <src/c4/format.hpp>

bool from_chars(csubstr buf, fmt::raw_wrapper *r)

Description

read a variable in raw binary format, using memcpy

Mentioned in

Source

Lines 35-45 in src/c4/format.cpp. Line 339 in src/c4/format.hpp.

bool from_chars(csubstr buf, fmt::raw_wrapper *r)
{
    void * vptr = (void*)buf.str;
    size_t space = buf.len;
    auto ptr = (decltype(buf.str)) std::align(r->alignment, r->len, vptr, space);
    C4_CHECK(ptr != nullptr);
    C4_CHECK(ptr >= buf.begin() && ptr <= buf.end());
    //size_t dim = (ptr - buf.str) + r->len;
    memcpy(r->buf, ptr, r->len);
    return true;
}

Synopsis

#include <src/c4/format.hpp>

bool from_chars(csubstr buf, fmt::raw_wrapper r)

Description

read a variable in raw binary format, using memcpy

Mentioned in

Source

Lines 341-344 in src/c4/format.hpp.

inline bool from_chars(csubstr buf, fmt::raw_wrapper r)
{
    return from_chars(buf, &r);
}

Synopsis

#include <src/c4/std/string.hpp>

bool from_chars(c4::csubstr buf, std::string *s)

Description

copy a string view to an existing std::string

Mentioned in

Source

Lines 56-62 in src/c4/std/string.hpp.

inline bool from_chars(c4::csubstr buf, std::string * s)
{
    s->resize(buf.len);
    C4_ASSERT(!buf.overlaps(to_csubstr(*s)));
    memcpy(&(*s)[0], buf.str, buf.len);
    return true;
}





Add Discussion as Guest

Log in