Back to index

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

List of all members.

Public Types

typedef PRUnichar input_type
typedef PRUnichar value_type

Public Member Functions

 txStringToDouble ()
PRUint32 write (const input_type *aSource, PRUint32 aSourceLength)
double getDouble ()

Private Types

enum  {
  eWhitestart, eDecimal, eMantissa, eWhiteend,
  eIllegal
}
enum  { eNegative = -1, ePositive = 1 }

Private Attributes

nsCAutoString mBuffer
enum txStringToDouble:: { ... }  mState
enum txStringToDouble:: { ... }  mSign

Detailed Description

Definition at line 166 of file Double.cpp.


Member Typedef Documentation

Definition at line 169 of file Double.cpp.

Definition at line 170 of file Double.cpp.


Member Enumeration Documentation

anonymous enum [private]
Enumerator:
eWhitestart 
eDecimal 
eMantissa 
eWhiteend 
eIllegal 

Definition at line 254 of file Double.cpp.

anonymous enum [private]
Enumerator:
eNegative 
ePositive 

Definition at line 261 of file Double.cpp.

         {
        eNegative = -1,
        ePositive = 1
    } mSign;

Constructor & Destructor Documentation

Definition at line 171 of file Double.cpp.


Member Function Documentation

double txStringToDouble::getDouble ( ) [inline]

Definition at line 244 of file Double.cpp.

    {
        if (mState == eIllegal || mBuffer.IsEmpty() ||
            (mBuffer.Length() == 1 && mBuffer[0] == '.')) {
            return Double::NaN;
        }
        return mSign*PR_strtod(mBuffer.get(), 0);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

PRUint32 txStringToDouble::write ( const input_type aSource,
PRUint32  aSourceLength 
) [inline]

Definition at line 174 of file Double.cpp.

    {
        if (mState == eIllegal) {
            return aSourceLength;
        }
        PRUint32 i = 0;
        PRUnichar c;
        for ( ; i < aSourceLength; ++i) {
            c = aSource[i];
            switch (mState) {
                case eWhitestart:
                    if (c == '-') {
                        mState = eDecimal;
                        mSign = eNegative;
                    }
                    else if (c >= '0' && c <= '9') {
                        mState = eDecimal;
                        mBuffer.Append((char)c);
                    }
                    else if (c == '.') {
                        mState = eMantissa;
                        mBuffer.Append((char)c);
                    }
                    else if (!XMLUtils::isWhitespace(c)) {
                        mState = eIllegal;
                        return aSourceLength;
                    }
                    break;
                case eDecimal:
                    if (c >= '0' && c <= '9') {
                        mBuffer.Append((char)c);
                    }
                    else if (c == '.') {
                        mState = eMantissa;
                        mBuffer.Append((char)c);
                    }
                    else if (XMLUtils::isWhitespace(c)) {
                        mState = eWhiteend;
                    }
                    else {
                        mState = eIllegal;
                        return aSourceLength;
                    }
                    break;
                case eMantissa:
                    if (c >= '0' && c <= '9') {
                        mBuffer.Append((char)c);
                    }
                    else if (XMLUtils::isWhitespace(c)) {
                        mState = eWhiteend;
                    }
                    else {
                        mState = eIllegal;
                        return aSourceLength;
                    }
                    break;
                case eWhiteend:
                    if (!XMLUtils::isWhitespace(c)) {
                        mState = eIllegal;
                        return aSourceLength;
                    }
                    break;
                default:
                    break;
            }
        }
        return aSourceLength;
    }

Here is the call graph for this function:


Member Data Documentation

Definition at line 253 of file Double.cpp.

enum { ... } txStringToDouble::mSign [private]
enum { ... } txStringToDouble::mState [private]

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