Back to index

lightning-sunbird  0.9+nobinonly
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes
AENamedClassIterator Class Reference

#include <nsAEClassIterator.h>

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

List of all members.

Public Types

enum  {
  eHasFormAbsolutePosition = (1 << eFormAbsolutePositionBit), eHasFormRelativePosition = (1 << eFormRelativePositionBit), eHasFormTest = (1 << eFormTestBit), eHasFormRange = (1 << eFormPropertyIDBit),
  eHasFormPropertyID = (1 << eFormRangeBit), eHasFormName = (1 << eFormNameBit), eStandardKeyFormSupport = (eHasFormAbsolutePosition | eHasFormRelativePosition | eHasFormRange | eHasFormName)
}
typedef UInt32 ItemRef
typedef UInt32 ItemID

Public Member Functions

 AENamedClassIterator (DescType classType)
 ~AENamedClassIterator ()
virtual void GetItemFromContainer (DescType desiredClass, const AEDesc *containerToken, DescType containerClass, DescType keyForm, const AEDesc *keyData, AEDesc *resultToken)

Protected Types

enum  {
  eFormAbsolutePositionBit = 0, eFormRelativePositionBit, eFormTestBit, eFormRangeBit,
  eFormPropertyIDBit, eFormNameBit
}

Protected Member Functions

virtual UInt32 GetNumItems (const AEDesc *containerToken)
virtual ItemRef GetNamedItemReference (const AEDesc *containerToken, const char *itemName)
virtual ItemRef GetIndexedItemReference (const AEDesc *containerToken, TAEListIndex itemIndex)
virtual TAEListIndex GetIndexFromItemID (const AEDesc *containerToken, ItemID itemID)
virtual Boolean NamedItemExists (const AEDesc *containerToken, const char *itemName)=0
virtual ItemID GetNamedItemID (const AEDesc *containerToken, const char *itemName)
virtual ItemID GetIndexedItemID (const AEDesc *containerToken, TAEListIndex itemIndex)
virtual void GetIndexedItemName (const AEDesc *containerToken, TAEListIndex itemIndex, char *outName, long maxLen)
virtual ItemID GetIDFromReference (const AEDesc *containerToken, ItemRef itemRef)
virtual ItemRef GetReferenceFromID (const AEDesc *containerToken, ItemID itemID)
virtual ItemID GetItemIDFromToken (const AEDesc *token)
virtual void SetItemIDInCoreToken (const AEDesc *containerToken, CoreTokenRecord *tokenRecord, ItemID itemID)
virtual void SetNamedItemIDInCoreToken (const AEDesc *containerToken, CoreTokenRecord *token, const char *itemName)=0
virtual ItemRef ProcessFormRelativePostition (const AEDesc *anchorToken, const AEDesc *keyData)
TAEListIndex NormalizeAbsoluteIndex (const AEDesc *keyData, TAEListIndex maxIndex, Boolean *isAllItems)
void ProcessFormRange (AEDesc *keyData, AEDesc *start, AEDesc *stop)
void CheckKeyFormSupport (DescType keyForm)
DescType GetClass ()

Protected Attributes

DescType mClass
UInt16 mKeyFormSupport

Static Protected Attributes

static const ItemRef kNoItemRef = -1
static const ItemID kNoItemID = -1

Detailed Description

Definition at line 135 of file nsAEClassIterator.h.


Member Typedef Documentation

typedef UInt32 AEClassIterator::ItemID [inherited]

Definition at line 94 of file nsAEClassIterator.h.

typedef UInt32 AEClassIterator::ItemRef [inherited]

Definition at line 93 of file nsAEClassIterator.h.


Member Enumeration Documentation

anonymous enum [protected, inherited]
Enumerator:
eFormAbsolutePositionBit 
eFormRelativePositionBit 
eFormTestBit 
eFormRangeBit 
eFormPropertyIDBit 
eFormNameBit 

Definition at line 51 of file nsAEClassIterator.h.

anonymous enum [inherited]
Enumerator:
eHasFormAbsolutePosition 
eHasFormRelativePosition 
eHasFormTest 
eHasFormRange 
eHasFormPropertyID 
eHasFormName 
eStandardKeyFormSupport 

Definition at line 64 of file nsAEClassIterator.h.


Constructor & Destructor Documentation

AENamedClassIterator::AENamedClassIterator ( DescType  classType) [inline]

