rwlogo

Rogue Wave Views
Data Access Package API Reference Guide

Product Documentation:

Rogue Wave Views
Documentation Home

 All Classes Files Functions Variables Typedefs Enumerations Enumerator
List of all members | Public Member Functions | Static Public Member Functions
IliFormat Class Reference

User interface class. More...

#include <ilviews/dataccess/format.h>

Public Member Functions

 IliFormat ()
 Initializes a default format.
 
 IliFormat (const char *definition)
 Initializes a format according to a definition. More...
 
 IliFormat (const IliFormat &)
 This is the copy constructor of the IliFormat class.
 
void format (IliString &dest, const char *val) const
 Formats string and appends the result to another string. More...
 
void format (IliString &dest, IlBoolean val) const
 Formats Boolean and appends the result to a string. More...
 
void format (IliString &dest, IlInt val) const
 Formats integer and appends the result to a string. More...
 
void format (IliString &dest, IlFloat val) const
 Formats float and appends the result to a string. More...
 
void format (IliString &dest, IlDouble val) const
 Formats double and appends the result to a string. More...
 
void format (IliString &dest, IliDecimal val) const
 Formats decimal and appends the result to a string. More...
 
void format (IliString &dest, const IliDate &val) const
 Formats date and appends the result to a string. More...
 
const char * getDefinition () const
 Returns the definition of the format. More...
 
IliFormatType getType () const
 Returns the type of the format. More...
 
IlBoolean isNull () const
 Returns IlTrue if the format definition is Null. More...
 
IlBoolean isPasswordFormat () const
 Returns IlTrue if the format can be used to format passwords. More...
 
IlBoolean isUserDefinedFormat () const
 Returns IlTrue if the format definition consists of a user-defined specification. More...
 
IliFormatoperator= (const IliFormat &fmt)
 Copies a format. More...
 
int operator== (const IliFormat &fmt) const
 Tests whether two formats are equal. More...
 
void read (IL_STDPREF istream &input)
 Reads the format from an input stream. More...
 
void setDefinition (const char *definition)
 Sets the definition of a format. More...
 
void write (IL_STDPREF ostream &output) const
 Writes the format definition to an output stream in such a way that it may be read back by the read member function. More...
 

Static Public Member Functions

static void AddAlias (const char *aliasName, const char *definition, IliFormatType type, IliFormatCategory category=IliUserFormat)
 Defines a new alias. More...
 
static void ConnectToMessageDatabase (IlvDisplay *display)
 Attaches a language hook to the display so that it can be notified about a change in the current language of the display. More...
 
static const char * GetAliasDefinition (IlInt aliasIndex)
 Returns the definition for one alias. More...
 
static const char * GetAliasDefinition (const char *aliasName)
 Returns the definition for one alias. More...
 
static IlInt GetAliasesCount ()
 Returns the count of the format aliases. More...
 
static IliFormatCategory GetAliasFormatCategory (IlInt aliasIndex)
 Returns the category for one alias. More...
 
static IliFormatType GetAliasFormatType (IlInt aliasIndex)
 Returns the format type for one alias. More...
 
static IlInt GetAliasIndex (const char *aliasName)
 Returns the position of one alias. More...
 
static const char * GetAliasName (IlInt aliasIndex)
 Returns the name of one alias. More...
 
static IliCurrencyPosition GetCurrencyPosition ()
 Returns the position of the currency symbol in formatted output. More...
 
static const char * GetCurrencySymbol ()
 Returns the character string used to represent the currency symbol in formatted output. More...
 
static char GetDateSeparator ()
 Returns the character used to represent a date separator in formatted output. More...
 
static char GetDecimalPoint ()
 Returns the character used to represent a decimal point in formatted output. More...
 
static const IliFormatGetDefaultFormat ()
 Returns a constant reference to the default format. More...
 
static const char * GetLongMonthLabel (IlInt month)
 Returns the character string used to represent a month. More...
 
static const char * GetLongWeekDayLabel (IlInt weekDay)
 Returns the character string used to represent the day. More...
 
static IlInt GetMonthByName (const char *name)
 Returns the index of the month from its name. More...
 
static const char * GetShortMonthLabel (IlInt month)
 Returns the abbreviated character string used to represent a month. More...
 
static const char * GetShortWeekDayLabel (IlInt weekDay)
 Returns the abbreviated character string used to represent the day. More...
 
static char GetThousandsSeparator ()
 Returns the character used to represent the thousands separator in formatted output. More...
 
static char GetTimeSeparator ()
 Returns the character used to represent a time separator in formatted output. More...
 
static IlBoolean IsDefaultStringLtoR ()
 Returns IlTrue if the formatting of strings proceeds by default from left to right. More...
 
