Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Public Attributes
txFormattedCounter Class Reference

#include <txXSLTNumber.h>

Inheritance diagram for txFormattedCounter:
Inheritance graph
[legend]
Collaboration diagram for txFormattedCounter:
Collaboration graph
[legend]

List of all members.

Public Member Functions

virtual ~txFormattedCounter ()
virtual void appendNumber (PRInt32 aNumber, nsAString &aDest)=0

Static Public Member Functions

static nsresult getCounterFor (const nsAFlatString &aToken, int aGroupSize, const nsAString &aGroupSeparator, txFormattedCounter *&aCounter)

Public Attributes

nsString mSeparator

Detailed Description

Definition at line 91 of file txXSLTNumber.h.


Constructor & Destructor Documentation

virtual txFormattedCounter::~txFormattedCounter ( ) [inline, virtual]

Definition at line 93 of file txXSLTNumber.h.

    {
    }

Member Function Documentation

virtual void txFormattedCounter::appendNumber ( PRInt32  aNumber,
nsAString &  aDest 
) [pure virtual]

Implemented in txRomanCounter, txAlphaCounter, and txDecimalCounter.

Here is the caller graph for this function:

nsresult txFormattedCounter::getCounterFor ( const nsAFlatString aToken,
int  aGroupSize,
const nsAString &  aGroupSeparator,
txFormattedCounter *&  aCounter 
) [static]

Definition at line 86 of file txXSLTNumberCounters.cpp.

{
    PRInt32 length = aToken.Length();
    NS_ASSERTION(length, "getting counter for empty token");
    aCounter = 0;
    
    if (length == 1) {
        PRUnichar ch = aToken.CharAt(0);
        switch (ch) {

            case 'i':
            case 'I':
                aCounter = new txRomanCounter(ch == 'I');
                break;
            
            case 'a':
            case 'A':
                aCounter = new txAlphaCounter(ch);
                break;
            
            case '1':
            default:
                // if we don't recognize the token then use "1"
                aCounter = new txDecimalCounter(1, aGroupSize,
                                                aGroupSeparator);
                break;
        }
        return aCounter ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
    }
    
    // for now, the only multi-char token we support are decimals
    PRInt32 i;
    for (i = 0; i < length-1; ++i) {
        if (aToken.CharAt(i) != '0')
            break;
    }
    if (i == length-1 && aToken.CharAt(i) == '1') {
        aCounter = new txDecimalCounter(length, aGroupSize, aGroupSeparator);
    }
    else {
        // if we don't recognize the token then use '1'
        aCounter = new txDecimalCounter(1, aGroupSize, aGroupSeparator);
    }

    return aCounter ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 103 of file txXSLTNumber.h.


The documentation for this class was generated from the following files: