Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
CharacterDelimitedLines/Writer.h
Go to the documentation of this file.
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. 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 /**
58 */
59#if qCompilerAndStdLib_DefaultMemberInitializerNeededEnclosingForDefaultFunArg_Buggy
60 Writer (const Options& options);
61 Writer ()
62 : Writer (Options{})
63 {
64 }
65#else
66 Writer (const Options& options = {});
67#endif
68
69 public:
70 /**
71 * @See Variant::Writer::Write, but overloaded to also take array of array of strings to write.
72 *
73 * \note Could have been called WriteMatrix (additional overloads) - but seemed best to emphasize connection
74 * to other Writers instead of similarity to Reader (where we call it ReadMatrix due to not being
75 * able to overload on return type).
76 */
77 using inherited::Write;
78 nonvirtual void Write (const Traversal::Iterable<Sequence<String>>& m, const Streams::OutputStream::Ptr<byte>& out);
80 nonvirtual void Write (const Traversal::Iterable<Sequence<String>>& m, ostream& out);
81 nonvirtual void Write (const Traversal::Iterable<Sequence<String>>& m, wostream& out);
82
83 public:
84 /**
85 * @See Variant::Writer::WriteAsString, but overloaded to also take array of array of strings to write.
86 */
88 [[nodiscard]] nonvirtual String WriteAsString (const Traversal::Iterable<Sequence<String>>& m);
89
90 public:
91 /**
92 * @See Variant::Writer::WriteAsBLOB, but overloaded to also take array of array of strings to write.
93 */
95 [[nodiscard]] nonvirtual Memory::BLOB WriteAsBLOB (const Traversal::Iterable<Sequence<String>>& m);
96
97 private:
98 nonvirtual shared_ptr<Rep_> GetRep_ () const;
99 };
100
101}
102
103/*
104 ********************************************************************************
105 ***************************** Implementation Details ***************************
106 ********************************************************************************
107 */
108#include "Writer.inl"
109
110#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.
Definition Sequence.h:187
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,...
Definition Writer.h:37
nonvirtual String WriteAsString(const VariantValue &v) const
Definition Writer.cpp:53
nonvirtual Memory::BLOB WriteAsBLOB(const VariantValue &v) const
Definition Writer.cpp:48
nonvirtual void Write(const VariantValue &v, const Streams::OutputStream::Ptr< byte > &out) const
Definition Writer.inl:30
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:237