static IlBoolean IsMonthBeforeDay ()
 Returns IlTrue if the month should be formatted to the left of the day. More...
 
static IlBoolean ReadMessageDatabase (IlvDisplay *disp, const char *file)
 Reads a message database file. More...
 
static void RemoveAlias (IlInt aliasIndex)
 Removes an alias. More...
 
static void SetAliasDefinition (IlInt aliasIndex, const char *definition)
 Sets the definition of one alias. More...
 
static void SetAliasFormatCategory (IlInt aliasIndex, IliFormatCategory c)
 Sets the format category for one alias. More...
 
static void SetAliasFormatType (IlInt aliasIndex, IliFormatType type)
 Sets the format type for one alias. More...
 
static void SetAliasName (IlInt aliasIndex, const char *name)
 Sets the name of one alias. More...
 
static void SetCurrencyPosition (IliCurrencyPosition pos)
 Sets the position of the currency symbol in formatted output. More...
 
static void SetCurrencySymbol (const char *c)
 Sets the character string used to represent the currency symbol in formatted output. More...
 
static void SetDateSeparator (char c)
 Sets the character used to represent a date separator in formatted output. More...
 
static void SetDecimalPoint (char c)
 Sets the character used to represent a decimal point in formatted output. More...
 
static void SetDefaultStringLtoR (IlBoolean direction)
 Sets the default formatting direction of strings. More...
 
static void SetLongMonthLabel (IlInt month, const char *label)
 Sets the character string used to represent a month. More...
 
static void SetLongWeekDayLabel (IlInt weekDay, const char *label)
 Sets the character string used to represent the day. More...
 
static void SetMonthBeforeDay (IlBoolean before)
 Specifies whether the month is shown before, or after the day, in the formatted output. More...
 
static void SetShortMonthLabel (IlInt month, const char *label)
 Sets the abbreviated character string used to represent a month. More...
 
static void SetShortWeekDayLabel (IlInt weekDay, const char *str)
 Sets the abbreviated character string used to represent the day. More...
 
static void SetThousandsSeparator (char c)
 Sets the character used to represent the thousands separator in formatted output. More...
 
static void SetTimeSeparator (char c)
 Sets the character used to represent a time separator in formatted output. More...
 

Detailed Description

User interface class.

Library: dataccess

An IliFormat object is used to format values into character strings according to specific rules. It is either a user-defined format specification (for example, "#,##0.00") or a predefined format (for example, "Currency"). Although the formatting process is controlled by the format specification, it may use some global settings (such as the character that represents a decimal point). The IliFormat class contains a set of static member functions that can be used to query and set the global settings, and that affect the formatting process. It is possible to name a format specification so that it may be conveniently referenced. This can be done through the aliasing mechanism provided by the IliFormat class.

See Also
IliDate, IliString, IliDecimal, IliCurrencyPosition, IliFormatCategory, IliFormatType

Constructor & Destructor Documentation

IliFormat::IliFormat ( const char *  definition)

Initializes a format according to a definition.

Parameters
definitionThe format definition.

Member Function Documentation

static void IliFormat::AddAlias ( const char *  aliasName,
const char *  definition,
IliFormatType  type,
IliFormatCategory  category = IliUserFormat 
)
static

Defines a new alias.

Parameters
aliasNameThe alias name.
definitionThe definition.
typeThe format type.
categoryThe format category can be one of the following values: IliSystemFormat, IliApplicationFormat or IliUserFormat.
static void IliFormat::ConnectToMessageDatabase ( IlvDisplay display)
static

Attaches a language hook to the display so that it can be notified about a change in the current language of the display.

It is necessary to call this member function at initialization time after the date.dbm message database file has been successfully read by the ReadMessageDatabase member function.

Parameters
displayThe display.
void IliFormat::format ( IliString dest,
const char *  val 
) const

Formats string and appends the result to another string.

Parameters
destThe destination string.
valThe value.
void IliFormat::format ( IliString dest,
IlBoolean  val 
) const

Formats Boolean and appends the result to a string.

Parameters
destThe destination string.
valThe value.
void IliFormat::format ( IliString dest,
IlInt  val 
) const

Formats integer and appends the result to a string.

Parameters
destThe destination string.
valThe value.
void IliFormat::format ( IliString dest,
IlFloat  val 
) const

Formats float and appends the result to a string.

Parameters
destThe destination string.
valThe value.
void IliFormat::format ( IliString dest,
IlDouble  val 
) const

Formats double and appends the result to a string.

Parameters
destThe destination string.
valThe value.
void IliFormat::format ( IliString dest,
IliDecimal  val 
) const

Formats decimal and appends the result to a string.

Parameters
destThe destination string.
valThe value.
void IliFormat::format ( IliString dest,
const IliDate val 
) const

Formats date and appends the result to a string.

Parameters
destThe destination string.
valThe value.
static const char* IliFormat::GetAliasDefinition ( IlInt  aliasIndex)
static

Returns the definition for one alias.

Parameters
aliasIndexThe alias index.
Returns
The definition.
static const char* IliFormat::GetAliasDefinition ( const char *  aliasName)
static

Returns the definition for one alias.

Parameters
aliasNameThe alias name.
Returns
The definition.
static IlInt IliFormat::GetAliasesCount ( )
static

Returns the count of the format aliases.

Returns
The count.
static IliFormatCategory IliFormat::GetAliasFormatCategory ( IlInt  aliasIndex)
static

Returns the category for one alias.

Parameters
aliasIndexThe alias index.
Returns
The category.
static IliFormatType IliFormat::GetAliasFormatType ( IlInt  aliasIndex)
static

Returns the format type for one alias.

Parameters
aliasIndexThe alias index.
Returns
The format type.
static IlInt IliFormat::GetAliasIndex ( const char *  aliasName)
static

Returns the position of one alias.

Parameters
aliasNameThe alias name.
Returns
The position if found, otherwise -1.
static const char* IliFormat::GetAliasName ( IlInt  aliasIndex)
static

Returns the name of one alias.

Parameters
aliasIndexThe alias index.
Returns
The name.
static IliCurrencyPosition IliFormat::GetCurrencyPosition ( )
static

Returns the position of the currency symbol in formatted output.

Returns
The position of the currency symbol in formatted output. The returned value can be one of the following: IliCP_AtLeft_NoSpace, IliCP_AtLeft_Space, IliCP_AtRight_NoSpace or IliCP_AtRight_Space.
static const char* IliFormat::GetCurrencySymbol ( )
static

Returns the character string used to represent the currency symbol in formatted output.

Returns
The character.
static char IliFormat::GetDateSeparator ( )
static

Returns the character used to represent a date separator in formatted output.

Returns
The character.
static char IliFormat::GetDecimalPoint ( )
static

Returns the character used to represent a decimal point in formatted output.

Returns
The character.
static const IliFormat& IliFormat::GetDefaultFormat ( )
static

Returns a constant reference to the default format.

Returns
A constant reference to the default format.
const char* IliFormat::getDefinition ( ) const

Returns the definition of the format.

Returns
The definition.
static const char* IliFormat::GetLongMonthLabel ( IlInt  month)
static

Returns the character string used to represent a month.

Parameters
monthThe month (an integer between 0 and 11).
Returns
The character string.
static const char* IliFormat::GetLongWeekDayLabel ( IlInt  weekDay)
static

Returns the character string used to represent the day.

Parameters
weekDayThe day (an integer between 0 and 6 ).
Returns
The character string.
static IlInt IliFormat::GetMonthByName ( const char *  name)
static

Returns the index of the month from its name.

Parameters
nameThe month name.
Returns
An integer between 0 and 11, if successful, and -1 if not.
static const char* IliFormat::GetShortMonthLabel ( IlInt  month)
static

Returns the abbreviated character string used to represent a month.

Parameters
monthThe month (an integer between 0 and 11).
Returns
The abbreviated character string.
static const char* IliFormat::GetShortWeekDayLabel ( IlInt  weekDay)
static

Returns the abbreviated character string used to represent the day.

Parameters
weekDayThe day (an integer between 0 and 6 ).
Returns
The abbreviated character string.
static char IliFormat::GetThousandsSeparator ( )
static

Returns the character used to represent the thousands separator in formatted output.

Returns
The character.
static char IliFormat::GetTimeSeparator ( )
static

Returns the character used to represent a time separator in formatted output.

Returns
The character.
IliFormatType IliFormat::getType ( ) const

Returns the type of the format.

Possible values are IliNullFormatType, IliStringFormatType, IliNumberFormatType, or IliDateFormatType.

Returns
The type.
static IlBoolean IliFormat::IsDefaultStringLtoR ( )
static

Returns IlTrue if the formatting of strings proceeds by default from left to right.

Returns
IlTrue if the formatting of strings proceeds by default (i.e., when the "!" symbol was not used in the format specifications) from left to right.
static IlBoolean IliFormat::IsMonthBeforeDay ( )
static

Returns IlTrue if the month should be formatted to the left of the day.

Returns
IlTrue if the month should be formatted to the left of the day.
IlBoolean IliFormat::isNull ( ) const

Returns IlTrue if the format definition is Null.

Returns
IlTrue if the format definition is Null.
IlBoolean IliFormat::isPasswordFormat ( ) const

Returns IlTrue if the format can be used to format passwords.

Returns
IlTrue if the format can be used to format passwords.
IlBoolean IliFormat::isUserDefinedFormat ( ) const

Returns IlTrue if the format definition consists of a user-defined specification.

Returns
IlTrue if the format definition consists of a user-defined specification.
IliFormat& IliFormat::operator= ( const IliFormat fmt)

Copies a format.

Parameters
fmtThe format that will be copied.
int IliFormat::operator== ( const IliFormat fmt) const

Tests whether two formats are equal.

Parameters
fmtThe second format.
void IliFormat::read ( IL_STDPREF istream &  input)

Reads the format from an input stream.

Parameters
inputThe input stream.
static IlBoolean IliFormat::ReadMessageDatabase ( IlvDisplay disp,
const char *  file 
)
static

Reads a message database file.

Parameters
dispThe display.
fileThe message database file must be a valid Rogue Wave Views message database file.
Returns
IlTrue if the file was successfully located.
static void IliFormat::RemoveAlias ( IlInt  aliasIndex)
static

Removes an alias.

Parameters
aliasIndexThe alias index.
static void IliFormat::SetAliasDefinition ( IlInt  aliasIndex,
const char *  definition 
)
static

Sets the definition of one alias.

Parameters
aliasIndexThe alias index.
definitionThe definition.
static void IliFormat::SetAliasFormatCategory ( IlInt  aliasIndex,
IliFormatCategory  c 
)
static

Sets the format category for one alias.

Parameters
aliasIndexThe alias index.
cThe format category.
static void IliFormat::SetAliasFormatType ( IlInt  aliasIndex,
IliFormatType  type 
)
static

Sets the format type for one alias.

Parameters
aliasIndexThe alias index.
typeThe format type.
static void IliFormat::SetAliasName ( IlInt  aliasIndex,
const char *  name 
)
static

Sets the name of one alias.

Parameters
aliasIndexThe alias index.
nameThe alias name.
static void IliFormat::SetCurrencyPosition ( IliCurrencyPosition  pos)
static

Sets the position of the currency symbol in formatted output.

Parameters
posThe position.
static void IliFormat::SetCurrencySymbol ( const char *  c)
static

Sets the character string used to represent the currency symbol in formatted output.

Parameters
cThe character.
static void IliFormat::SetDateSeparator ( char  c)
static

Sets the character used to represent a date separator in formatted output.

Parameters
cThe character.
static void IliFormat::SetDecimalPoint ( char  c)
static

Sets the character used to represent a decimal point in formatted output.

Parameters
cThe character.
static void IliFormat::SetDefaultStringLtoR ( IlBoolean  direction)
static

Sets the default formatting direction of strings.

Parameters
directionIf IlTrue, sets the default formatting direction of strings to "left to right". Otherwise the default formatting direction is set to "right to left".
void IliFormat::setDefinition ( const char *  definition)

Sets the definition of a format.

Parameters
definitionThe definition.
static void IliFormat::SetLongMonthLabel ( IlInt  month,
const char *  label 
)
static

Sets the character string used to represent a month.

Parameters
monthThe month (an integer between 0 and 11).
labelThe month label.
static void IliFormat::SetLongWeekDayLabel ( IlInt  weekDay,
const char *  label 
)
static

Sets the character string used to represent the day.

Parameters
weekDayThe day (an integer between 0 and 6 ).
labelThe day label.
static void IliFormat::SetMonthBeforeDay ( IlBoolean  before)
static

Specifies whether the month is shown before, or after the day, in the formatted output.

Parameters
beforeIf IlTrue the month is formatted to the left of the day.
static void IliFormat::SetShortMonthLabel ( IlInt  month,
const char *  label 
)
static

Sets the abbreviated character string used to represent a month.

Parameters
monthThe month (an integer between 0 and 11).
labelThe month label.
static void IliFormat::SetShortWeekDayLabel ( IlInt  weekDay,
const char *  str 
)
static

Sets the abbreviated character string used to represent the day.

Parameters
weekDayThe day (an integer between 0 and 6 ).
strThe day label.
static void IliFormat::SetThousandsSeparator ( char  c)
static

Sets the character used to represent the thousands separator in formatted output.

Parameters
cThe character.
static void IliFormat::SetTimeSeparator ( char  c)
static

Sets the character used to represent a time separator in formatted output.

Parameters
cThe character.
void IliFormat::write ( IL_STDPREF ostream &  output) const

Writes the format definition to an output stream in such a way that it may be read back by the read member function.

Parameters
outputThe output stream.

© Copyright 2015, Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave is a registered trademark of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.