#ifndef __IRIASSERVICE_H
#define __IRIASSERVICE_H
#include "CList.h"
enum IASCharacterSetCodes
{
kIASCharSetAscii = 0,
kIASCharSetISO_8859_1 = 1,
kIASCharSetISO_8859_2 = 2,
kIASCharSetISO_8859_3 = 3,
kIASCharSetISO_8859_4 = 4,
kIASCharSetISO_8859_5 = 5,
kIASCharSetISO_8859_6 = 6,
kIASCharSetISO_8859_7 = 7,
kIASCharSetISO_8859_8 = 8,
kIASCharSetISO_8859_9 = 9,
kIASCharSetUniCode = 0xff
};
enum IASFrameFlags
{
kIASFrameLstBit = 0x80,
kIASFrameAckBit = 0x40,
kIASFrameOpCodeMask = 0x3F
};
enum IASOpCodes
{
kIASOpUnassigned,
kIASOpGetInfoBaseDetails,
kIASOpGetObjects,
kIASOpGetValue,
kIASOpGetValueByClass, kIASOpGetObjectInfo,
kIASOpGetAttributeNames
};
enum IASReturnCodes
{
kIASRetOkay,
kIASRetNoSuchClass,
kIASRetNoSuchAttribute,
kIASRetUnsupported = 0xFF
};
enum IASValueTypes
{
kIASValueMissing,
kIASValueInteger,
kIASValueNBytes,
kIASValueString
};
enum IASCleanupFlags
{
kIASAddedClass = 0x01,
kIASAddedAttribute = 0x02,
kIASDeleteClass = kIASAddedClass, kIASDeleteAttribute = kIASAddedAttribute };
class CBuffer;
class TIASElement : public OSObject
{
OSDeclareDefaultStructors(TIASElement);
public:
static TIASElement *tIASElement(ULong theValue); static TIASElement *tIASElement(const UChar* theBytes, ULong length); static TIASElement *tIASElement(const UChar* theString, UChar charSet, ULong length); static TIASElement *tIASElement(CBuffer* buffer);
void free(void);
UByte GetType();
IrDAErr GetInteger(ULong *theValue);
IrDAErr GetNBytes(UByte **theBytes, ULong *theLength); IrDAErr GetString(UByte **theString, UByte *charSet, ULong *length);
void AddInfoToBuffer(CBuffer* buffer);
private:
Boolean init_with_long(ULong theValue);
Boolean init_with_nbytes(const UChar* theBytes, ULong length);
Boolean init_with_string(const UChar* theString, UChar charSet, ULong length);
Boolean init_with_buffer(CBuffer* buffer);
Boolean SetInteger(ULong theValue);
Boolean SetNBytes(const UChar* theBytes, ULong length);
Boolean SetString(const UChar* theString, UChar charSet, ULong length);
Boolean ExtractInfoFromBuffer(CBuffer* buffer);
UByte type;
ULong length;
UByte characterSet; ULong valueOrBytes; UByte* nameOrBytes;
};
class TIASNamedList : public CList
{
OSDeclareDefaultStructors(TIASNamedList);
Boolean Init(void); Boolean Init(const UChar* name); void free(void);
void *Search(const UChar* name);
private:
UChar *fName;
int fNameLen; };
class TIASAttribute : public TIASNamedList
{
OSDeclareDefaultStructors(TIASAttribute);
public:
static TIASAttribute * tIASAttribute(const UChar *name); static TIASAttribute * tIASAttribute(CBuffer* buffer);
IrDAErr Insert(TIASElement* element);
void AddInfoToBuffer(CBuffer* buffer);
private:
void free(void);
Boolean InitFromBuffer(CBuffer* buffer);
};
class TIASClass : public TIASNamedList
{
OSDeclareDefaultStructors(TIASClass);
public:
static TIASClass * tIASClass(const UChar *name);
IrDAErr Insert(TIASAttribute* element);
TIASAttribute* FindAttribute(const UChar* attributeName);
private:
void free(void);
};
class TIASService : public TIASNamedList
{
OSDeclareDefaultStructors(TIASService);
public:
static TIASService * tIASService(void);
IrDAErr AddIntegerEntry(const UChar* className, const UChar* attributeName, ULong intValue);
IrDAErr AddStringEntry(const UChar* className, const UChar* attributeName, const UChar* stringValue, UChar charSet, ULong length);
IrDAErr AddNBytesEntry(const UChar* className, const UChar* attributeName, const UChar* aFewBytes, ULong length);
TIASClass* FindClass(const UChar* className);
TIASAttribute* FindAttribute(const UChar* className, const UChar* attributeName);
IrDAErr RemoveAttribute(const UChar* className, const UChar* attributeName, ULong flags = kIASDeleteClass | kIASDeleteAttribute);
private:
void free(void);
TIASClass* AddClass(const UChar* className, ULong& flags);
TIASAttribute* AddAttribute(const UChar* className, const UChar* attributeName, ULong& flags);
IrDAErr AddAttributeEntry(const UChar* className, const UChar* attributeName, TIASElement* theEntry);
IrDAErr RemoveClass(const UChar* className, ULong flags = kIASDeleteClass);
};
inline UByte TIASElement::GetType(void) { return type; };
#endif // __IRIASSERVICE_H