ICU-13177 Fixing Visual Studio build warnings in number formatting code.

X-SVN-Rev: 40510
This commit is contained in:
Shane Carr 2017-09-28 22:53:31 +00:00
parent 79cf4fa012
commit d8368d6da4
7 changed files with 35 additions and 14 deletions

View file

@ -44,7 +44,8 @@ struct AffixTag {
{}
};
class SymbolProvider {
// Exported as U_I18N_API because it is a base class for other exported types
class U_I18N_API SymbolProvider {
public:
// TODO: Could this be more efficient if it returned by reference?
virtual UnicodeString getSymbol(AffixPatternType type) const = 0;

View file

@ -10,6 +10,7 @@
#include "unicode/plurrule.h"
#include "unicode/currpinf.h"
#include "unicode/unum.h"
#include "unicode/localpointer.h"
#include "number_types.h"
U_NAMESPACE_BEGIN
@ -17,7 +18,9 @@ namespace number {
namespace impl {
// TODO: Figure out a nicer way to deal with CurrencyPluralInfo.
struct CurrencyPluralInfoWrapper {
// Exported as U_I18N_API because it is a public member field of exported DecimalFormatProperties
struct U_I18N_API CurrencyPluralInfoWrapper {
#pragma warning(suppress: 4251) // LocalPointer is defined in a header file; why does Visual Studio complain?
LocalPointer<CurrencyPluralInfo> fPtr;
CurrencyPluralInfoWrapper() {}
@ -28,6 +31,7 @@ struct CurrencyPluralInfoWrapper {
}
};
// Exported as U_I18N_API because it is needed for the unit test PatternStringTest
struct U_I18N_API DecimalFormatProperties {
public:

View file

@ -16,21 +16,27 @@ U_NAMESPACE_BEGIN
namespace number {
namespace impl {
// Forward declaration
class MutablePatternModifier;
// Exported as U_I18N_API because it is needed for the unit test PatternModifierTest
class U_I18N_API ImmutablePatternModifier : public MicroPropsGenerator {
public:
ImmutablePatternModifier(ParameterizedModifier *pm, const PluralRules *rules,
const MicroPropsGenerator *parent);
~ImmutablePatternModifier() override = default;
~ImmutablePatternModifier() override = default;
void processQuantity(DecimalQuantity &, MicroProps &micros, UErrorCode &status) const override;
void applyToMicros(MicroProps &micros, DecimalQuantity &quantity) const;
private:
const LocalPointer<ParameterizedModifier> pm;
ImmutablePatternModifier(ParameterizedModifier *pm, const PluralRules *rules, const MicroPropsGenerator *parent);
#pragma warning(suppress: 4251) // Member is private and does not need to be exported
const LocalPointer<ParameterizedModifier> pm;
const PluralRules *rules;
const MicroPropsGenerator *parent;
friend class MutablePatternModifier;
};
/**

View file

@ -25,7 +25,8 @@ struct Endpoints {
int32_t end = 0;
};
struct ParsedSubpatternInfo {
// Exported as U_I18N_API because it is a public member field of exported ParsedPatternInfo
struct U_I18N_API ParsedSubpatternInfo {
int64_t groupingSizes = 0x0000ffffffff0000L;
int32_t integerLeadingHashSigns = 0;
int32_t integerTrailingHashSigns = 0;
@ -52,7 +53,8 @@ struct ParsedSubpatternInfo {
Endpoints paddingEndpoints;
};
struct U_I18N_API ParsedPatternInfo : public AffixPatternProvider {
// Exported as U_I18N_API because it is needed for the unit test PatternStringTest
struct U_I18N_API ParsedPatternInfo : public AffixPatternProvider, public UMemory {
UnicodeString pattern;
ParsedSubpatternInfo positive;
ParsedSubpatternInfo negative;
@ -93,7 +95,9 @@ struct U_I18N_API ParsedPatternInfo : public AffixPatternProvider {
// TODO: We don't currently do anything with the message string.
// This method is here as a shell for Java compatibility.
inline void toParseException(const char16_t *message) { (void)message; }
} state;
}
#pragma warning(suppress: 4251) // Member is private and does not need to be exported
state;
// NOTE: In Java, these are written as pure functions.
// In C++, they're written as methods.

View file

@ -33,7 +33,7 @@ class U_I18N_API ScientificModifier : public UMemory, public Modifier {
const ScientificHandler *fHandler;
};
class U_I18N_API ScientificHandler : public UMemory, public MicroPropsGenerator, public MultiplierProducer {
class ScientificHandler : public UMemory, public MicroPropsGenerator, public MultiplierProducer {
public:
ScientificHandler(const Notation *notation, const DecimalFormatSymbols *symbols,
const MicroPropsGenerator *parent);

View file

@ -94,7 +94,8 @@ enum CompactType {
// TODO: Should this be moved somewhere else, maybe where other ICU classes can use it?
class CharSequence {
// Exported as U_I18N_API because it is a base class for other exported types
class U_I18N_API CharSequence {
public:
virtual ~CharSequence() = default;
@ -147,6 +148,8 @@ class U_I18N_API AffixPatternProvider {
*
* A Modifier is usually immutable, except in cases such as {@link MurkyModifier}, which are mutable for performance
* reasons.
*
* Exported as U_I18N_API because it is a base class for other exported types
*/
class U_I18N_API Modifier {
public:
@ -205,7 +208,7 @@ class U_I18N_API Modifier {
* quantity-dependent. Each element in the linked list calls {@link #processQuantity} on its "parent", then does its
* work, and then returns the result.
*
* @author sffc
* Exported as U_I18N_API because it is a base class for other exported types
*
*/
class U_I18N_API MicroPropsGenerator {
@ -231,8 +234,9 @@ class MultiplierProducer {
virtual int32_t getMultiplier(int32_t magnitude) const = 0;
};
// Exported as U_I18N_API because it is a public member field of exported DecimalFormatProperties
template<typename T>
class NullableValue {
class U_I18N_API NullableValue {
public:
NullableValue() : fNull(true) {}

View file

@ -1818,7 +1818,9 @@ class U_I18N_API LocalizedNumberFormatter
~LocalizedNumberFormatter();
private:
#pragma warning(suppress: 4251) // Member is private and does not need to be exported
std::atomic<const impl::NumberFormatterImpl *> fCompiled{nullptr};
#pragma warning(suppress: 4251) // Member is private and does not need to be exported
std::atomic<uint32_t> fCallCount{0};
LocalizedNumberFormatter() = default;