Click here to Skip to main content
15,897,891 members
Articles / Desktop Programming / MFC

What's New in ACF 0.3

Rate me:
Please Sign up or sign in to vote.
3.39/5 (7 votes)
23 Jun 20043 min read 40.5K   193   8  
This article introduces what's new in ACF (Another C++ Framework) version 0.3.
//---------------------------------------------------------------------
//
// Copyright (C) 2004 Yingle Jia
//
// Permission to copy, use, modify, sell and distribute this software is 
// granted provided this copyright notice appears in all copies. 
// This software is provided "as is" without express or implied warranty, 
// and with no claim as to its suitability for any purpose.
//
// AcfNumberFormat.h
//

#ifndef __Acf_NumberFormat__
#define __Acf_NumberFormat__

namespace Acf {
    namespace Globalization {

class NumberFormatInfo;
typedef RefPtr<NumberFormatInfo>    NumberFormatInfoPtr;

//---------------------------------------------------------------------
// enum NumberStyles: used for the Parse methods

ACF_DECLARE_ENUM(NumberStyles)
    None				  = 0x00000000, 
    AllowLeadingWhite     = 0x00000001, 
    AllowTrailingWhite    = 0x00000002, // Bitflag indicating trailing whitespace is allowed.
    AllowLeadingSign      = 0x00000004, // Can the number start with a sign char.  
    AllowTrailingSign     = 0x00000008, // Allow the number to end with a sign char
    AllowParentheses      = 0x00000010, // Allow the number to be enclosed in parens
    AllowDecimalPoint     = 0x00000020, // Allow a decimal point
    AllowThousands        = 0x00000040, // Allow thousands separators (more properly, allow group separators)
    AllowExponent         = 0x00000080, // Allow an exponent
    AllowCurrencySymbol   = 0x00000100, // Allow a currency symbol.
    AllowHexSpecifier	  = 0x00000200, // Allow specifiying hexadecimal.

    Integer  = AllowLeadingWhite | AllowTrailingWhite | AllowLeadingSign,
    HexNumber = AllowLeadingWhite | AllowTrailingWhite | AllowHexSpecifier,
    Number   = AllowLeadingWhite | AllowTrailingWhite | AllowLeadingSign | AllowTrailingSign |
        AllowDecimalPoint | AllowThousands,
    Float    = AllowLeadingWhite | AllowTrailingWhite | AllowLeadingSign | 
        AllowDecimalPoint | AllowExponent,
    Currency = AllowLeadingWhite | AllowTrailingWhite | AllowLeadingSign | AllowTrailingSign |
        AllowParentheses  | AllowDecimalPoint | AllowThousands | AllowCurrencySymbol,
    Any      = AllowLeadingWhite | AllowTrailingWhite | AllowLeadingSign | AllowTrailingSign |
        AllowParentheses  | AllowDecimalPoint | AllowThousands | AllowCurrencySymbol | AllowExponent,
ACF_END_ENUM()

//---------------------------------------------------------------------
// class NumberFormatInfo

class NumberFormatInfo : public Object, public IFormatProvider
{
public:
    using Object::AddRef;
    using Object::Release;

// Static Fields
private:
    static const NumberFormatInfoPtr _invariantInfo;

// Fields
private:
    int _numberDecimalDigits;
    StringPtr _numberDecimalSeparator;
    StringPtr _numberGroupSeparator;
    RefPtr<Array<int> > _numberGroupSizes;
    int _numberNegativePattern;
    StringPtr _positiveSign;
    StringPtr _negativeSign;

    StringPtr _currencySymbol;
    int _currencyDecimalDigits;
    StringPtr _currencyDecimalSeparator;
    StringPtr _currencyGroupSeparator;
    RefPtr<Array<int> > _currencyGroupSizes;
    int _currencyPositivePattern;
    int _currencyNegativePattern;

    StringPtr _percentSymbol;
    int _percentDecimalDigits;
    StringPtr _percentDecimalSeparator;
    StringPtr _percentGroupSeparator;
    RefPtr<Array<int> > _percentGroupSizes;
    int _percentPositivePattern;
    int _percentNegativePattern;
    StringPtr _perMilleSymbol;

