/*

cls_2: Curl Like Syntax
Yauheni A. Akhotnikau (C) 2001-2003
eao197@yahoo.com
-------------------------------------------------

Permission is granted to anyone to use this software for any purpose on any
computer system, and to redistribute it freely, subject to the following
restrictions:

1. This software is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

2. The origin of this software must not be misrepresented, either by
   explicit claim or by omission.

3. Altered versions must be plainly marked as such, and must not be
   misrepresented as being the original software.

-------------------------------------------------

*/
#if !defined( _CLS_2__SIMPLE_TAG_FORMATTER_HPP_ )
#define _CLS_2__SIMPLE_TAG_FORMATTER_HPP_

#include <cls_2/h/cls.hpp>

namespace cls_2 {

//
// simple_class_formatter_t
//

/*
	Simple implementation of tag formatter.
	Object of this type simple use Writter << operator
	for output tag names, tag values and curly braces.

	Requirement:

	Writter & operator<<( Writter &, const char * )

	must be defined.
*/

template< class Writter >
class	simple_tag_formatter_t :
	public tag_formatter_t {
	public :
		simple_tag_formatter_t( Writter & writter );
		virtual ~simple_tag_formatter_t();

		virtual void
		start_tag( const char * tag_name );

		virtual void
		finish_tag();

		virtual void
		out_value( const char * value );

	protected :
		Writter &	m_writter;
};

template< class Writter >
simple_tag_formatter_t< Writter >::simple_tag_formatter_t(
	Writter & writter ) :
	m_writter( writter ) {
}

template< class Writter >
simple_tag_formatter_t< Writter >::~simple_tag_formatter_t() {
}

template< class Writter >
void
simple_tag_formatter_t< Writter >::start_tag(
	const char * tag_name ) {
	m_writter << "{" << tag_name << " ";
}

template< class Writter >
void
simple_tag_formatter_t< Writter >::finish_tag() {
	m_writter << "} ";
}

template< class Writter >
void
simple_tag_formatter_t< Writter >::out_value( const char * value ) {
	m_writter << value << " ";
}

} /* namespace cls_2 */

#endif
