-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleCommand.cc
More file actions
41 lines (34 loc) · 834 Bytes
/
SimpleCommand.cc
File metadata and controls
41 lines (34 loc) · 834 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
WeChat: cstutorcs
QQ: 749389476
Email: tutorcs@163.com
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include "SimpleCommand.hh"
SimpleCommand::SimpleCommand() {
_arguments = std::vector<std::string *>();
}
SimpleCommand::~SimpleCommand() {
// iterate over all the arguments and delete them
for (auto & arg : _arguments) {
delete arg;
}
}
void SimpleCommand::insertArgument( std::string * argument ) {
// simply add the argument to the vector
_arguments.push_back(argument);
}
// Print out the simple command
void SimpleCommand::print() {
for (auto & arg : _arguments) {
std::cout << "\"" << *arg << "\" \t";
}
// effectively the same as printf("\n\n");
std::cout << std::endl;
}
void SimpleCommand::clear() {
for (auto & arg : _arguments) {
delete arg;
}
_arguments.clear();
}