    StringPtr _naNSymbol;
    StringPtr _positiveInfinitySymbol;
    StringPtr _negativeInfinitySymbol;

    bool _isReadOnly;

// Constructors
public:
    NumberFormatInfo();

private:
    NumberFormatInfo(int lcid, bool readOnly = false);
    NumberFormatInfo(NumberFormatInfo* src);
    void ctor(int lcid, bool readOnly);

// Static Properties
public:
    static NumberFormatInfoPtr get_CurrentInfo();
    static NumberFormatInfoPtr get_InvariantInfo();

// Properties
public:
    // NumberDecimalDigits
    __declspec(property(get=get_NumberDecimalDigits, put=set_NumberDecimalDigits)) int NumberDecimalDigits;
    int get_NumberDecimalDigits();
    void set_NumberDecimalDigits(int value);
    // NumberDecimalSeparator
    __declspec(property(get=get_NumberDecimalSeparator, put=set_NumberDecimalSeparator)) StringPtr NumberDecimalSeparator;
    StringPtr get_NumberDecimalSeparator();
    void set_NumberDecimalSeparator(String* value);
    // NumberGroupSeparator
    __declspec(property(get=get_NumberGroupSeparator, put=set_NumberGroupSeparator)) StringPtr NumberGroupSeparator;
    StringPtr get_NumberGroupSeparator();
    void set_NumberGroupSeparator(String* value);
    // NumberGroupSizes
    __declspec(property(get=get_NumberGroupSizes, put=set_NumberGroupSizes)) RefPtr<Array<int> > NumberGroupSizes;
    RefPtr<Array<int> > get_NumberGroupSizes();
    void set_NumberGroupSizes(Array<int>* value);
    // NumberNegativePattern
    __declspec(property(get=get_NumberNegativePattern, put=set_NumberNegativePattern)) int NumberNegativePattern;
    int get_NumberNegativePattern();
    void set_NumberNegativePattern(int value);
    // PositiveSign
    __declspec(property(get=get_PositiveSign, put=set_PositiveSign)) StringPtr PositiveSign;
    StringPtr get_PositiveSign();
    void set_PositiveSign(String* value);
    // NegativeSign
    __declspec(property(get=get_NegativeSign, put=set_NegativeSign)) StringPtr NegativeSign;
    StringPtr get_NegativeSign();
    void set_NegativeSign(String* value);

    // CurrencySymbol
    __declspec(property(get=get_CurrencySymbol, put=set_CurrencySymbol)) StringPtr CurrencySymbol;
    StringPtr get_CurrencySymbol();
    void set_CurrencySymbol(String* value);
    // CurrencyDecimalDigits
    __declspec(property(get=get_CurrencyDecimalDigits, put=set_CurrencyDecimalDigits)) int CurrencyDecimalDigits;
    int get_CurrencyDecimalDigits();
    void set_CurrencyDecimalDigits(int value);
    // CurrencyDecimalSeparator
    __declspec(property(get=get_CurrencyDecimalSeparator, put=set_CurrencyDecimalSeparator)) StringPtr CurrencyDecimalSeparator;
    StringPtr get_CurrencyDecimalSeparator();
    void set_CurrencyDecimalSeparator(String* value);
    // CurrencyGroupSeparator
    __declspec(property(get=get_CurrencyGroupSeparator, put=set_CurrencyGroupSeparator)) StringPtr CurrencyGroupSeparator;
    StringPtr get_CurrencyGroupSeparator();
    void set_CurrencyGroupSeparator(String* value);
    // CurrencyGroupSizes
    __declspec(property(get=get_CurrencyGroupSizes, put=set_CurrencyGroupSizes)) RefPtr<Array<int> > CurrencyGroupSizes;
    RefPtr<Array<int> > get_CurrencyGroupSizes();
    void set_CurrencyGroupSizes(Array<int>* value);
    // CurrencyPositivePattern
    __declspec(property(get=get_CurrencyPositivePattern, put=set_CurrencyPositivePattern)) int CurrencyPositivePattern;
    int get_CurrencyPositivePattern();
    void set_CurrencyPositivePattern(int value);
    // CurrencyNegativePattern
    __declspec(property(get=get_CurrencyNegativePattern, put=set_CurrencyNegativePattern)) int CurrencyNegativePattern;
    int get_CurrencyNegativePattern();
    void set_CurrencyNegativePattern(int value);

