40 int main(
int argc,
char *argv[])
51 parser.
setDescription(
"An example MiniApp that converts the contents of a test file to upper case.");
67 "where to save the output (.txt/.example)",
80 std::map<std::string, us::Any> parsedArgs = parser.
parseArguments(argc, argv);
82 if (parsedArgs.size() == 0)
86 std::string inFilename =
us::any_cast<std::string>(parsedArgs[
"input"]);
87 std::string outFileName =
us::any_cast<std::string>(parsedArgs[
"output"]);
93 if (parsedArgs.count(
"verbose"))
109 if (inVector.empty())
111 std::string errorMessage =
"File at " + inFilename +
" could not be read. Aborting.";
123 std::string data = inExample->
GetData();
126 MITK_INFO <<
"String before conversion: " << data;
128 std::transform(data.begin(), data.end(), data.begin(), ::toupper);
131 MITK_INFO <<
"String after conversion: " << data;
133 outExample->SetData(data);
146 catch (itk::ExceptionObject e)
151 catch (std::exception e)
158 MITK_ERROR <<
"Unexpected error encountered.";
Base of all data objects.
virtual std::string GetData()
void setContributor(std::string contributor)
ValueType * any_cast(Any *operand)
std::map< std::string, us::Any > parseArguments(const StringContainerType &arguments, bool *ok=nullptr)
int main(int argc, char *argv[])
Example MiniApp that converts a text file content to upper case.
static bool SaveBaseData(mitk::BaseData *data, const std::string &path)
SaveBaseData Convenience method to save arbitrary baseData.
void addArgument(const std::string &longarg, const std::string &shortarg, Type type, const std::string &argLabel, const std::string &argHelp=std::string(), const us::Any &defaultValue=us::Any(), bool optional=true, bool ignoreRest=false, bool deprecated=false)
void setCategory(std::string category)
void setArgumentPrefix(const std::string &longPrefix, const std::string &shortPrefix)
static DataStorage::SetOfObjects::Pointer Load(const std::string &path, DataStorage &storage)
Load a file into the given DataStorage.
void setTitle(std::string title)
void setDescription(std::string description)
void beginGroup(const std::string &description)