company logo

TypeDefinition :: propertyExist - Check property path

The function checks, whether the property path is valid for the complex data type. Properties are searched in the current data type. In order to search properties in referenced data types, too, a dictionary has to be passed in addition. Otherwise, only base types are included.

Since functions as property() or propertyDefinition() throw an exception, when the requested property does not exist, this function might be called before opening subordinated property handles in order to avoid exceptions.

The function does not look for extension properties. In order to check the existence of an extension property, Database::extensionExist() might be called.

// fragment: Property   person

  TypeDefinition    td = person.currentTypeDef();

  

// search in complex data type

  if ( td.propertyExist("children") )

    getIncome(person.property("children");

    

// search in complex data type and references

// property path might contain selectors, which will be ignored

  Dictionary      dict = person.dictionary();

  if ( td.propertyExist(dict,"children(0).parents(0).address") )

    output(person.value("children(0).parents(0).address"));

Return value:  Success ( bool  )

The value is true when the function was executed successfully. Otherwise the value is set to false.

Implementation overview

Implementation details

  1. Search property in complex data type
    bool TypeDefinition  :: propertyExist ( odaba::String &vAccessPath )

    The function checks, whether the property path passed in vAccessPath is a property defined in the complex data type. Properties in the complex data type and its base types are searched for.

    // fails because children.name is not a property of person  

      td.existsProperty("children.name");

    • vAccessPath - Access path

      An access path may simply refer to an extent or property, but also to a calculated result. Thus, an access path may contain just a name, but also a sequence of path elements separated by '.' in order to refer to far properties or complex operations.

      The access path may start with two dots (.), which indicates, that the path starts in an upper property handle. One dot indicates, that the path starts in the current property handle. This distinction becomes necessary, when a property has the same name as an extent. To access a property in this case, one dot must precede the property name. The first dot can be omitted, when the property name is not an extent name.

      Forcing to a path to start in a parent property handle requires two dots (..), the parents parent three and so on.

      In order to pass no access path, an empty string ( String() ) has to be passed.

      address.street      // property path

      .address.street     // property path

      ..address.street    // address in parent property instance

      children(0).Age()   // operation path

      Person().children() // path property

      children('Anton')   // path property

  2. to list
  3. Search property in complex data type and references
    bool TypeDefinition  :: propertyExist ( odaba::Dictionary &cDictionary, odaba::String &vAccessPath )

    The function checks, whether the property path passed in vAccessPath is valid for the complex data type. The function also searches for properties in referenced data types.

    // succeeds because name is searched in the children reference

      td.existsProperty(dictionary,"children.name");

    • cDictionary - Dictionary handle

      The dictionary handle usually refers to an opened dictionary. Calling functions with invalid dictionary handles may cause an exception. For checking the dictionary handle, isValid() can be called.

    • vAccessPath - Access path

      An access path may simply refer to an extent or property, but also to a calculated result. Thus, an access path may contain just a name, but also a sequence of path elements separated by '.' in order to refer to far properties or complex operations.

      The access path may start with two dots (.), which indicates, that the path starts in an upper property handle. One dot indicates, that the path starts in the current property handle. This distinction becomes necessary, when a property has the same name as an extent. To access a property in this case, one dot must precede the property name. The first dot can be omitted, when the property name is not an extent name.

      Forcing to a path to start in a parent property handle requires two dots (..), the parents parent three and so on.

      In order to pass no access path, an empty string ( String() ) has to be passed.

      address.street      // property path

      .address.street     // property path

      ..address.street    // address in parent property instance

      children(0).Age()   // operation path

      Person().children() // path property

      children('Anton')   // path property

  4. to list