Definition at line 138 of file nsAEClassIterator.h.

                                          : AEClassIterator(classType, eHasFormName)
                                          {}

Definition at line 142 of file nsAEClassIterator.h.

{}

Member Function Documentation

void AEClassIterator::CheckKeyFormSupport ( DescType  keyForm) [protected, inherited]

Definition at line 368 of file nsAEClassIterator.cpp.

{
       UInt16               testMask;
       switch (keyForm)
       {
              case formAbsolutePosition:         testMask = eHasFormAbsolutePosition;             break;
              case formRelativePosition:         testMask = eHasFormRelativePosition;             break;
              case formTest:                                   testMask = eHasFormTest;                         break;
              case formRange:                           testMask = eHasFormRange;                        break;
              case formPropertyID:               testMask = eHasFormPropertyID;                   break;
              case formName:                            testMask = eHasFormName;                         break;
              default:
                     AE_ASSERT(false, "Unknown key form");
       }
       if ((mKeyFormSupport & testMask) == 0)
              ThrowOSErr(errAEBadKeyForm);
}

Here is the caller graph for this function:

DescType AEClassIterator::GetClass ( ) [inline, protected, inherited]

Definition at line 127 of file nsAEClassIterator.h.

{ return mClass; }

Here is the caller graph for this function:

virtual ItemID AENamedClassIterator::GetIDFromReference ( const AEDesc *  containerToken,
ItemRef  itemRef 
) [inline, protected, virtual]

Implements AEClassIterator.

Definition at line 171 of file nsAEClassIterator.h.

{ return kNoItemID; }
virtual ItemID AENamedClassIterator::GetIndexedItemID ( const AEDesc *  containerToken,
TAEListIndex  itemIndex 
) [inline, protected, virtual]

Implements AEClassIterator.

Definition at line 165 of file nsAEClassIterator.h.

{ return kNoItemID; }

Here is the caller graph for this function:

virtual void AENamedClassIterator::GetIndexedItemName ( const AEDesc *  containerToken,
TAEListIndex  itemIndex,
char *  outName,
long  maxLen 
) [inline, protected, virtual]

Implements AEClassIterator.

Definition at line 168 of file nsAEClassIterator.h.

{}
virtual ItemRef AENamedClassIterator::GetIndexedItemReference ( const AEDesc *  containerToken,
TAEListIndex  itemIndex 
) [inline, protected, virtual]

Implements AEClassIterator.

Definition at line 158 of file nsAEClassIterator.h.

{ return kNoItemRef; }
virtual TAEListIndex AENamedClassIterator::GetIndexFromItemID ( const AEDesc *  containerToken,
ItemID  itemID 
) [inline, protected, virtual]

Implements AEClassIterator.

Definition at line 160 of file nsAEClassIterator.h.

{ return 0; }
void AENamedClassIterator::GetItemFromContainer ( DescType  desiredClass,
const AEDesc *  containerToken,
DescType  containerClass,
DescType  keyForm,
const AEDesc *  keyData,
AEDesc *  resultToken 
) [virtual]

Reimplemented from AEClassIterator.

Definition at line 393 of file nsAEClassIterator.cpp.

{
       OSErr                       err    = noErr;
       
       CStr255                            itemName;
       DescType                           keyDataType   = keyData->descriptorType;

       Boolean                            wantsAllItems = false;

       StAEDesc                           startObject;  // These are used to resolve formRange
       StAEDesc                           stopObject;
              
       CoreTokenRecord             token;
       
       long                               numItems = GetNumItems(containerToken);
       
       CheckKeyFormSupport(keyForm);             // throws on error
       
       switch (keyForm)
       {
              case formName:                                                                                                                // item by name
                     if (DescToCString(keyData, itemName, 255) != noErr)
                            ThrowIfOSErr(errAECoercionFail);

                     if (!NamedItemExists(containerToken, itemName))
                            ThrowIfOSErr(errAENoSuchObject);
                     break;
              
/*
              case formAbsolutePosition:                                                                                             // item by number
                     DescType             ordinalDesc;
                     if (DescToDescType((AEDesc*)keyData, &ordinalDesc) != noErr)
                            ThrowOSErr(errAECoercionFail);

                     if (ordinalDesc != kAEAll)
                            ThrowOSErr(errAEWrongDataType);

                     wantsAllItems = true;
                     break; 
*/            
              default:
                     ThrowIfOSErr(errAEEventNotHandled);
       }
       
       ThrowIfOSErr(err);

       // fill in the result token
       token.dispatchClass  = GetClass();
       token.objectClass    = GetClass();
       token.propertyCode   = typeNull;
       
       if (wantsAllItems)
       {
              err = AECreateList(NULL, 0, false, (AEDescList*)resultToken);
              ThrowIfOSErr(err);
              
              for (TAEListIndex index = 1; index <= numItems; index++)
              {
                     ItemID        itemID = GetIndexedItemID(containerToken, index);
                     if (itemID != kNoItemID)
                     {
                            SetItemIDInCoreToken(containerToken, &token, itemID);
                            err = AEPutPtr(resultToken, 0, desiredClass, &token, sizeof(token));
                            ThrowIfOSErr(err);
                     }
              }
       }
       else
       {
              SetNamedItemIDInCoreToken(containerToken, &token, itemName);
              err = AECreateDesc(desiredClass, &token, sizeof(token), resultToken);
              ThrowIfOSErr(err);
       }
}

