Skip to content

Commit

Permalink
csv encode
Browse files Browse the repository at this point in the history
  • Loading branch information
danielaparker committed Jan 16, 2025
1 parent f142500 commit b3bb6ca
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
7 changes: 2 additions & 5 deletions include/jsoncons_ext/csv/csv_encoder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class basic_csv_encoder final : public basic_json_visitor<CharT>
std::vector<string_type,string_allocator_type> column_names_;
std::unordered_map<string_type,string_type, std::hash<string_type>,std::equal_to<string_type>,string_string_allocator_type> cname_value_map_;

std::size_t column_index_;
std::size_t column_index_{0};
std::vector<std::size_t> row_counts_;
string_type buffer_;
string_type value_buffer_;
Expand All @@ -112,8 +112,7 @@ class basic_csv_encoder final : public basic_json_visitor<CharT>
basic_csv_encoder(const basic_csv_encoder&) = delete;
basic_csv_encoder& operator=(const basic_csv_encoder&) = delete;
public:
basic_csv_encoder(Sink&& sink,
const Allocator& alloc = Allocator())
basic_csv_encoder(Sink&& sink, const Allocator& alloc = Allocator())
: basic_csv_encoder(std::forward<Sink>(sink), basic_csv_encode_options<CharT>(), alloc)
{
}
Expand All @@ -124,9 +123,7 @@ class basic_csv_encoder final : public basic_json_visitor<CharT>
: sink_(std::forward<Sink>(sink)),
options_(options),
alloc_(alloc),
stack_(),
fp_(options.float_format(), options.precision()),
column_index_(0),
buffer_(alloc),
value_buffer_(alloc)
{
Expand Down
17 changes: 6 additions & 11 deletions include/jsoncons_ext/csv/csv_options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,8 +470,8 @@ class basic_csv_decode_options : public virtual basic_csv_options_common<CharT>
bool unquoted_empty_value_is_null_:1;
bool infer_types_:1;
bool lossless_number_:1;
char_type comment_starter_;
csv_mapping_kind mapping_;
char_type comment_starter_{'\0'};
csv_mapping_kind mapping_{};
std::size_t header_lines_{0};
std::size_t max_lines_{(std::numeric_limits<std::size_t>::max)()};
string_type column_types_;
Expand All @@ -487,9 +487,7 @@ class basic_csv_decode_options : public virtual basic_csv_options_common<CharT>
trim_trailing_inside_quotes_(false),
unquoted_empty_value_is_null_(false),
infer_types_(true),
lossless_number_(false),
comment_starter_('\0'),
mapping_()
lossless_number_(false)
{}

basic_csv_decode_options(const basic_csv_decode_options& other) = default;
Expand Down Expand Up @@ -619,15 +617,12 @@ class basic_csv_encode_options : public virtual basic_csv_options_common<CharT>
using typename super_type::char_type;
using typename super_type::string_type;
private:
quote_style_kind quote_style_;
float_chars_format float_format_;
int8_t precision_;
quote_style_kind quote_style_{quote_style_kind::minimal};
float_chars_format float_format_{float_chars_format::general};
int8_t precision_{0};
string_type line_delimiter_;
public:
basic_csv_encode_options()
: quote_style_(quote_style_kind::minimal),
float_format_(float_chars_format::general),
precision_(0)
{
line_delimiter_.push_back('\n');
}
Expand Down

0 comments on commit b3bb6ca

Please sign in to comment.