1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/intl/icu/source/common/locbased.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,46 @@ 1.4 +/* 1.5 +********************************************************************** 1.6 +* Copyright (c) 2004, International Business Machines 1.7 +* Corporation and others. All Rights Reserved. 1.8 +********************************************************************** 1.9 +* Author: Alan Liu 1.10 +* Created: January 16 2004 1.11 +* Since: ICU 2.8 1.12 +********************************************************************** 1.13 +*/ 1.14 +#include "locbased.h" 1.15 +#include "cstring.h" 1.16 + 1.17 +U_NAMESPACE_BEGIN 1.18 + 1.19 +Locale LocaleBased::getLocale(ULocDataLocaleType type, UErrorCode& status) const { 1.20 + const char* id = getLocaleID(type, status); 1.21 + return Locale((id != 0) ? id : ""); 1.22 +} 1.23 + 1.24 +const char* LocaleBased::getLocaleID(ULocDataLocaleType type, UErrorCode& status) const { 1.25 + if (U_FAILURE(status)) { 1.26 + return NULL; 1.27 + } 1.28 + 1.29 + switch(type) { 1.30 + case ULOC_VALID_LOCALE: 1.31 + return valid; 1.32 + case ULOC_ACTUAL_LOCALE: 1.33 + return actual; 1.34 + default: 1.35 + status = U_ILLEGAL_ARGUMENT_ERROR; 1.36 + return NULL; 1.37 + } 1.38 +} 1.39 + 1.40 +void LocaleBased::setLocaleIDs(const char* validID, const char* actualID) { 1.41 + if (validID != 0) { 1.42 + uprv_strcpy(valid, validID); 1.43 + } 1.44 + if (actualID != 0) { 1.45 + uprv_strcpy(actual, actualID); 1.46 + } 1.47 +} 1.48 + 1.49 +U_NAMESPACE_END