List of all members | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions
casadi::XmlFile Class Reference

XML parser. More...

#include <xml_file.hpp>

Detailed Description

Can be used for parsing XML files into CasADi data structures.

Author
Joel Andersson
Date
2014

Extra doc: https://github.com/casadi/casadi/wiki/L_7k

Definition at line 47 of file xml_file.hpp.

Inheritance diagram for casadi::XmlFile:
Inheritance graph
[legend]
Collaboration diagram for casadi::XmlFile:
Collaboration graph
[legend]

Public Types

using internal_base_type = SharedObjectInternal
 
using base_type = SharedObject
 

Public Member Functions

 XmlFile ()
 
 XmlFile (const std::string &name)
 
 ~XmlFile ()
 
XmlFileInternaloperator-> ()
 Access functions of the node. More...
 
const XmlFileInternaloperator-> () const
 Const access functions of the node. More...
 
XmlNode parse (const std::string &filename)
 
void dump (const std::string &filename, const XmlNode &node)
 
std::string class_name () const
 Get class name. More...
 
void disp (std::ostream &stream, bool more=false) const
 Print a description of the object. More...
 
std::string get_str (bool more=false) const
 Get string representation. More...
 
void print_ptr (std::ostream &stream=casadi::uout()) const
 
void own (SharedObjectInternal *node)
 
void assign (SharedObjectInternal *node)
 Assign the node to a node class pointer without reference counting. More...
 
SharedObjectInternalget () const
 Get a const pointer to the node. More...
 
casadi_int getCount () const
 Get the reference count. More...
 
void swap (GenericShared &other)
 Swap content with another instance. More...
 
std::string debug_repr () const
 
bool is_null () const
 Is a null pointer? More...
 
casadi_int __hash__ () const
 Returns a number that is unique for a given Node. More...
 
GenericWeakRef< SharedObject, SharedObjectInternal > * weak ()
 Get a weak reference to the object. More...
 

Static Public Member Functions

static std::string type_name ()
 Get type name. More...
 
static void load_plugin (const std::string &name)
 Load a plugin dynamically. More...
 
static std::string doc (const std::string &name)
 Get solver specific documentation. More...
 

Protected Member Functions

void count_up ()
 
void count_down ()
 

Member Typedef Documentation

◆ base_type

Definition at line 103 of file shared_object.hpp.

◆ internal_base_type

Definition at line 102 of file shared_object.hpp.

Constructor & Destructor Documentation

◆ XmlFile() [1/2]

casadi::XmlFile::XmlFile ( )

Definition at line 30 of file xml_file.cpp.

30  {
31 }

◆ XmlFile() [2/2]

casadi::XmlFile::XmlFile ( const std::string &  name)

Definition at line 33 of file xml_file.cpp.

33  {
34  own(XmlFileInternal::getPlugin(name).creator());
35 }
static Plugin & getPlugin(const std::string &pname)
Load and get the creator function.

References casadi::PluginInterface< XmlFileInternal >::getPlugin(), and casadi::GenericShared< SharedObject, SharedObjectInternal >::own().

◆ ~XmlFile()

casadi::XmlFile::~XmlFile ( )

Definition at line 37 of file xml_file.cpp.

37  {
38 }

Member Function Documentation

◆ __hash__()

casadi_int casadi::GenericShared< SharedObject , SharedObjectInternal >::__hash__
inherited

If the Object does not point to any node, "0" is returned.

Extra doc: https://github.com/casadi/casadi/wiki/L_av

Definition at line 123 of file generic_shared_impl.hpp.

141  {
142  return reinterpret_cast<casadi_int>(get());
143  }

◆ assign()

void casadi::GenericShared< SharedObject , SharedObjectInternal >::assign ( Internal *  node)
inherited

improper use will cause memory leaks!

Extra doc: https://github.com/casadi/casadi/wiki/L_at

Definition at line 96 of file generic_shared_impl.hpp.

79  {
80  node = node_;
81  }

◆ class_name()

std::string casadi::SharedObject::class_name ( ) const
inherited

◆ count_down()

void casadi::GenericShared< SharedObject , SharedObjectInternal >::count_down
protectedinherited

Definition at line 133 of file generic_shared_impl.hpp.

46  {
47 #ifdef WITH_EXTRA_CHECKS
48  casadi_assert_dev(Function::call_depth_==0);
49 #endif // WITH_EXTRA_CHECKS
50  if (!node) return;
51  if (node->weak_ref_) {
52 #ifdef CASADI_WITH_THREADSAFE_SYMBOLICS
53  auto mutex = node->weak_ref_->get_mutex();
54  // Avoid triggering a delete while a weak_ref.shared_if_alive is being called
55  std::lock_guard<std::mutex> lock(*mutex);
56  // Could it be that this mutex is destroyed when the lock goes out of scope?
57 #endif // CASADI_WITH_THREADSAFE_SYMBOLICS
58 
59  if (--static_cast<Internal*>(node)->count == 0) {
60  delete node;
61  node = nullptr;
62  }
63  } else {
64  if (--static_cast<Internal*>(node)->count == 0) {
65  delete node;
66  node = nullptr;
67  }
68  }
69  }

◆ count_up()

void casadi::GenericShared< SharedObject , SharedObjectInternal >::count_up
protectedinherited

Definition at line 132 of file generic_shared_impl.hpp.

36  {
37 #ifdef WITH_EXTRA_CHECKS
38  casadi_assert_dev(Function::call_depth_==0);
39 #endif // WITH_EXTRA_CHECKS
40 
41  if (node) static_cast<Internal*>(node)->count++;
42 
43  }

◆ debug_repr()

std::string casadi::GenericShared< SharedObject , SharedObjectInternal >::debug_repr
inherited

Definition at line 112 of file generic_shared_impl.hpp.

84  {
85  if (node) {
86  return node->debug_repr(node);
87  } else {
88  return "NULL";
89  }
90  }
std::string debug_repr(const Internal *) const

◆ disp()

void casadi::SharedObject::disp ( std::ostream &  stream,
bool  more = false 
) const
inherited

Definition at line 35 of file shared_object.cpp.

35  {
36  if (is_null()) {
37  stream << "NULL";
38  } else {
39  (*this)->disp(stream, more);
40  }
41  }

References casadi::GenericShared< SharedObject, SharedObjectInternal >::is_null().

Referenced by casadi::Nlpsol::disp_more(), and casadi::CsparseInterface::nfact().

◆ doc()

std::string casadi::XmlFile::doc ( const std::string &  name)
static

Definition at line 60 of file xml_file.cpp.

60  {
61  return XmlFileInternal::getPlugin(name).doc;
62 }

References casadi::PluginInterface< XmlFileInternal >::getPlugin().

◆ dump()

void casadi::XmlFile::dump ( const std::string &  filename,
const XmlNode node 
)

Definition at line 52 of file xml_file.cpp.

52  {
53  return (*this)->dump(filename, node);
54 }
std::string filename(const std::string &path)
Definition: ghc.cpp:55

References casadi::filename().

Referenced by casadi::DaeBuilderInternal::generate_build_description(), and casadi::DaeBuilderInternal::generate_model_description().

◆ get()

Definition at line 99 of file generic_shared_impl.hpp.

108  {
109  return node;
110  }

◆ get_str()

std::string casadi::SharedObject::get_str ( bool  more = false) const
inlineinherited

Definition at line 91 of file shared_object.hpp.

91  {
92  std::stringstream ss;
93  disp(ss, more);
94  return ss.str();
95  }
void disp(std::ostream &stream, bool more=false) const
Print a description of the object.

◆ getCount()

casadi_int casadi::GenericShared< SharedObject , SharedObjectInternal >::getCount
inherited

Definition at line 102 of file generic_shared_impl.hpp.

131  {
132  return (*this)->getCount();
133  }

◆ is_null()

Definition at line 116 of file generic_shared_impl.hpp.

113  {
114  return node==nullptr;
115  }

◆ load_plugin()

void casadi::XmlFile::load_plugin ( const std::string &  name)
static

Definition at line 56 of file xml_file.cpp.

56  {
58 }
static Plugin load_plugin(const std::string &pname, bool register_plugin=true, bool needs_lock=true)
Load a plugin dynamically.

References casadi::PluginInterface< XmlFileInternal >::load_plugin().

◆ operator->() [1/2]

XmlFileInternal * casadi::XmlFile::operator-> ( )

Extra doc: https://github.com/casadi/casadi/wiki/L_7m

Definition at line 44 of file xml_file.cpp.

44  {
45  return static_cast<XmlFileInternal*>(SharedObject::operator->());
46 }
SharedObjectInternal * operator->() const
Access a member function or object.

References casadi::GenericShared< SharedObject, SharedObjectInternal >::operator->().

◆ operator->() [2/2]

const XmlFileInternal * casadi::XmlFile::operator-> ( ) const

Extra doc: https://github.com/casadi/casadi/wiki/L_7n

Definition at line 40 of file xml_file.cpp.

40  {
41  return static_cast<const XmlFileInternal*>(SharedObject::operator->());
42 }

References casadi::GenericShared< SharedObject, SharedObjectInternal >::operator->().

◆ own()

void casadi::GenericShared< SharedObject , SharedObjectInternal >::own ( Internal *  node)
inherited

Assign the node to a node class pointer (or null)

Definition at line 89 of file generic_shared_impl.hpp.

◆ parse()

XmlNode casadi::XmlFile::parse ( const std::string &  filename)

Definition at line 48 of file xml_file.cpp.

48  {
49  return (*this)->parse(filename);
50 }

References casadi::filename().

Referenced by casadi::DaeBuilderInternal::load_fmi_description().

◆ print_ptr()

void casadi::SharedObject::print_ptr ( std::ostream &  stream = casadi::uout()) const
inherited

Print the pointer to the internal class

Definition at line 43 of file shared_object.cpp.

43  {
44  stream << get();
45  }
SharedObjectInternal * get() const
Get a const pointer to the node.

References casadi::GenericShared< SharedObject, SharedObjectInternal >::get().

◆ swap()

Definition at line 105 of file generic_shared_impl.hpp.

124  {
125  GenericShared<Shared, Internal> temp = *this;
126  *this = other;
127  other = temp;
128  }

◆ type_name()

static std::string casadi::XmlFile::type_name ( )
inlinestatic

Extra doc: https://github.com/casadi/casadi/wiki/L_7l

Definition at line 54 of file xml_file.hpp.

54 {return "XmlFile";}

◆ weak()

Extra doc: https://github.com/casadi/casadi/wiki/L_aw

Definition at line 130 of file generic_shared_impl.hpp.

136  {
137  return (*this)->weak();
138  }

The documentation for this class was generated from the following files: