Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
externl committed Nov 15, 2024
1 parent c344270 commit 418ea56
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 16 deletions.
15 changes: 7 additions & 8 deletions cpp/include/Ice/Properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,30 +82,29 @@ namespace Ice
std::string getPropertyWithDefault(std::string_view key, std::string_view value) noexcept;

/**
* Get a property as an integer. If the property is not set, 0 is returned. Throws PropertyException if
* the property value is not a valid integer.
* Get a property as an integer. If the property is not set, 0 is returned.
* @param key The property key.
* @return The property value interpreted as an integer.
* @throws PropertyException If the property value is not a valid integer.
* @see #setProperty
*/
int getPropertyAsInt(std::string_view key);

/**
* Get an Ice property as an integer. If the property is not set, its default value is returned. Throws
* PropertyException if the property value is not a valid integer.
* Get an Ice property as an integer. If the property is not set, its default value is returned.
* @param key The property key.
* @return The property value interpreted as an integer, or the default value.
* @throws std::invalid_argument If the property is not a known Ice property.
* @throws PropertyException If the property is not a known Ice property or the value is not a valid integer.
* @see #setProperty
*/
int getIcePropertyAsInt(std::string_view key);

/**
* Get a property as an integer. If the property is not set, the given default value is returned. Throws
* PropertyException if the property value is not a valid integer.
* Get a property as an integer. If the property is not set, the given default value is returned.
* @param key The property key.
* @param value The default value to use if the property does not exist.
* @return The property value interpreted as an integer, or the default value.
* @throws PropertyException If the property value is not a valid integer.
* @see #setProperty
*/
int getPropertyAsIntWithDefault(std::string_view key, int value);
Expand All @@ -130,7 +129,7 @@ namespace Ice
* can be written as O'Reilly, "O'Reilly" or 'O\'Reilly'.
* @param key The property key.
* @return The property value interpreted as list of strings, or the default value.
* @throws std::invalid_argument If the property is not a known Ice property.
* @throws PropertyException If the property is not a known Ice property.
* @see #setProperty
*/
StringSeq getIcePropertyAsList(std::string_view key);
Expand Down
4 changes: 2 additions & 2 deletions csharp/src/Ice/Properties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ public string getPropertyWithDefault(string key, string value)

/// <summary>
/// Get an Ice property as an integer.
/// If the property is not set, its default value is returned. Throws PropertyException if the property
/// value is not a valid integer.
/// If the property is not set, its default value is returned. Throws PropertyException if the property is not a
/// known Ice property or the value is not a valid integer.
/// </summary>
/// <param name="key">The property key.</param>
/// <returns>The property value interpreted as an integer, or the default value.</returns>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ public int getPropertyAsInt(String key) {
*
* @param key The property key.
* @return The property value interpreted as an integer, or the default value.
* @throws PropertyException Raised if the property value is not a valid integer.
* @throws PropertyException Raised if the property is not a known Ice property or the value is
* not a valid integer.
* @see #setProperty
*/
public synchronized int getIcePropertyAsInt(String key) {
Expand Down
6 changes: 3 additions & 3 deletions php/test/Ice/properties/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ function run($args)
echo "ok\n";

echo "testing load properties exception... ";
$properties = Ice\createProperties();
try {
$properties = Ice\createProperties();
$properties->load("./config/xxxx.config");
test(False);
} catch (\Ice\LocalException $ex) {
Expand All @@ -62,8 +62,8 @@ function run($args)
echo "ok\n";

echo "testing that getting an unknown ice property throws an exception... ";
$properties = Ice\createProperties();
try {
$properties = Ice\createProperties();
$properties->getIceProperty("Ice.UnknownProperty");
test(False);
} catch (\Ice\PropertyException $ex) {
Expand All @@ -72,8 +72,8 @@ function run($args)
echo "ok\n";

echo "testing that trying to read a non-numeric value as an int throws... ";
$properties = Ice\createProperties();
try {
$properties = Ice\createProperties();
$properties->setProperty("Foo", "bar");
$properties->getPropertyAsInt("Foo");
test(False);
Expand Down
4 changes: 2 additions & 2 deletions ruby/test/Ice/properties/Client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ def run(args)
puts "ok"

print "testing that getting an unknown ice property throws an exception..."
properties = Ice.createProperties(args)
begin
properties = Ice.createProperties(args)
properties.getIceProperty("Ice.UnknownProperty")
test(false)
rescue Ice::PropertyException => ex
Expand All @@ -102,8 +102,8 @@ def run(args)
puts "ok"

print "testing that trying to read a non-numeric value as an int throws... "
properties = Ice.createProperties(args)
begin
properties = Ice.createProperties(args)
properties.setProperty("Foo", "bar")
properties.getPropertyAsInt("Foo")
test(false)
Expand Down
3 changes: 3 additions & 0 deletions swift/src/Ice/Properties.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,23 @@ public protocol Properties: AnyObject {
func getPropertyWithDefault(key: String, value: String) -> String

/// Get a property as an integer. If the property is not set, 0 is returned.
/// Throws PropertyException if the property value is not a valid integer.
///
/// - parameter _: `String` The property key.
///
/// - returns: `Int32` - The property value interpreted as an integer.
func getPropertyAsInt(_ key: String) throws -> Int32

/// Get an Ice property as an integer. If the property is not set,its default value is returned.
/// Throws PropertyException if the property value is not a valid integer.
///
/// - parameter key: `String` The property key.
///
/// - returns: `Int32` - The property value interpreted as an integer, or the default value.
func getIcePropertyAsInt(_ key: String) throws -> Int32

/// Get a property as an integer. If the property is not set, the given default value is returned.
/// Throws PropertyException if the property value is not a valid integer.
///
/// - parameter key: `String` The property key.
///
Expand Down

0 comments on commit 418ea56

Please sign in to comment.