Sample Code for dwgOutFields()

Most of the filer calls are writeItem(), a member function that has been overloaded for all supported data types. There are also other functions, such as writeInt32() used in the following example, that can be used to support automatic type casting. Such functions force the argument to be treated as the specified type regardless of its actual type in memory.

Note: If your class has integer data members, you need to use the read and write functions that explicitly state the integer size (for example, writeInt32).

The following is sample code from AsdkPoly::dwgOutFields():

Acad::ErrorStatus
AsdkPoly::dwgOutFields(AcDbDwgFiler* filer) const
{
    assertReadEnabled();
    Acad::ErrorStatus es;
    if ((es = AcDbCurve::dwgOutFields(filer))
        != Acad::eOk)
    {
        return es;
    }
    // Object Version - must always be the first item.
    // 
    Adesk::Int16 version = VERSION;
    filer->writeItem(version);
    filer->writePoint2d(mCenter);
    filer->writePoint2d(mStartPoint);
    filer->writeInt32(mNumSides);
    filer->writeVector3d(mPlaneNormal);
    filer->writeString(mpName);
    // mTextStyle is a hard pointer id, so filing it out to
    // the purge filer (kPurgeFiler) prevents purging of
    // this object.
    //
    filer->writeHardPointerId(mTextStyle);
    filer->writeDouble(mElevation);
    return filer->filerStatus();
}