Poco::OSP

class Properties

File Information

Library: OSP
Package: Util
Header: Poco/OSP/Properties.h

Description

The Properties class manages a collection of key-value pairs.

Property keys are not case sensitive.

Member Summary

Member Functions: get, getBool, getFloat, getInt, getInt64, has, keys, operator =, operator [], set, swap

Nested Classes

struct ILT protected

 

Types Aliases

PropsMap protected

using PropsMap = std::map < std::string, std::string, ILT >;

Constructors

Properties

Properties();

Creates an empty Properties object.

Properties

Properties(
    const Properties & props
);

Creates a Properties object by copying another one.

Destructor

~Properties

~Properties();

Destroys the Properties object.

Member Functions

get

std::string get(
    const std::string & key
) const;

Returns the value for the given key.

Throws a Poco::NotFoundException if the given key does not exist.

get

std::string get(
    const std::string & key,
    const std::string & deflt
) const;

Returns the value for the given key, or deflt if the key does not exist.

getBool

bool getBool(
    const std::string & key
) const;

Returns the given value as a boolean. To be true, the string value must be something other than "false".

Throws a Poco::NotFoundException if the given key does not exist.

getBool

bool getBool(
    const std::string & key,
    bool deflt
) const;

Returns the given value as a boolean. To be true, the string value must be something other than "false".

Returns deflt if key does not exist.

getFloat

double getFloat(
    const std::string & key
) const;

Returns the given value as an integer.

Throws a Poco::NotFoundException if the given key does not exist and a Poco::SyntaxException if the property value is not a valid floating point number.

getFloat

double getFloat(
    const std::string & key,
    double deflt
) const;

Returns the given value as a double.

Returns deflt if key does not exist.

getInt

int getInt(
    const std::string & key
) const;

Returns the given value as an integer.

Throws a Poco::NotFoundException if the given key does not exist and a Poco::SyntaxException if the property value is not a valid integer.

getInt

int getInt(
    const std::string & key,
    int deflt
) const;

Returns the given value as an integer.

Returns deflt if key does not exist.

getInt64

Poco::Int64 getInt64(
    const std::string & key
) const;

Returns the given value as a 64-bit integer.

Throws a Poco::NotFoundException if the given key does not exist and a Poco::SyntaxException if the property value is not a valid integer.

getInt64

Poco::Int64 getInt64(
    const std::string & key,
    Poco::Int64 deflt
) const;

Returns the given value as a 64-bit integer.

Returns deflt if key does not exist.

has

bool has(
    const std::string & key
) const;

Returns true iff a property with the given key exists.

keys inline

void keys(
    std::vector < std::string > & keys
) const;

Fills the given vector with all keys.

keys

std::vector < std::string > keys() const;

Returns a vector containing all keys.

operator =

Properties & operator = (
    const Properties & props
);

Assigns another Properties object.

operator []

std::string operator[] (
    const std::string & key
) const;

Returns the value for the given key.

Throws a Poco::NotFoundException if the given key does not exist.

set

void set(
    const std::string & key,
    const std::string & value
);

Adds a new or updates an existing property.

set

void set(
    const std::string & key,
    const char * value
);

Adds a new or updates an existing property.

set

void set(
    const std::string & key,
    bool value
);

Adds a new or updates an existing property.

set

void set(
    const std::string & key,
    int value
);

Adds a new or updates an existing property.

set

void set(
    const std::string & key,
    Poco::Int64 value
);

Adds a new or updates an existing property.

set

void set(
    const std::string & key,
    double value
);

Adds a new or updates an existing property.

swap

void swap(
    Properties & props
);

Exchanges the contents of the Properties object with those from another one.

Variables

PROP_FALSE protected static

static const std::string PROP_FALSE;

PROP_TRUE protected static

static const std::string PROP_TRUE;