@@ -38,7 +38,6 @@ namespace message2 {
3838
3939// Function registry implementation
4040
41- FunctionFactory::~FunctionFactory () {}
4241Function::~Function () {}
4342FunctionValue::~FunctionValue () {}
4443
@@ -52,9 +51,9 @@ MFFunctionRegistry MFFunctionRegistry::Builder::build() {
5251}
5352
5453MFFunctionRegistry::Builder&
55- MFFunctionRegistry::Builder::adoptFunctionFactory (const FunctionName& functionName,
56- FunctionFactory * function,
57- UErrorCode& errorCode) {
54+ MFFunctionRegistry::Builder::adoptFunction (const FunctionName& functionName,
55+ Function * function,
56+ UErrorCode& errorCode) {
5857 if (U_SUCCESS (errorCode)) {
5958 U_ASSERT (functions != nullptr );
6059 functions->put (functionName, function, errorCode);
@@ -100,9 +99,9 @@ MFFunctionRegistry::Builder::~Builder() {
10099
101100// Returns non-owned pointer. Returns pointer rather than reference because it can fail.
102101// Returns non-const because Function is mutable.
103- FunctionFactory * MFFunctionRegistry::getFunction (const FunctionName& functionName) const {
102+ Function * MFFunctionRegistry::getFunction (const FunctionName& functionName) const {
104103 U_ASSERT (functions != nullptr );
105- return static_cast <FunctionFactory *>(functions->get (functionName));
104+ return static_cast <Function *>(functions->get (functionName));
106105}
107106
108107UBool MFFunctionRegistry::getDefaultFormatterNameByType (const UnicodeString& type, FunctionName& name) const {
@@ -227,54 +226,19 @@ MFFunctionRegistry::~MFFunctionRegistry() {
227226
228227// --------- Number
229228
230- /* static */ StandardFunctions::NumberFactory*
231- StandardFunctions::NumberFactory::integer (UErrorCode& success) {
232- return NumberFactory::create (true , success);
233- }
234-
235- /* static */ StandardFunctions::NumberFactory*
236- StandardFunctions::NumberFactory::number (UErrorCode& success) {
237- return NumberFactory::create (false , success);
238- }
239-
240- /* static */ StandardFunctions::NumberFactory*
241- StandardFunctions::NumberFactory::create (bool isInteger,
242- UErrorCode& success) {
243- NULL_ON_ERROR (success);
244-
245- LocalPointer<NumberFactory> result (new NumberFactory (isInteger));
246- if (!result.isValid ()) {
247- success = U_MEMORY_ALLOCATION_ERROR;
248- return nullptr ;
249- }
250- return result.orphan ();
251- }
252-
253- Function*
254- StandardFunctions::NumberFactory::createFunction (UErrorCode& errorCode) {
255- NULL_ON_ERROR (errorCode);
256-
257- Number* result = new Number (isInteger);
258- if (result == nullptr ) {
259- errorCode = U_MEMORY_ALLOCATION_ERROR;
260- }
261- return result;
262- }
263-
264229/* static */ StandardFunctions::Number*
265- StandardFunctions::Number::integer (const Locale& loc, UErrorCode& success) {
266- return create (loc, true , success);
230+ StandardFunctions::Number::integer (UErrorCode& success) {
231+ return create (true , success);
267232}
268233
269234/* static */ StandardFunctions::Number*
270- StandardFunctions::Number::number (const Locale& loc, UErrorCode& success) {
271- return create (loc, false , success);
235+ StandardFunctions::Number::number (UErrorCode& success) {
236+ return create (false , success);
272237}
273238
274239/* static */ StandardFunctions::Number*
275- StandardFunctions::Number::create (const Locale& loc, bool isInteger, UErrorCode& success) {
240+ StandardFunctions::Number::create (bool isInteger, UErrorCode& success) {
276241 NULL_ON_ERROR (success);
277- (void ) loc;
278242
279243 LocalPointer<Number> result (new Number (isInteger));
280244 if (!result.isValid ()) {
@@ -622,7 +586,6 @@ UnicodeString StandardFunctions::NumberValue::formatToString(UErrorCode& errorCo
622586 return formattedNumber.toString (errorCode);
623587}
624588
625- StandardFunctions::NumberFactory::~NumberFactory () {}
626589StandardFunctions::Number::~Number () {}
627590StandardFunctions::NumberValue::~NumberValue () {}
628591
@@ -728,59 +691,23 @@ void StandardFunctions::NumberValue::selectKeys(const UnicodeString* keys,
728691
729692// --------- DateTime
730693
731- /*
732- // Date/time options only
733- static UnicodeString defaultForOption(const UnicodeString& optionName) {
734- if (optionName == UnicodeString("dateStyle")
735- || optionName == UnicodeString("timeStyle")
736- || optionName == UnicodeString("style")) {
737- return UnicodeString("short");
738- }
739- return {}; // Empty string is default
740- }
741- */
742-
743- /* static */ StandardFunctions::DateTimeFactory*
744- StandardFunctions::DateTimeFactory::date (UErrorCode& success) {
745- return DateTimeFactory::create (DateTimeType::kDate , success);
746- }
747-
748- /* static */ StandardFunctions::DateTimeFactory*
749- StandardFunctions::DateTimeFactory::time (UErrorCode& success) {
750- return DateTimeFactory::create (DateTimeType::kTime , success);
751- }
752-
753- /* static */ StandardFunctions::DateTimeFactory*
754- StandardFunctions::DateTimeFactory::dateTime (UErrorCode& success) {
755- return DateTimeFactory::create (DateTimeType::kDateTime , success);
694+ /* static */ StandardFunctions::DateTime*
695+ StandardFunctions::DateTime::date (UErrorCode& success) {
696+ return DateTime::create (DateTimeType::kDate , success);
756697}
757698
758- /* static */ StandardFunctions::DateTimeFactory*
759- StandardFunctions::DateTimeFactory::create (DateTimeFactory::DateTimeType type,
760- UErrorCode& success) {
761- NULL_ON_ERROR (success);
762-
763- LocalPointer<DateTimeFactory> result (new DateTimeFactory (type));
764- if (!result.isValid ()) {
765- success = U_MEMORY_ALLOCATION_ERROR;
766- return nullptr ;
767- }
768- return result.orphan ();
699+ /* static */ StandardFunctions::DateTime*
700+ StandardFunctions::DateTime::time (UErrorCode& success) {
701+ return DateTime::create (DateTimeType::kTime , success);
769702}
770703
771- Function*
772- StandardFunctions::DateTimeFactory::createFunction (UErrorCode& errorCode) {
773- NULL_ON_ERROR (errorCode);
774-
775- DateTime* result = new DateTime (type);
776- if (result == nullptr ) {
777- errorCode = U_MEMORY_ALLOCATION_ERROR;
778- }
779- return result;
704+ /* static */ StandardFunctions::DateTime*
705+ StandardFunctions::DateTime::dateTime (UErrorCode& success) {
706+ return DateTime::create (DateTimeType::kDateTime , success);
780707}
781708
782709/* static */ StandardFunctions::DateTime*
783- StandardFunctions::DateTime::create (DateTimeFactory ::DateTimeType type,
710+ StandardFunctions::DateTime::create (DateTime ::DateTimeType type,
784711 UErrorCode& success) {
785712 NULL_ON_ERROR (success);
786713
@@ -838,7 +765,7 @@ UnicodeString StandardFunctions::DateTimeValue::formatToString(UErrorCode& statu
838765 return formattedDate;
839766}
840767
841- StandardFunctions::DateTimeValue::DateTimeValue (DateTimeFactory ::DateTimeType type,
768+ StandardFunctions::DateTimeValue::DateTimeValue (DateTime ::DateTimeType type,
842769 const FunctionContext& context,
843770 FunctionValue& val,
844771 FunctionOptions&& options,
@@ -873,7 +800,7 @@ StandardFunctions::DateTimeValue::DateTimeValue(DateTimeFactory::DateTimeType ty
873800 bool hasTimeStyleOption = timeStyleOption.length () > 0 ;
874801 bool noOptions = opts.optionsCount () == 0 ;
875802
876- using DateTimeType = DateTimeFactory ::DateTimeType;
803+ using DateTimeType = DateTime ::DateTimeType;
877804
878805 bool useStyle = (type == DateTimeType::kDateTime
879806 && (hasDateStyleOption || hasTimeStyleOption
@@ -1090,24 +1017,11 @@ StandardFunctions::DateTimeValue::DateTimeValue(DateTimeFactory::DateTimeType ty
10901017 formattedDate = result;
10911018}
10921019
1093- StandardFunctions::DateTimeFactory::~DateTimeFactory () {}
10941020StandardFunctions::DateTime::~DateTime () {}
10951021StandardFunctions::DateTimeValue::~DateTimeValue () {}
10961022
10971023// --------- String
10981024
1099- /* static */ StandardFunctions::StringFactory*
1100- StandardFunctions::StringFactory::string (UErrorCode& success) {
1101- NULL_ON_ERROR (success);
1102-
1103- LocalPointer<StringFactory> result (new StringFactory ());
1104- if (!result.isValid ()) {
1105- success = U_MEMORY_ALLOCATION_ERROR;
1106- return nullptr ;
1107- }
1108- return result.orphan ();
1109- }
1110-
11111025/* static */ StandardFunctions::String*
11121026StandardFunctions::String::string (UErrorCode& success) {
11131027 NULL_ON_ERROR (success);
@@ -1120,17 +1034,6 @@ StandardFunctions::String::string(UErrorCode& success) {
11201034 return result.orphan ();
11211035}
11221036
1123- Function*
1124- StandardFunctions::StringFactory::createFunction (UErrorCode& errorCode) {
1125- NULL_ON_ERROR (errorCode);
1126-
1127- String* result = new String ();
1128- if (result == nullptr ) {
1129- errorCode = U_MEMORY_ALLOCATION_ERROR;
1130- }
1131- return result;
1132- }
1133-
11341037extern UnicodeString formattableToString (const Locale&,
11351038 const UBiDiDirection,
11361039 const Formattable&,
@@ -1185,7 +1088,6 @@ void StandardFunctions::StringValue::selectKeys(const UnicodeString* keys,
11851088 }
11861089}
11871090
1188- StandardFunctions::StringFactory::~StringFactory () {}
11891091StandardFunctions::String::~String () {}
11901092StandardFunctions::StringValue::~StringValue () {}
11911093
0 commit comments