Changeset 80:4ff097a063d4 in finroc_plugins_parameters


Ignore:
Timestamp:
15.04.2019 18:48:36 (5 months ago)
Author:
Max Reichardt <max.reichardt@…>
Branch:
17.03
Parents:
79:22aeba8ea3c7 (diff), 66:3700e332142e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Phase:
public
Tags:
tip
Message:

Merge with changes from finroc.org

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • tConfigFile.cpp

    r66 r80  
    222222  } 
    223223} 
     224 
     225std::vector<std::string> tConfigFile::GetChildrenNames(const std::string &entry) 
     226{ 
     227  std::vector<rrlib::xml::tNode *> nodes; 
     228  this->GetEntryImplementation(nodes, entry, wrapped.RootNode(), 0); 
     229  if (nodes.size() > 1) 
     230  { 
     231    FINROC_LOG_PRINT(WARNING, "There are ", nodes.size(), " entries in config file with the qualified name '", entry, "'. Using the first one."); 
     232  } 
     233 
     234  if (nodes.size() == 0) 
     235  { 
     236    throw std::runtime_error("Config node not found: " + entry); 
     237  } 
     238  if (nodes[0]->Name() == cXML_LEAF_NAME) 
     239  { 
     240    throw std::runtime_error("Config node is a leaf: " + entry); 
     241  } 
     242 
     243  std::vector<std::string> result; 
     244  for (auto it = nodes.front()->ChildrenBegin(); it != nodes.front()->ChildrenEnd(); ++it) 
     245  { 
     246    result.push_back(it->GetStringAttribute("name")); 
     247  } 
     248  return result; 
     249} 
     250 
    224251 
    225252void tConfigFile::GetEntryImplementation(std::vector<rrlib::xml::tNode*>& result, const std::string& entry, rrlib::xml::tNode& node, size_t entry_string_index) 
  • tConfigFile.cpp

    r78 r80  
    7878 
    7979/*! Initializes annotation type so that it can be transferred to finstruct */ 
     80__attribute__((unused)) 
    8081static rrlib::rtti::tDataType<tConfigFile> cTYPE; 
    8182 
     
    211212    std::string name = result[0]->GetStringAttribute("name"); 
    212213    tXMLNode& parent = result[0]->Parent(); 
     214    tXMLNode& new_node = result[0]->AddNextSibling(cXML_LEAF_NAME); 
     215    new_node.SetAttribute("name", name); 
    213216    parent.RemoveChildNode(*result[0]); 
    214     tXMLNode& new_node = parent.AddChildNode(cXML_LEAF_NAME); 
    215     new_node.SetAttribute("name", name); 
    216217    return new_node; 
    217218  } 
     
    364365} 
    365366 
     367void tConfigFile::Reload() 
     368{ 
     369  if (core::FinrocFileExists(filename)) 
     370  { 
     371    try 
     372    { 
     373      wrapped = core::GetFinrocXMLDocument(filename, false); // false = do not validate with dtd 
     374      return; 
     375    } 
     376    catch (const std::exception& e) 
     377    { 
     378      FINROC_LOG_PRINT(ERROR, e); 
     379    } 
     380  } 
     381} 
     382 
    366383void tConfigFile::SaveFile(const std::string& new_filename) 
    367384{ 
  • tConfigFile.h

    r64 r80  
    116116  rrlib::xml::tNode& GetEntry(const std::string& entry, bool create = false); 
    117117 
     118  /*! 
     119   * Get children of configuration file node 
     120   * 
     121   * \param entry Entry 
     122   * \return list of node names directly below entry 
     123   */ 
     124  std::vector<std::string> GetChildrenNames(const std::string &entry); 
    118125 
    119126  /*! 
  • tConfigFile.h

    r78 r80  
    184184 
    185185  /*! 
     186   * Reloads config file 
     187   */ 
     188  void Reload(); 
     189 
     190  /*! 
    186191   * Saves configuration file back to HDD 
    187192   * 
Note: See TracChangeset for help on using the changeset viewer.