Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Z
zipr-sdk
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Open Source Software
zipr-sdk
Commits
11df218b
Commit
11df218b
authored
9 years ago
by
whh8b
Browse files
Options
Downloads
Patches
Plain Diff
Update to the new options API.
parent
c72321a5
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/memory_space.h
+0
-1
0 additions, 1 deletion
include/memory_space.h
include/zipr_options.h
+237
-9
237 additions, 9 deletions
include/zipr_options.h
include/zipr_plugin.h
+4
-1
4 additions, 1 deletion
include/zipr_plugin.h
with
241 additions
and
11 deletions
include/memory_space.h
+
0
−
1
View file @
11df218b
...
@@ -34,7 +34,6 @@
...
@@ -34,7 +34,6 @@
namespace
Zipr_SDK
namespace
Zipr_SDK
{
{
class
Options_t
;
typedef
std
::
set
<
Range_t
,
Range_tCompare
>
RangeSet_t
;
typedef
std
::
set
<
Range_t
,
Range_tCompare
>
RangeSet_t
;
...
...
This diff is collapsed.
Click to expand it.
include/zipr_options.h
+
237
−
9
View file @
11df218b
...
@@ -28,27 +28,255 @@
...
@@ -28,27 +28,255 @@
* E-mail: jwd@zephyr-software.com
* E-mail: jwd@zephyr-software.com
**************************************************************************/
**************************************************************************/
#ifndef zipr_sdk_zipr_options_h
#ifndef zipr_sdk_zipr_
plugin_
options_h
#define zipr_sdk_zipr_options_h
#define zipr_sdk_zipr_
plugin_
options_h
#include
<string>
#include
<string>
#include
<unistd.h>
#include
<unistd.h>
#include
<libIRDB-core.hpp>
#include
<libIRDB-core.hpp>
#include
<iostream>
namespace
Zipr_SDK
namespace
Zipr_SDK
{
{
class
ZiprUntypedOption_t
{
public:
ZiprUntypedOption_t
()
:
m_key
(
""
),
m_untyped_value
(
""
),
m_takes_value
(
true
),
m_needs_value
(
true
),
m_required
(
false
),
m_set
(
false
)
{};
ZiprUntypedOption_t
(
std
::
string
key
,
std
::
string
value
)
:
m_key
(
key
),
m_untyped_value
(
value
),
m_takes_value
(
true
),
m_needs_value
(
true
),
m_required
(
false
),
m_set
(
false
)
{};
virtual
void
SetValue
(
const
std
::
string
&
value
)
=
0
;
virtual
void
Set
()
=
0
;
std
::
string
StringValue
()
{
return
m_untyped_value
;
}
std
::
string
Namespace
()
{
return
m_namespace
;
}
std
::
string
Key
()
{
return
m_key
;
}
void
SetNeedsValue
(
bool
needs_value
)
{
m_needs_value
=
needs_value
;
}
bool
NeedsValue
()
{
return
m_needs_value
;
}
void
SetTakesValue
(
bool
takes_value
)
{
m_takes_value
=
takes_value
;
}
bool
TakesValue
()
{
return
m_takes_value
;
}
bool
Required
()
{
return
m_required
;
}
void
SetRequired
(
bool
required
)
{
m_required
=
required
;
}
bool
RequirementMet
()
{
return
(
!
m_required
)
||
(
m_set
);
}
virtual
std
::
string
Description
()
{
return
m_description
;
}
void
SetDescription
(
std
::
string
description
)
{
m_description
=
description
;
}
void
AddObserver
(
ZiprUntypedOption_t
*
observer
)
{
observer
->
SetValue
(
m_untyped_value
);
m_observers
.
insert
(
observer
);
}
protected
:
std
::
string
m_namespace
,
m_key
,
m_untyped_value
,
m_description
;
std
::
set
<
ZiprUntypedOption_t
*>
m_observers
;
bool
m_takes_value
,
m_needs_value
;
bool
m_required
;
bool
m_set
;
void
SetObserverValues
(
std
::
string
value
)
{
std
::
set
<
ZiprUntypedOption_t
*>::
const_iterator
it
=
m_observers
.
begin
();
std
::
set
<
ZiprUntypedOption_t
*>::
const_iterator
it_end
=
m_observers
.
end
();
for
(;
it
!=
it_end
;
it
++
)
(
*
it
)
->
SetValue
(
value
);
}
};
class
Options_t
template
<
typename
T
>
class
ZiprTypedOption_t
:
public
ZiprUntypedOption_t
{
{
public:
public:
virtual
std
::
string
GetOutputFileName
(
libIRDB
::
File_t
*
p_file
)
=
0
;
using
ZiprUntypedOption_t
::
ZiprUntypedOption_t
;
virtual
std
::
string
GetCallbackFileName
()
=
0
;
void
SetValue
(
const
std
::
string
&
value
)
{
virtual
int
GetVariantID
()
=
0
;
m_set
=
true
;
virtual
int
GetVerbose
()
=
0
;
m_untyped_value
=
value
;
virtual
int
GetArchitecture
()
=
0
;
m_value
=
ConvertToTyped
(
value
);
virtual
std
::
string
GetObjcopyPath
()
=
0
;
SetObserverValues
(
value
);
}
virtual
void
Set
()
{
}
T
Value
()
const
{
return
m_value
;
}
operator
T
()
const
{
return
Value
();
};
bool
operator
==
(
const
T
&
r
)
{
return
Value
()
==
r
;
}
std
::
string
Description
()
final
{
return
std
::
string
(
m_key
+
":
\t
"
+
m_description
+
" ("
+
TypeName
()
+
", "
+
((
!
m_required
)
?
"not "
:
""
)
+
"required)"
);
}
protected
:
T
m_value
;
virtual
T
ConvertToTyped
(
std
::
string
)
=
0
;
virtual
std
::
string
ConvertToUntyped
(
T
)
=
0
;
virtual
std
::
string
TypeName
()
=
0
;
};
class
ZiprStringOption_t
:
public
ZiprTypedOption_t
<
std
::
string
>
{
public:
using
ZiprTypedOption_t
<
std
::
string
>::
ZiprTypedOption_t
;
ZiprStringOption_t
(
std
::
string
key
,
std
::
string
value
=
""
)
:
ZiprTypedOption_t
(
key
,
value
)
{
m_value
=
ConvertToTyped
(
value
);
}
protected
:
std
::
string
ConvertToTyped
(
std
::
string
value_to_convert
)
{
return
std
::
string
(
value_to_convert
);
}
std
::
string
ConvertToUntyped
(
std
::
string
value_to_convert
)
{
return
std
::
string
(
value_to_convert
);
}
std
::
string
TypeName
()
{
return
"string"
;
}
};
class
ZiprBooleanOption_t
:
public
ZiprTypedOption_t
<
bool
>
{
public:
ZiprBooleanOption_t
(
std
::
string
key
,
std
::
string
value
=
""
)
{
m_key
=
key
;
m_untyped_value
=
value
;
m_needs_value
=
false
;
}
ZiprBooleanOption_t
(
std
::
string
key
,
bool
value
)
:
ZiprBooleanOption_t
(
key
)
{
m_value
=
value
;
m_untyped_value
=
ConvertToUntyped
(
value
);
}
void
Set
()
{
m_untyped_value
=
"true"
;
m_value
=
true
;
m_set
=
true
;
SetObserverValues
(
m_untyped_value
);
}
private
:
bool
ConvertToTyped
(
std
::
string
value_to_convert
)
{
if
(
value_to_convert
==
"true"
)
return
true
;
else
return
false
;
}
std
::
string
ConvertToUntyped
(
bool
value_to_convert
)
{
return
(
value_to_convert
?
std
::
string
(
"true"
)
:
std
::
string
(
"false"
));
}
std
::
string
TypeName
()
{
return
"bool"
;
}
};
class
ZiprIntegerOption_t
:
public
ZiprTypedOption_t
<
int
>
{
public:
using
ZiprTypedOption_t
<
int
>::
ZiprTypedOption_t
;
ZiprIntegerOption_t
(
std
::
string
key
,
std
::
string
value
=
""
)
:
ZiprTypedOption_t
(
key
,
value
)
{
m_value
=
ConvertToTyped
(
value
);
}
ZiprIntegerOption_t
(
std
::
string
key
,
int
value
)
:
ZiprTypedOption_t
(
key
,
""
)
{
m_value
=
value
;
m_untyped_value
=
ConvertToUntyped
(
value
);
}
void
SetValue
(
int
value
)
{
std
::
set
<
ZiprUntypedOption_t
*>::
const_iterator
it
=
m_observers
.
begin
();
std
::
set
<
ZiprUntypedOption_t
*>::
const_iterator
it_end
=
m_observers
.
end
();
m_value
=
value
;
m_untyped_value
=
ConvertToUntyped
(
value
);
SetObserverValues
(
m_untyped_value
);
}
private
:
int
ConvertToTyped
(
std
::
string
value_to_convert
)
{
try
{
return
std
::
stoi
(
value_to_convert
);
}
catch
(
std
::
exception
&
e
)
{
m_set
=
false
;
m_untyped_value
=
""
;
return
0
;
}
}
std
::
string
ConvertToUntyped
(
int
value_to_convert
)
{
try
{
return
std
::
to_string
(
value_to_convert
);
}
catch
(
std
::
exception
&
e
)
{
return
std
::
string
(
""
);
}
}
std
::
string
TypeName
()
{
return
"integer"
;
}
};
class
ZiprOptionsNamespace_t
:
public
std
::
set
<
ZiprUntypedOption_t
*>
{
public:
ZiprOptionsNamespace_t
(
std
::
string
ns
)
:
m_namespace
(
ns
)
{}
std
::
string
Namespace
()
{
return
m_namespace
;
};
void
PrintNamespace
();
ZiprUntypedOption_t
*
OptionByKey
(
std
::
string
key
);
void
AddOption
(
ZiprUntypedOption_t
*
option
);
void
PrintUsage
(
int
tabs
,
std
::
ostream
&
out
);
bool
RequirementsMet
();
void
MergeNamespace
(
ZiprOptionsNamespace_t
*
);
private
:
std
::
string
m_namespace
;
};
class
ZiprOptions_t
{
public:
ZiprOptions_t
(
int
argc
,
char
**
argv
);
void
AddNamespace
(
ZiprOptionsNamespace_t
*
);
void
PrintNamespaces
();
bool
Parse
(
std
::
ostream
&
error
=
std
::
cout
,
std
::
ostream
&
warn
=
std
::
cerr
);
ZiprOptionsNamespace_t
*
Namespace
(
std
::
string
);
void
PrintUsage
(
std
::
ostream
&
out
);
bool
RequirementsMet
();
private:
std
::
vector
<
std
::
string
>
m_arguments
;
std
::
set
<
ZiprOptionsNamespace_t
*>
m_namespaces
;
};
};
}
}
...
...
This diff is collapsed.
Click to expand it.
include/zipr_plugin.h
+
4
−
1
View file @
11df218b
...
@@ -40,11 +40,14 @@ class ZiprPluginInterface_t
...
@@ -40,11 +40,14 @@ class ZiprPluginInterface_t
{
{
return
0
;
return
0
;
}
}
virtual
std
::
string
ToString
()
virtual
std
::
string
ToString
()
{
{
return
"NamelessPlugin"
;
return
"NamelessPlugin"
;
}
}
virtual
ZiprOptionsNamespace_t
*
RegisterOptions
(
ZiprOptionsNamespace_t
*
)
{
return
new
ZiprOptionsNamespace_t
(
""
);
}
};
};
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment