PrevNextUpHome SophiaFramework UNIVERSE 5.3
SFXConfig
Class which manages various application settings.
#include <SFXConfig.h.hpp>
class SFXConfig;
SFMTYPEDEFCLASS(SFXConfig)

Collaboration diagram

 Collaboration diagram of SFXConfigClass

Description

The SFXConfig class is used to save the entries of (tag, value) to file.

If the entries of (tag, value) are written into the SFXConfig instance when the applet ends or suspends, they can be restored from this instance when the applet starts or resumes.

When a entry of (tag, value) is written, any value from 0 to 65535 of the UInt16 type can be set as the tag and any numeric, string, or buffer can be set as the value.

By specifying the tag, the corresponding value can be read from the SFXConfig instance.

[Caution] About MIF File Setting

It is necessary to turn on the File option in the MIF file setting of privilege level when the SFXConfig class is used.

Example 807. Writing the entry of (tag, value)

SFXConfig config;

// write the entry of (tag: 1, value: "saving data") into SFXConfig
config.WriteSFXAnsiString(1, "saving data");

// save the SFXConfig instance to the configuration file
config.Save(SFXPath("/data/applet.cfg"));

Example 808. Reading the value of the entry with the specified tag

SFXConfig config;

// load the SFXConfig instance from the configuration file
config.Load(SFXPath("/data/applet.cfg"));

// get the value of the entry where tag is "1"
// * the second argument is the default value, 
//   which will be returned if the entry in question is not found
SFXAnsiString value = config.ReadSFXAnsiString(1, "default text");
// now, value is set to "saving data"

Example 809. Writing and reading various values

config.WriteSInt32(2, -17); // value of the SInt32 type
config.WriteUInt08(3, 'a'); // value of the UInt08 type
config.WriteBool(4, true);  // value of the Bool type


ByteConst data[] = {0x01, 0x11, 0x22, 0x33, 0x44};
SFXBuffer buffer(data, lengthof(data));
config.WriteSFXBuffer(5, buffer);        // value of the SFXBuffer type

// get the value of the entry with the specified tag
// * the second argument is the default value, 
//   which will be returned if the pair element in question is not found

SInt32 n1 = config.ReadSInt32(2, -9999); // value of the entry where tag is "2"
// n1 = -17 of the SInt32 type

AChar c = config.ReadUInt08(3, '\0');    // value of the entry where tag is "3"
// c = 'a' of the UInt08 type

Bool b = config.ReadBool(4, false);      // value of the entry where tag is "4"
// b = true of the Bool type

SFXBuffer buff = config.ReadSFXBuffer(5, SFXBuffer()); // value of the entry where tag is "5"
// buff = {0x01, 0x11, 0x22, 0x33, 0x44}

Reference

SFXAnsiString | SFXWideString | SFXBuffer

Member

Constructor/Destructor
SFXConfig( Void )
Constructor of the SFXConfig class.
~SFXConfig( Void )
Destructor of the SFXConfig class.
Public Functions
Void Clear( Void )
Delete all entries from this SFXConfig instance.
static
SFXConfigConstRef
EmptyInstance( Void )
Get an empty config.
SInt32 GetSize( Void )
Get the number of entries in this SFXConfig instance.
SFCError Load( SFXPathConstRef path )
Load the SFXConfig instance from the specified configuration file.
SFCError ReadBinary( UInt16 tag , VoidConstHandle value , UInt16Ptr length )
Read the Binary value of the entry with the specified tag from this SFXConfig instance.
Bool ReadBool( UInt16 tag , Bool initial )
Read the Bool value of the entry with the specified tag from this SFXConfig instance.
Float32 ReadFloat32( UInt16 tag , Float32 initial )
Read the Float32 value of the entry with the specified tag from this SFXConfig instance.
Float64 ReadFloat64( UInt16 tag , Float64 initial )
Read the Float64 value of the entry with the specified tag from this SFXConfig instance.
SFXAnsiString ReadSFXAnsiString( UInt16 tag , SFXAnsiStringConstRef initial )
Read the SFXAnsiString value of the entry with the specified tag from this SFXConfig instance.
SFXBuffer ReadSFXBuffer( UInt16 tag , SFXBufferConstRef initial )
Read the SFXBuffer value of the entry with the specified tag from this SFXConfig instance.
SFXWideString ReadSFXWideString( UInt16 tag , SFXWideStringConstRef initial )
Read the SFXWideString value of the entry with the specified tag from this SFXConfig instance.
SInt08 ReadSInt08( UInt16 tag , SInt08 initial )
Read the SInt08 value of the entry with the specified tag from this SFXConfig instance.
SInt16 ReadSInt16( UInt16 tag , SInt16 initial )
Read the SInt16 value of the entry with the specified tag from this SFXConfig instance.
SInt32 ReadSInt32( UInt16 tag , SInt32 initial )
Read the SInt32 value of the entry with the specified tag from this SFXConfig instance.
SInt64 ReadSInt64( UInt16 tag , SInt64 initial )
Read the SInt64 value of the entry with the specified tag from this SFXConfig instance.
UInt08 ReadUInt08( UInt16 tag , UInt08 initial )
Read the UInt08 value of the entry with the specified tag from this SFXConfig instance.
UInt16 ReadUInt16( UInt16 tag , UInt16 initial )
Read the UInt16 value of the entry with the specified tag from this SFXConfig instance.
UInt32 ReadUInt32( UInt16 tag , UInt32 initial )
Read the UInt32 value of the entry with the specified tag from this SFXConfig instance.
UInt64 ReadUInt64( UInt16 tag , UInt64 initial )
Read the UInt64 value of the entry with the specified tag from this SFXConfig instance.
Void Remove( UInt16 tag )
Delete the specified entry.
SFCError Save( SFXPathConstRef path )
Save this SFXConfig instance to the specified configuration file.
SFCError Save( Void )
Save this SFXConfig instance to the specified configuration file.
SFCError WriteBinary( UInt16 tag , VoidConstPtr value , UInt16 length )
Write the entry of the specified tag and the specified Binary value into this SFXConfig instance.
SFCError WriteBool( UInt16 tag , Bool value )
Write the entry of the specified tag and the specified Bool value into this SFXConfig instance.
SFCError WriteFloat32( UInt16 tag , Float32 value )
Write the entry of the specified tag and the specified Float32 value into this SFXConfig instance.
SFCError WriteFloat64( UInt16 tag , Float64 value )
Write the entry of the specified tag and the specified Float64 value into this SFXConfig instance.
SFCError WriteSFXAnsiString( UInt16 tag , SFXAnsiStringConstRef value )
Write the entry of the specified tag and the specified SFXAnsiString value into this SFXConfig instance.
SFCError WriteSFXBuffer( UInt16 tag , SFXBufferConstRef value )
Write the entry of the specified tag and the specified WriteSFXBuffer value into this SFXConfig instance.
SFCError WriteSFXWideString( UInt16 tag , SFXWideStringConstRef value )
Write the entry of the specified tag and the specified SFXWideString value into this SFXConfig instance.
SFCError WriteSInt08( UInt16 tag , SInt08 value )
Write the entry of the specified tag and the specified SInt08 value into this SFXConfig instance.
SFCError WriteSInt16( UInt16 tag , SInt16 value )
Write the entry of the specified tag and the specified SInt16 value into this SFXConfig instance.
SFCError WriteSInt32( UInt16 tag , SInt32 value )
Write the entry of the specified tag and the specified SInt32 value into this SFXConfig instance.
SFCError WriteSInt64( UInt16 tag , SInt64 value )
Write the entry of the specified tag and the specified SInt64 value into this SFXConfig instance.
SFCError WriteUInt08( UInt16 tag , UInt08 value )
Write the entry of the specified tag and the specified UInt08 value into this SFXConfig instance.
SFCError WriteUInt16( UInt16 tag , UInt16 value )
Write the entry of the specified tag and the specified UInt16 value into this SFXConfig instance.
SFCError WriteUInt32( UInt16 tag , UInt32 value )
Write the entry of the specified tag and the specified UInt32 value into this SFXConfig instance.
SFCError WriteUInt64( UInt16 tag , UInt64 value )
Write the entry of the specified tag and the specified UInt64 value into this SFXConfig instance.

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

Description

This constructor does nothing.


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

Description

This destructor deletes all entries in this SFXConfig instance by calling the SFXConfig::Clear function internally.

Reference

SFXConfig::Clear


SFXConfig::Clear
Delete all entries from this SFXConfig instance.
[ public ]
Void Clear(Void);

Description

The content of the SFXConfig instance updated by the SFXConfig::Clear function is not reflected to the configuration file until the SFXConfig::Save function is called.

Example

SFXConfig  config;

// load the SFXConfig instance from the configuration file
config.Load(SFXPath("config.cfg"));

// write Bool values into the SFXConfig instance
config.WriteBool(100, true);
config.WriteBool(101, false);

// delete all entries from the SFXConfig instance
config.Clear();

Reference

SFXConfig::Remove | SFXConfig::EmptyInstance | SFXConfig::Save | SFXConfig::~SFXConfig


SFXConfig::EmptyInstance
Get an empty config.
[ public, static ]
SFXConfigConstRef EmptyInstance(Void);

Description

This function gets an instance that represents an empty config.


SFXConfig::GetSize
Get the number of entries in this SFXConfig instance.
[ public, const ]
SInt32 GetSize(Void);

Return value

Number of entries in this SFXConfig instance

Description

This function gets the number of entries in this SFXConfig instance.

Example

SFXConfig   config;
UInt32      entryNum = 0;

// load the SFXConfig instance from the configuration file
config.Load(SFXPath("config.cfg"));

// write the entry of the specified tag and the specified Bool value into the SFXConfig instance
config.WriteBool(100, true);
config.WriteBool(101, false);

// get number of entries in the SFXConfig instance
entryNum = config.GetSize();

SFXConfig::Load
Load the SFXConfig instance from the specified configuration file.
[ public ]
SFCError Load(
    SFXPathConstRef path   // path of the configuration file 
);

Return value

  • If succeeds, or the configuration file does not exist: SFERR_NO_ERROR
  • If the path argument is a directory: SFERR_INVALID_PARAM
  • If the specified configuration file has already been opened: SFERR_INVALID_STATE
  • If insufficient memory: SFERR_NO_MEMORY
  • If other error occurs: error that BREW API IFILEMGR_GetLastError function returns or SFERR_FAILED

Description

This function loads the SFXConfig instance from the specified configuration file saved with the SFXConfig::Save function.

This SFXConfig instance contains the pass of the configuration file specified in the path argument. And if the SFXConfig::Save fucntion is called without specifying no argument, the SFXConfig instance will be save to the file of this path.

[Tip] Tip

To use the SFXConfig class, this function needs to be called first.

[Note] Note
If more than one configuration file are loaded, only the content of the configuration file loaded last will be valid. The contents of the other configuration files will be destroyed.

