Comments (2)
Found a workaround for now:
template <>
struct glz::meta<Foo>
{
static constexpr auto custom_write = true;
static constexpr auto value = enumerate(Foo::eABC);
};
This basically tricks glaze into treating Foo
as a glaze_enum_t
which goes into the string-ish branch of write_pair_content
. I should mention that in my actual use case for this, the enum comes from a third party lib and has hundreds of values and the enum to string function is not constexpr, so using the enumerate_no_reflect
function on its own will not work. It's sufficient to just do a enumerate()
with a single enum value which is enough to get glaze to treat it like an enum.
from glaze.
Another solution for your original code is to use the .raw
option in glz::opts
when writing. The .raw
option writes out string-like values without quotes.
This line: write<json>::op<Opts>(fooName(foo), args...);
becomes:
write<json>::op<opt_true<Opts, &opts::raw>>(fooName(foo), args...);
glz::opt_true
is used as a helper for setting the appropriate boolean at compile time of the templated options, so that the rest of the options get properly passed through.
Here's a working example on compiler explorer of your code: https://gcc.godbolt.org/z/jsf6W57oa
from glaze.
Related Issues (20)
- prettify_json("\xf3") invokes out ouf bounds read in prettify.hpp HOT 3
- reading generic json on invalid input causes out of bounds read in read.hpp HOT 1
- reading generic json can cause a stack overflow HOT 2
- prettify_json("\"") invokes memcpy on nullptr in dump.hpp HOT 8
- glz::minify_json invoked on "f" causes out of bounds read in minify.hpp HOT 3
- CMAKE Version update HOT 2
- converting float -8536070.f to string gives "-08536070" HOT 10
- Optionally Write Keys at Runtime (while using Partials) HOT 2
- Roundtrip failure for double -0x1.e42427b42cb42p+949 HOT 2
- out of bounds write in prettify_json
- read_json on json_t invoked with invalid unicode causes out of bounds read in hex_to_u32 HOT 1
- [BUG?] Build fails on latest version (using g++) HOT 1
- deprectaed in c++17 out-of-line definition of constexpr static data member HOT 1
- clang - remainder by zero is undefined HOT 1
- size_t wraparound causes huge allocation when reading generic json HOT 1
- size_t wraparound causes huge allocation when reading generic json (again) HOT 5
- Issue with indentation_level HOT 2
- Quirk on retrieving via json pointer syntax
- Fix nested variant problem HOT 1
- Compilation failure with more than 32 elements
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from glaze.