[mlpack-svn] r10854 - mlpack/trunk/src/mlpack/core/util
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Fri Dec 16 09:43:06 EST 2011
Author: rcurtin
Date: 2011-12-16 09:43:05 -0500 (Fri, 16 Dec 2011)
New Revision: 10854
Modified:
mlpack/trunk/src/mlpack/core/util/save_restore_utility.cpp
mlpack/trunk/src/mlpack/core/util/save_restore_utility.hpp
mlpack/trunk/src/mlpack/core/util/save_restore_utility_impl.hpp
Log:
Clarify error messages, and actually assign the parameter to what is read for a
few cases. Use std::string& not std::string for LoadParameter().
Modified: mlpack/trunk/src/mlpack/core/util/save_restore_utility.cpp
===================================================================
--- mlpack/trunk/src/mlpack/core/util/save_restore_utility.cpp 2011-12-16 14:33:20 UTC (rev 10853)
+++ mlpack/trunk/src/mlpack/core/util/save_restore_utility.cpp 2011-12-16 14:43:05 UTC (rev 10854)
@@ -15,8 +15,9 @@
xmlDocPtr xmlDocTree = NULL;
if (NULL == (xmlDocTree = xmlReadFile(filename.c_str(), NULL, 0)))
{
- Log::Fatal << "Clearly, we couldn't load the XML file\n";
+ Log::Fatal << "Could not load XML file '" << filename << "'!" << std::endl;
}
+
xmlNodePtr root = xmlDocGetRootElement(xmlDocTree);
parameters.clear();
@@ -119,22 +120,22 @@
}
else
{
- Log::Fatal << "Missing the correct name\n";
+ Log::Fatal << "LoadParameter(): node '" << name << "' not found.\n";
}
return matrix;
}
-std::string SaveRestoreUtility::LoadParameter(std::string str,
+std::string SaveRestoreUtility::LoadParameter(std::string& str,
const std::string name)
{
std::map<std::string, std::string>::iterator it = parameters.find(name);
if (it != parameters.end())
{
- return (*it).second;
+ return str = (*it).second;
}
else
{
- Log::Fatal << "Missing the correct name\n";
+ Log::Fatal << "LoadParameter(): node '" << name << "' not found.\n";
}
return "";
}
@@ -148,11 +149,11 @@
std::string value = (*it).second;
std::istringstream input (value);
input >> temp;
- return (char) temp;
+ return c = (char) temp;
}
else
{
- Log::Fatal << "Missing the correct name\n";
+ Log::Fatal << "LoadParameter(): node '" << name << "' not found.\n";
}
return 0;
}
Modified: mlpack/trunk/src/mlpack/core/util/save_restore_utility.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/util/save_restore_utility.hpp 2011-12-16 14:33:20 UTC (rev 10853)
+++ mlpack/trunk/src/mlpack/core/util/save_restore_utility.hpp 2011-12-16 14:43:05 UTC (rev 10854)
@@ -71,7 +71,7 @@
/**
* LoadParameter loads a string from the parameters map.
*/
- std::string LoadParameter(std::string str, const std::string name);
+ std::string LoadParameter(std::string& str, const std::string name);
/**
* LoadParameter loads an arma::mat from the parameters map.
Modified: mlpack/trunk/src/mlpack/core/util/save_restore_utility_impl.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/util/save_restore_utility_impl.hpp 2011-12-16 14:33:20 UTC (rev 10853)
+++ mlpack/trunk/src/mlpack/core/util/save_restore_utility_impl.hpp 2011-12-16 14:43:05 UTC (rev 10854)
@@ -27,7 +27,7 @@
}
else
{
- Log::Fatal << "Missing the correct name\n";
+ Log::Fatal << "LoadParameter(): node '" << name << "' not found.\n";
}
return t;
}
@@ -57,7 +57,7 @@
}
else
{
- Log::Fatal << "Failed to load the parameter " << name << std::endl;
+ Log::Fatal << "LoadParameter(): node '" << name << "' not found.\n";
}
return v;
}
More information about the mlpack-svn
mailing list