    // PercentSymbol
    __declspec(property(get=get_PercentSymbol, put=set_PercentSymbol)) StringPtr PercentSymbol;
    StringPtr get_PercentSymbol();
    void set_PercentSymbol(String* value);
    // PercentDecimalDigits
    __declspec(property(get=get_PercentDecimalDigits, put=set_PercentDecimalDigits)) int PercentDecimalDigits;
    int get_PercentDecimalDigits();
    void set_PercentDecimalDigits(int value);
    // PercentDecimalSeparator
    __declspec(property(get=get_PercentDecimalSeparator, put=set_PercentDecimalSeparator)) StringPtr PercentDecimalSeparator;
    StringPtr get_PercentDecimalSeparator();
    void set_PercentDecimalSeparator(String* value);
    // PercentGroupSeparator
    __declspec(property(get=get_PercentGroupSeparator, put=set_PercentGroupSeparator)) StringPtr PercentGroupSeparator;
    StringPtr get_PercentGroupSeparator();
    void set_PercentGroupSeparator(String* value);
    // PercentGroupSizes
    __declspec(property(get=get_PercentGroupSizes, put=set_PercentGroupSizes)) RefPtr<Array<int> > PercentGroupSizes;
    RefPtr<Array<int> > get_PercentGroupSizes();
    void set_PercentGroupSizes(Array<int>* value);
    // PercentPositivePattern
    __declspec(property(get=get_PercentPositivePattern, put=set_PercentPositivePattern)) int PercentPositivePattern;
    int get_PercentPositivePattern();
    void set_PercentPositivePattern(int value);
    // PercentNegativePattern
    __declspec(property(get=get_PercentNegativePattern, put=set_PercentNegativePattern)) int PercentNegativePattern;
    int get_PercentNegativePattern();
    void set_PercentNegativePattern(int value);
    // PerMilleSymbol
    __declspec(property(get=get_PerMilleSymbol, put=set_PerMilleSymbol)) StringPtr PerMilleSymbol;
    StringPtr get_PerMilleSymbol();
    void set_PerMilleSymbol(String* value);

    // NaNSymbol
    __declspec(property(get=get_NaNSymbol, put=set_NaNSymbol)) StringPtr NaNSymbol;
    StringPtr get_NaNSymbol();
    void set_NaNSymbol(String* value);
    // PositiveInfinitySymbol
    __declspec(property(get=get_PositiveInfinitySymbol, put=set_PositiveInfinitySymbol)) StringPtr PositiveInfinitySymbol;
    StringPtr get_PositiveInfinitySymbol();
    void set_PositiveInfinitySymbol(String* value);
    // NegativeInfinitySymbol
    __declspec(property(get=get_NegativeInfinitySymbol, put=set_NegativeInfinitySymbol)) StringPtr NegativeInfinitySymbol;
    StringPtr get_NegativeInfinitySymbol();
    void set_NegativeInfinitySymbol(String* value);

    // IsReadOnly
    __declspec(property(get=get_IsReadOnly)) bool IsReadOnly;
    bool get_IsReadOnly();

// Static Methods
public:
    static NumberFormatInfoPtr ReadOnly(NumberFormatInfo* nfi);
    static NumberFormatInfoPtr GetInstance(IFormatProvider* formatProvider);

// Methods
public:
    virtual ObjectPtr GetFormat(Type* formatType);
};

    } // namespace Globalization
} // namespace Acf

#endif // #ifndef __Acf_NumberFormat__

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
China China
Yingle Jia is a software engineer located in Beijing, China. He currently works at IBM CSDL (China Software Development Lab). His interests include C++/COM/C#/.NET/XML, etc. He likes coding and writing.

He is the creator of ACF (Another C++ Framework) project. See http://acfproj.sourceforge.net/.

He also has a blog at http://blogs.wwwcoder.com/yljia/

Comments and Discussions