/*

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__SCALAR__NONSPACE_FORMAT_HPP_ )
#define _CLS_2__SCALAR__NONSPACE_FORMAT_HPP_

#include <string>

#include <auto_ptr_3/h/vect_ptr.hpp>

#include <cls_2/h/cls.hpp>

namespace cls_2 {

//
// scalar_nonspace_format_t
//

/*
	Class for processing NONSPACE tokens as std::string values
*/
class	scalar_nonspace_format_t {
	public :
		typedef std::string	value_type_t;

	public :
		scalar_nonspace_format_t();
		~scalar_nonspace_format_t();

		// Called for processing 'NONSPACE' token
		// Default implementation returns c_ok
		static int
		on_tok_nonspace(
			parser_context_t & context,
			const char * tok_value,
			value_type_t & result );

		// Called for processing 'STRING' token
		// Default implementation returns c_semantic_error
		static int
		on_tok_string(
			parser_context_t & context,
			const char * tok_value,
			value_type_t & result );

		// Called for formating valid value
		const char *
		format( const value_type_t & value );

		// Called for formating disallowed value
		// during error reporting.
		const char *
		format_disallowed_value(
			const value_type_t & value ) {
			return value.c_str();
		}

	protected :
		// Result of formatting
		auto_ptr_3::vect_ptr_t< char >	m_fmt_value;
};

} /* namespace cls_2 */

#endif
