Debian Codegraph @

cutl/compiler/sloc-counter.hxx

raw
1 // file : cutl/compiler/sloc-counter.hxx
2 // copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
3 // license : MIT; see accompanying LICENSE file
4
5 #ifndef CUTL_COMPILER_SLOC_COUNTER_HXX
6 #define CUTL_COMPILER_SLOC_COUNTER_HXX
7
8 #include <cstddef> // std::size_t
9
10 #include <cutl/compiler/code-stream.hxx>
11
12 namespace cutl
13 {
14 namespace compiler
15 {
16 template <typename C>
17 class sloc_counter: public code_stream<C>
18 {
19 public:
20 sloc_counter (code_stream<C>& out);
21
22 std::size_t
23 count () const
24 {
25 return count_;
26 }
27
28 private:
29 sloc_counter (sloc_counter const&);
30
31 sloc_counter&
32 operator= (sloc_counter const&);
33
34 public:
35 virtual void
36 put (C);
37
38 virtual void
39 unbuffer ();
40
41 private:
42 void
43 code (C);
44
45 void
46 c_comment (C);
47
48 void
49 cxx_comment (C);
50
51 void
52 char_literal (C);
53
54 void
55 string_literal (C);
56
57 private:
58 code_stream<C>& out_;
59 std::size_t count_;
60
61 C prev_; // Previous character or '\0'.
62 bool code_counted_; // This code line has already been counted.
63
64 enum construct
65 {
66 con_code,
67 con_c_com,
68 con_cxx_com,
69 con_char_lit,
70 con_string_lit
71 } construct_;
72 };
73 }
74 }
75
76 #include <cutl/compiler/sloc-counter.txx>
77
78 #endif // CUTL_COMPILER_SLOC_COUNTER_HXX