formattable.h

来自「一个symbian 冒险游戏代码」· C头文件 代码 · 共 75 行

H
75
字号
#ifndef _LANG_FORMATTABLE_H
#define _LANG_FORMATTABLE_H


#include <lang/String.h>


namespace lang
{


/** 
 * Container for an argument that can be formatted to text. 
 * 
 * @ingroup lang
 */
class Formattable
{
public:
	/** Type of value. */
	enum ValueType 
	{ 
		/** There is no value. */
		VALUE_NONE, 
		/** Value is numeric. */
		VALUE_DOUBLE, 
		/** Value is string. */
		VALUE_STRING 
	};

	/** Stores empty value. */
	Formattable();

	/** Stores numeric value. */
	Formattable( int value );

	/** Stores string value. */
	Formattable( const String& value );

	/** Stores string value. */
	Formattable( const char* value );

	/** Returns type of value. */
	ValueType	type() const;

	/** Returns numeric value. */
	int			doubleValue() const;

	/** Returns string value. */
	String		stringValue() const;

	/**
	 * Formats the value to the buffer using English/US locale and UTF-8 encoding.
	 * @param buffer Receives formatted value.
	 * @param size Maximum number of characters in the formatted value.
	 * @param pattern Pattern for formatting the value.
	 * @param pos Pattern position for the formatting options. (-1 if none)
	 * @return Number of characters needed to format the value.
	 */
	int			format( char* buffer, int size, const String& pattern, int pos ) const;

private:
	int			m_dbl;
	String		m_str;
	ValueType	m_type;
};


} // lang


#endif // _LANG_FORMATTABLE_H


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?