src/common/libfactory.cpp
std::string LibFactory::getPathFromDescription(
    const std::string& id,
    const std::string& fname) const
{
    std::string res = "";
    // process only files with .xml extension
    if (base::Utils::getFileExt(fname) != "xml")
    {
        // nothing to do
        return res;
    }
    try
    {
        XML xml;
        xml.parseFromFile(fname);
        std::string xpath_id = "/klkdata/module/id";
        if (xml.getValue(xpath_id) == id)
        {
            std::string xpath_lib = "/klkdata/module/lib_path";
            // found it
            res = xml.getValue(xpath_lib);
        }
    }
    catch(const std::exception& err)
    {
        // ignore errors
        klk_log(KLKLOG_ERROR, "Got an error while processing '%s': %s",
                fname.c_str(), err.what());
    }

    return res;
}
// Gets module's path by its id from a modules description
// @param[in] id the module's id
// @param[in] fname - the file name for test
// @return the pointer to a module or NULL if there was an error
// @note - there is an internal method that does not do any locks
Gets module's path by its id from a modules description
Gets module ' s path by its id from a modules description
std::string LibFactory::getPathFromDescription(
    const std::string& id,
    const std::string& fname) const
{
    std::string res = "";
    if (base::Utils::getFileExt(fname) != "xml")
    {
        return res;
    }
    try
    {
        XML xml;
        xml.parseFromFile(fname);
        std::string xpath_id = "/klkdata/module/id";
        if (xml.getValue(xpath_id) == id)
        {
            std::string xpath_lib = "/klkdata/module/lib_path";
            res = xml.getValue(xpath_lib);
        }
    }
    catch(const std::exception& err)
    {
        klk_log(KLKLOG_ERROR, "Got an error while processing '%s': %s",
                fname.c_str(), err.what());
    }
    return res;
}
std :: string LibFactory :: getPathFromDescription ( const std :: string & id , const std :: string & fname ) const { std :: string res = " " ; if ( base :: Utils :: getFileExt ( fname ) != " " ) { return res ; } try { XML xml ; xml . parseFromFile ( fname ) ; std :: string xpath_id = " " ; if ( xml . getValue ( xpath_id ) == id ) { std :: string xpath_lib = " " ; res = xml . getValue ( xpath_lib ) ; } } catch ( const std :: exception & err ) { klk_log ( KLKLOG_ERROR , " " , fname . c_str ( ) , err . what ( ) ) ; } return res ; }
Gets module's path by its id from a modules description
Gets module ' s path by its id from a modules description
// process only files with .xml extension // nothing to do // found it // ignore errors