LCOV - code coverage report
Current view: top level - libreoffice/workdir/unxlngi6.pro/UnpackedTarball/orcus/include/orcus - tokens.hpp (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 1 100.0 %
Date: 2012-12-17 Functions: 1 1 100.0 %
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             : #ifndef __ORCUS_TOKENS_BASE_HPP__
      29             : #define __ORCUS_TOKENS_BASE_HPP__
      30             : 
      31             : #include "orcus/types.hpp"
      32             : #include "orcus/pstring.hpp"
      33             : 
      34             : #include <algorithm>
      35             : #include <boost/unordered_map.hpp>
      36             : 
      37             : namespace orcus {
      38             : 
      39             : class pstring;
      40             : 
      41           8 : class tokens
      42             : {
      43             : public:
      44             : 
      45             :     tokens(const char** token_names, size_t token_name_count, const char** nstoken_names, size_t nstoken_name_count);
      46             : 
      47             :     /**
      48             :      * Check if a token returned from get_token() method is valid.
      49             :      *
      50             :      * @return true if valid, false otherwise.
      51             :      */
      52             :     bool is_valid_token(xml_token_t token) const;
      53             : 
      54             :     /**
      55             :      * Get token from a specified name.
      56             :      *
      57             :      * @param name textural token name
      58             :      *
      59             :      * @return token value representing the given textural token.
      60             :      */
      61             :     xml_token_t get_token(const pstring& name) const;
      62             : 
      63             :     /**
      64             :      * Get textural token name from a token value.
      65             :      *
      66             :      * @param token numeric token value
      67             :      *
      68             :      * @return textural token name, or empty string in case the given token is
      69             :      *         not valid.
      70             :      */
      71             :     const char* get_token_name(xml_token_t token) const;
      72             : 
      73             :     /**
      74             :      * Check if a namespace token returned from get_nstoken() method is valid.
      75             :      *
      76             :      * @return true if valid, false otherwise.
      77             :      */
      78             :     bool is_valid_nstoken(xmlns_token_t token) const;
      79             : 
      80             :     /**
      81             :      * Get a namespace token from a specified name.
      82             :      *
      83             :      * @param name textural token name
      84             :      *
      85             :      * @return token value representing the given textural token.
      86             :      */
      87             :     xmlns_token_t get_nstoken(const pstring& name) const;
      88             : 
      89             :     /**
      90             :      * Get textural token name from a namespace token value.
      91             :      *
      92             :      * @param token numeric token value
      93             :      *
      94             :      * @return textural token name, or empty string in case the given token is
      95             :      *         not valid.
      96             :      */
      97             :     const char* get_nstoken_name(xmlns_token_t token) const;
      98             : 
      99             : private:
     100             :     typedef boost::unordered_map<pstring, xml_token_t, pstring::hash>     token_map_type;
     101             :     typedef boost::unordered_map<pstring, xmlns_token_t, pstring::hash>   nstoken_map_type;
     102             : 
     103             :     token_map_type   m_tokens;
     104             :     nstoken_map_type m_nstokens;
     105             : 
     106             :     const char** m_token_names;
     107             :     const char** m_nstoken_names;
     108             :     size_t m_token_name_count;
     109             :     size_t m_nstoken_name_count;
     110             : };
     111             : 
     112             : }
     113             : 
     114             : #endif

Generated by: LCOV version 1.10