/usr/include/Synopsis/Trace.hh is in libsynopsis0.12-dev 0.12-8.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | //
// Copyright (C) 2004 Stefan Seefeld
// All rights reserved.
// Licensed to the public under the terms of the GNU LGPL (>= 2),
// see the file COPYING for details.
//
#ifndef Synopsis_Trace_hh_
#define Synopsis_Trace_hh_
#include <iostream>
#include <string>
namespace Synopsis
{
class Trace
{
public:
  // This category list is incomplete and needs to be filled in as
  // more code is being written.
  enum Category { NONE=0x0,
		  PTREE=0x01,
		  SYMBOLLOOKUP=0x02,
		  PARSING=0x04,
		  TRANSLATION=0x08,
		  ALL=0xff};
  struct Entry
  {
    Entry(bool e);
    Entry(Entry const &e) : enabled(e.enabled) { e.enabled = false;}
    ~Entry();
    template <typename T> Entry const &operator<<(T const &t) const;
    mutable bool enabled;
  };
  friend struct Entry;
  Trace(std::string const &s, unsigned int c)
    : my_scope(s), my_visibility(my_mask & c)
  {
    if (!my_visibility) return;
    std::cout << indent() << "entering " << my_scope << std::endl;
    ++my_level;
  }
  template <typename T>
  Trace(std::string const &s, unsigned int c, T const &t)
    : my_scope(s), my_visibility(my_mask & c)
  {
    if (!my_visibility) return;
    std::cout << indent() << "entering " << my_scope << ' ' << t << std::endl;
    ++my_level;
  }
  ~Trace()
  {
    if (!my_visibility) return;
    --my_level;
    std::cout << indent() << "leaving " << my_scope << std::endl;
  }
  template <typename T>
  Entry operator<<(T const &t) const;
  static void enable(unsigned int mask = ALL) { my_mask = mask;}
private:
  static std::string indent() { return std::string(my_level, ' ');}
  static unsigned int my_mask;
  static size_t       my_level;
  std::string         my_scope;
  bool                my_visibility;
};
inline Trace::Entry::Entry(bool e) 
  : enabled(e)
{
  if (enabled)
    std::cout << Trace::indent();
}
inline Trace::Entry::~Entry() 
{
  if (enabled)
    std::cout << std::endl;
}
template <typename T> 
inline Trace::Entry const &Trace::Entry::operator<<(T const &t) const
{
  if (enabled)
    std::cout << t;
  return *this;
}
template <typename T>
inline Trace::Entry Trace::operator<<(T const &t) const
{
  Entry entry(my_visibility);
  return entry << t;
}
}
#endif
 |