dlugolecki.net.pl
Dziennik
Polecane
Software
projects
/
command.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Update README with newly released version url
[command.git]
/
include
/
argument.h
diff --git
a/include/argument.h
b/include/argument.h
index 5690e5dbf6ba2973147535ce32d66459ad23dd95..bf5fc3354f304c7b894252069969451275ec7fff 100644
(file)
--- a/
include/argument.h
+++ b/
include/argument.h
@@
-4,6
+4,7
@@
#include <string>
#include <sstream>
#include <iostream>
#include <string>
#include <sstream>
#include <iostream>
+#include <functional>
#include "parameter.h"
#include "callable.h"
#include "parameter.h"
#include "callable.h"
@@
-31,7
+32,7
@@
namespace command {
* @param description Description of current Argument
* @param function Function used to handle current Argument.
*/
* @param description Description of current Argument
* @param function Function used to handle current Argument.
*/
- Argument(const std::string & description,
void (*function)(ParameterType)
)
+ Argument(const std::string & description,
std::function<void(ParameterType)> function
)
: Parameter(description), Callable<ParameterType>(function) {
}
: Parameter(description), Callable<ParameterType>(function) {
}
@@
-45,6
+46,7
@@
namespace command {
*/
virtual void handle() {
this->call(value);
*/
virtual void handle() {
this->call(value);
+ this->used = true;
}
/**
}
/**
@@
-64,20
+66,24
@@
namespace command {
* against next value.
*/
virtual bool understand(const std::string & argv) {
* against next value.
*/
virtual bool understand(const std::string & argv) {
- if (!isUsed()) {
- std::stringstream ss;
+ std::stringstream ss;
-
ss
<< argv;
-
ss >> value;
+
ss << std::fixed
<< argv;
+ ss >> value;
- if (!ss.fail()) {
- this->used = true;
- return true;
- }
+ if (!ss.fail()) {
+ return true;
}
return false;
}
}
return false;
}
+
+ /**
+ * \inheritdoc
+ */
+ virtual unsigned int valuePosition(const std::string & ) {
+ return 0;
+ }
};
}
};
}