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
fac1bf45
Commit
fac1bf45
authored
9 years ago
by
whh8b
Browse files
Options
Downloads
Patches
Plain Diff
Go away from anything C++11 related.
parent
95759446
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/zipr_options.h
+34
-25
34 additions, 25 deletions
include/zipr_options.h
include/zipr_plugin.h
+1
-1
1 addition, 1 deletion
include/zipr_plugin.h
with
35 additions
and
26 deletions
include/zipr_options.h
+
34
−
25
View file @
fac1bf45
...
...
@@ -35,6 +35,7 @@
#include
<unistd.h>
#include
<libIRDB-core.hpp>
#include
<iostream>
#include
<sstream>
namespace
Zipr_SDK
{
...
...
@@ -50,6 +51,7 @@ enum ZiprOptionType {
class
ZiprOption_t
{
public:
/*
ZiprOption_t(ZiprOptionType type)
: m_key(""),
m_untyped_value(""),
...
...
@@ -59,6 +61,7 @@ class ZiprOption_t
m_required(false),
m_set(false),
m_option_type(type) {};
*/
ZiprOption_t
(
ZiprOptionType
type
,
std
::
string
key
,
std
::
string
value
)
:
m_key
(
key
),
m_untyped_value
(
value
),
...
...
@@ -138,7 +141,10 @@ template <typename T>
class
ZiprTypedOption_t
:
public
ZiprOption_t
{
public:
using
ZiprOption_t
::
ZiprOption_t
;
ZiprTypedOption_t
(
ZiprOptionType
type
,
std
::
string
key
,
std
::
string
value
)
:
ZiprOption_t
(
type
,
key
,
value
)
{}
void
SetValue
(
const
std
::
string
&
value
)
{
m_set
=
true
;
m_untyped_value
=
value
;
...
...
@@ -180,7 +186,10 @@ template <class T>
class
ZiprCompositeOption_t
:
public
ZiprTypedOption_t
<
T
>
,
public
T
{
public:
using
ZiprTypedOption_t
<
T
>::
ZiprTypedOption_t
;
ZiprCompositeOption_t
(
ZiprOptionType
type
,
std
::
string
key
,
std
::
string
value
)
:
ZiprTypedOption_t
<
T
>
(
type
,
key
,
value
)
{}
using
ZiprTypedOption_t
<
T
>::
ConvertToTyped
;
void
SetValue
(
const
std
::
string
&
value
)
{
ZiprTypedOption_t
<
T
>::
SetValue
(
value
);
...
...
@@ -191,7 +200,6 @@ class ZiprCompositeOption_t : public ZiprTypedOption_t<T>, public T
class
ZiprStringOption_t
:
public
ZiprCompositeOption_t
<
std
::
string
>
{
public:
using
ZiprCompositeOption_t
<
std
::
string
>::
ZiprTypedOption_t
;
ZiprStringOption_t
(
std
::
string
key
,
std
::
string
value
=
""
)
:
ZiprCompositeOption_t
(
ZiprStringOptionType
,
key
,
value
)
{
SetValue
(
value
);
...
...
@@ -211,7 +219,6 @@ class ZiprStringOption_t : public ZiprCompositeOption_t<std::string>
class
ZiprBooleanOption_t
:
public
ZiprTypedOption_t
<
bool
>
{
public:
using
ZiprTypedOption_t
<
bool
>::
ZiprTypedOption_t
;
ZiprBooleanOption_t
(
std
::
string
key
,
std
::
string
value
=
""
)
:
ZiprTypedOption_t
(
ZiprBooleanOptionType
,
key
,
value
)
{
m_key
=
key
;
...
...
@@ -219,7 +226,7 @@ class ZiprBooleanOption_t : public ZiprTypedOption_t<bool>
m_needs_value
=
false
;
}
ZiprBooleanOption_t
(
std
::
string
key
,
bool
value
)
:
Zipr
BooleanOption_t
(
key
)
{
:
Zipr
TypedOption_t
(
ZiprBooleanOptionType
,
key
,
""
)
{
m_value
=
value
;
m_untyped_value
=
ConvertToUntyped
(
value
);
}
...
...
@@ -247,13 +254,12 @@ class ZiprBooleanOption_t : public ZiprTypedOption_t<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
(
ZiprIntegerOptionType
,
key
,
value
)
{
m_value
=
ConvertToTyped
(
value
);
}
ZiprIntegerOption_t
(
std
::
string
key
,
int
value
)
:
ZiprIntegerOption
_t
(
key
,
""
)
{
:
ZiprTypedOption_t
(
ZiprIntegerOption
Type
,
key
,
""
)
{
m_value
=
value
;
m_untyped_value
=
ConvertToUntyped
(
value
);
}
...
...
@@ -263,20 +269,22 @@ class ZiprIntegerOption_t : public ZiprTypedOption_t<int>
}
private
:
int
ConvertToTyped
(
std
::
string
value_to_convert
)
{
try
{
return
std
::
stoi
(
value_to_convert
);
}
catch
(
std
::
exception
&
e
)
{
int
converted
=
0
;
char
*
endptr
=
NULL
;
converted
=
strtol
(
value_to_convert
.
c_str
(),
&
endptr
,
10
);
if
(
*
endptr
!=
'\0'
)
{
m_set
=
false
;
m_untyped_value
=
""
;
return
0
;
}
return
converted
;
}
std
::
string
ConvertToUntyped
(
int
value_to_convert
)
{
try
{
return
std
::
to_string
(
value_to_convert
);
}
catch
(
std
::
exception
&
e
)
{
return
std
::
string
(
""
);
}
std
::
stringstream
ss
;
ss
<<
value_to_convert
;
return
ss
.
str
();
}
std
::
string
TypeName
()
{
return
"integer"
;
...
...
@@ -286,13 +294,12 @@ class ZiprIntegerOption_t : public ZiprTypedOption_t<int>
class
ZiprDoubleOption_t
:
public
ZiprTypedOption_t
<
double
>
{
public:
using
ZiprTypedOption_t
<
double
>::
ZiprTypedOption_t
;
ZiprDoubleOption_t
(
std
::
string
key
,
std
::
string
value
=
""
)
:
ZiprTypedOption_t
(
ZiprDoubleOptionType
,
key
,
value
)
{
m_value
=
ConvertToTyped
(
value
);
}
ZiprDoubleOption_t
(
std
::
string
key
,
double
value
)
:
ZiprDoubleOption
_t
(
key
,
""
)
{
:
ZiprTypedOption_t
(
ZiprDoubleOption
Type
,
key
,
""
)
{
m_value
=
value
;
m_untyped_value
=
ConvertToUntyped
(
value
);
}
...
...
@@ -302,20 +309,22 @@ class ZiprDoubleOption_t : public ZiprTypedOption_t<double>
}
private
:
double
ConvertToTyped
(
std
::
string
value_to_convert
)
{
try
{
return
(
double
)
std
::
stof
(
value_to_convert
);
}
catch
(
std
::
exception
&
e
)
{
double
converted
=
0.
;
char
*
endptr
=
NULL
;
converted
=
strtof
(
value_to_convert
.
c_str
(),
&
endptr
);
if
(
*
endptr
!=
'\0'
)
{
m_set
=
false
;
m_untyped_value
=
""
;
return
0
;
}
return
converted
;
}
std
::
string
ConvertToUntyped
(
double
value_to_convert
)
{
try
{
return
std
::
to_string
(
value_to_convert
);
}
catch
(
std
::
exception
&
e
)
{
return
std
::
string
(
""
);
}
std
::
stringstream
ss
;
ss
<<
value_to_convert
;
return
ss
.
str
();
}
std
::
string
TypeName
()
{
return
"double"
;
...
...
This diff is collapsed.
Click to expand it.
include/zipr_plugin.h
+
1
−
1
View file @
fac1bf45
...
...
@@ -34,7 +34,7 @@ class ZiprPluginInterface_t
virtual
ZiprPreference
PlopAddress
(
const
RangeAddress_t
&
jump
,
const
Dollop_t
&
dollop
,
Range_t
&
place
)
{
return
ZiprPreference
::
None
;
return
None
;
}
virtual
bool
WillPluginPlop
(
libIRDB
::
Instruction_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