Skip to content
Snippets Groups Projects
Commit 68ed5f8c authored by Andy Cedilnik's avatar Andy Cedilnik
Browse files

ENH: Move callback structure out of the public interface. Also block the...

ENH: Move callback structure out of the public interface. Also block the warning on Visual Studio Debug
parent d389e401
No related branches found
No related tags found
No related merge requests found
...@@ -25,6 +25,10 @@ ...@@ -25,6 +25,10 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#ifdef _MSC_VER
# pragma warning (disable: 4786)
#endif
namespace KWSYS_NAMESPACE namespace KWSYS_NAMESPACE
{ {
...@@ -41,13 +45,24 @@ public: ...@@ -41,13 +45,24 @@ public:
StdString(s, pos, n) {} StdString(s, pos, n) {}
}; };
struct CommandLineArgumentsCallbackStructure
{
const char* Argument;
int ArgumentType;
CommandLineArguments::CallbackType Callback;
void* CallData;
void* Variable;
int VariableType;
const char* Help;
};
class CommandLineArgumentsVectorOfStrings : class CommandLineArgumentsVectorOfStrings :
public kwsys_stl::vector<CommandLineArgumentsString> {}; public kwsys_stl::vector<CommandLineArgumentsString> {};
class CommandLineArgumentsSetOfStrings : class CommandLineArgumentsSetOfStrings :
public kwsys_stl::set<CommandLineArgumentsString> {}; public kwsys_stl::set<CommandLineArgumentsString> {};
class CommandLineArgumentsMapOfStrucs : class CommandLineArgumentsMapOfStrucs :
public kwsys_stl::map<CommandLineArgumentsString, public kwsys_stl::map<CommandLineArgumentsString,
CommandLineArguments::CallbackStructure> {}; CommandLineArgumentsCallbackStructure> {};
class CommandLineArgumentsInternal class CommandLineArgumentsInternal
{ {
...@@ -143,7 +158,7 @@ int CommandLineArguments::Parse() ...@@ -143,7 +158,7 @@ int CommandLineArguments::Parse()
it ++ ) it ++ )
{ {
const CommandLineArguments::Internal::String& parg = it->first; const CommandLineArguments::Internal::String& parg = it->first;
CommandLineArguments::CallbackStructure *cs = &it->second; CommandLineArgumentsCallbackStructure *cs = &it->second;
if (cs->ArgumentType == CommandLineArguments::NO_ARGUMENT || if (cs->ArgumentType == CommandLineArguments::NO_ARGUMENT ||
cs->ArgumentType == CommandLineArguments::SPACE_ARGUMENT) cs->ArgumentType == CommandLineArguments::SPACE_ARGUMENT)
{ {
...@@ -175,7 +190,7 @@ int CommandLineArguments::Parse() ...@@ -175,7 +190,7 @@ int CommandLineArguments::Parse()
// So, the longest one is probably the right one. Now see if it has any // So, the longest one is probably the right one. Now see if it has any
// additional value // additional value
const char* value = 0; const char* value = 0;
CommandLineArguments::CallbackStructure *cs CommandLineArgumentsCallbackStructure *cs
= &this->Internals->Callbacks[matches[maxidx]]; = &this->Internals->Callbacks[matches[maxidx]];
const CommandLineArguments::Internal::String& sarg = matches[maxidx]; const CommandLineArguments::Internal::String& sarg = matches[maxidx];
if ( cs->ArgumentType == NO_ARGUMENT ) if ( cs->ArgumentType == NO_ARGUMENT )
...@@ -328,7 +343,7 @@ void CommandLineArguments::GetRemainingArguments(int* argc, char*** argv) ...@@ -328,7 +343,7 @@ void CommandLineArguments::GetRemainingArguments(int* argc, char*** argv)
void CommandLineArguments::AddCallback(const char* argument, ArgumentTypeEnum type, void CommandLineArguments::AddCallback(const char* argument, ArgumentTypeEnum type,
CallbackType callback, void* call_data, const char* help) CallbackType callback, void* call_data, const char* help)
{ {
CommandLineArguments::CallbackStructure s; CommandLineArgumentsCallbackStructure s;
s.Argument = argument; s.Argument = argument;
s.ArgumentType = type; s.ArgumentType = type;
s.Callback = callback; s.Callback = callback;
...@@ -345,7 +360,7 @@ void CommandLineArguments::AddCallback(const char* argument, ArgumentTypeEnum ty ...@@ -345,7 +360,7 @@ void CommandLineArguments::AddCallback(const char* argument, ArgumentTypeEnum ty
void CommandLineArguments::AddArgument(const char* argument, ArgumentTypeEnum type, void CommandLineArguments::AddArgument(const char* argument, ArgumentTypeEnum type,
VariableTypeEnum vtype, void* variable, const char* help) VariableTypeEnum vtype, void* variable, const char* help)
{ {
CommandLineArguments::CallbackStructure s; CommandLineArgumentsCallbackStructure s;
s.Argument = argument; s.Argument = argument;
s.ArgumentType = type; s.ArgumentType = type;
s.Callback = 0; s.Callback = 0;
...@@ -434,7 +449,7 @@ const char* CommandLineArguments::GetHelp(const char* arg) ...@@ -434,7 +449,7 @@ const char* CommandLineArguments::GetHelp(const char* arg)
// Since several arguments may point to the same argument, find the one this // Since several arguments may point to the same argument, find the one this
// one point to if this one is pointing to another argument. // one point to if this one is pointing to another argument.
CommandLineArguments::CallbackStructure *cs = &(it->second); CommandLineArgumentsCallbackStructure *cs = &(it->second);
while ( 1 ) while ( 1 )
{ {
CommandLineArguments::Internal::CallbacksMap::iterator hit CommandLineArguments::Internal::CallbacksMap::iterator hit
...@@ -465,7 +480,7 @@ void CommandLineArguments::GenerateHelp() ...@@ -465,7 +480,7 @@ void CommandLineArguments::GenerateHelp()
it != this->Internals->Callbacks.end(); it != this->Internals->Callbacks.end();
it ++ ) it ++ )
{ {
CommandLineArguments::CallbackStructure *cs = &(it->second); CommandLineArgumentsCallbackStructure *cs = &(it->second);
mpit = mp.find(cs->Help); mpit = mp.find(cs->Help);
if ( mpit != mp.end() ) if ( mpit != mp.end() )
{ {
...@@ -481,7 +496,7 @@ void CommandLineArguments::GenerateHelp() ...@@ -481,7 +496,7 @@ void CommandLineArguments::GenerateHelp()
it != this->Internals->Callbacks.end(); it != this->Internals->Callbacks.end();
it ++ ) it ++ )
{ {
CommandLineArguments::CallbackStructure *cs = &(it->second); CommandLineArgumentsCallbackStructure *cs = &(it->second);
mpit = mp.find(cs->Help); mpit = mp.find(cs->Help);
if ( mpit != mp.end() ) if ( mpit != mp.end() )
{ {
......
...@@ -71,17 +71,6 @@ public: ...@@ -71,17 +71,6 @@ public:
void* call_data); void* call_data);
typedef int(*ErrorCallbackType)(const char* argument, void* client_data); typedef int(*ErrorCallbackType)(const char* argument, void* client_data);
struct CallbackStructure
{
const char* Argument;
int ArgumentType;
CallbackType Callback;
void* CallData;
void* Variable;
int VariableType;
const char* Help;
};
/** /**
* Initialize internal data structures. This should be called before parsing. * Initialize internal data structures. This should be called before parsing.
*/ */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment