Skip to content

Commit

Permalink
Lighten semantic_tag names
Browse files Browse the repository at this point in the history
  • Loading branch information
danielaparker committed May 18, 2019
1 parent 11db194 commit 33a0e60
Show file tree
Hide file tree
Showing 44 changed files with 244 additions and 244 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ int main()
encoder.begin_array(3); // a fixed length array
encoder.string_value("foo");
encoder.byte_string_value(byte_string{'P','u','s','s'}); // no suggested conversion
encoder.big_integer_value("-18446744073709551617");
encoder.bigint_value("-18446744073709551617");
encoder.end_array();
encoder.end_array();
encoder.flush();
Expand Down Expand Up @@ -383,7 +383,7 @@ int main()
// Print JSON representation with different options
json_options options;
options.byte_string_format(byte_string_chars_format::base64)
.big_integer_format(big_integer_chars_format::base64url);
.bigint_format(bigint_chars_format::base64url);
std::cout << "(5)\n";
std::cout << pretty_print(j, options) << "\n\n";
Expand All @@ -392,7 +392,7 @@ int main()
json another_array = json::array();
another_array.emplace_back(byte_string({'P','u','s','s'}),
semantic_tag::base64); // suggested conversion to base64
another_array.emplace_back("273.15", semantic_tag::big_decimal);
another_array.emplace_back("273.15", semantic_tag::bigdec);
another_array.emplace(another_array.array_range().begin(),"bar"); // place at front
j.push_back(std::move(another_array));
Expand Down Expand Up @@ -514,11 +514,11 @@ int main()

j.emplace_back(0.000071);

j.emplace_back("-18446744073709551617",semantic_tag::big_integer);
j.emplace_back("-18446744073709551617",semantic_tag::bigint);

j.emplace_back("1.23456789012345678901234567890", semantic_tag::big_decimal);
j.emplace_back("1.23456789012345678901234567890", semantic_tag::bigdec);

j.emplace_back(json::array({-1,3}), semantic_tag::big_float);
j.emplace_back(json::array({-1,3}), semantic_tag::bigfloat);

// Encode to JSON
std::cout << "(1)\n";
Expand Down
8 changes: 4 additions & 4 deletions doc/Examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ json j = json::parse(is);
By default, jsoncons parses a number with an exponent or fractional part
into a double precision floating point number. If you wish, you can
keep the number as a string with semantic tagging `big_decimal`,
keep the number as a string with semantic tagging `bigdec`,
using the `lossless_number` option. You can then put it into a `float`,
`double`, a boost multiprecision number, or whatever other type you want.
Expand Down Expand Up @@ -898,7 +898,7 @@ namespace jsoncons
static bool is(const Json& val) noexcept
{
if (!(val.is_string() && val.semantic_tag() == semantic_tag::big_decimal))
if (!(val.is_string() && val.semantic_tag() == semantic_tag::bigdec))
{
return false;
}
Expand All @@ -915,7 +915,7 @@ namespace jsoncons
static Json to_json(multiprecision_type val)
{
return Json(val.str(), semantic_tag::big_decimal);
return Json(val.str(), semantic_tag::bigdec);
}
};
}
Expand Down Expand Up @@ -1295,7 +1295,7 @@ double price = j["price"].as<double>();
#### Retrieve a big integer that's been parsed as a string

If an integer exceeds the range of an `int64_t` or `uint64_t`, jsoncons parses it as a string
with semantic tagging `big_integer`.
with semantic tagging `bigint`.

