Function from_chars

Summary

#include <src/c4/base64.hpp>

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

#include <src/c4/format.hpp>

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

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

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

(4) 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 91-94 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/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 37-47 in src/c4/format.cpp. Line 350 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 352-355 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