Stroika Library 3.0d23
 
Loading...
Searching...
No Matches
Variant/Reader.inl
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2026. All rights reserved
3 */
4#include "Stroika/Foundation/Streams/TextToBinary.h"
5
6namespace Stroika::Foundation::DataExchange::Variant {
7
8 /*
9 ********************************************************************************
10 ******************************* Variant::Reader ********************************
11 ********************************************************************************
12 */
13 inline auto Reader::MakeSharedRep_ (const _IRep& t) -> shared_ptr<_IRep>
14 {
15 return t.Clone ();
16 }
17 inline Reader::Reader (const shared_ptr<_IRep>& rep)
18 : fRep_{rep}
19 {
20 RequireNotNull (rep);
21 }
22 inline optional<filesystem::path> Reader::GetDefaultFileSuffix () const
23 {
24 AssertNotNull (fRep_);
25 return fRep_->GetDefaultFileSuffix ();
26 }
27 inline VariantValue Reader::Read (const Streams::InputStream::Ptr<byte>& in) const
28 {
29 AssertNotNull (fRep_);
30 return fRep_->Read (in);
31 }
32 inline VariantValue Reader::Read (const Streams::InputStream::Ptr<Characters::Character>& in) const
33 {
34 AssertNotNull (fRep_);
35 return fRep_->Read (in);
36 }
37 inline VariantValue Variant::Reader::Read (const Traversal::Iterable<Characters::Character>& in) const
38 {
39 return Read (_ToCharacterReader (in));
40 }
41 inline VariantValue Variant::Reader::Read (istream& in) const
42 {
43 return Read (_ToByteReader (in));
44 }
45 inline VariantValue Variant::Reader::Read (wistream& in) const
46 {
47 return Read (_ToCharacterReader (in));
48 }
49 inline Reader::_IRep& Reader::_GetRep ()
50 {
51 AssertNotNull (fRep_);
52 EnsureNotNull (fRep_.rwget ());
53 return *fRep_.rwget ();
54 }
55 inline const Reader::_IRep& Reader::_GetRep () const
56 {
57 EnsureNotNull (fRep_.cget ());
58 return *fRep_.cget ();
59 }
65 {
66 return Streams::TextToBinary::Reader::New (in);
67 }
72
73}
#define AssertNotNull(p)
Definition Assertions.h:334
#define EnsureNotNull(p)
Definition Assertions.h:341
#define RequireNotNull(p)
Definition Assertions.h:348
static Streams::InputStream::Ptr< byte > _ToByteReader(const Streams::InputStream::Ptr< byte > &in)
simple helper so subclasses can more easily provide varied Read overloads
static Streams::InputStream::Ptr< Characters::Character > _ToCharacterReader(const Streams::InputStream::Ptr< Characters::Character > &in)
simple helper so subclasses can more easily provide varied Read overloads
Simple variant-value (case variant union) object, with (variant) basic types analogous to a value in ...
nonvirtual const element_type * cget() const noexcept
InputStream<>::Ptr is Smart pointer (with abstract Rep) class defining the interface to reading from ...
Iterable<T> is a base class for containers which easily produce an Iterator<T> to traverse them.
Definition Iterable.h:237