1999-08-16 21:50:52 +00:00
|
|
|
/*
|
1999-11-22 20:25:35 +00:00
|
|
|
*******************************************************************************
|
|
|
|
* Copyright (C) 1997-1999, International Business Machines Corporation and *
|
|
|
|
* others. All Rights Reserved. *
|
|
|
|
*******************************************************************************
|
1999-08-16 21:50:52 +00:00
|
|
|
*
|
|
|
|
* File FORMAT.CPP
|
|
|
|
*
|
|
|
|
* Modification History:
|
|
|
|
*
|
|
|
|
* Date Name Description
|
|
|
|
* 02/19/97 aliu Converted from java.
|
|
|
|
* 03/17/97 clhuang Implemented with new APIs.
|
|
|
|
* 03/27/97 helena Updated to pass the simple test after code review.
|
1999-11-22 20:25:35 +00:00
|
|
|
* 07/20/98 stephen Added explicit init values for Field/ParsePosition
|
1999-08-16 21:50:52 +00:00
|
|
|
********************************************************************************
|
|
|
|
*/
|
|
|
|
// *****************************************************************************
|
|
|
|
// This file was generated from the java source file Format.java
|
|
|
|
// *****************************************************************************
|
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
#include "unicode/format.h"
|
1999-08-16 21:50:52 +00:00
|
|
|
|
|
|
|
// *****************************************************************************
|
|
|
|
// class Format
|
|
|
|
// *****************************************************************************
|
|
|
|
|
|
|
|
// -------------------------------------
|
|
|
|
// default constructor
|
|
|
|
|
|
|
|
Format::Format()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------
|
|
|
|
|
|
|
|
Format::~Format()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------
|
|
|
|
// copy constructor
|
|
|
|
|
2000-08-15 18:25:20 +00:00
|
|
|
Format::Format(const Format& /*that*/)
|
1999-08-16 21:50:52 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------
|
|
|
|
// assignment operator
|
|
|
|
|
|
|
|
Format&
|
2000-08-15 18:25:20 +00:00
|
|
|
Format::operator=(const Format& /*that*/)
|
1999-08-16 21:50:52 +00:00
|
|
|
{
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------
|
|
|
|
// Formats the obj and append the result in the buffer, toAppendTo.
|
|
|
|
// This calls the actual implementation in the concrete subclasses.
|
|
|
|
|
|
|
|
UnicodeString&
|
|
|
|
Format::format(const Formattable& obj,
|
|
|
|
UnicodeString& toAppendTo,
|
|
|
|
UErrorCode& status) const
|
|
|
|
{
|
1999-10-18 22:48:32 +00:00
|
|
|
if (U_FAILURE(status)) return toAppendTo;
|
1999-08-16 21:50:52 +00:00
|
|
|
|
|
|
|
// {sfb} should really be FieldPosition::DONT_CARE, not 0
|
|
|
|
// leave at 0 for now, to keep in sync with Java
|
|
|
|
FieldPosition pos(0);
|
|
|
|
|
|
|
|
return format(obj, toAppendTo, pos, status);
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------
|
|
|
|
// Parses the source string and create the corresponding
|
|
|
|
// result object. Checks the parse position for errors.
|
|
|
|
|
|
|
|
void
|
|
|
|
Format::parseObject(const UnicodeString& source,
|
|
|
|
Formattable& result,
|
|
|
|
UErrorCode& status) const
|
|
|
|
{
|
1999-10-18 22:48:32 +00:00
|
|
|
if (U_FAILURE(status)) return;
|
1999-08-16 21:50:52 +00:00
|
|
|
|
|
|
|
ParsePosition parsePosition(0);
|
|
|
|
parseObject(source, result, parsePosition);
|
|
|
|
if (parsePosition.getIndex() == 0) {
|
1999-10-07 00:07:53 +00:00
|
|
|
status = U_INVALID_FORMAT_ERROR;
|
1999-08-16 21:50:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------
|
|
|
|
|
2000-05-18 22:08:39 +00:00
|
|
|
UBool
|
2000-08-15 18:25:20 +00:00
|
|
|
Format::operator==(const Format& /*that*/) const
|
1999-08-16 21:50:52 +00:00
|
|
|
{
|
|
|
|
// Add this implementation to make linker happy.
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//eof
|