/*

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.

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

*/
#include <cls_2/h/to_cls_format.hpp>

#include <cls_2/scalar/h/nonspace_format.hpp>

namespace cls_2 {

//
// scalar_nonspace_format_t
//

scalar_nonspace_format_t::scalar_nonspace_format_t() {
}

scalar_nonspace_format_t::~scalar_nonspace_format_t() {
}

int
scalar_nonspace_format_t::on_tok_nonspace(
	parser_context_t & context,
	const char * tok_value,
	value_type_t & result ) {
	result = tok_value;
	return c_ok;
}

int
scalar_nonspace_format_t::on_tok_string(
	parser_context_t & context,
	const char * tok_value,
	value_type_t & result ) {
	context.show_error( context.find_msg(
		c_msg_unexpected_tok_string ) );

	return c_semantic_error;
}

const char *
scalar_nonspace_format_t::format( const value_type_t & value ) {
	m_fmt_value.destroy();

	m_fmt_value.set( to_cls_format_t::format_nonspace(
		value.c_str() ), 0 );
	return m_fmt_value.query();
}

} /* namespace cls_2 */
