tsc_Attribute

This base class represents one attribute in the list of attributes within a feature.  An attribute will be one of the eight different data types, such as Number (floating point), Integer, Text (a string), etc.  These is one subclass of tsc_Attribute for each different data type.

For more information about attributes in general, see Features and attributes.

Public constructors

tsc_Attribute ();

Constructs an empty object.

tsc_Attribute (const tsc_Attribute&);

The copy constructor makes a reference to the same object.

tsc_Attribute (const tsc_LibraryAttribute&);

Constructs an attribute using a library attribute as a template, and computes the default value.

Public methods

tsc_Attribute& operator= (const tsc_Attribute&);

Assignment makes a reference to the same object.

tsc_String Name () const;

Returns the name of the attribute.

tsc_AttributeType Type () const;

Returns the type of the attribute value.

bool IsNull () const;

Returns true if the attribute is null, probably as a result of a failed operation.

virtual tsc_String ToString () const;

Returns a string representation of the attribute's value.  This may be acceptable for most attribute types, except number attributes where the number of decimal places displayed is fixed at 3.

The ToString() method allows tsc_Attribute to be used in a tsc_String::Format() like this:

tsc_String message = tsc_String::Format("The %s is %s.", attrib.Name(), attrib);

Conversions

The following methods convert a tsc_Attribute base class instance to the appropriate subclass as determined by the type.  The following code illustrates typical usage:

tsc_Attribute att = new tsc_IntegerAttribute("Diameter", 6); att.AsIntegerAttribute().Value();   // Returns 6. att.AsIntegerAttribute().Value(3);  // Changes the value of <att> to 3. 

class tsc_IntegerAttribute AsIntegerAttribute () const;

Returns this attribute as an integer attribute.

class tsc_NumberAttribute AsNumberAttribute () const;

Returns this attribute as a number attribute.

class tsc_TextAttribute AsTextAttribute () const;

Returns this attribute as a text attribute.

class tsc_ListAttribute AsListAttribute () const;

Returns this attribute as a list attribute.

class tsc_DateAttribute AsDateAttribute () const;

Returns this attribute as a date attribute.

class tsc_TimeAttribute AsTimeAttribute () const;

Returns this attribute as a time attribute.

class tsc_FileAttribute AsFileAttribute () const;

Returns this attribute as a file attribute.

class tsc_PhotoAttribute AsPhotoAttribute () const;

Returns this attribute as a photograph attribute.