LCOV - code coverage report
Current view: top level - mnt/wasteland/wcohen/systemtap_write/systemtap/re2c-migrate - re2c-globals.h (source / functions) Hit Total Coverage
Test: stap.info Lines: 14 21 66.7 %
Date: 2013-03-08 Functions: 5 11 45.5 %
Branches: 1 16 6.2 %

           Branch data     Line data    Source code
       1                 :            : // -*- C++ -*-
       2                 :            : // Copyright (C) 2012-2013 Red Hat Inc.
       3                 :            : //
       4                 :            : // This file is part of systemtap, and is free software.  You can
       5                 :            : // redistribute it and/or modify it under the terms of the GNU General
       6                 :            : // Public License (GPL); either version 2, or (at your option) any
       7                 :            : // later version.
       8                 :            : //
       9                 :            : // ---
      10                 :            : //
      11                 :            : // This file incorporates code from the re2c project; please see
      12                 :            : // re2c-migrate/README for details.
      13                 :            : 
      14                 :            : #ifndef _re2c_globals_h
      15                 :            : #define _re2c_globals_h
      16                 :            : 
      17                 :            : #ifdef HAVE_CONFIG_H
      18                 :            : #include "config.h"
      19                 :            : #elif defined(_WIN32)
      20                 :            : #include "config_w32.h"
      21                 :            : #endif
      22                 :            : 
      23                 :            : #include <set>
      24                 :            : #include <algorithm>
      25                 :            : #include <iostream>
      26                 :            : #include <string>
      27                 :            : #include <stdexcept>
      28                 :            : #include <string.h>
      29                 :            : 
      30                 :            : namespace re2c
      31                 :            : {
      32                 :            : 
      33                 :            : struct re2c_error: public std::runtime_error
      34                 :            : {
      35                 :            :   unsigned pos;
      36                 :            :   re2c_error (const std::string& msg):
      37                 :            :     runtime_error(msg), pos(0) {}
      38                 :          0 :   re2c_error (const std::string& msg, unsigned pos):
      39                 :          0 :     runtime_error(msg), pos(pos) {}
      40         [ #  # ]:          0 :   ~re2c_error () throw () {}
      41                 :            : };
      42                 :            : 
      43                 :            : extern bool DFlag;
      44                 :            : extern bool eFlag;
      45                 :            : extern bool uFlag;
      46                 :            : extern bool wFlag;
      47                 :            : 
      48                 :            : extern const unsigned asc2asc[256];
      49                 :            : extern const unsigned asc2ebc[256];
      50                 :            : extern const unsigned ebc2asc[256];
      51                 :            : 
      52                 :            : extern const unsigned *xlat;
      53                 :            : extern const unsigned *talx;
      54                 :            : 
      55                 :            : extern char octCh(unsigned c);
      56                 :            : extern char hexCh(unsigned c);
      57                 :            : 
      58                 :            : // ------------------------------------------------------------
      59                 :            : 
      60                 :            : // moved here from substr.h
      61                 :            : 
      62                 :            : class SubStr
      63                 :            : {
      64                 :            : public:
      65                 :            :         const char * str;
      66                 :            :         const char * const org;
      67                 :            :         unsigned         len;
      68                 :            : 
      69                 :            : public:
      70                 :            :         friend bool operator==(const SubStr &, const SubStr &);
      71                 :            :         SubStr(const unsigned char*, unsigned);
      72                 :            :         SubStr(const char*, unsigned);
      73                 :            :         explicit SubStr(const char*);
      74                 :            :         SubStr(const SubStr&);
      75                 :            :         virtual ~SubStr();
      76                 :            :         void out(std::ostream&) const;
      77                 :            :         std::string to_string() const;
      78                 :            :         unsigned ofs() const;
      79                 :            : 
      80                 :            : #ifdef PEDANTIC
      81                 :            : protected:
      82                 :            :         SubStr& operator = (const SubStr& oth);
      83                 :            : #endif
      84                 :            : };
      85                 :            : 
      86                 :            : class Str: public SubStr
      87                 :            : {
      88                 :            : public:
      89                 :            :         explicit Str(const char*);
      90                 :            :         Str(const SubStr&);
      91                 :            :         Str();
      92                 :            :         virtual ~Str();
      93                 :            : };
      94                 :            : 
      95                 :         90 : inline std::ostream& operator<<(std::ostream& o, const SubStr &s)
      96                 :            : {
      97                 :         90 :         s.out(o);
      98                 :         90 :         return o;
      99                 :            : }
     100                 :            : 
     101                 :            : inline std::ostream& operator<<(std::ostream& o, const SubStr* s)
     102                 :            : {
     103                 :            :         return o << *s;
     104                 :            : }
     105                 :            : 
     106                 :            : inline SubStr::SubStr(const unsigned char *s, unsigned l)
     107                 :            :                 : str((char*)s), org((char*)s), len(l)
     108                 :            : { }
     109                 :            : 
     110                 :         48 : inline SubStr::SubStr(const char *s, unsigned l)
     111                 :         48 :                 : str(s), org(s), len(l)
     112                 :         48 : { }
     113                 :            : 
     114                 :        132 : inline SubStr::SubStr(const char *s)
     115                 :        132 :                 : str(s), org(s), len(strlen(s))
     116                 :        132 : { }
     117                 :            : 
     118                 :         84 : inline SubStr::SubStr(const SubStr &s)
     119                 :         84 :                 : str(s.str), org(s.str), len(s.len)
     120                 :         84 : { }
     121                 :            : 
     122                 :        264 : inline SubStr::~SubStr()
     123         [ -  + ]:        264 : { }
     124                 :            : 
     125                 :          0 : inline std::string SubStr::to_string() const
     126                 :            : {
     127 [ #  # ][ #  # ]:          0 :         return str && len ? std::string(str, len) : std::string();
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     128                 :            : }
     129                 :            : 
     130                 :          0 : inline unsigned SubStr::ofs() const
     131                 :            : {
     132                 :          0 :         return str - org;
     133                 :            : }
     134                 :            : 
     135                 :            : #ifdef PEDANTIC
     136                 :            : inline SubStr& SubStr::operator = (const SubStr& oth)
     137                 :            : {
     138                 :            :         new(this) SubStr(oth);
     139                 :            :         return *this;
     140                 :            : }
     141                 :            : #endif
     142                 :            : 
     143                 :            : } // end namespace re2c
     144                 :            : 
     145                 :            : #if defined(_MSC_VER) && !defined(vsnprintf)
     146                 :            : #define vsnprintf _vsnprintf
     147                 :            : #endif
     148                 :            : 
     149                 :            : #endif

Generated by: LCOV version 1.9