From 0143e511f7a5f3595907787a832bee4e3cd03daf Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 13 Sep 2009 11:52:46 +0200 Subject: Add code stream interface and SLOC counter --- cutl/compiler/code-stream.txx | 96 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 cutl/compiler/code-stream.txx (limited to 'cutl/compiler/code-stream.txx') diff --git a/cutl/compiler/code-stream.txx b/cutl/compiler/code-stream.txx new file mode 100644 index 0000000..e834da7 --- /dev/null +++ b/cutl/compiler/code-stream.txx @@ -0,0 +1,96 @@ +// file : cutl/compiler/code-stream.txx +// author : Boris Kolpackov +// copyright : Copyright (c) 2009 Code Synthesis Tools CC +// license : MIT; see accompanying LICENSE file + +namespace cutl +{ + namespace compiler + { + // code_stream + // + + template + code_stream::~code_stream () + { + } + + // from_streambuf_adapter + // + + template + void from_streambuf_adapter:: + put (C c) + { + int_type i (stream_.sputc (c)); + + if (i == traits_type::eof ()) + throw eof (); + } + + template + void from_streambuf_adapter:: + unbuffer () + { + if (stream_.pubsync () != 0) + throw sync (); + } + + // to_streambuf_adapter + // + + template + typename to_streambuf_adapter::int_type to_streambuf_adapter:: + overflow (int_type i) + { + try + { + stream_.put (traits_type::to_char_type (i)); + return i; + } + catch (typename from_streambuf_adapter::eof const&) + { + return traits_type::eof (); + } + } + + template + int to_streambuf_adapter:: + sync () + { + return 0; + } + + // ostream_filter + // + + template