src/PredFinder/macros/ReadingMacroSet.cpp
/**
 * Recursively reads a collection of ReadingMacroSets
 * from a directory or a single ReadingMacroSet file.
 *
 * @param path The path to a directory or file
 * containing one or more macro sets.
 * @return A set of shared pointers, one for each
 * macro set read.
 * 
 * @author nward@bbn.com
 * @date 2010.10.22
 **/
Recursively reads a collection of ReadingMacroSets
from a directory or a single ReadingMacroSet file.

@param path The path to a directory or file
containing one or more macro sets.
@return A set of shared pointers, one for each
macro set read.


Recursively reads a collection of ReadingMacroSets from a directory or a single ReadingMacroSet file . @param path The path to a directory or file containing one or more macro sets . @return A set of shared pointers one for each macro set read .
ReadingMacroSetSortedSet ReadingMacroSet::read(const std::string & path) {
	boost::filesystem::path full_path = boost::filesystem::system_complete(boost::filesystem::path(path));
	std::stringstream error;
	if (!boost::filesystem::exists(full_path)) {
		error << "Specified macro set input (" << full_path << ") doesn't exist";
		throw std::runtime_error(error.str().c_str());
	}
	if (boost::filesystem::is_directory(full_path)) {
		return read_from_dir(full_path);
	} else if (boost::filesystem::is_regular_file(full_path)) {
		ReadingMacroSetSortedSet macro_sets;
		macro_sets.insert(read_from_file(full_path));
		return macro_sets;
	} else {
		error << "Macro set input (" << full_path << ") is not a file or directory";
		throw std::runtime_error(error.str().c_str());
	}
}
ReadingMacroSetSortedSet ReadingMacroSet :: read ( const std :: string & path ) { boost :: filesystem :: path full_path = boost :: filesystem :: system_complete ( boost :: filesystem :: path ( path ) ) ; std :: stringstream error ; if ( ! boost :: filesystem :: exists ( full_path ) ) { error << " " << full_path << " " ; throw std :: runtime_error ( error . str ( ) . c_str ( ) ) ; } if ( boost :: filesystem :: is_directory ( full_path ) ) { return read_from_dir ( full_path ) ; } else if ( boost :: filesystem :: is_regular_file ( full_path ) ) { ReadingMacroSetSortedSet macro_sets ; macro_sets . insert ( read_from_file ( full_path ) ) ; return macro_sets ; } else { error << " " << full_path << " " ; throw std :: runtime_error ( error . str ( ) . c_str ( ) ) ; } }
Recursively reads a collection of ReadingMacroSets
 from a directory or a single ReadingMacroSet file.
Recursively reads a collection of ReadingMacroSets from a directory or a single ReadingMacroSet file .
// Get the full path
 // Make sure input exists
 // Read
