Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
Variant/INI/Reader.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_INI_Reader_h_
5#define _Stroika_Foundation_DataExchange_Variant_INI_Reader_h_ 1
6
7#include "Stroika/Foundation/StroikaPreComp.h"
8
9#include "Stroika/Foundation/Common/Common.h"
10#include "Stroika/Foundation/Containers/Collection.h"
14
15/**
16 * \file
17 *
18 * TODO:
19 * @todo Quoted characters (see http://en.wikipedia.org/wiki/INI_file)
20 *
21 * @todo VERY PRIMITIVE IMPL (no error checking/validation) - or at least little
22 *
23 * @todo Add these references to docs:
24 * http://en.wikipedia.org/wiki/INI_file
25 * http://stackoverflow.com/questions/190629/what-is-the-easiest-way-to-parse-an-ini-file-in-java
26 *
27 * @todo Config params should take choice about quoting (always, never)???
28 *
29 * @todo Characterset / BOM
30 *
31 */
32
33namespace Stroika::Foundation::DataExchange::Variant::INI {
34
35 /**
36 * \brief Reader for INI format files
37 *
38 * \note INI format - https://en.wikipedia.org/wiki/INI_file
39 * Example from wikipedia
40 * ; last modified 1 April 2001 by John Doe
41 * [owner]
42 * name=John Doe
43 * organization=Acme Widgets Inc.
44 *
45 * [database]
46 * ; use IP address in case network name resolution is not working
47 * server=192.0.2.62
48 * port=143
49 * file="payroll.dat"
50 *
51 * The section headers (e.g. [database]) mark the start of sections. Each section is essential a name-value pair map.
52 *
53 * Often there is a single unnamed section. And often there are named sections. These are collected together in what we call here
54 * a Profile.
55 *
56 * \par Example Usage
57 * \code
58 * stringstream tmp;
59 * tmp << "NAME=\"Ubuntu\"" << endl;
60 * tmp << "VERSION=\"13.10, Saucy Salamander\"" << endl;
61 * tmp << "ID=ubuntu" << endl;
62 * tmp << "ID_LIKE=debian" << endl;
63 * tmp << "PRETTY_NAME=\"Ubuntu 13.10\"" << endl;
64 * tmp << "VERSION_ID=\"13.10\"" << endl;
65 * tmp << "HOME_URL=\"http://www.ubuntu.com/\"" << endl;
66 * tmp << "SUPPORT_URL=\"http://help.ubuntu.com/\"" << endl;
67 * tmp << "BUG_REPORT_URL=\"http://bugs.launchpad.net/ubuntu/\"" << endl;
68 * Variant::INI::Profile p = Variant::INI::Reader ().ReadProfile (tmp);
69 * EXPECT_TRUE (p.fNamedSections.empty ());
70 * EXPECT_TRUE (p.fUnnamedSection.fProperties.LookupValue ("NAME") == "Ubuntu");
71 * EXPECT_TRUE (p.fUnnamedSection.fProperties.LookupValue ("SUPPORT_URL") == "http://help.ubuntu.com/");
72 * \endcode
73 */
74 class Reader : public Variant::Reader {
75 private:
77
78 private:
79 class Rep_;
80
81 public:
82 Reader ();
83
84 public:
85 /**
86 * \brief though can read directly as VariantValue, reading as a Profile object maybe handier for this type of file.
87 */
91 nonvirtual Profile ReadProfile (istream& in);
92 nonvirtual Profile ReadProfile (wistream& in);
93 };
94
95}
96
97/*
98 ********************************************************************************
99 ***************************** Implementation Details ***************************
100 ********************************************************************************
101 */
102#include "Reader.inl"
103
104#endif /*_Stroika_Foundation_DataExchange_Variant_INI_Reader_h_*/
nonvirtual Profile ReadProfile(const Streams::InputStream::Ptr< byte > &in)
though can read directly as VariantValue, reading as a Profile object maybe handier for this type of ...
abstract class specifying interface for readers that map a source like XML or JSON to a VariantValue ...
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