Skip to main content

DPF Cpp Client Library 2026 R1

Class ansys::dpf::DataTree

Last update: 25.03.2026

Define a DOM (Document-Object-Model) tree.

Inherits from:

Members

Friends

Public functions

Function DataTree

ansys::dpf::DataTree::DataTree()

Return type:

Function DataTree

ansys::dpf::DataTree::DataTree(Client const *const client)

Parameters:

  • Client const *const client: [in] Client instance designating the IP, port and protocol to use.

Return type:

Function ~DataTree

ansys::dpf::DataTree::~DataTree()

Return type:

Function DataTree

ansys::dpf::DataTree::DataTree(DataTree const &)

Parameters:

  • DataTree const &

Return type:

Function DataTree

ansys::dpf::DataTree::DataTree(DataTree &&) noexcept

Parameters:

  • DataTree &&

Return type:

Function operator=

DataTree & ansys::dpf::DataTree::operator=(DataTree const &)

Parameters:

  • DataTree const &

Return type: DataTree &

Function operator=

DataTree & ansys::dpf::DataTree::operator=(DataTree &&) noexcept

Parameters:

  • DataTree &&

Return type: DataTree &

Function fillFromJson

void ansys::dpf::DataTree::fillFromJson(std::istream const &stream) const

Fill this data tree with the content of a json file generated by another tree (See DataTree::writeToJson).

Parameters:

  • std::istream const & stream

Return type: void

Function fillFromTxt

void ansys::dpf::DataTree::fillFromTxt(std::istream const &stream) const

Fill this data tree with the content of a txt file generated by another tree (See DataTree::writeToTxt).

Parameters:

  • std::istream const & stream

Return type: void

Function writeToTxt

void ansys::dpf::DataTree::writeToTxt(std::ostream &stream) const

Write the attributes and the subtrees of this data tree as text in a c++ standard output stream (example: std::ofstream, std::ostringstream).

Parameters:

  • std::ostream & stream

Return type: void

Function writeToJson

void ansys::dpf::DataTree::writeToJson(std::ostream &stream) const

Write the attributes and the subtrees of this data tree in a json like format in a c++ standard output stream (example: std::ofstream, std::ostringstream).

Parameters:

  • std::ostream & stream

Return type: void

Function getAvailableAttributeNames

std::vector< std::string > ansys::dpf::DataTree::getAvailableAttributeNames() const

Returns:

the list of attributes names available (without recursivity in the subtrees).

Return type: std::vector< std::string >

Function getAvailableSubTreeNames

std::vector< std::string > ansys::dpf::DataTree::getAvailableSubTreeNames() const

Returns:

the list of first rank substree names available (without recursivity in the subtrees).

Return type: std::vector< std::string >

Function getSubByName

const DataTree ansys::dpf::DataTree::getSubByName(std::string const &name) const

Returns:

a subtree by its name (return an empty substree if it doesn't exist).

Parameters:

  • std::string const & name

Return type: const DataTree

Function getIntAttribute

int ansys::dpf::DataTree::getIntAttribute(std::string const &name, int default_value=0) const

Returns:

an attribute by its name.

Parameters:

  • Name: of the attribute.
  • Default: value of the attribute. @information: if the attribute doesn't exist, the default value is returned.

Parameters:

  • std::string const & name
  • int default_value = 0

Return type: int

Function tryGetIntAttribute

bool ansys::dpf::DataTree::tryGetIntAttribute(std::string const &name, int &value) const

Get an attribute by its name.

Available since Ansys 2025R2. Parameters:

  • Name: of the attribute.
  • Output: value of the attribute.

Returns:

true if the attribute exists, false otherwise.

Parameters:

  • std::string const & name
  • int & value

Return type: bool

Function getBoolAttribute

bool ansys::dpf::DataTree::getBoolAttribute(std::string const &name, bool default_value=false) const

Returns:

an attribute by its name.

Parameters:

  • Name: of the attribute.
  • Default: value of the attribute. @information: if the attribute doesn't exist, the default value is returned.

Parameters:

  • std::string const & name
  • bool default_value = false

Return type: bool

Function tryGetBoolAttribute

bool ansys::dpf::DataTree::tryGetBoolAttribute(std::string const &name, bool &value) const

Get an attribute by its name.

Available since Ansys 2025R2. Parameters:

  • Name: of the attribute.
  • Output: value of the attribute.

Returns:

true if the attribute exists, false otherwise.

Parameters:

  • std::string const & name
  • bool & value

Return type: bool

Function getUnsignedIntAttribute

unsigned int ansys::dpf::DataTree::getUnsignedIntAttribute(std::string const &name, unsigned int default_value=0) const

Returns:

an attribute by its name.

Parameters:

  • Name: of the attribute.
  • Default: value of the attribute. @information: if the attribute doesn't exist, the default value is returned.

Parameters:

  • std::string const & name
  • unsigned int default_value = 0

Return type: unsigned int

Function tryGetUnsignedIntAttribute

bool ansys::dpf::DataTree::tryGetUnsignedIntAttribute(std::string const &name, unsigned int &value) const

Returns:

an attribute by its name.

Available since Ansys 2025R2. Parameters:

  • Name: of the attribute.
  • Output: value of the attribute.

Returns:

true if the attribute exists, false otherwise.

Parameters:

  • std::string const & name
  • unsigned int & value

Return type: bool

Function getDoubleAttribute

double ansys::dpf::DataTree::getDoubleAttribute(std::string const &name, double default_value=0.0) const

Returns:

an attribute by its name.

Parameters:

  • Name: of the attribute.
  • Default: value of the attribute. @information: if the attribute doesn't exist, the default value is returned.

Parameters:

  • std::string const & name
  • double default_value = 0.0

Return type: double

Function tryGetDoubleAttribute

bool ansys::dpf::DataTree::tryGetDoubleAttribute(std::string const &name, double &value) const

Returns:

an attribute by its name.

Available since Ansys 2025R2. Parameters:

  • Name: of the attribute.
  • Output: value of the attribute.

Returns:

true if the attribute exists, false otherwise.

Parameters:

  • std::string const & name
  • double & value

Return type: bool

Function getStringAttribute

std::string ansys::dpf::DataTree::getStringAttribute(std::string const &name, std::string="") const

Returns:

an attribute by its name.

Parameters:

  • Name: of the attribute.
  • Default: value of the attribute. @information: if the attribute doesn't exist, the default value is returned.

Parameters:

  • std::string const & name
  • std::string = ""

Return type: std::string

Function tryGetStringAttribute

bool ansys::dpf::DataTree::tryGetStringAttribute(std::string const &name, std::string &value) const

Returns:

an attribute by its name.

Available since Ansys 2025R2. Parameters:

  • Name: of the attribute.
  • Output: value of the attribute.

Returns:

true if the attribute exists, false otherwise.

Parameters:

  • std::string const & name
  • std::string & value

Return type: bool

Function getVectIntAttribute

std::vector< int > ansys::dpf::DataTree::getVectIntAttribute(std::string const &name, std::vector< int > default_value={}) const

Returns:

an attribute by its name

Parameters:

  • Name: of the attribute.
  • Default: value of the attribute. @information: if the attribute doesn't exist, the default value is returned.

Parameters:

  • std::string const & name
  • std::vector< int > default_value = {}

Return type: std::vector< int >

Function tryGetVectIntAttribute

bool ansys::dpf::DataTree::tryGetVectIntAttribute(std::string const &name, std::vector< int > &value) const

Returns:

an attribute by its name.

Available since Ansys 2025R2. Parameters:

  • Name: of the attribute.
  • Output: value of the attribute.

Returns:

true if the attribute exists, false otherwise.

Parameters:

  • std::string const & name
  • std::vector< int > & value

Return type: bool

Function getVectDoubleAttribute

std::vector< double > ansys::dpf::DataTree::getVectDoubleAttribute(std::string const &name, std::vector< double > default_value={}) const

Returns:

an attribute by its name.

Parameters:

  • Name: of the attribute.
  • Default: value of the attribute. @information: if the attribute doesn't exist, the default value is returned.

Parameters:

  • std::string const & name
  • std::vector< double > default_value = {}

Return type: std::vector< double >

Function tryGetVectDoubleAttribute

bool ansys::dpf::DataTree::tryGetVectDoubleAttribute(std::string const &name, std::vector< double > &value) const

Returns:

an attribute by its name.

Available since Ansys 2025R2. Parameters:

  • Name: of the attribute.
  • Output: value of the attribute.

Returns:

true if the attribute exists, false otherwise.

Parameters:

  • std::string const & name
  • std::vector< double > & value

Return type: bool

Function getVectStringAttribute

std::vector< std::string > ansys::dpf::DataTree::getVectStringAttribute(std::string const &name, std::vector< std::string > default_value={}) const

Returns:

an attribute by its name.

Parameters:

  • Name: of the attribute.
  • Default: value of the attribute. @information: if the attribute doesn't exist, the default value is returned.

Parameters:

  • std::string const & name
  • std::vector< std::string > default_value = {}

Return type: std::vector< std::string >

Function tryGetVectStringAttribute

bool ansys::dpf::DataTree::tryGetVectStringAttribute(std::string const &name, std::vector< std::string > &value) const

Returns:

an attribute by its name.

Available since Ansys 2025R2. Parameters:

  • Name: of the attribute.
  • Output: value of the attribute.

Returns:

true if the attribute exists, false otherwise.

Parameters:

  • std::string const & name
  • std::vector< std::string > & value

Return type: bool

Function makeIntAttribute

void ansys::dpf::DataTree::makeIntAttribute(std::string const &name, int value)

create or replace an attribute.

Parameters:

  • std::string const & name
  • int value

Return type: void

Function makeBoolAttribute

void ansys::dpf::DataTree::makeBoolAttribute(std::string const &name, bool value)

create or replace an attribute.

Parameters:

  • std::string const & name
  • bool value

Return type: void

Function makeUnsignedIntAttribute

void ansys::dpf::DataTree::makeUnsignedIntAttribute(std::string const &name, unsigned int value)

create or replace an attribute.

Parameters:

  • std::string const & name
  • unsigned int value

Return type: void

Function makeDoubleAttribute

void ansys::dpf::DataTree::makeDoubleAttribute(std::string const &name, double value)

create or replace an attribute.

Parameters:

  • std::string const & name
  • double value

Return type: void

Function makeStringAttribute

void ansys::dpf::DataTree::makeStringAttribute(std::string const &name, std::string const &value)

create or replace an attribute.

Parameters:

  • std::string const & name
  • std::string const & value

Return type: void

Function makeVectIntAttribute

void ansys::dpf::DataTree::makeVectIntAttribute(std::string const &name, std::vector< int > const &value)

create or replace an attribute.

Parameters:

  • std::string const & name
  • std::vector< int > const & value

Return type: void

Function makeVectDoubleAttribute

void ansys::dpf::DataTree::makeVectDoubleAttribute(std::string const &name, std::vector< double > const &value)

create or replace an attribute.

Parameters:

  • std::string const & name
  • std::vector< double > const & value

Return type: void

Function makeVectStringAttribute

void ansys::dpf::DataTree::makeVectStringAttribute(std::string const &name, std::vector< std::string > const &value)

create or replace an attribute.

Parameters:

  • std::string const & name
  • std::vector< std::string > const & value

Return type: void

Function makeSub

DataTree ansys::dpf::DataTree::makeSub(std::string const &name)

create a subtree with a name. If the substree already exists, it is returned. Returns:

the created subtree to fill it.

Parameters:

  • std::string const & name

Return type: DataTree

Function makeSubTreeAttribute

void ansys::dpf::DataTree::makeSubTreeAttribute(std::string const &name, DataTree const *const sub_tree)

Parameters:

  • std::string const & name
  • DataTree const *const sub_tree

Return type: void

Function hasAttribute

bool ansys::dpf::DataTree::hasAttribute(std::string const &attribute_name) const

Returns:

true if an attribute exists (accepts sub attributes by adding "/", example attribute_name="sub_name/attrib_name").

Parameters:

  • std::string const & attribute_name

Return type: bool

Function hasSub

bool ansys::dpf::DataTree::hasSub(std::string const &attribute_name) const

Returns:

true if a subtree exists.

Parameters:

  • std::string const & attribute_name

Return type: bool

Function deep_copy

DataTree ansys::dpf::DataTree::deep_copy(ansys::dpf::Client const *const client=nullptr) const

Make a deep copy on a given client.

Parameters:

Return type: DataTree

Public static functions

Function emptyDataTree

static DataTree ansys::dpf::DataTree::emptyDataTree()

Create an empty DataTree. Returns:

Empty DataTree.

Return type: DataTree

Connect with Ansys