Here is the call graph for this function:

virtual ItemID AENamedClassIterator::GetItemIDFromToken ( const AEDesc *  token) [inline, protected, virtual]

Implements AEClassIterator.

Definition at line 174 of file nsAEClassIterator.h.

{ return kNoItemID; }
virtual ItemID AENamedClassIterator::GetNamedItemID ( const AEDesc *  containerToken,
const char *  itemName 
) [inline, protected, virtual]

Implements AEClassIterator.

Definition at line 164 of file nsAEClassIterator.h.

{ return kNoItemID; }
virtual ItemRef AENamedClassIterator::GetNamedItemReference ( const AEDesc *  containerToken,
const char *  itemName 
) [inline, protected, virtual]

Implements AEClassIterator.

Definition at line 157 of file nsAEClassIterator.h.

{ return kNoItemRef; }
virtual UInt32 AENamedClassIterator::GetNumItems ( const AEDesc *  containerToken) [inline, protected, virtual]

Implements AEClassIterator.

Definition at line 155 of file nsAEClassIterator.h.

{ return 0; }

Here is the caller graph for this function:

virtual ItemRef AENamedClassIterator::GetReferenceFromID ( const AEDesc *  containerToken,
ItemID  itemID 
) [inline, protected, virtual]

Implements AEClassIterator.

Definition at line 172 of file nsAEClassIterator.h.

{ return kNoItemRef; }
virtual Boolean AENamedClassIterator::NamedItemExists ( const AEDesc *  containerToken,
const char *  itemName 
) [protected, pure virtual]

Here is the caller graph for this function:

TAEListIndex AEClassIterator::NormalizeAbsoluteIndex ( const AEDesc *  keyData,
TAEListIndex  maxIndex,
Boolean isAllItems 
) [protected, inherited]

Definition at line 268 of file nsAEClassIterator.cpp.

{
       TAEListIndex  index;
       *isAllItems = false;                                                  // set to true if we receive kAEAll constant
       
       // Extract the formAbsolutePosition data, either a integer or a literal constant
       
       switch (keyData->descriptorType)
       {
              case typeLongInteger:                                          // positve or negative index
                     if (DescToLong(keyData, &index) != noErr)
                            ThrowOSErr(errAECoercionFail);
                            
                     if (index < 0)                                                 // convert a negative index from end of list to a positive index from beginning of list
                            index = maxIndex + index + 1;
                     break;
                     
          case typeAbsoluteOrdinal:                                                                      // 'abso'
                     DescType             ordinalDesc;
                     if (DescToDescType((AEDesc*)keyData, &ordinalDesc) != noErr)
                            ThrowOSErr(errAECoercionFail);
                     
                     switch (ordinalDesc)
                     {
                            case kAEFirst:
                                   index = 1;
                                   break;
                                   
                            case kAEMiddle:
                                   index = (maxIndex >> 1) + (maxIndex % 2);
                                   break;
                                          
                            case kAELast:
                                   index = maxIndex;
                                   break;
                                          
                            case kAEAny:
                                   index = (TickCount() % maxIndex) + 1;            // poor man's random
                                   break;
                                          
                            case kAEAll:
                                   index = 1;
                                   *isAllItems = true;
                                   break;
                     }
                     break;

              default:
                     ThrowOSErr(errAEWrongDataType);
       }

       // range-check the new index number
       if ((index < 1) || (index > maxIndex))
              ThrowOSErr(errAEIllegalIndex);
              
       return index;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void AEClassIterator::ProcessFormRange ( AEDesc *  keyData,
AEDesc *  start,
AEDesc *  stop 
) [protected, inherited]

Definition at line 333 of file nsAEClassIterator.cpp.

{
       OSErr         err = noErr;
       StAEDesc             rangeRecord;
       StAEDesc             ospec;
       
       // coerce the range record data into an AERecord 
       
       err = AECoerceDesc(keyData, typeAERecord, &rangeRecord);
       ThrowIfOSErr(err);
        
       // object specifier for first object in the range
       err = AEGetKeyDesc(&rangeRecord, keyAERangeStart, typeWildCard, &ospec);
       if (err == noErr && ospec.descriptorType == typeObjectSpecifier)
              err = AEResolve(&ospec, kAEIDoMinimum, start);
              
       ThrowIfOSErr(err);
              
       ospec.Clear();
              
       // object specifier for last object in the range
       
       err = AEGetKeyDesc(&rangeRecord, keyAERangeStop, typeWildCard, &ospec);
       if (err == noErr && ospec.descriptorType == typeObjectSpecifier)
              err = AEResolve(&ospec, kAEIDoMinimum, stop);

       ThrowIfOSErr(err);
}

Here is the call graph for this function:

Here is the caller graph for this function:

AEClassIterator::ItemRef AEClassIterator::ProcessFormRelativePostition ( const AEDesc *  anchorToken,
const AEDesc *  keyData 
) [protected, virtual, inherited]

Definition at line 212 of file nsAEClassIterator.cpp.

{
       OSErr         err = noErr;
       ItemID        anchorItemID = GetItemIDFromToken(anchorToken);
       TAEListIndex  anchorListIndex = GetIndexFromItemID(anchorToken, anchorItemID);
       TAEListIndex  wantedListIndex = 0;
       long                 numItems = GetNumItems(anchorToken);
       ItemRef              returnRef = kNoItemRef;

       if (anchorListIndex != 0)
       {
              switch (keyData->descriptorType)
              {
                 case typeEnumerated:
                            DescType             positionEnum; 
                            if (DescToDescType((AEDesc*)keyData, &positionEnum) != noErr)
                                   ThrowIfOSErr(errAECoercionFail);

                            switch (positionEnum)
                            {
                                   case kAENext:                                    // get the window behind the anchor
                                          wantedListIndex = anchorListIndex + 1;
                                          if (wantedListIndex > numItems)
                                                 err = errAENoSuchObject;
                                          break;
                                          
                                   case kAEPrevious:                                // get the document in front of the anchor
                                          wantedListIndex = anchorListIndex - 1;
                                          if (wantedListIndex < 1)
                                                 err = errAENoSuchObject;
                                          break;
                                          
                                   default:
                                          err = errAEEventNotHandled;
                                          break;
                            }
                            ThrowIfOSErr(err);
                            break;
                            
                     default:
                            err = errAECoercionFail;
                            break;
              }
       }
       
       ThrowIfOSErr(err);
       return GetIndexedItemReference(anchorToken, wantedListIndex);
}

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void AENamedClassIterator::SetItemIDInCoreToken ( const AEDesc *  containerToken,
CoreTokenRecord tokenRecord,
ItemID  itemID 
) [inline, protected, virtual]

Implements AEClassIterator.

Definition at line 175 of file nsAEClassIterator.h.

{}

Here is the caller graph for this function:

virtual void AENamedClassIterator::SetNamedItemIDInCoreToken ( const AEDesc *  containerToken,
CoreTokenRecord token,
const char *  itemName 
) [protected, pure virtual]

Here is the caller graph for this function:


Member Data Documentation

const AEClassIterator::ItemID AEClassIterator::kNoItemID = -1 [static, protected, inherited]

Definition at line 99 of file nsAEClassIterator.h.

const AEClassIterator::ItemRef AEClassIterator::kNoItemRef = -1 [static, protected, inherited]

Definition at line 98 of file nsAEClassIterator.h.

DescType AEClassIterator::mClass [protected, inherited]

Definition at line 130 of file nsAEClassIterator.h.

UInt16 AEClassIterator::mKeyFormSupport [protected, inherited]

Definition at line 131 of file nsAEClassIterator.h.


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