```c++
#include <jsoncons/json.hpp>
Expand Down
14 changes: 7 additions & 7 deletions doc/ref/big_integer_chars_format.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
### jsoncons::big_integer_chars_format
### jsoncons::bigint_chars_format

```c++
enum class big_integer_chars_format : uint8_t {number, base10, base64, base64url};
enum class bigint_chars_format : uint8_t {number, base10, base64, base64url};
```
#### Header
Expand Down Expand Up @@ -32,19 +32,19 @@ int main()

std::cout << "(integer) ";
json_options options1;
options1.big_integer_format(big_integer_chars_format::number);
options1.bigint_format(bigint_chars_format::number);
j.dump(std::cout, options1);
std::cout << "\n\n";

std::cout << "(base64) ";
json_options options3;
options3.big_integer_format(big_integer_chars_format::base64);
options3.bigint_format(bigint_chars_format::base64);
j.dump(std::cout, options3);
std::cout << "\n\n";

std::cout << "(base64url) ";
json_options options4;
options4.big_integer_format(big_integer_chars_format::base64url);
options4.bigint_format(bigint_chars_format::base64url);
j.dump(std::cout, options4);
std::cout << "\n\n";
}
Expand Down Expand Up @@ -79,13 +79,13 @@ int main()

std::cout << "(2) ";
json_options options1;
options1.big_integer_format(big_integer_chars_format::number);
options1.bigint_format(bigint_chars_format::number);
j.dump(std::cout, options1);
std::cout << "\n\n";

std::cout << "(3) ";
json_options options2;
options2.big_integer_format(big_integer_chars_format::base64url);
options2.bigint_format(bigint_chars_format::base64url);
j.dump(std::cout, options2);
std::cout << "\n\n";
}
Expand Down
8 changes: 4 additions & 4 deletions doc/ref/bignum.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,13 @@ int main()

std::cout << "(4) ";
json_options options1;
options1.big_integer_format(big_integer_chars_format::number);
options1.bigint_format(bigint_chars_format::number);
j.dump(std::cout, options1);
std::cout << "\n\n";

std::cout << "(5) ";
json_options options2;
options2.big_integer_format(big_integer_chars_format::base64url);
options2.bigint_format(bigint_chars_format::base64url);
j.dump(std::cout, options2);
std::cout << "\n\n";
}
Expand Down Expand Up @@ -257,13 +257,13 @@ int main()

std::cout << "(2) ";
json_options options1;
options1.big_integer_format(big_integer_chars_format::number);
options1.bigint_format(bigint_chars_format::number);
j.dump(std::cout, options1);
std::cout << "\n\n";

std::cout << "(3) ";
json_options options2;
options2.big_integer_format(big_integer_chars_format::base64url);
options2.bigint_format(bigint_chars_format::base64url);
j.dump(std::cout, options2);
std::cout << "\n\n";
}
Expand Down
6 changes: 3 additions & 3 deletions doc/ref/bson/bson_encoder.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ Constructs a new encoder that writes to the specified result.
semantic_tag tag=semantic_tag::none,
const ser_context& context=null_ser_context());
bool big_integer_value(const string_view_type& s,
bool bigint_value(const string_view_type& s,
const ser_context& context=null_ser_context());
bool big_decimal_value(const string_view_type& s,
bool bigdec_value(const string_view_type& s,
const ser_context& context=null_ser_context());
bool date_time_value(const string_view_type& s,
bool datetime_value(const string_view_type& s,
const ser_context& context=null_ser_context());
bool timestamp_value(int64_t val,
Expand Down
24 changes: 12 additions & 12 deletions doc/ref/cbor/cbor.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,26 @@ data structures, using [json_type_traits](../json_type_traits.md).
All tags not explicitly mentioned below are ignored.

0 (standard date/time string)
CBOR standard date/time strings are decoded into jsoncons strings tagged with `semantic_tag::date_time`.
jsoncons strings tagged with `semantic_tag::date_time` are encoded into CBOR standard date/time strings.
CBOR standard date/time strings are decoded into jsoncons strings tagged with `semantic_tag::datetime`.
jsoncons strings tagged with `semantic_tag::datetime` are encoded into CBOR standard date/time strings.

1 (epoch time)
CBOR epoch times are decoded into jsoncons int64_t, uint64_t and double and tagged with `semantic_tag::timestamp`.
jsoncons int64_t, uint64_t and double tagged with `semantic_tag::timestamp` are encoded into CBOR epoch time.

2,3 (positive and negative bignum)
CBOR positive and negative bignums are decoded into jsoncons strings and tagged with `semantic_tag::big_integer`.
jsoncons strings tagged with `semantic_tag::big_integer` are encoded into CBOR positive or negative bignums.
CBOR positive and negative bignums are decoded into jsoncons strings and tagged with `semantic_tag::bigint`.
jsoncons strings tagged with `semantic_tag::bigint` are encoded into CBOR positive or negative bignums.

4 (decimal fratction)
CBOR decimal fractions are decoded into jsoncons strings tagged with `semantic_tag::big_decimal`.
jsoncons strings tagged with `semantic_tag::big_decimal` are encoded into CBOR decimal fractions.
CBOR decimal fractions are decoded into jsoncons strings tagged with `semantic_tag::bigdec`.
jsoncons strings tagged with `semantic_tag::bigdec` are encoded into CBOR decimal fractions.

5 (bigfloat)
CBOR bigfloats are decoded into a jsoncons array that contains a base-2 exponent and a mantissa,
and tagged with `semantic_tag::big_float`. The exponent is represented as an int64_t or uint64_t,
while the mantissa can be an int64_t or uint64_t, or a string tagged with `semantic_tag::big_integer`.
jsoncons arrays tagged with `semantic_tag::big_float` are encoded into CBOR bigfloats.
and tagged with `semantic_tag::bigfloat`. The exponent is represented as an int64_t or uint64_t,
while the mantissa can be an int64_t or uint64_t, or a string tagged with `semantic_tag::bigint`.
jsoncons arrays tagged with `semantic_tag::bigfloat` are encoded into CBOR bigfloats.

21, 22, 23 (byte string expected conversion is base64url, base64 or base16)
CBOR byte strings tagged with 21, 22 and 23 are decoded into jsoncons byte strings tagged with
Expand Down Expand Up @@ -69,9 +69,9 @@ uint64 | timestamp | unsigned integer | 1 (epoch-based date/time)
double | | half-precision float, float, or double |&#160;
double | timestamp | double | 1 (epoch-based date/time)
string | | string |&#160;
string | big_integer | byte string | 2 (positive bignum) or 2 (negative bignum)
string | big_decimal | array | 4 (decimal fraction)
string | date_time | string | 0 (date/time string)
string | bigint | byte string | 2 (positive bignum) or 2 (negative bignum)
string | bigdec | array | 4 (decimal fraction)
string | datetime | string | 0 (date/time string)
string | uri | string | 32 (uri)
string | base64url | string | 33 (base64url)
string | base64 | string | 34 (base64)
Expand Down
10 changes: 5 additions & 5 deletions doc/ref/cbor/cbor_encoder.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ Constructs a new encoder that writes to the specified result.
semantic_tag tag=semantic_tag::none,
const ser_context& context=null_ser_context());
bool big_integer_value(const string_view_type& s,
bool bigint_value(const string_view_type& s,
const ser_context& context=null_ser_context());
bool big_decimal_value(const string_view_type& s,
bool bigdec_value(const string_view_type& s,
const ser_context& context=null_ser_context());
bool date_time_value(const string_view_type& s,
bool datetime_value(const string_view_type& s,
const ser_context& context=null_ser_context());
bool timestamp_value(int64_t val,
Expand Down Expand Up @@ -172,8 +172,8 @@ int main()
cbor::cbor_encoder encoder(os);

encoder.begin_array(3); // array of length 3
encoder.big_integer_value("-18446744073709551617");
encoder.big_decimal_value("184467440737095516.16");
encoder.bigint_value("-18446744073709551617");
encoder.bigdec_value("184467440737095516.16");
encoder.timestamp_value(1431027667);
encoder.end_array();
encoder.flush();
Expand Down
6 changes: 3 additions & 3 deletions doc/ref/csv/csv_encoder.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@ and uses the specified [csv options](csv_options.md).
semantic_tag tag=semantic_tag::none,
const ser_context& context=null_ser_context());
bool big_integer_value(const string_view_type& s,
bool bigint_value(const string_view_type& s,
const ser_context& context=null_ser_context());
bool big_decimal_value(const string_view_type& s,
bool bigdec_value(const string_view_type& s,
const ser_context& context=null_ser_context());
bool date_time_value(const string_view_type& s,
bool datetime_value(const string_view_type& s,
const ser_context& context=null_ser_context());
bool timestamp_value(int64_t val,
Expand Down
2 changes: 1 addition & 1 deletion doc/ref/csv/csv_options.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Quote character. Default is quote character "
Infer null, true, false, integers and floating point values in the CSV source. Default is `true`.

basic_csv_options& lossless_number(bool value);
If set to `true`, parse numbers with exponents and fractional parts as strings with semantic tagging `semantic_tag::big_decimal`. Default is `false`.
If set to `true`, parse numbers with exponents and fractional parts as strings with semantic tagging `semantic_tag::bigdec`. Default is `false`.

basic_csv_options& quote_escape_char(CharT value);
Character to escape quote character (by default the quote character is doubled). Default is quote character `"`.
Expand Down
18 changes: 9 additions & 9 deletions doc/ref/data-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ uint64 | timestamp | unsigned integer | 1 (epoch-based date/time)
double | | half-precision float, float, or double |&#160;
double | timestamp | double | 1 (epoch-based date/time)
string | | string |&#160;
string | big_integer | byte string | 2 (positive bignum) or 3 (negative bignum)
string | big_decimal | array | 4 (decimal fraction)
string | date_time | string | 0 (date/time string)
string | bigint | byte string | 2 (positive bignum) or 3 (negative bignum)
string | bigdec | array | 4 (decimal fraction)
string | datetime | string | 0 (date/time string)
string | uri | string | 32 (uri)
string | base64url | string | 33 (base64url)
string | base64 | string | 34 (base64)
Expand All @@ -41,7 +41,7 @@ byte_string | base64url | byte string | 21 (Expected conversion to base
byte_string | base64 | byte string | 22 (Expected conversion to base64 encoding)
byte_string | base16 | byte string | 23 (Expected conversion to base16 encoding)
array | | array |&#160;
array | big_float | array |&#160; | 5 (bigfloat)
array | bigfloat | array |&#160; | 5 (bigfloat)
object | | map |&#160;

### Examples
Expand All @@ -60,9 +60,9 @@ int main()

j.emplace_back("foo");
j.emplace_back(byte_string{ 'b','a','r' });
j.emplace_back("-18446744073709551617", semantic_tag::big_integer);
j.emplace_back("273.15", semantic_tag::big_decimal);
j.emplace_back("2018-10-19 12:41:07-07:00", semantic_tag::date_time);
j.emplace_back("-18446744073709551617", semantic_tag::bigint);
j.emplace_back("273.15", semantic_tag::bigdec);
j.emplace_back("2018-10-19 12:41:07-07:00", semantic_tag::datetime);
j.emplace_back(1431027667, semantic_tag::timestamp);
j.emplace_back(-1431027667, semantic_tag::timestamp);
j.emplace_back(1431027667.5, semantic_tag::timestamp);
Expand Down Expand Up @@ -139,9 +139,9 @@ void main()
encoder.begin_array(); // indefinite length outer array
encoder.string_value("foo");
encoder.byte_string_value(byte_string({'b','a','r'}));
encoder.big_integer_value("-18446744073709551617");
encoder.bigint_value("-18446744073709551617");
encoder.decimal_value("273.15");
encoder.date_time_value("2018-10-19 12:41:07-07:00");
encoder.datetime_value("2018-10-19 12:41:07-07:00");
encoder.epoch_time_value(1431027667);
encoder.int64_value(-1431027667, semantic_tag::timestamp);
encoder.double_value(1431027667.5, semantic_tag::timestamp);
Expand Down
6 changes: 3 additions & 3 deletions doc/ref/json_content_handler.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,21 +89,21 @@ line and column number is provided in the [context](ser_context.md) parameter.
Returns `true` if the producer should continue streaming events, `false` otherwise.
Throws a [ser_error](ser_error.md) to indicate an error.

bool big_integer_value(const string_view_type& s,
bool bigint_value(const string_view_type& s,
const ser_context& context=null_ser_context());
Writes a bignum using the decimal string representation of a bignum. Contextual information including
line and column number is provided in the [context](ser_context.md) parameter.
Returns `true` if the producer should continue streaming events, `false` otherwise.
Throws a [ser_error](ser_error.md) to indicate an error.

bool big_decimal_value(const string_view_type& s,
bool bigdec_value(const string_view_type& s,
const ser_context& context=null_ser_context());
Writes a decimal value using the decimal string representation. Contextual information including
line and column number is provided in the [context](ser_context.md) parameter.
Returns `true` if the producer should continue streaming events, `false` otherwise.
Throws a [ser_error](ser_error.md) to indicate an error.

bool date_time_value(const string_view_type& s,
bool datetime_value(const string_view_type& s,
const ser_context& context=null_ser_context());
Writes a date-time value using the string representation. Contextual information including
line and column number is provided in the [context](ser_context.md) parameter.
Expand Down
2 changes: 1 addition & 1 deletion doc/ref/json_decode_options.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Indicates `Negative Infinity` replacement for string when parsing.
When parsing JSON text, replace string with minus infinity if `is_neginf_to_str()` returns true.

virtual bool lossless_number() const = 0;
If set to `true`, parse decimal numbers as strings with semantic tagging `semantic_tag::big_decimal` instead of double.
If set to `true`, parse decimal numbers as strings with semantic tagging `semantic_tag::bigdec` instead of double.

virtual size_t max_nesting_depth() = 0;
Maximum nesting depth when parsing JSON.
Expand Down
6 changes: 3 additions & 3 deletions doc/ref/json_encode_options.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ Overrides [floating point format](chars_format.md) when serializing json.
The default, for a floating point value that was previously decoded from json text, is to preserve the original format when serializing.
The default, for a floating point value that was directly inserted into a json value, to serialize with [chars_format::general](chars_format.md).

virtual big_integer_chars_format big_integer_format() const = 0
Overrides [bignum format](big_integer_chars_format.md) when serializing json.
The default is [big_integer_chars_format::base10](big_integer_chars_format.md).
virtual bigint_chars_format bigint_format() const = 0
Overrides [bignum format](bigint_chars_format.md) when serializing json.
The default is [bigint_chars_format::base10](bigint_chars_format.md).

virtual byte_string_chars_format byte_string_format() const = 0
Overrides [byte string format](byte_string_chars_format.md) when serializing json.
Expand Down
6 changes: 3 additions & 3 deletions doc/ref/json_encoder.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@ and uses the specified [json options](json_options.md).
semantic_tag tag=semantic_tag::none,
const ser_context& context=null_ser_context());

bool big_integer_value(const string_view_type& s,
bool bigint_value(const string_view_type& s,
const ser_context& context=null_ser_context());

bool big_decimal_value(const string_view_type& s,
bool bigdec_value(const string_view_type& s,
const ser_context& context=null_ser_context());

bool date_time_value(const string_view_type& s,
bool datetime_value(const string_view_type& s,
const ser_context& context=null_ser_context());

bool timestamp_value(int64_t val,
Expand Down
Loading

0 comments on commit 33a0e60

Please sign in to comment.