Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Member Functions | Private Attributes
mozSqlResultStream Class Reference

#include <mozSqlResult.h>

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

List of all members.

Public Member Functions

 mozSqlResultStream (mozSqlResult *aResult)
virtual ~mozSqlResultStream ()
AString getColumnHeader (in long aColumnIndex)
 Retrieves the name of a column given its index.
void setColumnHeader (in long aColumnIndex, in AString aLabel)
 Sets the name of a column given its index.
void close ()
 Close the stream.
unsigned long available ()
unsigned long read (in charPtr aBuf, in unsigned long aCount)
 Read data from the stream.
unsigned long readSegments (in nsWriteSegmentFun aWriter, in voidPtr aClosure, in unsigned long aCount)
 Low-level read method that has access to the stream's underlying buffer.
boolean isNonBlocking ()

Protected Member Functions

nsresult EnsureBuffer ()

Private Attributes

mozSqlResultmResult
nsCAutoString mBuffer
PRBool mInitialized
PRUint32 mPosition

Detailed Description

Definition at line 410 of file mozSqlResult.h.


Constructor & Destructor Documentation

Definition at line 2131 of file mozSqlResult.cpp.

Here is the call graph for this function:

Definition at line 2140 of file mozSqlResult.cpp.


Member Function Documentation

unsigned long nsIInputStream::available ( ) [inherited]
Returns:
number of bytes currently available in the stream
void nsIInputStream::close ( ) [inherited]

Close the stream.

Definition at line 2236 of file mozSqlResult.cpp.

{
  if (!mInitialized) {
    mBuffer.AppendLiteral("<?xml version=\"1.0\"?>\n");
    mBuffer.AppendLiteral("<document>\n<body>\n");
    PRInt32 rowCount = mResult->mRows.Count();
    PRInt32 columnCount = mResult->mColumnInfo.Count();
    for (PRInt32 i = 0; i < rowCount; i++) {
      mBuffer.AppendLiteral("<row>\n");
      Row* row = (Row*)mResult->mRows[i];
      for (PRInt32 j = 0; j < columnCount; j++) {
        mBuffer.AppendLiteral("<cell>\n");
        Cell* cell = row->mCells[j];
        if (cell->IsNull())
          mBuffer.AppendLiteral("null");
        else {
          PRInt32 type = cell->GetType();
          if (type == mozISqlResult::TYPE_STRING)
            mBuffer.Append(NS_ConvertUCS2toUTF8(cell->mString));
          else if (type == mozISqlResult::TYPE_INT)
            mBuffer.AppendInt(cell->mInt);
          else if (type == mozISqlResult::TYPE_FLOAT ||
                   type == mozISqlResult::TYPE_DECIMAL)
            mBuffer.AppendFloat(cell->mFloat);
          else if (type == mozISqlResult::TYPE_DATE ||
                   type == mozISqlResult::TYPE_TIME ||
                   type == mozISqlResult::TYPE_DATETIME) {
            nsAutoString value;
            mozSqlResult::gFormat->FormatPRTime(nsnull,
                                  type != mozISqlResult::TYPE_TIME ? kDateFormatLong : kDateFormatNone,
                                  type != mozISqlResult::TYPE_DATE ? kTimeFormatSeconds : kTimeFormatNone,
                                  PRTime(cell->mDate),
                                  value);
            mBuffer.Append(NS_ConvertUCS2toUTF8(value));
          }
          else if (type == mozISqlResult::TYPE_BOOL) {
            if (cell->mBool)
              mBuffer.AppendLiteral("true");
            else
              mBuffer.AppendLiteral("false");
          }
        }
        mBuffer.AppendLiteral("</cell>\n");
      }
      mBuffer.AppendLiteral("</row>\n");
    }
    mBuffer.AppendLiteral("</body>\n</document>\n");

    mInitialized = PR_TRUE;
  }

  return NS_OK;
}

Here is the call graph for this function:

AString mozISqlInputStream::getColumnHeader ( in long  aColumnIndex) [inherited]

Retrieves the name of a column given its index.

Indicies start at zero.

Parameters:
aColumnIndexthe index of the column to return
Returns:
the column name
Returns:
true if stream is non-blocking
unsigned long nsIInputStream::read ( in charPtr  aBuf,
in unsigned long  aCount 
) [inherited]

Read data from the stream.

Parameters:
aBufthe buffer into which the data is to be read
aCountthe maximum number of bytes to be read
Returns:
number of bytes read (may be less than aCount).
0 if reached end of file
Exceptions:
NS_BASE_STREAM_WOULD_BLOCKif reading from the input stream would block the calling thread (non-blocking mode only)
<other-error>on failure
unsigned long nsIInputStream::readSegments ( in nsWriteSegmentFun  aWriter,
in voidPtr  aClosure,
in unsigned long  aCount 
) [inherited]

Low-level read method that has access to the stream's underlying buffer.

The writer function may be called multiple times for segmented buffers. ReadSegments is expected to keep calling the writer until either there is nothing left to read or the writer returns an error. ReadSegments should not call the writer with zero bytes to consume.

Parameters:
aWriterthe "consumer" of the data to be read
aClosureopaque parameter passed to writer
aCountthe maximum number of bytes to be read
Returns:
number of bytes read (may be less than aCount)
0 if reached end of file (or if aWriter refused to consume data)
Exceptions:
NS_BASE_STREAM_WOULD_BLOCKif reading from the input stream would block the calling thread (non-blocking mode only)
<other-error>on failure

NOTE: this function may be unimplemented if a stream has no underlying buffer (e.g., socket input stream).

void mozISqlInputStream::setColumnHeader ( in long  aColumnIndex,
in AString  aLabel 
) [inherited]

Sets the name of a column given its index.

Indicies start at zero.

Parameters:
aColumnIndexthe index of the column to change
aLabelthe column name

Member Data Documentation

Definition at line 428 of file mozSqlResult.h.

Definition at line 429 of file mozSqlResult.h.

Definition at line 430 of file mozSqlResult.h.

Definition at line 427 of file mozSqlResult.h.


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