From 8286ac511144e4f17d34eac9affb97e50646344a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Wed, 23 Jul 2014 15:25:44 +0200 Subject: Imported Upstream version 4.0.0 --- libcutl/cutl/compiler/sloc-counter.hxx | 78 ++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 libcutl/cutl/compiler/sloc-counter.hxx (limited to 'libcutl/cutl/compiler/sloc-counter.hxx') diff --git a/libcutl/cutl/compiler/sloc-counter.hxx b/libcutl/cutl/compiler/sloc-counter.hxx new file mode 100644 index 0000000..cbcdede --- /dev/null +++ b/libcutl/cutl/compiler/sloc-counter.hxx @@ -0,0 +1,78 @@ +// file : cutl/compiler/sloc-counter.hxx +// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +// license : MIT; see accompanying LICENSE file + +#ifndef CUTL_COMPILER_SLOC_COUNTER_HXX +#define CUTL_COMPILER_SLOC_COUNTER_HXX + +#include // std::size_t + +#include + +namespace cutl +{ + namespace compiler + { + template + class sloc_counter: public code_stream + { + public: + sloc_counter (code_stream& out); + + std::size_t + count () const + { + return count_; + } + + private: + sloc_counter (sloc_counter const&); + + sloc_counter& + operator= (sloc_counter const&); + + public: + virtual void + put (C); + + virtual void + unbuffer (); + + private: + void + code (C); + + void + c_comment (C); + + void + cxx_comment (C); + + void + char_literal (C); + + void + string_literal (C); + + private: + code_stream& out_; + std::size_t count_; + + C prev_; // Previous character or '\0'. + bool code_counted_; // This code line has already been counted. + + enum construct + { + con_code, + con_c_com, + con_cxx_com, + con_char_lit, + con_string_lit + } construct_; + }; + } +} + +#include + +#endif // CUTL_COMPILER_SLOC_COUNTER_HXX -- cgit v1.2.3