Began removal of platform/. The Monitor:: namespace is completely converted.
[aesalon.git] / src / misc / ArgumentList.cpp
blob2a26a8ca83fea78f28dd838a1432ca2e2539bcc4
1 #include <cstring>
2 #include <iostream>
3 #include "ArgumentList.h"
5 namespace Aesalon {
6 namespace Misc {
8 void ArgumentList::from_string(std::string string) {
9 /* TODO: support quoted arguments . . . */
10 while(string.length()) {
11 std::string argument = string.substr(0, string.find(" "));
12 if(string.find(" ") != std::string::npos) string.erase(0, string.find(" ")+1);
13 else return;
14 add_argument(argument);
18 char **ArgumentList::get_as_argv() {
19 char **arguments;
21 arguments = new char *[argument_vector.size()+1];
23 for(std::size_t x = 0; x < argument_vector.size(); x ++) {
24 arguments[x] = new char[std::strlen(argument_vector[x].c_str()) + 1];
25 std::strcpy(arguments[x], argument_vector[x].c_str());
27 arguments[argument_vector.size()] = 0;
29 return arguments;
32 } // namespace Misc
33 } // namespace Aesalon