ICU-9748 MSVC2010 issues, move EnumSet<> to separate header
X-SVN-Rev: 32838
This commit is contained in:
parent
34fdf50b05
commit
858972dfa6
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -52,6 +52,7 @@ icu4c/icu4c.css -text
|
||||
icu4c/source/allinone/icucheck.bat -text
|
||||
icu4c/source/common/common.vcxproj -text
|
||||
icu4c/source/common/common.vcxproj.filters -text
|
||||
icu4c/source/common/unicode/enumset.h -text
|
||||
icu4c/source/data/curr/pool.res -text
|
||||
icu4c/source/data/in/coll/invuca.icu -text
|
||||
icu4c/source/data/in/coll/ucadata.icu -text
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
@ -580,6 +580,7 @@
|
||||
<ClInclude Include="uenumimp.h" />
|
||||
<ClInclude Include="uhash.h" />
|
||||
<ClInclude Include="ulist.h" />
|
||||
<ClInclude Include="unicode\enumset.h" />
|
||||
<ClInclude Include="ustrenum.h" />
|
||||
<ClInclude Include="utrie.h" />
|
||||
<ClInclude Include="utrie2.h" />
|
||||
@ -1707,4 +1708,4 @@
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
@ -808,6 +808,9 @@
|
||||
<ClInclude Include="uchar_props_data.h">
|
||||
<Filter>properties & sets</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="unicode\enumset.h">
|
||||
<Filter>data & memory</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="common.rc">
|
||||
@ -1045,4 +1048,4 @@
|
||||
<CustomBuild Include="unicode\ustringtrie.h" />
|
||||
<CustomBuild Include="unicode\listformatter.h" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
55
icu4c/source/common/unicode/enumset.h
Normal file
55
icu4c/source/common/unicode/enumset.h
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2012, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C++: internal template EnumSet<>
|
||||
*/
|
||||
|
||||
#ifndef ENUMSET_H
|
||||
#define ENUMSET_H
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
|
||||
/**
|
||||
* enum bitset for boolean fields. Similar to Java EnumSet<>.
|
||||
* Needs to range check.
|
||||
* @internal
|
||||
*/
|
||||
template<typename T, uint32_t minValue, uint32_t limitValue>
|
||||
class EnumSet {
|
||||
public:
|
||||
inline EnumSet() : fBools(0) {}
|
||||
inline EnumSet(const EnumSet<T,minValue,limitValue>& other) : fBools(other.fBools) {}
|
||||
inline ~EnumSet() {}
|
||||
inline void clear() { fBools=0; }
|
||||
inline void add(T toAdd) { set(toAdd, 1); }
|
||||
inline void remove(T toRemove) { set(toRemove, 0); }
|
||||
inline int32_t contains(T toCheck) const { return get(toCheck); }
|
||||
inline void set(T toSet, int32_t v) { fBools=(fBools&(~flag(toSet)))|(v?(flag(toSet)):0); }
|
||||
inline int32_t get(T toCheck) const { return (fBools & flag(toCheck))?1:0; }
|
||||
inline UBool isValidEnum(T toCheck) const { return (toCheck>=minValue&&toCheck<limitValue); }
|
||||
inline UBool isValidValue(int32_t v) const { return (v==0||v==1); }
|
||||
inline const EnumSet<T,minValue,limitValue>& operator=(const EnumSet<T,minValue,limitValue>& other) {
|
||||
fBools = other.fBools;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline uint32_t getAll() const {
|
||||
return fBools;
|
||||
}
|
||||
|
||||
private:
|
||||
inline uint32_t flag(T toCheck) const { return (1<<(toCheck-minValue)); }
|
||||
private:
|
||||
uint32_t fBools;
|
||||
};
|
||||
|
||||
#endif
|
@ -339,7 +339,7 @@ uprv_detectWindowsTimeZone() {
|
||||
/* if icuTZ has more than one city, take only the first (i.e. terminate icuTZ at first space) */
|
||||
int index=0;
|
||||
while (! (*icuTZ == '\0' || *icuTZ ==' ')) {
|
||||
tmpid[index++]=*icuTZ++;
|
||||
tmpid[index++]=(char)(*icuTZ++); /* safe to assume 'char' is ASCII compatible on windows */
|
||||
}
|
||||
tmpid[index]='\0';
|
||||
}
|
||||
|
@ -750,13 +750,13 @@ $(ICUBRK)\khmerdict.dict:
|
||||
!IFNDEF ICUDATA_SOURCE_ARCHIVE
|
||||
# Rule for creating converters
|
||||
$(CNV_FILES): $(UCM_SOURCE)
|
||||
@echo Making Charset Conversion tables
|
||||
@echo Building Charset Conversion table $(@B)
|
||||
@"$(ICUTOOLS)\makeconv\$(CFG)\makeconv" -c -d"$(ICUBLD_PKG)" $(ICUSRCDATA_RELATIVE_PATH)\$(ICUUCM)\$(@B).ucm
|
||||
!ENDIF
|
||||
|
||||
!IFDEF BUILD_SPECIAL_CNV_FILES
|
||||
$(CNV_FILES_SPECIAL): $(UCM_SOURCE_SPECIAL)
|
||||
@echo Making Special Charset Conversion tables
|
||||
@echo Building Special Charset Conversion table $(@B)
|
||||
@"$(ICUTOOLS)\makeconv\$(CFG)\makeconv" -c --ignore-siso-check -d"$(ICUBLD_PKG)" $(ICUSRCDATA_RELATIVE_PATH)\$(ICUUCM)\$(@B).ucm
|
||||
!ENDIF
|
||||
|
||||
|
@ -946,13 +946,6 @@ DigitList::isZero() const
|
||||
return decNumberIsZero(fDecNumber);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void * U_EXPORT2 DigitList::operator new(size_t /*size*/, void *stack, EStackMode /*mode*/) U_NO_THROW {
|
||||
return stack;
|
||||
}
|
||||
|
||||
|
||||
U_NAMESPACE_END
|
||||
#endif // #if !UCONFIG_NO_FORMATTING
|
||||
|
||||
|
@ -414,12 +414,19 @@ private:
|
||||
public:
|
||||
|
||||
using UMemory::operator new;
|
||||
using UMemory::operator delete;
|
||||
|
||||
/**
|
||||
* Placement new for stack usage
|
||||
* @internal
|
||||
*/
|
||||
static void * U_EXPORT2 operator new(size_t size, void *onStack, EStackMode mode) U_NO_THROW;
|
||||
static inline void * U_EXPORT2 operator new(size_t size, void *onStack, EStackMode mode) U_NO_THROW { return onStack; }
|
||||
|
||||
/**
|
||||
* Placement delete for stack usage
|
||||
* @internal
|
||||
*/
|
||||
static inline void U_EXPORT2 operator delete(void *ptr, void *onStack, EStackMode mode) U_NO_THROW {}
|
||||
|
||||
private:
|
||||
inline void internalSetDouble(double d) {
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "unicode/fpositer.h"
|
||||
#include "unicode/stringpiece.h"
|
||||
#include "unicode/curramt.h"
|
||||
#include "unicode/enumset.h"
|
||||
|
||||
/**
|
||||
* \def UNUM_DECIMALFORMAT_INTERNAL_SIZE
|
||||
@ -56,39 +57,12 @@ class Hashtable;
|
||||
class UnicodeSet;
|
||||
class FieldPositionHandler;
|
||||
|
||||
/**
|
||||
* enum bitset for boolean fields. Similar to Java EnumSet<>.
|
||||
* Needs to range check. Not specific to decimal format.
|
||||
* @internal
|
||||
*/
|
||||
template<typename T, uint32_t minValue, uint32_t limitValue>
|
||||
class EnumSet {
|
||||
public:
|
||||
EnumSet() : fBools(0) {}
|
||||
EnumSet(const EnumSet<T,minValue,limitValue>& other) : fBools(other.fBools) {}
|
||||
~EnumSet() {}
|
||||
void clear() { fBools=0; }
|
||||
void add(T toAdd) { set(toAdd, 1); }
|
||||
void remove(T toRemove) { set(toRemove, 0); }
|
||||
int32_t contains(T toCheck) const { return get(toCheck); }
|
||||
void set(T toSet, int32_t v) { fBools=(fBools&(~flag(toSet)))|(v?(flag(toSet)):0); }
|
||||
int32_t get(T toCheck) const { return (fBools & flag(toCheck))?1:0; }
|
||||
UBool isValidEnum(T toCheck) const { return (toCheck>=minValue&&toCheck<limitValue); }
|
||||
UBool isValidValue(int32_t v) const { return (v==0||v==1); }
|
||||
const EnumSet<T,minValue,limitValue>& operator=(const EnumSet<T,minValue,limitValue>& other) {
|
||||
fBools = other.fBools;
|
||||
return *this;
|
||||
}
|
||||
|
||||
uint32_t getAll() const {
|
||||
return fBools;
|
||||
}
|
||||
|
||||
private:
|
||||
uint32_t flag(T toCheck) const { return (1<<(toCheck-minValue)); }
|
||||
private:
|
||||
uint32_t fBools;
|
||||
};
|
||||
// explicit template instantiation. see digitlst.h
|
||||
#if !U_PLATFORM_IS_DARWIN_BASED
|
||||
template class U_I18N_API EnumSet<UNumberFormatAttribute,
|
||||
UNUM_MAX_NONBOOLEAN_ATTRIBUTE+1,
|
||||
UNUM_LIMIT_BOOLEAN_ATTRIBUTE>;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* DecimalFormat is a concrete subclass of NumberFormat that formats decimal
|
||||
|
Loading…
Reference in New Issue
Block a user