Example

SFXConfig   config;
Bool        bool_0(true), bool_1(false);
Bool        bool_a, bool_b;

// load the SFXConfig instance from the configuration file
config.Load(SFXPath("config.cfg"));

// write the entry of the specified tag and the specified Bool value into the SFXConfig instance
config.WriteBool(100, bool_0);
config.WriteBool(101, bool_1);

// save the SFXConfig instance to the configuration file
config.Save();

// load the SFXConfig instance from the configuration file
config.Load(SFXPath("config.cfg"));

// read the Bool value of the entry with the specified tag from the SFXConfig instance
bool_a = config.ReadBool(100, bool_0);
bool_b = config.ReadBool(101, bool_1);

Reference

SFXConfig::Save | SFXConfig | BREW API IFILEMGR_GetLastError


SFXConfig::ReadBinary
Read the Binary value of the entry with the specified tag from this SFXConfig instance.
[ public, const ]
SFCError ReadBinary(
    UInt16 tag              // tag
    VoidConstHandle value   // handle of data to store
    UInt16Ptr length        // length of data
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If the entry with the specified tag does not exist: SFERR_FAILED

Description

This function reads the Binary value of the entry with the specified tag written with the SFXConfig::WriteBinary function from this SFXConfig instance.

[Note] Note

If the entry of the specified tag and the Binary value does not exist, SFERR_FAILED will be returned.

Example

SFXConfig          config;
AChar              moji[] = {"abcdefghijkxyz"};
VoidConstPtr       data;
UInt16             len;

// load the SFXConfig instance from the configuration file
config.Load(SFXPath("config.cfg"));

// write the entry of the specified tag and the specified Binary value into the SFXConfig instance
config.WriteBinary(100, (VoidConstPtr)moji, SFXHelper::strlen(moji) + 1);

// save the SFXConfig instance to the configuration file
config.Save();

// load the SFXConfig instance from the configuration file
config.Load(SFXPath("config.cfg"));

// read the Binary value of the entry with the specified tag from the SFXConfig instance
config.ReadBinary(100, &data, &len);

Reference

SFXConfig::WriteBinary | SFXConfig


SFXConfig::ReadBool
Read the Bool value of the entry with the specified tag from this SFXConfig instance.
[ public, const ]
Bool ReadBool(
    UInt16 tag     // tag
    Bool initial   // default value
);

Return value

  • If the entry of the specified tag and the Bool value exists in this SFXConfig instance: Bool value
  • Otherwise: default value specified in the initial argument

Description

This function reads the Bool value of the entry with the specified tag written with the SFXConfig::WriteBool function from this SFXConfig instance.

[Note] Note

If the entry of the specified tag and the Bool value does not exist, the default value specified in the initial argument will be returned.

Example

SFXConfig   config;
Bool        bool_0(true), bool_1(false);
Bool        bool_a, bool_b;

// load the SFXConfig instance from the configuration file
config.Load(SFXPath("config.cfg"));

// write the entry of the specified tag and the specified Bool value into the SFXConfig instance
config.WriteBool(100, bool_0);
config.WriteBool(101, bool_1);

// save the SFXConfig instance to the configuration file
config.Save();

// load the SFXConfig instance from the configuration file
config.Load(SFXPath("config.cfg"));

// read the Bool value of the entry with the specified tag from the SFXConfig instance
bool_a = config.ReadBool(100, bool_0);
bool_b = config.ReadBool(101, bool_1);

Reference

SFXConfig::WriteBool | SFXConfig


SFXConfig::ReadFloat32
Read the Float32 value of the entry with the specified tag from this SFXConfig instance.
[ public, const ]
Float32 ReadFloat32(
    UInt16 tag        // tag
    Float32 initial   // default value
);

Return value

  • If the entry of the specified tag and the Float32 value exists in this SFXConfig instance: Float32 value
  • Otherwise: default value specified in the initial argument

Description

This function reads the Float32 value of the entry with the specified tag written with the SFXConfig::WriteFloat32 function from this SFXConfig instance.

[Note] Note

If the entry of the specified tag and the Float32 value does not exist, the default value specified in the initial argument will be returned.

Reference

SFXConfig::WriteFloat32 | SFXConfig


SFXConfig::ReadFloat64
Read the Float64 value of the entry with the specified tag from this SFXConfig instance.
[ public, const ]
Float64 ReadFloat64(
    UInt16 tag        // tag
    Float64 initial   // default value
);

Return value

  • If the entry of the specified tag and the Float64 value exists in this SFXConfig instance: Float64 value
  • Otherwise: default value specified in the initial argument

Description

This function reads the Float64 value of the entry with the specified tag written with the SFXConfig::WriteFloat64 function from this SFXConfig instance.

[Note] Note

If the entry of the specified tag and the Float64 value does not exist, the default value specified in the initial argument will be returned.

Example

SFXConfig   config;
Float64     float64_0(0.12345), float64_1(0.000000), float64_2(-1.234);
Float64     float64_a, float64_b, float64_c;

// load the SFXConfig instance from the configuration file
config.Load(SFXPath("config.cfg"));

// write the entry of the specified tag and the specified Float64 value into the SFXConfig instance
config.WriteFloat64(100, float64_0);
config.WriteFloat64(101, float64_1);
config.WriteFloat64(102, float64_2);

// save the SFXConfig instance to the configuration file
config.Save();

// load the SFXConfig instance from the configuration file
config.Load(SFXPath("config.cfg"));

// read the Float64 value of the entry with the specified tag from the SFXConfig instance
float64_a = config.ReadFloat64(100, float64_0);
float64_b = config.ReadFloat64(101, float64_1);
float64_c = config.ReadFloat64(102, float64_2);

Reference

SFXConfig::WriteFloat64 | SFXConfig


SFXConfig::ReadSFXAnsiString
Read the SFXAnsiString value of the entry with the specified tag from this SFXConfig instance.
[ public, const ]
SFXAnsiString ReadSFXAnsiString(
    UInt16 tag                      // tag
    SFXAnsiStringConstRef initial   // default value
);

Return value

  • If the entry of the specified tag and the SFXAnsiString value exists in this SFXConfig instance and its length is more than 0: SFXAnsiString value
  • Otherwise: default value specified in the initial argument

Description

This function reads the SFXAnsiString value of the entry with the specified tag written with the SFXConfig::WriteSFXAnsiString function from this SFXConfig instance.

[Note] Note

If the entry of the specified tag and the SFXAnsiString value does not exist, the default value specified in the initial argument will be returned.

[Note] Note

The returned SFXAnsiString value includes the null character. If its length equals 1 byte, it is the null string.

Example

SFXConfig      config;
SFXAnsiString  string;

// load configuration file
config.Load(SFXPath("config.cfg"));

// write the entry of the specified tag and the specified SFXAnsiString value into the SFXConfig instance
config.WriteSFXAnsiString(100, "Config");
config.WriteSFXAnsiString(101, "Sample");
config.WriteSFXAnsiString(102, "SophiaFramework");

// save the SFXConfig instance to the configuration file
config.Save();

// load the SFXConfig instance from the configuration file
config.Load(SFXPath("config.cfg"));

// read the SFXAnsiString value of the entry with the specified tag from the SFXConfig instance
string = config.ReadSFXAnsiString(100, "Read Config");

Reference

SFXConfig::WriteSFXAnsiString | SFXAnsiString | SFXConfig


SFXConfig::ReadSFXBuffer
Read the SFXBuffer value of the entry with the specified tag from this SFXConfig instance.
[ public, const ]
SFXBuffer ReadSFXBuffer(
    UInt16 tag                  // tag
    SFXBufferConstRef initial   // default value
);

Return value

  • If the entry of the specified tag and the SFXBuffer value exists in this SFXConfig instance: SFXBuffer value
  • Otherwise: default value specified in the initial argument

Description

This function reads the SFXBuffer value of the entry with the specified tag written with the SFXConfig::WriteSFXBuffer function from this SFXConfig instance.

[Note] Note

If the entry of the specified tag and the SFXBuffer value does not exist, the default value specified in the initial argument will be returned.

Reference

SFXConfig::WriteSFXBuffer | SFXBuffer | SFXConfig


SFXConfig::ReadSFXWideString
Read the SFXWideString value of the entry with the specified tag from this SFXConfig instance.
[ public, const ]
SFXWideString ReadSFXWideString(
    UInt16 tag                      // tag
    SFXWideStringConstRef initial   // default value
);

Return value

  • If the entry of the specified tag and the SFXWideString value exists in this SFXConfig instance and its length is more than 0: SFXWideString value
  • Otherwise: default value specified in the initial argument

Description

This function reads the SFXWideString value of the entry with the specified tag written with the SFXConfig::WriteSFXWideString function from this SFXConfig instance.

[Note] Note

If the entry of the specified tag and the SFXWideString value does not exist, the default value specified in the initial argument will be returned.

[Note] Note

The returned SFXWideString value includes the null character. If its length equals 2 bytes, it is the null string.

Example

SFXConfig      config;
SFXWideString  string;

// load configuration file
config.Load(SFXPath("config.cfg"));

// write the entry of the specified tag and the specified SFXWideString value into the SFXConfig instance
config.WriteSFXWideString(100, "Config");
config.WriteSFXWideString(101, "Sample");
config.WriteSFXWideString(102, "SophiaFramework");

// save the SFXConfig instance to the configuration file
config.Save();

// load the SFXConfig instance from the configuration file
config.Load(SFXPath("config.cfg"));

// read the SFXWideString value of the entry with the specified tag from the SFXConfig instance
string = config.ReadSFXWideString(100, "Read Config");

Reference

SFXConfig::WriteSFXWideString | SFXConfig


SFXConfig::ReadSInt08
Read the SInt08 value of the entry with the specified tag from this SFXConfig instance.
[ public, const ]
SInt08 ReadSInt08(
    UInt16 tag       // tag
    SInt08 initial   // default value
);

Return value

  • If the entry of the specified tag and the SInt08 value exists in this SFXConfig instance: SInt08 value
  • Otherwise: default value specified in the initial argument

Description

This function reads the SInt08 value of the entry with the specified tag written with the SFXConfig::WriteSInt08 function from this SFXConfig instance.

[Note] Note

If the entry of the specified tag and the SInt08 value does not exist, the default value specified in the initial argument will be returned.

Reference

SFXConfig::WriteSInt08 | SFXConfig


SFXConfig::ReadSInt16
Read the SInt16 value of the entry with the specified tag from this SFXConfig instance.
[ public, const ]
SInt16 ReadSInt16(
    UInt16 tag       // tag
    SInt16 initial   // default value
);

Return value

  • If the entry of the specified tag and the SInt16 value exists in this SFXConfig instance: SInt16 value
  • Otherwise: default value specified in the initial argument

Description

This function reads the SInt16 value of the entry with the specified tag written with the SFXConfig::WriteSInt16 function from this SFXConfig instance.

[Note] Note

If the entry of the specified tag and the SInt16 value does not exist, the default value specified in the initial argument will be returned.

Reference

SFXConfig::WriteSInt16 | SFXConfig


SFXConfig::ReadSInt32
Read the SInt32 value of the entry with the specified tag from this SFXConfig instance.
[ public, const ]
SInt32 ReadSInt32(
    UInt16 tag       // tag
    SInt32 initial   // default value
);

Return value

  • If the entry of the specified tag and the SInt32 value exists in this SFXConfig instance: SInt32 value
  • Otherwise: default value specified in the initial argument

Description

This function reads the SInt32 value of the entry with the specified tag written with the SFXConfig::WriteSInt32 function from this SFXConfig instance.

[Note] Note

If the entry of the specified tag and the SInt32 value does not exist, the default value specified in the initial argument will be returned.

Example

SFXConfig   config;
SInt32      i_0(10), i_1(20), i_2(30);
SInt32      i_a, i_b, i_c;

// load configuration file
config.Load(SFXPath("config.cfg"));

// write the entry of the specified tag and the specified SInt32 value into the SFXConfig instance
config.WriteSInt32(100, i_0);
config.WriteSInt32(101, i_1);
config.WriteSInt32(102, i_2);

// save the SFXConfig instance to the configuration file
config.Save();

// load the SFXConfig instance from the configuration file
config.Load(SFXPath("config.cfg"));

// read the SInt32 value of the entry with the specified tag from the SFXConfig instance
i_a = config.ReadSInt32(100, i_0);
i_b = config.ReadSInt32(101, i_1);
i_c = config.ReadSInt32(102, i_2);

Reference

SFXConfig::WriteSInt32 | SFXConfig


SFXConfig::ReadSInt64
Read the SInt64 value of the entry with the specified tag from this SFXConfig instance.
[ public, const ]
SInt64 ReadSInt64(
    UInt16 tag       // tag
    SInt64 initial   // default value
);

Return value

  • If the entry of the specified tag and the SInt64 value exists in this SFXConfig instance: SInt64 value
  • Otherwise: default value specified in the initial argument

Description

This function reads the SInt64 value of the entry with the specified tag written with the SFXConfig::WriteSInt64 function from this SFXConfig instance.

[Note] Note

If the entry of the specified tag and the SInt64 value does not exist, the default value specified in the initial argument will be returned.

Reference

SFXConfig::WriteSInt64 | SFXConfig


SFXConfig::ReadUInt08
Read the UInt08 value of the entry with the specified tag from this SFXConfig instance.
[ public, const ]
UInt08 ReadUInt08(
    UInt16 tag       // tag
    UInt08 initial   // default value
);

Return value

  • If the entry of the specified tag and the UInt08 value exists in this SFXConfig instance: UInt08 value
  • Otherwise: default value specified in the initial argument

Description

This function reads the UInt08 value of the entry with the specified tag written with the SFXConfig::WriteUInt08 function from this SFXConfig instance.

[Note] Note

If the entry of the specified tag and the UInt08 value does not exist, the default value specified in the initial argument will be returned.

Reference

SFXConfig::WriteUInt08 | SFXConfig


SFXConfig::ReadUInt16
Read the UInt16 value of the entry with the specified tag from this SFXConfig instance.
[ public, const ]
UInt16 ReadUInt16(
    UInt16 tag       // tag
    UInt16 initial   // default value
);

Return value

  • If the entry of the specified tag and the UInt16 value exists in this SFXConfig instance: UInt16 value
  • Otherwise: default value specified in the initial argument

Description

This function reads the UInt16 value of the entry with the specified tag written with the SFXConfig::WriteUInt16 function from this SFXConfig instance.

[Note] Note

If the entry of the specified tag and the UInt16 value does not exist, the default value specified in the initial argument will be returned.

Reference

SFXConfig::WriteUInt16 | SFXConfig


SFXConfig::ReadUInt32
Read the UInt32 value of the entry with the specified tag from this SFXConfig instance.
[ public, const ]
UInt32 ReadUInt32(
    UInt16 tag       // tag
    UInt32 initial   // default value
);

Return value

  • If the entry of the specified tag and the UInt32 value exists in this SFXConfig instance: UInt32 value
  • Otherwise: default value specified in the initial argument

Description

This function reads the UInt32 value of the entry with the specified tag written with the SFXConfig::WriteUInt32 function from this SFXConfig instance.

[Note] Note

If the entry of the specified tag and the UInt32 value does not exist, the default value specified in the initial argument will be returned.

Reference

SFXConfig::WriteUInt32 | SFXConfig


SFXConfig::ReadUInt64
Read the UInt64 value of the entry with the specified tag from this SFXConfig instance.
[ public, const ]
UInt64 ReadUInt64(
    UInt16 tag       // tag
    UInt64 initial   // default value
);

Return value

  • If the entry of the specified tag and the UInt64 value exists in this SFXConfig instance: UInt64 value
  • Otherwise: default value specified in the initial argument

Description

This function reads the UInt64 value of the entry with the specified tag written with the SFXConfig::WriteUInt64 function from this SFXConfig instance.

[Note] Note

If the entry of the specified tag and the UInt64 value does not exist, the default value specified in the initial argument will be returned.

Reference

SFXConfig::WriteUInt64 | SFXConfig


SFXConfig::Remove
Delete the specified entry.
[ public ]
Void Remove(
    UInt16 tag   // tag
);

Description

Delete the specified entry if it exists in the SFXConfig instance.

The content of the SFXConfig instance updated by the SFXConfig::Remove function is not reflected in the configuration file until the SFXConfig::Save function is called.

Example

SFXConfig     config;

// load configuration file
config.Load(SFXPath("config.cfg"));

// write value of Bool type
config.WriteBool(100, true);
config.WriteBool(101, false);

// delete specified entry
config.Remove(101);

Reference

SFXConfig::Save


SFXConfig::Save
Save this SFXConfig instance to the specified configuration file.
[ public ]
SFCError Save(
    SFXPathConstRef path   // path of the configuration file
);
[ public ]
SFCError Save(Void);

Return value

  • If succeeds, or the configuration file does not exist: SFERR_NO_ERROR
  • If the path argument is a directory: SFERR_INVALID_PARAM
  • If the specified configuration file has already been opened: SFERR_INVALID_STATE
  • If insufficient memory: SFERR_NO_MEMORY
  • If other error occurs: error that BREW API IFILEMGR_GetLastError function returns or SFERR_FAILED

Description

This function saves this SFXConfig instance to the specified configuration file, which will be loaded with the SFXConfig::Load function.

If no argument is specified, this SFXConfig instance will be saved to the file from which the SFXConfig::Load function loaded this instance.

Example

SFXConfig   config;
Bool        bool_0(true), bool_1(false);
Bool        bool_a, bool_b;

// load the SFXConfig instance from the configuration file
config.Load(SFXPath("config.cfg"));

// write the entry of the specified tag and the specified Bool value into the SFXConfig instance
config.WriteBool(100, bool_0);
config.WriteBool(101, bool_1);

// save the SFXConfig instance to the configuration file
config.Save();

// load the SFXConfig instance from the configuration file
config.Load(SFXPath("config.cfg"));

// read the Bool value of the entry with the specified tag from the SFXConfig instance
bool_a = config.ReadBool(100, bool_0);
bool_b = config.ReadBool(101, bool_1);

Reference

SFXConfig::Load | SFXConfig | BREW API IFILEMGR_GetLastError


SFXConfig::WriteBinary
Write the entry of the specified tag and the specified Binary value into this SFXConfig instance.
[ public ]
SFCError WriteBinary(
    UInt16 tag           // tag
    VoidConstPtr value   // pointer to binary data
    UInt16 length        // length of binary data
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If insufficient memory: SFERR_NO_MEMORY
  • If the value argument is null or the length argument is 0: SFERR_INVALID_PARAM

Description

This function writes the entry of the specified tag and the specified Binary value into this SFXConfig instance, which can be read with the SFXConfig::ReadBinary function.

If the entry with the specified tag has already existed in this SFXConfig instance, its value will be overwritten with the specified Binary value.

Example

SFXConfig          config;
AChar              moji[] = {"abcdefghijkxyz"};
VoidConstPtr       data;
UInt16             len;

// load the SFXConfig instance from the configuration file
config.Load(SFXPath("config.cfg"));

// write the entry of the specified tag and the specified Binary value into the SFXConfig instance
config.WriteBinary(100, (VoidConstPtr)moji, SFXHelper::strlen(moji) + 1);

// save the SFXConfig instance to the configuration file
config.Save();

// load the SFXConfig instance from the configuration file
config.Load(SFXPath("config.cfg"));

// read the Binary value of the entry with the specified tag from the SFXConfig instance
config.ReadBinary(100, &data, &len);

Reference

SFXConfig::ReadBinary | SFXConfig


SFXConfig::WriteBool
Write the entry of the specified tag and the specified Bool value into this SFXConfig instance.
[ public ]
SFCError WriteBool(
    UInt16 tag   // tag
    Bool value   // value
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If insufficient memory: SFERR_NO_MEMORY

Description

This function writes the entry of the specified tag and the specified Bool value into this SFXConfig instance, which can be read with the SFXConfig::ReadBool function.

If the entry with the specified tag has already existed in this SFXConfig instance, its value will be overwritten with the specified Bool value.

Example

SFXConfig   config;
Bool        bool_0(true), bool_1(false);
Bool        bool_a, bool_b;

// load the SFXConfig instance from the configuration file
config.Load(SFXPath("config.cfg"));

// write the entry of the specified tag and the specified Bool value into the SFXConfig instance
config.WriteBool(100, bool_0);
config.WriteBool(101, bool_1);

// save the SFXConfig instance to the configuration file
config.Save();

// load the SFXConfig instance from the configuration file
config.Load(SFXPath("config.cfg"));

// read the Bool value of the entry with the specified tag from the SFXConfig instance
bool_a = config.ReadBool(100, bool_0);
bool_b = config.ReadBool(101, bool_1);

Reference

SFXConfig::ReadBool | SFXConfig


SFXConfig::WriteFloat32
Write the entry of the specified tag and the specified Float32 value into this SFXConfig instance.
[ public ]
SFCError WriteFloat32(
    UInt16 tag      // tag
    Float32 value   // value
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If insufficient memory: SFERR_NO_MEMORY

Description

This function writes the entry of the specified tag and the specified Float32 value into this SFXConfig instance, which can be read with the SFXConfig::ReadFloat32 function.

If the entry with the specified tag has already existed in this SFXConfig instance, its value will be overwritten with the specified Float32 value.

Reference

SFXConfig::ReadFloat32 | SFXConfig


SFXConfig::WriteFloat64
Write the entry of the specified tag and the specified Float64 value into this SFXConfig instance.
[ public ]
SFCError WriteFloat64(
    UInt16 tag      // tag
    Float64 value   // value
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If insufficient memory: SFERR_NO_MEMORY

Description

This function writes the entry of the specified tag and the specified Float64 value into this SFXConfig instance, which can be read with the SFXConfig::ReadFloat64 function.

If the entry with the specified tag has already existed in this SFXConfig instance, its value will be overwritten with the specified Float64 value.

Example

SFXConfig   config;
Float64     float64_0(0.12345), float64_1(0.000000), float64_2(-1.234);
Float64     float64_a, float64_b, float64_c;

// load the SFXConfig instance from the configuration file
config.Load(SFXPath("config.cfg"));

// write the entry of the specified tag and the specified Float64 value into the SFXConfig instance
config.WriteFloat64(100, float64_0);
config.WriteFloat64(101, float64_1);
config.WriteFloat64(102, float64_2);

// save the SFXConfig instance to the configuration file
config.Save();

// load the SFXConfig instance from the configuration file
config.Load(SFXPath("config.cfg"));

// read the Float64 value of the entry with the specified tag from the SFXConfig instance
float64_a = config.ReadFloat64(100, float64_0);
float64_b = config.ReadFloat64(101, float64_1);
float64_c = config.ReadFloat64(102, float64_2);

Reference

SFXConfig::ReadFloat64 | SFXConfig


SFXConfig::WriteSFXAnsiString
Write the entry of the specified tag and the specified SFXAnsiString value into this SFXConfig instance.
[ public ]
SFCError WriteSFXAnsiString(
    UInt16 tag                    // tag
    SFXAnsiStringConstRef value   // SFXAnsiString to be written
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If insufficient memory: SFERR_NO_MEMORY
  • If the length of the SFXAnsiString value to be written is greater than UINT16_MAXIMUM: SFERR_INVALID_PARAM

Description

This function writes the entry of the specified tag and the specified SFXAnsiString value into this SFXConfig instance, which can be read with the SFXConfig::ReadSFXAnsiString function.

If the entry with the specified tag has already existed in this SFXConfig instance, its value will be overwritten with the specified SFXAnsiString value.

If the specified string is empty(or the null string), the null string will be written.

Example

SFXConfig      config;
SFXAnsiString  string;

// load configuration file
config.Load(SFXPath("config.cfg"));

// write the entry of the specified tag and the specified SFXAnsiString value into the SFXConfig instance
config.WriteSFXAnsiString(100, "Config");
config.WriteSFXAnsiString(101, "Sample");
config.WriteSFXAnsiString(102, "SophiaFramework");

// save the SFXConfig instance to the configuration file
config.Save();

// load the SFXConfig instance from the configuration file
config.Load(SFXPath("config.cfg"));

// read the SFXAnsiString value of the entry with the specified tag from the SFXConfig instance
string = config.ReadSFXAnsiString(100, "Read Config");

Reference

SFXConfig::ReadSFXAnsiString | SFXAnsiString | SFXConfig


SFXConfig::WriteSFXBuffer
Write the entry of the specified tag and the specified WriteSFXBuffer value into this SFXConfig instance.
[ public ]
SFCError WriteSFXBuffer(
    UInt16 tag                // tag
    SFXBufferConstRef value   // data of SFXBuffer type
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If insufficient memory: SFERR_NO_MEMORY
  • If the length of the SFXBuffer value to be written is greater than UINT16_MAXIMUM: SFERR_INVALID_PARAM

Description

This function writes the entry of the specified tag and the specified SFXBuffer value into this SFXConfig instance, which can be read with the SFXConfig::ReadSFXBuffer function.

If the entry with the specified tag has already existed in this SFXConfig instance, its value will be overwritten with the specified SFXBuffer value.

Reference

SFXConfig::ReadSFXBuffer | SFXBuffer | SFXConfig


SFXConfig::WriteSFXWideString
Write the entry of the specified tag and the specified SFXWideString value into this SFXConfig instance.
[ public ]
SFCError WriteSFXWideString(
    UInt16 tag                    // tag
    SFXWideStringConstRef value   // SFXWideString to be written
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If insufficient memory: SFERR_NO_MEMORY
  • If the length of the SFXWideString value to be written is greater than UINT16_MAXIMUM: SFERR_INVALID_PARAM

Description

This function writes the entry of the specified tag and the specified SFXWideString value into this SFXConfig instance, which can be read with the SFXConfig::ReadSFXWideString function.

If the entry with the specified tag has already existed in this SFXConfig instance, its value will be overwritten with the specified SFXWideString value.

If the specified string is empty(or the null string), the null string will be written.

Example

SFXConfig      config;
SFXWideString  string;

// load configuration file
config.Load(SFXPath("config.cfg"));

// write the entry of the specified tag and the specified SFXWideString value into the SFXConfig instance
config.WriteSFXWideString(100, "Config");
config.WriteSFXWideString(101, "Sample");
config.WriteSFXWideString(102, "SophiaFramework");

// save the SFXConfig instance to the configuration file
config.Save();

// load the SFXConfig instance from the configuration file
config.Load(SFXPath("config.cfg"));

// read the SFXWideString value of the entry with the specified tag from the SFXConfig instance
string = config.ReadSFXWideString(100, "Read Config");

Reference

SFXConfig::ReadSFXWideString | SFXWideString | SFXConfig


SFXConfig::WriteSInt08
Write the entry of the specified tag and the specified SInt08 value into this SFXConfig instance.
[ public ]
SFCError WriteSInt08(
    UInt16 tag     // tag
    SInt08 value   // value
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If insufficient memory: SFERR_NO_MEMORY

Description

This function writes the entry of the specified tag and the specified SInt08 value into this SFXConfig instance, which can be read with the SFXConfig::ReadSInt08 function.

If the entry with the specified tag has already existed in this SFXConfig instance, its value will be overwritten with the specified SInt08 value.

Reference

SFXConfig::ReadSInt08 | SFXConfig


SFXConfig::WriteSInt16
Write the entry of the specified tag and the specified SInt16 value into this SFXConfig instance.
[ public ]
SFCError WriteSInt16(
    UInt16 tag     // tag
    SInt16 value   // value
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If insufficient memory: SFERR_NO_MEMORY

Description

This function writes the entry of the specified tag and the specified SInt16 value into this SFXConfig instance, which can be read with the SFXConfig::ReadSInt16 function.

If the entry with the specified tag has already existed in this SFXConfig instance, its value will be overwritten with the specified SInt16 value.

Reference

SFXConfig::ReadSInt16 | SFXConfig


SFXConfig::WriteSInt32
Write the entry of the specified tag and the specified SInt32 value into this SFXConfig instance.
[ public ]
SFCError WriteSInt32(
    UInt16 tag     // tag
    SInt32 value   // value
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If insufficient memory: SFERR_NO_MEMORY

Description

This function writes the entry of the specified tag and the specified SInt32 value into this SFXConfig instance, which can be read with the SFXConfig::ReadSInt32 function.

If the entry with the specified tag has already existed in this SFXConfig instance, its value will be overwritten with the specified SInt32 value.

Example

SFXConfig   config;
SInt32      i_0(10), i_1(20), i_2(30);
SInt32      i_a, i_b, i_c;

// load configuration file
config.Load(SFXPath("config.cfg"));

// write the entry of the specified tag and the specified SInt32 value into the SFXConfig instance
config.WriteSInt32(100, i_0);
config.WriteSInt32(101, i_1);
config.WriteSInt32(102, i_2);

// save the SFXConfig instance to the configuration file
config.Save();

// load the SFXConfig instance from the configuration file
config.Load(SFXPath("config.cfg"));

// read the SInt32 value of the entry with the specified tag from the SFXConfig instance
i_a = config.ReadSInt32(100, i_0);
i_b = config.ReadSInt32(101, i_1);
i_c = config.ReadSInt32(102, i_2);

Reference

SFXConfig::ReadSInt32 | SFXConfig


SFXConfig::WriteSInt64
Write the entry of the specified tag and the specified SInt64 value into this SFXConfig instance.
[ public ]
SFCError WriteSInt64(
    UInt16 tag     // tag
    SInt64 value   // value
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If insufficient memory: SFERR_NO_MEMORY

Description

This function writes the entry of the specified tag and the specified SInt64 value into this SFXConfig instance, which can be read with the SFXConfig::ReadSInt64 function.

If the entry with the specified tag has already existed in this SFXConfig instance, its value will be overwritten with the specified SInt64 value.

Reference

SFXConfig::ReadSInt64 | SFXConfig


SFXConfig::WriteUInt08
Write the entry of the specified tag and the specified UInt08 value into this SFXConfig instance.
[ public ]
SFCError WriteUInt08(
    UInt16 tag     // tag
    UInt08 value   // value
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If insufficient memory: SFERR_NO_MEMORY

Description

This function writes the entry of the specified tag and the specified UInt08 value into this SFXConfig instance, which can be read with the SFXConfig::ReadUInt08 function.

If the entry with the specified tag has already existed in this SFXConfig instance, its value will be overwritten with the specified UInt08 value.

Reference

SFXConfig::ReadUInt08 | SFXConfig


SFXConfig::WriteUInt16
Write the entry of the specified tag and the specified UInt16 value into this SFXConfig instance.
[ public ]
SFCError WriteUInt16(
    UInt16 tag     // tag
    UInt16 value   // value
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If insufficient memory: SFERR_NO_MEMORY

Description

This function writes the entry of the specified tag and the specified UInt16 value into this SFXConfig instance, which can be read with the SFXConfig::ReadUInt16 function.

If the entry with the specified tag has already existed in this SFXConfig instance, its value will be overwritten with the specified UInt16 value.

Reference

SFXConfig::ReadUInt16 | SFXConfig


SFXConfig::WriteUInt32
Write the entry of the specified tag and the specified UInt32 value into this SFXConfig instance.
[ public ]
SFCError WriteUInt32(
    UInt16 tag     // tag
    UInt32 value   // value
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If insufficient memory: SFERR_NO_MEMORY

Description

This function writes the entry of the specified tag and the specified UInt32 value into this SFXConfig instance, which can be read with the SFXConfig::ReadUInt32 function.

If the entry with the specified tag has already existed in this SFXConfig instance, its value will be overwritten with the specified UInt32 value.

Reference

SFXConfig::ReadUInt32 | SFXConfig


SFXConfig::WriteUInt64
Write the entry of the specified tag and the specified UInt64 value into this SFXConfig instance.
[ public ]
SFCError WriteUInt64(
    UInt16 tag     // tag
    UInt64 value   // value
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • If insufficient memory: SFERR_NO_MEMORY

Description

This function writes the entry of the specified tag and the specified UInt64 value into this SFXConfig instance, which can be read with the SFXConfig::ReadUInt64 function.

If the entry with the specified tag has already existed in this SFXConfig instance, its value will be overwritten with the specified UInt64 value.

Reference

SFXConfig::ReadUInt64 | SFXConfig