PrevNextUpHome SophiaFramework UNIVERSE 5.3
SFXProperty
Class which manages several pairs of string key and its string value.
#include <SFXProperty.h.hpp>
class SFXProperty;
SFMTYPEDEFCLASS(SFXProperty)

Description

The SFXProperty class is used to manage the set of the key / value pair elements in the appended order.

The SFXProperty class is similar to the SFXArray or SFXHashmap class, but different in that both key and value are of the SFXAnsiString type and more than one element may have the same string key.

Example 829. Defining an instance variable

SFXProperty property;

Example 830. Setting an element

property.Set("unix", "??");
property.Append("macos", "CR");
property.Insert(1, "windows", "CRLF");
property.Set("unix", "LF");
property.Append("macos", "LF");

Example 831. Getting an element

SFXAnsiString str1 = property.Get("unix");
SFXAnsiString str2 = property.GetKey(2);
SFXAnsiString str3 = property.GetValue(2);

Example 832. Getting the number of the elements

SInt32 n = property.GetSize();

Example 833. Deleting an element

property.Remove(2);
property.Clear("macos");
property.Clear();

Reference

SFXArray | SFXHashmap | SFXAnsiString

Member

Constructor/Destructor
SFXProperty( Void )
Constructor of the SFXProperty class.
~SFXProperty( Void )
Destructor of the SFXProperty class.
Public Functions
SFCError Append( SFXAnsiStringConstRef key , SFXAnsiStringConstRef value )
Append the specified key / value pair element to this property.
Void Clear( SFXAnsiStringConstRef key , Bool sensitive = true )
Delete the elements.
Void Clear( Void )
Delete the elements.
Bool Contains( SFXAnsiStringConstRef key , Bool sensitive = true )
Check whether or not the element with the specified key is contained by this property.
static
SFXPropertyConstRef
EmptyInstance( Void )
Get an empty property.
SInt32 FirstIndexOf( SFXAnsiStringConstRef key , SInt32 index = SINT32_MINIMUM , Bool sensitive = true )
Get the first index of the element to match the specified key by searching from the beginning.
SFXAnsiStringConstRef Get( SFXAnsiStringConstRef key , Bool sensitive = true )
Get the value of the pair element to match the specified key.
SFXAnsiStringConstRef GetKey( SInt32 index )
Get the key of the pair element at the specified index.
SInt32 GetSize( Void )
Get the number of the pair elements in this property.
SFXAnsiStringConstRef GetValue( SInt32 index )
Get the value of the pair element at the specified index.
SFCError Insert( SInt32 index , SFXAnsiStringConstRef key , SFXAnsiStringConstRef value )
Insert the specified key / value pair element at the specified index.
Bool IsEmpty( Void )
Check whether or not this property is empty.
SInt32 LastIndexOf( SFXAnsiStringConstRef key , SInt32 index = SINT32_MAXIMUM , Bool sensitive = true )
Get the last index of the element to match the specified key by searching from the end.
Void Remove( SInt32 begin , SInt32 end )
Remove the pair element at the specified index or ones in the specified range.
Void Remove( SInt32 index )
Remove the pair element at the specified index or ones in the specified range.
SFCError Set( SFXAnsiStringConstRef key , SFXAnsiStringConstRef value , Bool sensitive = true )
Set the value of the pair element with the specified key.
SFCError SetKey( SInt32 index , SFXAnsiStringConstRef key )
Set the key of the pair element at the specified index to the specified key.
SFCError SetValue( SInt32 index , SFXAnsiStringConstRef value )
Get the value of the pair element at the specified index to the specified value.

SFXProperty::SFXProperty
Constructor of the SFXProperty class.
[ public, explicit ]
SFXProperty(Void);

Description

This constructor does nothing.


SFXProperty::~SFXProperty
Destructor of the SFXProperty class.
[ public ]
~SFXProperty(Void);

Description

This destructor deletes all the key / value pair elements from this property by calling the SFXProperty::Clear function internally.

Reference

SFXProperty::Clear


