Skip to content

Commit 75883d8

Browse files
committed
Simplify DelimWriter factory functions
1 parent 571407f commit 75883d8

8 files changed

Lines changed: 103 additions & 118 deletions

File tree

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ See `tests/AGENTS.md` for test strategy, checklist, and conventions.
7070
- **Trivial one-liner accessors** may be unconditionally `inline` in the header when the call overhead is measurable and the body will never change.
7171
- **Consolidation:** If a `.cpp` would be under ~100 lines *and* the split causes excessive comment duplication between the two files, prefer a single `.hpp` with definitions marked `inline` (free functions and methods alike). Do not use `CSV_INLINE` for consolidated definitions — `CSV_INLINE` expands to empty in multi-header mode, which would produce ODR violations across TUs. Do not consolidate just for brevity — only when duplication is the dominant cost.
7272
7. **Prefer LF (`\n`) line endings for tracked source, test, CMake, and Markdown files.** When you touch a file with mixed line endings, normalize the edited file to LF unless there is a file-specific reason not to. Avoid introducing mixed CRLF/LF endings in the same file.
73+
8. **Keep preprocessor directives flush left.** `#define`, `#if`, `#ifdef`, `#else`, and `#endif` should start at column 0. Code inside multi-line macros should be indented exactly as the equivalent non-macro code would be; do not add extra indentation just because it lives inside a macro body.
7374
7475
### Rules for Comments
7576
1. **Always update or remove incorrect comments.**

ARCHITECTURE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Notes:
2222
- When editing a function, remove `@param` and `@return` descriptions that merely restate the function name or signature.
2323
- Private member naming should prefer trailing underscores; when editing mixed-style code, normalize the touched region toward that convention.
2424
- Prefer LF (`\n`) line endings for tracked source, test, CMake, and Markdown files; when touching a file with mixed endings, normalize it to LF unless there is a file-specific reason not to.
25+
- Keep preprocessor directives flush left; `#define`, `#if`, `#ifdef`, `#else`, and `#endif` should start at column 0, and code inside multi-line macros should be indented as if the macro wrapper were not present.
2526
- Compatibility macros defined in `common.hpp` must only be referenced after including `common.hpp`. See AGENTS.md and CLAUDE.md for details.
2627
- API constraints should be user-friendly: do not over-constrain templates unless needed for correctness, safety, or a measured performance win.
2728
- `CSVReader` is intentionally non-copyable and move-enabled; use explicit ownership transfer patterns (`std::move`, `std::unique_ptr`) at API boundaries.

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
- **`CSVReader` is non-copyable and move-enabled** — prefer explicit ownership transfer (`std::move`) or `std::unique_ptr<CSVReader>` when handing off parser ownership
4040
- **Prefer trailing underscore for private members** — when touching mixed-style code, normalize the edited region toward names like `source_` and `leftover_`
4141
- **Prefer LF (`\n`) line endings** for tracked source, test, CMake, and Markdown files — when touching a file with mixed endings, normalize it to LF unless a file-specific reason says otherwise
42+
- **Keep preprocessor directives flush left**`#define`, `#if`, `#ifdef`, `#else`, and `#endif` start at column 0; indent code inside multi-line macros exactly as equivalent non-macro code would be
4243
- **Prefer user-friendly API constraints** — do not narrow template constraints unless required for correctness, safety, or a measured performance win; if common containers/ranges already work, keep them accepted
4344
- **Respect compile-time compatibility macros** — keep constructs like `IF_CONSTEXPR` and `CONSTEXPR_VALUE` unless there is a correctness bug
4445
- **Do not rewrite compile-time logic to silence warnings** — prefer tightly scoped suppression at the exact site when needed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,7 @@ auto writer = make_csv_writer(ss);
660660
// auto writer = make_tsv_writer(ss); // For tab-separated files
661661
// DelimWriter<stringstream, '|', '"'> writer(ss); // Your own custom format
662662
// set_decimal_places(2); // How many places after the decimal will be written for floats
663+
// writer.set_auto_flush(false); // Buffer writes until flush()/destructor
663664

664665
writer << vector<string>({ "A", "B", "C" })
665666
<< deque<string>({ "I'm", "too", "tired" })

docs/source/csv_writing.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ CSV/TSV data.
1414
Use `csv::make_csv_writer()` for comma-delimited output and
1515
`csv::make_tsv_writer()` for tab-delimited output.
1616

17+
If you want buffered behavior, call `set_auto_flush(false)` on the writer
18+
instead of using a separate factory:
19+
20+
@code
21+
std::stringstream output;
22+
auto writer = csv::make_csv_writer(output).set_auto_flush(false);
23+
@endcode
24+
1725
## Writing Containers with `operator<<`
1826

1927
Any row-like container of string-convertible values can be streamed directly.

0 commit comments

Comments
 (0)