diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-07-22 09:17:06 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-07-22 09:17:06 +0100 |
| commit | b08e6b4c723efef245903caca49c2dafb11f8722 (patch) | |
| tree | e98a07d4606b2c6d08d8bcbf2be2d710de5eb85b /src | |
| parent | 26181f4db08a6d295e34fc666592cdaa64a36782 (diff) | |
Fix GPL boilerplate. Add locked_sstream dependency. Remove
Document::read_stream; improve Document::read_string efficiency.
Use locked_stringstream instead of plain one to try to fix
DCP-o-matic crashes on OS X.
Diffstat (limited to 'src')
| -rw-r--r-- | src/cxml.cc | 25 | ||||
| -rw-r--r-- | src/cxml.h | 22 | ||||
| -rw-r--r-- | src/wscript | 21 |
3 files changed, 38 insertions, 30 deletions
diff --git a/src/cxml.cc b/src/cxml.cc index 567dc50..3248324 100644 --- a/src/cxml.cc +++ b/src/cxml.cc @@ -1,32 +1,29 @@ /* - Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net> - This program is free software; you can redistribute it and/or modify + This file is part of libcxml. + + libcxml is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - This program is distributed in the hope that it will be useful, + libcxml is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with libcxml. If not, see <http://www.gnu.org/licenses/>. */ -#include <sstream> -#include <iostream> #include <boost/filesystem.hpp> #include <boost/algorithm/string.hpp> #include <libxml++/libxml++.h> #include "cxml.h" using std::string; -using std::stringstream; -using std::istream; using std::list; using boost::shared_ptr; using boost::optional; @@ -265,17 +262,9 @@ cxml::Document::read_file (boost::filesystem::path file) } void -cxml::Document::read_stream (istream& stream) -{ - _parser->parse_stream (stream); - take_root_node (); -} - -void cxml::Document::read_string (string s) { - stringstream t (s); - _parser->parse_stream (t); + _parser->parse_memory (s); take_root_node (); } @@ -1,32 +1,33 @@ /* - Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net> - This program is free software; you can redistribute it and/or modify + This file is part of libcxml. + + libcxml is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - This program is distributed in the hope that it will be useful, + libcxml is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with libcxml. If not, see <http://www.gnu.org/licenses/>. */ #ifndef LIBCXML_CXML_H #define LIBCXML_CXML_H +#include <locked_sstream.h> #include <boost/shared_ptr.hpp> #include <boost/optional.hpp> #include <boost/filesystem.hpp> #include <boost/algorithm/string/erase.hpp> #include <stdint.h> #include <string> -#include <sstream> #include <list> /* Hack for OS X compile failure; see https://bugs.launchpad.net/hugin/+bug/910160 */ @@ -112,7 +113,7 @@ public: { std::string s = string_child (c); boost::erase_all (s, " "); - std::stringstream t; + locked_stringstream t; t.imbue (std::locale::classic ()); t << s; T n; @@ -130,7 +131,7 @@ public: std::string t = s.get (); boost::erase_all (t, " "); - std::stringstream u; + locked_stringstream u; u.imbue (std::locale::classic ()); u << t; T n; @@ -161,7 +162,7 @@ public: { std::string s = string_attribute (c); boost::erase_all (s, " "); - std::stringstream t; + locked_stringstream t; t.imbue (std::locale::classic ()); t << s; T n; @@ -179,7 +180,7 @@ public: std::string t = s.get (); boost::erase_all (t, " "); - std::stringstream u; + locked_stringstream u; u.imbue (std::locale::classic ()); u << t; T n; @@ -225,7 +226,6 @@ public: virtual ~Document (); void read_file (boost::filesystem::path); - void read_stream (std::istream &); void read_string (std::string); std::string root_name () const { diff --git a/src/wscript b/src/wscript index 1d5c3f3..5d24f84 100644 --- a/src/wscript +++ b/src/wscript @@ -1,3 +1,23 @@ +# -*- mode: python -*- +# +# Copyright (C) 2016 Carl Hetherington <cth@carlh.net> +# +# This file is part of libcxml. +# +# libcxml is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# libcxml is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with libcxml. If not, see <http://www.gnu.org/licenses/>. +# + def build(bld): if bld.env.STATIC: obj = bld(features='cxx cxxstlib') @@ -13,4 +33,3 @@ def build(bld): bld.install_files('${PREFIX}/include/libcxml', "cxml.h") if bld.env.STATIC: bld.install_files('${PREFIX}/lib', 'libcxml.a') - |
