Stroika Library 3.0d25
 
Loading...
Searching...
No Matches
Variant/CharacterDelimitedLines/Writer.h
Go to the documentation of this file.
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2026. All rights reserved
3 */
4#ifndef _Stroika_Foundation_DataExchange_Variant_CharacterDelimitedLines_Writer_h_
5#define _Stroika_Foundation_DataExchange_Variant_CharacterDelimitedLines_Writer_h_ 1
6
7#include "Stroika/Foundation/StroikaPreComp.h"
8
9#include "Stroika/Foundation/Common/Common.h"
13
14/**
15 * \file
16 *
17 * \note Code-Status: <a href="Code-Status.md#Beta">Beta</a>
18 *
19 */
20
21namespace Stroika::Foundation::DataExchange::Variant::CharacterDelimitedLines {
22
23 /**
24 * \brief This COULD be easily used to read CSV files, or tab-delimited files, for example.
25 *
26 * \par Example Usage
27 * Source file:
28 * # This file was automatically generated by the
29 * # update-mime-database command. DO NOT EDIT!
30 * 3, 4
31 * 4, 5
32 *...
33 * \code
34 * Sequence<Sequence<int>> results{
35 * Sequence<int>{3,4},
36 * Sequence<int>{4,5},
37 * };
38 * Variant::CharacterDelimitedLines::Write{}.Write (results);
39 * \endcode
40 */
41 class Writer : public Variant::Writer {
42 private:
44
45 private:
46 class Rep_;
47
48 public:
49 /**
50 */
51 struct Options {
52 Characters::Character fSeparator{','};
53 bool fSpaceSeparate{false}; // if true, emit space after all separators on a line but the last
54 };
55
56 public:
57#if qCompilerAndStdLib_default_member_initializer_needed_within_enclosing_class_Buggy
58 Writer (const Options& options);
59 Writer (); ///< \brief Same as Writer{Options{}}
60#else
61 Writer (const Options& options = {});
62#endif
63
64 public:
65 /**
66 * @See Variant::Writer::Write, but overloaded to also take array of array of strings to write.
67 *
68 * \note Could have been called WriteMatrix (additional overloads) - but seemed best to emphasize connection
69 * to other Writers instead of similarity to Reader (where we call it ReadMatrix due to not being
70 * able to overload on return type).
71 */
72 using inherited::Write;
73 nonvirtual void Write (const Traversal::Iterable<Sequence<String>>& m, const Streams::OutputStream::Ptr<byte>& out) const;
74 nonvirtual void Write (const Traversal::Iterable<Sequence<String>>& m, const Streams::OutputStream::Ptr<Characters::Character>& out) const;
75 nonvirtual void Write (const Traversal::Iterable<Sequence<String>>& m, ostream& out) const;
76 nonvirtual void Write (const Traversal::Iterable<Sequence<String>>& m, wostream& out) const;
77
78 public:
79 /**
80 * @See Variant::Writer::WriteAsString, but overloaded to also take array of array of strings to write.
81 */
83 [[nodiscard]] nonvirtual String WriteAsString (const Traversal::Iterable<Sequence<String>>& m) const;
84
85 public:
86 /**
87 * @See Variant::Writer::WriteAsBLOB, but overloaded to also take array of array of strings to write.
88 */
90 [[nodiscard]] nonvirtual Memory::BLOB WriteAsBLOB (const Traversal::Iterable<Sequence<String>>& m) const;
91 };
92
93}
94
95/*
96 ********************************************************************************
97 ***************************** Implementation Details ***************************
98 ********************************************************************************
99 */
100#include "Writer.inl"
101
102#endif /*_Stroika_Foundation_DataExchange_Variant_CharacterDelimitedLines_Writer_h_*/
String is like std::u32string, except it is much easier to use, often much more space efficient,...
Definition String.h:201
A generalization of a vector: a container whose elements are keyed by the natural numbers.
This COULD be easily used to read CSV files, or tab-delimited files, for example.
abstract class specifying interface for writers VariantValue objects to serialized formats like JSON,...
nonvirtual String WriteAsString(const VariantValue &v) const
nonvirtual Memory::BLOB WriteAsBLOB(const VariantValue &v) const
nonvirtual void Write(const VariantValue &v, const Streams::OutputStream::Ptr< byte > &out) const
OutputStream<>::Ptr is Smart pointer to a stream-based sink of data.
Iterable<T> is a base class for containers which easily produce an Iterator<T> to traverse them.
Definition Iterable.h:234