MCPcopy Create free account
hub / github.com/awslabs/aws-lambda-cpp / Arguments

Class Arguments

tests/gtest/gtest-all.cc:8437–8469  ·  view source on GitHub ↗

Utility class for accumulating command-line arguments.

Source from the content-addressed store, hash-verified

8435
8436// Utility class for accumulating command-line arguments.
8437class Arguments {
8438 public:
8439 Arguments() { args_.push_back(nullptr); }
8440
8441 ~Arguments() {
8442 for (std::vector<char*>::iterator i = args_.begin(); i != args_.end();
8443 ++i) {
8444 free(*i);
8445 }
8446 }
8447 void AddArgument(const char* argument) {
8448 args_.insert(args_.end() - 1, posix::StrDup(argument));
8449 }
8450
8451 template <typename Str>
8452 void AddArguments(const ::std::vector<Str>& arguments) {
8453 for (typename ::std::vector<Str>::const_iterator i = arguments.begin();
8454 i != arguments.end();
8455 ++i) {
8456 args_.insert(args_.end() - 1, posix::StrDup(i->c_str()));
8457 }
8458 }
8459 char* const* Argv() {
8460 return &args_[0];
8461 }
8462
8463 int size() {
8464 return args_.size() - 1;
8465 }
8466
8467 private:
8468 std::vector<char*> args_;
8469};
8470
8471// Waits for the child in a death test to exit, returning its exit
8472// status, or 0 if no child process exists. As a side effect, sets the

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected