diff options
author | Nikola Pajkovsky <npajkovs@redhat.com> | 2009-11-12 13:18:27 +0100 |
---|---|---|
committer | Nikola Pajkovsky <npajkovs@redhat.com> | 2009-11-12 13:18:27 +0100 |
commit | 2707930a0c1a2f4642a0f9371b6674d0b23d1b67 (patch) | |
tree | df10c6c02450c1973a7da74d43b2983fc54f74fa /lib/Utils/stringops.cpp | |
parent | 5b3c6da6b19c69611179a98dabd17721db670668 (diff) | |
download | abrt-2707930a0c1a2f4642a0f9371b6674d0b23d1b67.tar.gz abrt-2707930a0c1a2f4642a0f9371b6674d0b23d1b67.tar.xz abrt-2707930a0c1a2f4642a0f9371b6674d0b23d1b67.zip |
Factored ParseArg
Diffstat (limited to 'lib/Utils/stringops.cpp')
-rw-r--r-- | lib/Utils/stringops.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/Utils/stringops.cpp b/lib/Utils/stringops.cpp new file mode 100644 index 0000000..2304acc --- /dev/null +++ b/lib/Utils/stringops.cpp @@ -0,0 +1,32 @@ +#include "abrtlib.h" + +void parse_args(const char *psArgs, vector_string_t& pArgs, const char quote) +{ + unsigned ii; + bool is_quote = false; + std::string item; + + for (ii = 0; psArgs[ii]; ii++) + { + if (quote != -1 && psArgs[ii] == quote) + { + is_quote = !is_quote; + } + else if (psArgs[ii] == ',' && !is_quote) + { + printf("%s\n", item.c_str()); + pArgs.push_back(item); + item.clear(); + } + else + { + item += psArgs[ii]; + } + } + + if (item.size() != 0) + { + printf("%s\n", item.c_str()); + pArgs.push_back(item); + } +} |