This forum has been archived. Please start a new discussion on GitHub.

How to load empty properties?

Ice v.3.1.0, C++.

I use Ice Properties facility to configure my own application. I was trying to use the feature of setting a property to an empty string in order to unset any previously loaded value. Internally Ice does it for files specified with --Ice.Config (Sec. 28.3)

It seems that either Properties::load() or Properties::getCommandLineOptions() strips the empty properties. For example, i have this config file:
# Example config file for Ice
Ice.MessageSizeMax = 2048 # Largest message size is 2MB
Ice.Trace.Network=3 # Highest level of tracing for network
Ice.Trace.Protocol= # Disable protocol tracing

I load it like this:
Ice::PropertiesPtr p = Ice::createProperties();
p->load( filename );
Ice::StringSeq propSeq = p->getCommandLineOptions();
cout<<"loaded "<<propSeq.size()<<" properties"<<endl;
for ( unsigned int i=0; i<propSeq.size(); ++i ) {

and get this output:
loaded 2 properties

So now I cannot tell if Ice.Trace.Protocol was specified in the file. Of course, the result is the same if I use getProperty() on THIS properties set, but if I want to override some "global" config setting then I cannot do it.

Is this the expected behaviour? Would it make sense to preserve all specified properties?

Thanks, Alex


  • bernard
    bernard Jupiter, FL
    Hi Alex,

    That's the expected behavior. "Setting" a property to the empty string means unsetting this property if it is already set.

    Usually, this means resetting the property to its default behavior. From the Ice manual:

    "If not stated otherwise in the description of the individual properties, the default value for all properties is the empty string. If the property takes a numeric value, the empty string is interpreted as zero."