LCOV - code coverage report
Current view: top level - libreoffice/workdir/unxlngi6.pro/UnpackedTarball/orcus/src/liborcus - global.cpp (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 27 3.7 %
Date: 2012-12-17 Functions: 2 6 33.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*************************************************************************
       2             :  *
       3             :  * Copyright (c) 2010-2012 Kohei Yoshida
       4             :  *
       5             :  * Permission is hereby granted, free of charge, to any person
       6             :  * obtaining a copy of this software and associated documentation
       7             :  * files (the "Software"), to deal in the Software without
       8             :  * restriction, including without limitation the rights to use,
       9             :  * copy, modify, merge, publish, distribute, sublicense, and/or sell
      10             :  * copies of the Software, and to permit persons to whom the
      11             :  * Software is furnished to do so, subject to the following
      12             :  * conditions:
      13             :  *
      14             :  * The above copyright notice and this permission notice shall be
      15             :  * included in all copies or substantial portions of the Software.
      16             :  *
      17             :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
      18             :  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
      19             :  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
      20             :  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
      21             :  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
      22             :  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      23             :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
      24             :  * OTHER DEALINGS IN THE SOFTWARE.
      25             :  *
      26             :  ************************************************************************/
      27             : 
      28             : #include "orcus/global.hpp"
      29             : #include "orcus/tokens.hpp"
      30             : #include "orcus/exception.hpp"
      31             : 
      32             : #include <fstream>
      33             : #include <iostream>
      34             : #include <sstream>
      35             : #include <algorithm>
      36             : 
      37             : using namespace std;
      38             : 
      39             : namespace orcus {
      40             : 
      41             : namespace {
      42             : 
      43             : struct attr_printer : unary_function<void, xml_token_attr_t>
      44             : {
      45             : public:
      46             :     attr_printer(const tokens& tokens) :
      47           0 :         m_tokens(tokens) {}
      48             : 
      49           0 :     void operator()(const xml_token_attr_t& attr) const
      50             :     {
      51           0 :         cout << "  ";
      52           0 :         if (attr.ns != XMLNS_UNKNOWN_TOKEN)
      53           0 :             cout << m_tokens.get_nstoken_name(attr.ns) << ":";
      54             : 
      55           0 :         cout << m_tokens.get_token_name(attr.name) << " = \"" << attr.value << "\"" << endl;
      56           0 :     }
      57             : 
      58             : private:
      59             :     const tokens& m_tokens;
      60             : };
      61             : 
      62             : }
      63             : 
      64           0 : void print_element(const tokens& tokens, xmlns_token_t ns, xml_token_t name)
      65             : {
      66           0 :     if (ns != XMLNS_UNKNOWN_TOKEN)
      67           0 :         cout << tokens.get_nstoken_name(ns) << ":";
      68           0 :     cout << tokens.get_token_name(name) << endl;
      69           0 : }
      70             : 
      71           0 : void print_attrs(const tokens& tokens, const xml_attrs_t& attrs)
      72             : {
      73           0 :     for_each(attrs.begin(), attrs.end(), attr_printer(tokens));
      74           0 : }
      75             : 
      76           0 : void load_file_content(const char* filepath, string& strm)
      77             : {
      78           0 :     ifstream file(filepath);
      79           0 :     if (!file)
      80             :     {
      81             :         // failed to open the specified file.
      82           0 :         ostringstream os;
      83           0 :         os << "failed to load " << filepath;
      84           0 :         throw general_error(os.str());
      85             :     }
      86             : 
      87           0 :     ostringstream os;
      88           0 :     os << file.rdbuf();
      89           0 :     file.close();
      90           0 :     strm = os.str();
      91           0 : }
      92             : 
      93          24 : }

Generated by: LCOV version 1.10