[mlpack-svn] r10109 - mlpack/trunk/src/mlpack/core/io
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Tue Nov 1 13:36:37 EDT 2011
Author: mamidon
Date: 2011-11-01 13:36:36 -0400 (Tue, 01 Nov 2011)
New Revision: 10109
Modified:
mlpack/trunk/src/mlpack/core/io/cli.hpp
mlpack/trunk/src/mlpack/core/io/cli_deleter.cpp
mlpack/trunk/src/mlpack/core/io/cli_deleter.hpp
mlpack/trunk/src/mlpack/core/io/cli_impl.hpp
mlpack/trunk/src/mlpack/core/io/log.cpp
mlpack/trunk/src/mlpack/core/io/log.hpp
mlpack/trunk/src/mlpack/core/io/nulloutstream.cpp
mlpack/trunk/src/mlpack/core/io/nulloutstream.hpp
mlpack/trunk/src/mlpack/core/io/option.cpp
mlpack/trunk/src/mlpack/core/io/option.hpp
mlpack/trunk/src/mlpack/core/io/option_impl.hpp
mlpack/trunk/src/mlpack/core/io/optionshierarchy.cpp
mlpack/trunk/src/mlpack/core/io/optionshierarchy.hpp
mlpack/trunk/src/mlpack/core/io/prefixedoutstream.cpp
mlpack/trunk/src/mlpack/core/io/prefixedoutstream.hpp
Log:
Formatted according to new brace styles.
Modified: mlpack/trunk/src/mlpack/core/io/cli.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/io/cli.hpp 2011-11-01 17:18:30 UTC (rev 10108)
+++ mlpack/trunk/src/mlpack/core/io/cli.hpp 2011-11-01 17:36:36 UTC (rev 10109)
@@ -395,7 +395,8 @@
namespace po = boost::program_options;
-namespace mlpack {
+namespace mlpack
+{
// Externally defined in option.hpp, this class holds information about the
// program being run.
@@ -537,7 +538,8 @@
* collisions are still possible, and they produce bizarre error messages. See
* http://mlpack.org/ticket/74 for more information.
*/
-class CLI {
+class CLI
+{
public:
/**
* Adds a parameter to the hierarchy; use the PARAM_*() macros instead of this
Modified: mlpack/trunk/src/mlpack/core/io/cli_deleter.cpp
===================================================================
--- mlpack/trunk/src/mlpack/core/io/cli_deleter.cpp 2011-11-01 17:18:30 UTC (rev 10108)
+++ mlpack/trunk/src/mlpack/core/io/cli_deleter.cpp 2011-11-01 17:36:36 UTC (rev 10109)
@@ -17,14 +17,16 @@
/***
* Empty constructor that does nothing.
*/
-CLIDeleter::CLIDeleter() {
+CLIDeleter::CLIDeleter()
+{
/* nothing to do */
}
/***
* This destructor deletes the CLI singleton.
*/
-CLIDeleter::~CLIDeleter() {
+CLIDeleter::~CLIDeleter()
+{
// Delete the singleton!
CLI::Destroy();
}
Modified: mlpack/trunk/src/mlpack/core/io/cli_deleter.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/io/cli_deleter.hpp 2011-11-01 17:18:30 UTC (rev 10108)
+++ mlpack/trunk/src/mlpack/core/io/cli_deleter.hpp 2011-11-01 17:36:36 UTC (rev 10109)
@@ -7,8 +7,10 @@
#ifndef __MLPACK_CORE_IO_CLI_DELETER_HPP
#define __MLPACK_CORE_IO_CLI_DELETER_HPP
-namespace mlpack {
-namespace io {
+namespace mlpack
+{
+namespace io
+{
/**
* Extremely simple class whose only job is to delete the existing CLI object at
@@ -17,7 +19,8 @@
* CLIDeleter class, which will be initialized at the beginning of the program
* and deleted at the end. The destructor destroys the CLI singleton.
*/
-class CLIDeleter {
+class CLIDeleter
+{
public:
CLIDeleter();
~CLIDeleter();
Modified: mlpack/trunk/src/mlpack/core/io/cli_impl.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/io/cli_impl.hpp 2011-11-01 17:18:30 UTC (rev 10108)
+++ mlpack/trunk/src/mlpack/core/io/cli_impl.hpp 2011-11-01 17:36:36 UTC (rev 10109)
@@ -14,7 +14,8 @@
//Include option.hpp here because it requires CLI but is also templated.
#include "option.hpp"
-namespace mlpack {
+namespace mlpack
+{
/**
* @brief Adds a parameter to CLI, making it accessibile via GetParam &
@@ -32,7 +33,8 @@
void CLI::Add(const char* identifier,
const char* description,
const char* parent,
- bool required) {
+ bool required)
+{
po::options_description& desc = CLI::GetSingleton().desc;
// Generate the full pathname and insert the node into the hierarchy.
@@ -61,7 +63,8 @@
* valid.
*/
template<typename T>
-T& CLI::GetParam(const char* identifier) {
+T& CLI::GetParam(const char* identifier)
+{
// Used to ensure we have a valid value.
T tmp = T();
@@ -71,13 +74,15 @@
po::variables_map& vmap = GetSingleton().vmap;
// If we have the option, set its value.
- if (vmap.count(key) && !gmap.count(key)) {
+ if (vmap.count(key) && !gmap.count(key))
+ {
gmap[key] = boost::any(vmap[identifier].as<T>());
}
// We may have whatever is on the commandline, but what if the programmer has
// made modifications?
- if (!gmap.count(key)) { // The programmer hasn't done anything; register it
+ if (!gmap.count(key))
+ { // The programmer hasn't done anything; register it
gmap[key] = boost::any(tmp);
*boost::any_cast<T>(&gmap[key]) = tmp;
}
Modified: mlpack/trunk/src/mlpack/core/io/log.cpp
===================================================================
--- mlpack/trunk/src/mlpack/core/io/log.cpp 2011-11-01 17:18:30 UTC (rev 10108)
+++ mlpack/trunk/src/mlpack/core/io/log.cpp 2011-11-01 17:36:36 UTC (rev 10109)
@@ -37,12 +37,15 @@
// Only do anything for Assert() if in debugging mode.
#ifdef DEBUG
-void Log::Assert(bool condition, const char* message) {
- if(!condition) {
+void Log::Assert(bool condition, const char* message)
+{
+ if(!condition)
+ {
Log::Debug << message << std::endl;
exit(1);
}
}
#else
-void Log::Assert(bool condition, const char* message) { }
+void Log::Assert(bool condition, const char* message)
+{ }
#endif
Modified: mlpack/trunk/src/mlpack/core/io/log.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/io/log.hpp 2011-11-01 17:18:30 UTC (rev 10108)
+++ mlpack/trunk/src/mlpack/core/io/log.hpp 2011-11-01 17:36:36 UTC (rev 10109)
@@ -10,7 +10,8 @@
#include "prefixedoutstream.hpp"
#include "nulloutstream.hpp"
-namespace mlpack {
+namespace mlpack
+{
/**
* Provides a convenient way to give formatted output.
@@ -44,7 +45,8 @@
*
* @see PrefixedOutStream, NullOutStream, CLI
*/
-class Log {
+class Log
+{
public:
/**
* Checks if the specified condition is true.
Modified: mlpack/trunk/src/mlpack/core/io/nulloutstream.cpp
===================================================================
--- mlpack/trunk/src/mlpack/core/io/nulloutstream.cpp 2011-11-01 17:18:30 UTC (rev 10108)
+++ mlpack/trunk/src/mlpack/core/io/nulloutstream.cpp 2011-11-01 17:36:36 UTC (rev 10109)
@@ -9,43 +9,61 @@
using namespace mlpack::io;
-NullOutStream::NullOutStream() { /* Nothing to do */ }
+NullOutStream::NullOutStream()
+{ /* Nothing to do */ }
-NullOutStream::NullOutStream(const NullOutStream& other) { /* Nothing to do */ }
+NullOutStream::NullOutStream(const NullOutStream& other)
+{ /* Nothing to do */ }
-NullOutStream& NullOutStream::operator<< (bool val) { return *this; }
+NullOutStream& NullOutStream::operator<< (bool val)
+{ return *this; }
-NullOutStream& NullOutStream::operator<< (short val) { return *this; }
+NullOutStream& NullOutStream::operator<< (short val)
+{ return *this; }
-NullOutStream& NullOutStream::operator<< (unsigned short val) { return *this; }
+NullOutStream& NullOutStream::operator<< (unsigned short val)
+{ return *this; }
-NullOutStream& NullOutStream::operator<< (int val) { return *this; }
+NullOutStream& NullOutStream::operator<< (int val)
+{ return *this; }
-NullOutStream& NullOutStream::operator<< (unsigned int val) { return *this; }
+NullOutStream& NullOutStream::operator<< (unsigned int val)
+{ return *this; }
-NullOutStream& NullOutStream::operator<< (long val) { return *this; }
+NullOutStream& NullOutStream::operator<< (long val)
+{ return *this; }
-NullOutStream& NullOutStream::operator<< (unsigned long val) { return *this; }
+NullOutStream& NullOutStream::operator<< (unsigned long val)
+{ return *this; }
-NullOutStream& NullOutStream::operator<< (float val) { return *this; }
+NullOutStream& NullOutStream::operator<< (float val)
+{ return *this; }
-NullOutStream& NullOutStream::operator<< (double val) { return *this; }
+NullOutStream& NullOutStream::operator<< (double val)
+{ return *this; }
-NullOutStream& NullOutStream::operator<< (long double val) { return *this; }
+NullOutStream& NullOutStream::operator<< (long double val)
+{ return *this; }
-NullOutStream& NullOutStream::operator<< (void* val) { return *this; }
+NullOutStream& NullOutStream::operator<< (void* val)
+{ return *this; }
-NullOutStream& NullOutStream::operator<< (std::string& str) { return *this; }
+NullOutStream& NullOutStream::operator<< (std::string& str)
+{ return *this; }
-NullOutStream& NullOutStream::operator<< (const char* str) { return *this; }
+NullOutStream& NullOutStream::operator<< (const char* str)
+{ return *this; }
-NullOutStream& NullOutStream::operator<< (std::streambuf* val) { return *this; }
+NullOutStream& NullOutStream::operator<< (std::streambuf* val)
+{ return *this; }
-NullOutStream& NullOutStream::operator<< (std::ostream& (*pf) (std::ostream&)) {
+NullOutStream& NullOutStream::operator<< (std::ostream& (*pf) (std::ostream&))
+{
return *this;
}
-NullOutStream& NullOutStream::operator<< (std::ios& (*pf) (std::ios&)) {
+NullOutStream& NullOutStream::operator<< (std::ios& (*pf) (std::ios&))
+{
return *this;
}
Modified: mlpack/trunk/src/mlpack/core/io/nulloutstream.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/io/nulloutstream.hpp 2011-11-01 17:18:30 UTC (rev 10108)
+++ mlpack/trunk/src/mlpack/core/io/nulloutstream.hpp 2011-11-01 17:36:36 UTC (rev 10109)
@@ -68,7 +68,8 @@
//! Does nothing.
template<typename T>
- NullOutStream& operator<<(T s) { return *this; }
+ NullOutStream& operator<<(T s)
+ { return *this; }
};
} // namespace io
Modified: mlpack/trunk/src/mlpack/core/io/option.cpp
===================================================================
--- mlpack/trunk/src/mlpack/core/io/option.cpp 2011-11-01 17:18:30 UTC (rev 10108)
+++ mlpack/trunk/src/mlpack/core/io/option.cpp 2011-11-01 17:36:36 UTC (rev 10109)
@@ -29,7 +29,8 @@
const std::string defaultModule) :
programName(programName),
documentation(documentation),
- defaultModule(defaultModule) {
+ defaultModule(defaultModule)
+{
// Register this with CLI.
CLI::RegisterProgramDoc(this);
}
Modified: mlpack/trunk/src/mlpack/core/io/option.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/io/option.hpp 2011-11-01 17:18:30 UTC (rev 10108)
+++ mlpack/trunk/src/mlpack/core/io/option.hpp 2011-11-01 17:36:36 UTC (rev 10109)
@@ -12,8 +12,10 @@
#include "cli.hpp"
-namespace mlpack {
-namespace io {
+namespace mlpack
+{
+namespace io
+{
/**
* A static object whose constructor registers a parameter with the CLI class.
@@ -24,7 +26,8 @@
* @see core/io/cli.hpp, mlpack::CLI
*/
template<typename N>
-class Option {
+class Option
+{
public:
/**
* Construct an Option object. When constructed, it will register
@@ -71,7 +74,8 @@
*
* @see core/io/cli.hpp, mlpack::CLI
*/
-class ProgramDoc {
+class ProgramDoc
+{
public:
/**
* Construct a ProgramDoc object. When constructed, it will register itself
Modified: mlpack/trunk/src/mlpack/core/io/option_impl.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/io/option_impl.hpp 2011-11-01 17:18:30 UTC (rev 10108)
+++ mlpack/trunk/src/mlpack/core/io/option_impl.hpp 2011-11-01 17:36:36 UTC (rev 10109)
@@ -11,8 +11,10 @@
#ifndef __MLPACK_CORE_IO_OPTION_IMPL_HPP
#define __MLPACK_CORE_IO_OPTION_IMPL_HPP
-namespace mlpack {
-namespace io {
+namespace mlpack
+{
+namespace io
+{
/**
* Registers a parameter with CLI.
@@ -23,10 +25,12 @@
const char* identifier,
const char* description,
const char* parent,
- bool required) {
+ bool required)
+{
if (ignoreTemplate)
CLI::Add(identifier, description, parent, required);
- else {
+ else
+ {
CLI::Add<N>(identifier, description, parent, required);
// Create the full pathname to set the default value.
@@ -42,7 +46,8 @@
template<typename N>
Option<N>::Option(const char* identifier,
const char* description,
- const char* parent) {
+ const char* parent)
+{
CLI::AddFlag(identifier, description, parent);
}
Modified: mlpack/trunk/src/mlpack/core/io/optionshierarchy.cpp
===================================================================
--- mlpack/trunk/src/mlpack/core/io/optionshierarchy.cpp 2011-11-01 17:18:30 UTC (rev 10108)
+++ mlpack/trunk/src/mlpack/core/io/optionshierarchy.cpp 2011-11-01 17:36:36 UTC (rev 10109)
@@ -17,7 +17,8 @@
/* Ctors, Dtors, and R2D2 [actually, just copy-tors] */
/* Constructs an empty OptionsHierarchy node. */
-OptionsHierarchy::OptionsHierarchy() : children() {
+OptionsHierarchy::OptionsHierarchy() : children()
+{
nodeData.node = "";
nodeData.desc = "";
nodeData.tname = "";
@@ -29,7 +30,8 @@
*
* @param name The name of the node to be created.
*/
-OptionsHierarchy::OptionsHierarchy(const char* name) : children() {
+OptionsHierarchy::OptionsHierarchy(const char* name) : children()
+{
nodeData.node = string(name);
nodeData.desc = "";
nodeData.tname = "";
@@ -41,14 +43,16 @@
*
* @param other The node to be copied
*/
-OptionsHierarchy::OptionsHierarchy(const OptionsHierarchy& other) {
+OptionsHierarchy::OptionsHierarchy(const OptionsHierarchy& other)
+{
return;
}
/*
* Destroys the node.
*/
-OptionsHierarchy::~OptionsHierarchy() {
+OptionsHierarchy::~OptionsHierarchy()
+{
return;
}
@@ -59,7 +63,8 @@
* @param pathname The full pathname of the given node, eg /foo/bar.
* @param tname A string unique to the type of the node.
*/
-void OptionsHierarchy::AppendNode(string& pathname, string& tname) {
+void OptionsHierarchy::AppendNode(string& pathname, string& tname)
+{
string tmp = string("");
OptionsData d;
d.node = pathname;
@@ -78,7 +83,8 @@
*/
void OptionsHierarchy::AppendNode(string& pathname,
string& tname,
- string& description) {
+ string& description)
+{
OptionsData d;
d.node = pathname;
d.desc = description;
@@ -96,14 +102,16 @@
* @param data Specifies all fields of the new node.
*/
void OptionsHierarchy::AppendNode(string& pathname, string& tname,
- string& description, OptionsData& data) {
+ string& description, OptionsData& data)
+{
string name = GetName(pathname);
string path = GetPath(pathname);
//Append the new name, if it isn't already there
if (children.count(name) == 0)
children[name] = OptionsHierarchy(name.c_str());
- if (pathname.find('/') == pathname.npos || path.length() < 1) {
+ if (pathname.find('/') == pathname.npos || path.length() < 1)
+ {
children[name].nodeData = data;
return;
}
@@ -120,12 +128,14 @@
* @return Pointer to the node with that pathname,
* null if not found.
*/
-OptionsHierarchy* OptionsHierarchy::FindNode(string& pathname) {
+OptionsHierarchy* OptionsHierarchy::FindNode(string& pathname)
+{
return FindNodeHelper(pathname, pathname);
}
OptionsHierarchy* OptionsHierarchy::FindNodeHelper(string& pathname,
- string& target) {
+ string& target)
+{
string name = GetName(pathname);
string path = GetPath(pathname);
//If the node is there, recurse to it.
@@ -145,7 +155,8 @@
* @return The data associated with the node,
* eg it's name, description, and value.
*/
-OptionsData OptionsHierarchy::GetNodeData() {
+OptionsData OptionsHierarchy::GetNodeData()
+{
return nodeData;
}
@@ -157,7 +168,8 @@
* @return The identifiers of all nodes after the next node in the path,
* eg fizz/bar in foo/fizz/bar.
*/
-string OptionsHierarchy::GetPath(string& pathname) {
+string OptionsHierarchy::GetPath(string& pathname)
+{
//Want to make sure we return a valid string
if (pathname.find('/') == pathname.npos)
return string("");
@@ -173,7 +185,8 @@
* @return The name of the next node in the path
* eg foo in foo/bar.
*/
-string OptionsHierarchy::GetName(string& pathname) {
+string OptionsHierarchy::GetName(string& pathname)
+{
//Want to makesure we return a valid string
if (pathname.find('/') == pathname.npos)
return pathname;
@@ -191,7 +204,8 @@
* @return Vector containing relative pathnames of subordinant nodes.
*/
std::vector<std::string>
- OptionsHierarchy::GetRelativePaths(std::string& pathname) {
+ OptionsHierarchy::GetRelativePaths(std::string& pathname)
+{
std::vector<std::string> ret;
//Obtain the starting node.
@@ -204,7 +218,8 @@
}
std::vector<std::string>
- OptionsHierarchy::GetRelativePathsHelper(OptionsHierarchy& node) {
+ OptionsHierarchy::GetRelativePathsHelper(OptionsHierarchy& node)
+{
std::vector<std::string> ret;
std::vector<std::string> tmp;
@@ -213,7 +228,8 @@
for(iter = node.children.begin(); iter != node.children.end(); iter++)
tmp = GetRelativePathsHelper((*iter).second);
- while(tmp.size()) {
+ while(tmp.size())
+ {
ret.push_back(tmp.back());
tmp.pop_back();
}
@@ -223,7 +239,8 @@
/*
* Prints a node, followed by it's entries and submodules.
*/
-void OptionsHierarchy::Print() {
+void OptionsHierarchy::Print()
+{
//Print the node, append '/' if that node is not a leaf
PrintNode();
@@ -238,10 +255,12 @@
/*
* Prints every node and it's value, if any.
*/
-void OptionsHierarchy::PrintAll() {
+void OptionsHierarchy::PrintAll()
+{
PrintNode();
map<string, OptionsHierarchy>::iterator iter;
- for (iter = children.begin(); iter != children.end(); iter++) {
+ for (iter = children.begin(); iter != children.end(); iter++)
+ {
iter->second.PrintAll();
}
}
@@ -249,7 +268,8 @@
/*
* Prints every node and it's description.
*/
-void OptionsHierarchy::PrintAllHelp() {
+void OptionsHierarchy::PrintAllHelp()
+{
// Special case for the top of the hierarchy.
if (nodeData.node == "Allowed Options")
cout << "Allowed Options:" << endl << endl;
@@ -259,7 +279,8 @@
// Now print all the children.
map<string, OptionsHierarchy>::iterator iter;
// First print modules.
- for (iter = children.begin(); iter != children.end(); iter++) {
+ for (iter = children.begin(); iter != children.end(); iter++)
+ {
if (iter->second.children.size() > 0)
iter->second.PrintAllHelp();
}
@@ -270,7 +291,8 @@
if (nodeData.node == "Allowed Options")
cout << "Other options:" << endl << endl;
- for (iter = children.begin(); iter != children.end(); iter++) {
+ for (iter = children.begin(); iter != children.end(); iter++)
+ {
if (iter->second.children.size() == 0)
iter->second.PrintAllHelp();
}
@@ -280,41 +302,51 @@
}
/* Prints all children of this node which are parents */
-void OptionsHierarchy::PrintBranches() {
+void OptionsHierarchy::PrintBranches()
+{
map<string, OptionsHierarchy>::iterator iter;
// Iterate through all children
for (iter = children.begin(); iter != children.end(); iter++)
// Does this child have children?
- if (iter->second.children.size()) {
+ if (iter->second.children.size())
+ {
iter->second.PrintNode();
}
}
/* Prints all children nodes that have no children themselves */
-void OptionsHierarchy::PrintLeaves() {
+void OptionsHierarchy::PrintLeaves()
+{
map<string, OptionsHierarchy>::iterator iter;
- for (iter = children.begin(); iter != children.end(); iter++) {
- if (!iter->second.children.size()) {
+ for (iter = children.begin(); iter != children.end(); iter++)
+ {
+ if (!iter->second.children.size())
+ {
// Print the node's name, data, and description, but only if it is not a
// timer.
if (iter->second.nodeData.tname != TYPENAME(timeval))
iter->second.PrintNode();
- } else {
+ } else
+ {
iter->second.PrintLeaves();
}
}
}
/* Prints all children nodes that are timers */
-void OptionsHierarchy::PrintTimers() {
+void OptionsHierarchy::PrintTimers()
+{
map<string, OptionsHierarchy>::iterator iter;
- for (iter = children.begin(); iter != children.end(); iter++) {
- if (!iter->second.children.size()) {
+ for (iter = children.begin(); iter != children.end(); iter++)
+ {
+ if (!iter->second.children.size())
+ {
if (iter->second.nodeData.tname == TYPENAME(timeval))
iter->second.PrintNode();
- } else {
+ } else
+ {
iter->second.PrintTimers();
}
}
@@ -323,14 +355,16 @@
/*
* Prints a node and its value.
*/
-void OptionsHierarchy::PrintNode() {
+void OptionsHierarchy::PrintNode()
+{
Log::Info << " " << nodeData.node << " = " ;
if (nodeData.tname == TYPENAME(bool))
Log::Info << boolalpha << CLI::GetParam<bool>(nodeData.node.c_str());
else if (nodeData.tname == TYPENAME(int))
Log::Info << CLI::GetParam<int>(nodeData.node.c_str());
- else if (nodeData.tname == TYPENAME(std::string)) {
+ else if (nodeData.tname == TYPENAME(std::string))
+ {
std::string value = CLI::GetParam<std::string>(nodeData.node.c_str());
if (value == "")
value = "\"\""; // So that the user isn't presented with an empty space.
@@ -339,7 +373,8 @@
Log::Info << CLI::GetParam<float>(nodeData.node.c_str());
else if (nodeData.tname == TYPENAME(double))
Log::Info << CLI::GetParam<double>(nodeData.node.c_str());
- else if (nodeData.tname == TYPENAME(timeval)) {
+ else if (nodeData.tname == TYPENAME(timeval))
+ {
timeval& t = CLI::GetParam<timeval>(nodeData.node.c_str());
Log::Info << t.tv_sec << "." << std::setw(6) << std::setfill('0')
<< t.tv_usec << "s";
@@ -350,27 +385,32 @@
int seconds = (t.tv_sec % 60);
// No output if it didn't even take a minute.
- if (!(days == 0 && hours == 0 && minutes == 0)) {
+ if (!(days == 0 && hours == 0 && minutes == 0))
+ {
bool output = false; // Denotes if we have output anything yet.
Log::Info << " (";
// Only output units if they have nonzero values (yes, a bit tedious).
- if (days > 0) {
+ if (days > 0)
+ {
Log::Info << days << " days";
output = true;
}
- if (hours > 0) {
+ if (hours > 0)
+ {
if (output)
Log::Info << ", ";
Log::Info << hours << " hrs";
output = true;
}
- if (minutes > 0) {
+ if (minutes > 0)
+ {
if (output)
Log::Info << ", ";
Log::Info << minutes << " mins";
output = true;
}
- if (seconds > 0) {
+ if (seconds > 0)
+ {
if (output)
Log::Info << ", ";
Log::Info << seconds << "." << std::setw(1) << (t.tv_usec / 100000) <<
@@ -389,10 +429,12 @@
* Prints a node and its description. The format is similar to that help given
* by the ImageMagick suite of programs.
*/
-void OptionsHierarchy::PrintNodeHelp() {
+void OptionsHierarchy::PrintNodeHelp()
+{
// We want to print differently if this is a module node (i.e. if it has any
// children).
- if (children.size() > 0) {
+ if (children.size() > 0)
+ {
if (nodeData.node == "default") // Special case for default module.
cout << "Default options:" << endl;
else // Other standard module title output.
@@ -431,13 +473,15 @@
// So, we only want to use a new line if we have used more than 30 characters
// already. Descriptions start at character 30.
- if (len < 30) {
+ if (len < 30)
+ {
cout << std::string(30 - len, ' ');
if (nodeData.desc.length() > 0)
cout << HyphenateString(nodeData.desc, 30) << endl;
else
cout << "Undocumented option." << endl;
- } else {
+ } else
+ {
cout << endl << std::string(30, ' ');
if (nodeData.desc.length() > 0)
cout << HyphenateString(nodeData.desc, 30) << endl;
@@ -453,7 +497,8 @@
* @param str String to hyphenate (splits are on ' ').
* @param padding Amount of padding on the left for each new line.
*/
-string OptionsHierarchy::HyphenateString(string str, int padding) {
+string OptionsHierarchy::HyphenateString(string str, int padding)
+{
size_t margin = 80 - padding;
if (str.length() < margin)
return str;
@@ -462,15 +507,19 @@
unsigned int pos = 0;
// First try to look as far as possible.
- while(pos < str.length() - 1) {
+ while(pos < str.length() - 1)
+ {
size_t splitpos;
// Check that we don't have a newline first.
splitpos = str.find('\n', pos);
- if (splitpos == string::npos || splitpos > (pos + margin)) {
+ if (splitpos == string::npos || splitpos > (pos + margin))
+ {
// We did not find a newline.
- if (str.length() - pos < margin) {
+ if (str.length() - pos < margin)
+ {
splitpos = str.length(); // The rest fits on one line.
- } else {
+ } else
+ {
splitpos = str.rfind(' ', margin + pos); // Find nearest space.
if (splitpos <= pos || splitpos == string::npos) // Not found.
splitpos = pos + margin;
@@ -478,7 +527,8 @@
}
out += str.substr(pos, (splitpos - pos));
- if (splitpos < str.length()) {
+ if (splitpos < str.length())
+ {
out += '\n';
out += string(padding, ' ');
}
Modified: mlpack/trunk/src/mlpack/core/io/optionshierarchy.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/io/optionshierarchy.hpp 2011-11-01 17:18:30 UTC (rev 10108)
+++ mlpack/trunk/src/mlpack/core/io/optionshierarchy.hpp 2011-11-01 17:36:36 UTC (rev 10109)
@@ -12,14 +12,17 @@
#include <string>
#include <vector>
-namespace mlpack {
-namespace io {
+namespace mlpack
+{
+namespace io
+{
/**
* Aids in the extensibility of OptionsHierarchy by focusing the potential
* changes into one structure.
*/
-struct OptionsData {
+struct OptionsData
+{
//! Name of this node.
std::string node;
//! Description of this node, if any.
@@ -33,7 +36,8 @@
* information about itself and can have any number of children, each with
* unique names.
*/
-class OptionsHierarchy {
+class OptionsHierarchy
+{
private:
//! Holds all node specific data.
OptionsData nodeData;
Modified: mlpack/trunk/src/mlpack/core/io/prefixedoutstream.cpp
===================================================================
--- mlpack/trunk/src/mlpack/core/io/prefixedoutstream.cpp 2011-11-01 17:18:30 UTC (rev 10108)
+++ mlpack/trunk/src/mlpack/core/io/prefixedoutstream.cpp 2011-11-01 17:36:36 UTC (rev 10109)
@@ -21,90 +21,107 @@
* may not be the actual case, but it works when these is here.
*/
-PrefixedOutStream& PrefixedOutStream::operator<<(bool val) {
+PrefixedOutStream& PrefixedOutStream::operator<<(bool val)
+{
BaseLogic<bool>(val);
return *this;
}
-PrefixedOutStream& PrefixedOutStream::operator<<(short val) {
+PrefixedOutStream& PrefixedOutStream::operator<<(short val)
+{
BaseLogic<short>(val);
return *this;
}
-PrefixedOutStream& PrefixedOutStream::operator<<(unsigned short val) {
+PrefixedOutStream& PrefixedOutStream::operator<<(unsigned short val)
+{
BaseLogic<unsigned short>(val);
return *this;
}
-PrefixedOutStream& PrefixedOutStream::operator<<(int val) {
+PrefixedOutStream& PrefixedOutStream::operator<<(int val)
+{
BaseLogic<int>(val);
return *this;
}
-PrefixedOutStream& PrefixedOutStream::operator<<(unsigned int val) {
+PrefixedOutStream& PrefixedOutStream::operator<<(unsigned int val)
+{
BaseLogic<unsigned int>(val);
return *this;
}
-PrefixedOutStream& PrefixedOutStream::operator<<(long val) {
+PrefixedOutStream& PrefixedOutStream::operator<<(long val)
+{
BaseLogic<long>(val);
return *this;
}
-PrefixedOutStream& PrefixedOutStream::operator<<(unsigned long val) {
+PrefixedOutStream& PrefixedOutStream::operator<<(unsigned long val)
+{
BaseLogic<unsigned long>(val);
return *this;
}
-PrefixedOutStream& PrefixedOutStream::operator<<(float val) {
+PrefixedOutStream& PrefixedOutStream::operator<<(float val)
+{
BaseLogic<float>(val);
return *this;
}
-PrefixedOutStream& PrefixedOutStream::operator<<(double val) {
+PrefixedOutStream& PrefixedOutStream::operator<<(double val)
+{
BaseLogic<double>(val);
return *this;
}
-PrefixedOutStream& PrefixedOutStream::operator<<(long double val) {
+PrefixedOutStream& PrefixedOutStream::operator<<(long double val)
+{
BaseLogic<long double>(val);
return *this;
}
-PrefixedOutStream& PrefixedOutStream::operator<<(void* val) {
+PrefixedOutStream& PrefixedOutStream::operator<<(void* val)
+{
BaseLogic<void*>(val);
return *this;
}
-PrefixedOutStream& PrefixedOutStream::operator<<(const char* str) {
+PrefixedOutStream& PrefixedOutStream::operator<<(const char* str)
+{
BaseLogic<const char*>(str);
return *this;
}
-PrefixedOutStream& PrefixedOutStream::operator<<(std::string& str) {
+PrefixedOutStream& PrefixedOutStream::operator<<(std::string& str)
+{
BaseLogic<std::string&>(str);
return *this;
}
-PrefixedOutStream& PrefixedOutStream::operator<<(std::streambuf* sb) {
+PrefixedOutStream& PrefixedOutStream::operator<<(std::streambuf* sb)
+{
BaseLogic<std::streambuf*>(sb);
return *this;
}
PrefixedOutStream& PrefixedOutStream::operator<<(
- std::ostream& (*pf)(std::ostream&)) {
+ std::ostream& (*pf)(std::ostream&))
+{
BaseLogic<std::ostream& (*)(std::ostream&)>(pf);
return *this;
}
-PrefixedOutStream& PrefixedOutStream::operator<<(std::ios& (*pf)(std::ios&)) {
+PrefixedOutStream& PrefixedOutStream::operator<<(std::ios& (*pf)(std::ios&))
+{
BaseLogic<std::ios& (*)(std::ios&)>(pf);
return *this;
}
PrefixedOutStream& PrefixedOutStream::operator<<(
- std::ios_base& (*pf) (std::ios_base&)) {
+ std::ios_base& (*pf) (std::ios_base&))
+{
BaseLogic<std::ios_base& (*)(std::ios_base&)>(pf);
return *this;
}
Modified: mlpack/trunk/src/mlpack/core/io/prefixedoutstream.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/io/prefixedoutstream.hpp 2011-11-01 17:18:30 UTC (rev 10108)
+++ mlpack/trunk/src/mlpack/core/io/prefixedoutstream.hpp 2011-11-01 17:36:36 UTC (rev 10109)
@@ -15,8 +15,10 @@
#include <boost/lexical_cast.hpp>
-namespace mlpack {
-namespace io {
+namespace mlpack
+{
+namespace io
+{
/**
* Allows us to output to an ostream with a prefix at the beginning of each
@@ -43,7 +45,8 @@
* These objects are used for the mlpack::Log levels (DEBUG, INFO, WARN, and
* FATAL).
*/
-class PrefixedOutStream {
+class PrefixedOutStream
+{
public:
/**
* Set up the PrefixedOutStream.
More information about the mlpack-svn
mailing list