JSON Voorhees
Killer JSON for C++
coerce.hpp File Reference

A jsonv::value has a number of as_X operators, which strictly performs a transformation to a C++ data type. More...

#include <jsonv/config.hpp>
#include <jsonv/value.hpp>
#include <map>
#include <vector>

Go to the source code of this file.

Functions

JSONV_PUBLIC bool jsonv::can_coerce (const kind &from, const kind &to)
 Can the given kind be converted from a kind to another? More...
 
JSONV_PUBLIC bool jsonv::can_coerce (const value &from, const kind &to)
 Can the given value be converted from a kind to another? More...
 
JSONV_PUBLIC std::nullptr_t jsonv::coerce_null (const value &from)
 Coerce from into a null. More...
 
JSONV_PUBLIC std::map< std::string, value > jsonv::coerce_object (const value &from)
 Coerce from into a map. More...
 
JSONV_PUBLIC std::vector< value > jsonv::coerce_array (const value &from)
 Coerce from into a vector. More...
 
JSONV_PUBLIC std::string jsonv::coerce_string (const value &from)
 Coerce from into an std::string. More...
 
JSONV_PUBLIC std::int64_t jsonv::coerce_integer (const value &from)
 Coerce from into an integer. More...
 
JSONV_PUBLIC double jsonv::coerce_decimal (const value &from)
 Coerce from into a double. More...
 
JSONV_PUBLIC bool jsonv::coerce_boolean (const value &from)
 Coerce from into a bool. More...
 
JSONV_PUBLIC value jsonv::coerce_merge (value a, value b)
 Combines a and b in any way possible. More...
 

Detailed Description

A jsonv::value has a number of as_X operators, which strictly performs a transformation to a C++ data type.

However, sometimes when working with things like user input, you would like to be more free-form in what you accept as "valid."

Copyright (c) 2014-2015 by Travis Gockel. All rights reserved.

This program is free software: you can redistribute it and/or modify it under the terms of the Apache License as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later version.

Author
Travis Gockel (travi.nosp@m.s@go.nosp@m.ckelh.nosp@m.ut.c.nosp@m.om)

Definition in file coerce.hpp.