basic-xml 1.0.1
Very basic loader/writer of XML tags with attributes and content.
xml.cpp
Go to the documentation of this file.
1// Copyright (c) 2019-2024 Made to Order Software Corp. All Rights Reserved
2//
3// https://snapwebsites.org/project/basic-xml
4// contact@m2osw.com
5//
6// This program is free software: you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation, either version 3 of the License, or
9// (at your option) any later version.
10//
11// This program is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15//
16// You should have received a copy of the GNU General Public License
17// along with this program. If not, see <https://www.gnu.org/licenses/>.
18
19
27// self
28//
29#include "basic-xml/xml.h"
30
31#include "basic-xml/exception.h"
32#include "basic-xml/parser.h"
33
34// C++
35//
36#include <fstream>
37
38
39// C
40//
41#include <string.h>
42
43
44// last include
45//
46#include <snapdev/poison.h>
47
48
49
112namespace basic_xml
113{
114
115
116
117xml::xml(std::string const & filename)
118{
119 std::ifstream in(filename);
120 if(!in.is_open())
121 {
122 int const e(errno);
123 throw file_not_found("could not open XML file \""
124 + filename
125 + "\": " + strerror(e) + ".");
126 }
127
128 parser p(filename, in, f_root);
129}
130
131
132xml::xml(std::string const & filename, std::istream & in)
133{
134 parser p(filename, in, f_root);
135}
136
137
138node::pointer_t xml::root()
139{
140 return f_root;
141}
142
143
144
145} // namespace prinbee
146// vim: ts=4 sw=4 et
Snap! Database exceptions.
Database file implementation.
Very simple XML parser.

This document is part of the Snap! Websites Project.

Copyright by Made to Order Software Corp.