SFXProperty::Append
Append the specified key / value pair element to this property.
[ public ]
SFCError Append(
    SFXAnsiStringConstRef key     // key of string
    SFXAnsiStringConstRef value   // value of string
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If insufficient memory: SFERR_NO_MEMOERY

Description

This function Append the specified key / value pair element to this property.

[Note] Note

More than one pair element can have the same key.

[Note] Note

Both of the key and the value of the pair element are of the SFXAnsiString type.

Reference

SFXProperty::Insert | SFXProperty::Set | SFXProperty::Remove | SFXAnsiString


SFXProperty::Clear
Delete the elements.
[ public ]
Void Clear(
    SFXAnsiStringConstRef key   // key of string
    Bool sensitive = true       // whether or not the key is case-sensitive
);
[ public ]
Void Clear(Void);

Description

This function deletes the elements.

If the key argument is specified, the elements related with it will be deleted.

If no argument is specified, all the elements will be deleted.

[Note] Note

This function is called in the SFXProperty::~SFXProperty destructor.

Reference

SFXProperty::~SFXProperty


SFXProperty::Contains
Check whether or not the element with the specified key is contained by this property.
[ public, const ]
Bool Contains(
    SFXAnsiStringConstRef key   // key of string
    Bool sensitive = true       // whether or not the key will be compared with case-sensitivity
);

Return value

  • If contained: true
  • Otherwise: false

Description

This function checks whether or not the element with the specified key is contained by this property.

If false is specified in the sensitive argument, the key will be compared without case-sensitivity. By defualt, true is set.

[Note] Note

The key of the pair element is of the SFXAnsiString type.

Reference

SFXAnsiString


SFXProperty::EmptyInstance
Get an empty property.
[ public, static ]
SFXPropertyConstRef EmptyInstance(Void);

Description

This function gets an instance that represents an empty property.


SFXProperty::FirstIndexOf
Get the first index of the element to match the specified key by searching from the beginning.
[ public, const ]
SInt32 FirstIndexOf(
    SFXAnsiStringConstRef key       // key of string to match
    SInt32 index = SINT32_MINIMUM   // index to search from
    Bool sensitive = true           // whether or not the key will be compared with case-sensitivity
);

Return value

  • If succeeds: first index of the element to match the specified key
  • If failed: -1

Description

This function gets the first index of the element to match the specified key by searching from the beginning.

By specifying the index argument, you can search from any position other than the beginning. (The origin index is 0.)

If false is specified in the sensitive argument, the key will be compared without case-sensitivity. By defualt, this argument is set to true.

Reference

SFXProperty::LastIndexOf


SFXProperty::Get
Get the value of the pair element to match the specified key.
[ public, const ]
SFXAnsiStringConstRef Get(
    SFXAnsiStringConstRef key   // key of string to match
    Bool sensitive = true       // whether or not the key will be compared with case-sensitivity
);

Return value

Value of the pair element to match the specified key or the null string(SFXAnsiString::EmptyInstance).

Description

This function gets the value of the pair element to match the specified key.

If more than one pair element have the same key specified in the key argument, the value of the pair element whose index is the greatest among them will be returned.

If no element matches the specified key, the null string(SFXAnsiString::EmptyInstance) will be returned.

If false is specified in the sensitive argument, the key will be compared without case-sensitivity. By defualt, true is set.

[Note] Note

Both of the key and the value of the pair element are of the SFXAnsiString type.

Reference

SFXProperty::Set | SFXAnsiString::EmptyInstance | SFXAnsiString


SFXProperty::GetKey
Get the key of the pair element at the specified index.
[ public, const ]
SFXAnsiStringConstRef GetKey(
    SInt32 index   // index
);

Return value

Key of the pair element at the specified index or the null string(SFXAnsiString::EmptyInstance).

Description

This function gets the key of the pair element at the specified index.

If no element exists at the specified index, the null string(SFXAnsiString::EmptyInstance) will be returned.

[Note] Note

The key of the pair element is of the SFXAnsiString type.

Reference

SFXProperty::SetKey | SFXAnsiString::EmptyInstance | SFXAnsiString


SFXProperty::GetSize
Get the number of the pair elements in this property.
[ public, const ]
SInt32 GetSize(Void);

Return value

Number of the pair elements in this property.

Description

This function gets the number of the pair elements in this property.


SFXProperty::GetValue
Get the value of the pair element at the specified index.
[ public, const ]
SFXAnsiStringConstRef GetValue(
    SInt32 index   // index
);

Return value

Value of the pair element at the specified index or the null string(SFXAnsiString::EmptyInstance).

Description

This function gets the value of the pair element at the specified index.

If no element exists at the specified index, the null string(SFXAnsiString::EmptyInstance) will be returned.

[Note] Note

The value of the pair element is of the SFXAnsiString type.

Reference

SFXProperty::SetValue | SFXAnsiString::EmptyInstance | SFXAnsiString


SFXProperty::Insert
Insert the specified key / value pair element at the specified index.
[ public ]
SFCError Insert(
    SInt32 index                  // index to insert at
    SFXAnsiStringConstRef key     // key of string
    SFXAnsiStringConstRef value   // value of string
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If insufficient memory: SFERR_NO_MEMOERY

Description

This function inserts the specified key / value pair element at the specified index.

More than one pair element have the same key in this property.

[Note] Note

Both of the key and the value of the pair element are of the SFXAnsiString type.

Reference

SFXProperty::Append | SFXProperty::Set | SFXProperty::Remove | SFXAnsiString


SFXProperty::IsEmpty
Check whether or not this property is empty.
[ public, const ]
Bool IsEmpty(Void);

Return value

  • If empty: true
  • Otherwise: false

Description

This function checks whether or not this property is empty.


SFXProperty::LastIndexOf
Get the last index of the element to match the specified key by searching from the end.
[ public, const ]
SInt32 LastIndexOf(
    SFXAnsiStringConstRef key       // key of string to match
    SInt32 index = SINT32_MAXIMUM   // index to search from
    Bool sensitive = true           // whether or not the key will be compared with case-sensitivity
);

Return value

  • If succeeds: last index of the element to match the specified key
  • If failed: -1

Description

This function gets the last index of the element to match the specified key by searching from the end.

By specifying the index argument, you can search from any position other than the end. (The origin index is 0.)

If false is specified in the sensitive argument, the key will be compared without case-sensitivity. By defualt, this argument is set to true.

Reference

SFXProperty::FirstIndexOf


SFXProperty::Remove
Remove the pair element at the specified index or ones in the specified range.
[ public ]
Void Remove(
    SInt32 begin   // beginning index to remove(this index is included)
    SInt32 end     // ending index to remove(this index is not included)
);
[ public ]
Void Remove(
    SInt32 index   // index to remove
);

Description

This function removes the pair element at the specified index or ones in the specified range..

[Note] Note

Though the value specified in the begin argument will be included in the indexes of the pair elements to be deleted, one specified in the end argument will not be included.

Reference

SFXProperty::Insert | SFXProperty::Append | SFXProperty::Set


SFXProperty::Set
Set the value of the pair element with the specified key.
[ public ]
SFCError Set(
    SFXAnsiStringConstRef key     // key of string
    SFXAnsiStringConstRef value   // value of string
    Bool sensitive = true         // whether or not the key will be compared with case-sensitivity
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If insufficient memory: SFERR_NO_MEMOERY

Description

This function sets the value of the pair element with the specified key.

If more than one pair element have the same key specified in the key argument, the value of the pair element whose index is the greatest among them will be overwitten.

If no element matches the specified key, the pair element with the specified key and value will be appended to this property.

If false is specified in the sensitive argument, the key will be compared without case-sensitivity. By defualt, true is set.

[Note] Note

Both of the key and the value of the pair element are of the SFXAnsiString type.

Reference

SFXProperty::Append | SFXProperty::Insert | SFXProperty::Remove | SFXAnsiString


SFXProperty::SetKey
Set the key of the pair element at the specified index to the specified key.
[ public ]
SFCError SetKey(
    SInt32 index                // index
    SFXAnsiStringConstRef key   // key of string
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If insufficient memory: SFERR_NO_MEMOERY
  • If there is no pair element at the specified index: SFERR_INVALID_PARAM

Description

This function sets the key of the pair element at the specified index to the specified key.

If no element exists at the specified index, SFERR_INVALID_PARAM will be returned.

[Note] Note

The key of the pair element is of the SFXAnsiString type.

Reference

SFXProperty::GetKey | SFXAnsiString


SFXProperty::SetValue
Get the value of the pair element at the specified index to the specified value.
[ public ]
SFCError SetValue(
    SInt32 index                  // index
    SFXAnsiStringConstRef value   // value of string
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If insufficient memory: SFERR_NO_MEMOERY
  • If there is no pair element at the specified index: SFERR_INVALID_PARAM

Description

This function sets the value of the pair element at the specified index to the specified value.

If no element exists at the specified index, SFERR_INVALID_PARAM will be returned.

[Note] Note

The value of the pair element is of the SFXAnsiString type.

Reference

SFXProperty::GetValue | SFXAnsiString