Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Public Attributes | Private Attributes
txAlphaCounter Class Reference
Inheritance diagram for txAlphaCounter:
Inheritance graph
[legend]
Collaboration diagram for txAlphaCounter:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 txAlphaCounter (PRUnichar aOffset)
virtual void appendNumber (PRInt32 aNumber, nsAString &aDest)

Static Public Member Functions

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

Public Attributes

nsString mSeparator

Private Attributes

PRUnichar mOffset

Detailed Description

Definition at line 60 of file txXSLTNumberCounters.cpp.


Constructor & Destructor Documentation

Definition at line 62 of file txXSLTNumberCounters.cpp.

                                      : mOffset(aOffset)
    {
    }

Member Function Documentation

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

Implements txFormattedCounter.

Definition at line 197 of file txXSLTNumberCounters.cpp.

{
    PRUnichar buf[12];
    buf[11] = 0;
    PRInt32 pos = 11;
    while (aNumber > 0) {
        --aNumber;
        PRInt32 ch = aNumber % 26;
        aNumber /= 26;
        buf[--pos] = ch + mOffset;
    }
    
    aDest.Append(buf + pos, (PRUint32)(11 - pos));
}
nsresult txFormattedCounter::getCounterFor ( const nsAFlatString aToken,
int  aGroupSize,
const nsAString &  aGroupSeparator,
txFormattedCounter *&  aCounter 
) [static, inherited]

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 69 of file txXSLTNumberCounters.cpp.

Definition at line 103 of file txXSLTNumber.h.


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