Changeset 174


Ignore:
Timestamp:
Feb 14, 2006 11:07:53 PM (18 years ago)
Author:
dkearney
Message:
  1. changed the output of get(...) so that it returns an empty string if the

requested path does not exist but node is available.
ie. lib->get(input.number(max))

  1. changed get to call getString instead of copying the code from getString
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/RpLibrary.cc

    r135 r174  
    588588RpLibrary::get (std::string path)
    589589{
     590    return (this->getString(path));
     591}
     592
     593/**********************************************************************/
     594// METHOD: getString()
     595/// Return the string value of the object held at location 'path'
     596/**
     597 */
     598
     599std::string
     600RpLibrary::getString (std::string path)
     601{
    590602    scew_element* retNode = _find(path,0);
     603    XML_Char const* retCStr = NULL;
    591604
    592605    if (retNode == NULL) {
    593606        // need to raise error
    594         return "";
    595     }
    596 
    597     return std::string(scew_element_contents(retNode));
    598 }
    599 
    600 /**********************************************************************/
    601 // METHOD: getString()
    602 /// Return the string value of the object held at location 'path'
    603 /**
    604  */
    605 
    606 std::string
    607 RpLibrary::getString (std::string path)
    608 {
    609     scew_element* retNode = _find(path,0);
    610 
    611     if (retNode == NULL) {
    612         // need to raise error
    613         return "";
    614     }
    615 
    616     return std::string(scew_element_contents(retNode));
     607        return std::string("");
     608    }
     609
     610    retCStr = scew_element_contents(retNode);
     611
     612    if (!retCStr) {
     613        return std::string("");
     614    }
     615
     616    return std::string(retCStr);
    617617}
    618618
Note: See TracChangeset for help on using the changeset viewer.