Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gmsh
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
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Larry Price
gmsh
Commits
06b0b0f2
Commit
06b0b0f2
authored
12 years ago
by
Christophe Geuzaine
Browse files
Options
Downloads
Patches
Plain Diff
make sure we don't call substr(..., 0)
parent
f48600e2
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
Common/onelab.h
+14
-3
14 additions, 3 deletions
Common/onelab.h
utils/solvers/c++/onelab.h
+24
-9
24 additions, 9 deletions
utils/solvers/c++/onelab.h
utils/solvers/c++/solver.cpp
+1
-1
1 addition, 1 deletion
utils/solvers/c++/solver.cpp
with
39 additions
and
13 deletions
Common/onelab.h
+
14
−
3
View file @
06b0b0f2
...
@@ -146,8 +146,19 @@ namespace onelab{
...
@@ -146,8 +146,19 @@ namespace onelab{
{
{
if
(
first
==
std
::
string
::
npos
)
return
""
;
if
(
first
==
std
::
string
::
npos
)
return
""
;
std
::
string
::
size_type
last
=
msg
.
find_first_of
(
separator
,
first
);
std
::
string
::
size_type
last
=
msg
.
find_first_of
(
separator
,
first
);
std
::
string
next
=
msg
.
substr
(
first
,
last
-
first
);
std
::
string
next
;
first
=
(
last
==
std
::
string
::
npos
)
?
last
:
last
+
1
;
if
(
last
==
std
::
string
::
npos
){
next
=
msg
.
substr
(
first
);
first
=
last
;
}
else
if
(
first
==
last
){
next
=
""
;
first
=
last
+
1
;
}
else
{
next
=
msg
.
substr
(
first
,
last
-
first
);
first
=
last
+
1
;
}
return
next
;
return
next
;
}
}
static
std
::
vector
<
std
::
string
>
split
(
const
std
::
string
&
msg
,
static
std
::
vector
<
std
::
string
>
split
(
const
std
::
string
&
msg
,
...
...
This diff is collapsed.
Click to expand it.
utils/solvers/c++/onelab.h
+
24
−
9
View file @
06b0b0f2
...
@@ -146,8 +146,19 @@ namespace onelab{
...
@@ -146,8 +146,19 @@ namespace onelab{
{
{
if
(
first
==
std
::
string
::
npos
)
return
""
;
if
(
first
==
std
::
string
::
npos
)
return
""
;
std
::
string
::
size_type
last
=
msg
.
find_first_of
(
separator
,
first
);
std
::
string
::
size_type
last
=
msg
.
find_first_of
(
separator
,
first
);
std
::
string
next
=
msg
.
substr
(
first
,
last
-
first
);
std
::
string
next
;
first
=
(
last
==
std
::
string
::
npos
)
?
last
:
last
+
1
;
if
(
last
==
std
::
string
::
npos
){
next
=
msg
.
substr
(
first
);
first
=
last
;
}
else
if
(
first
==
last
){
next
=
""
;
first
=
last
+
1
;
}
else
{
next
=
msg
.
substr
(
first
,
last
-
first
);
first
=
last
+
1
;
}
return
next
;
return
next
;
}
}
static
std
::
vector
<
std
::
string
>
split
(
const
std
::
string
&
msg
,
static
std
::
vector
<
std
::
string
>
split
(
const
std
::
string
&
msg
,
...
@@ -275,8 +286,8 @@ namespace onelab{
...
@@ -275,8 +286,8 @@ namespace onelab{
class
number
:
public
parameter
{
class
number
:
public
parameter
{
private:
private:
double
_value
,
_min
,
_max
,
_step
;
double
_value
,
_min
,
_max
,
_step
;
// when in a loop, indicates current index in the vector _choices;
is -1
// when in a loop, indicates current index in the vector _choices;
// when not in a loop
//
is -1
when not in a loop
int
_index
;
int
_index
;
std
::
vector
<
double
>
_choices
;
std
::
vector
<
double
>
_choices
;
std
::
map
<
double
,
std
::
string
>
_valueLabels
;
std
::
map
<
double
,
std
::
string
>
_valueLabels
;
...
@@ -284,7 +295,7 @@ namespace onelab{
...
@@ -284,7 +295,7 @@ namespace onelab{
number
(
const
std
::
string
&
name
=
""
,
double
value
=
0.
,
number
(
const
std
::
string
&
name
=
""
,
double
value
=
0.
,
const
std
::
string
&
label
=
""
,
const
std
::
string
&
help
=
""
)
const
std
::
string
&
label
=
""
,
const
std
::
string
&
help
=
""
)
:
parameter
(
name
,
label
,
help
),
_value
(
value
),
:
parameter
(
name
,
label
,
help
),
_value
(
value
),
_min
(
-
maxNumber
()),
_max
(
maxNumber
()),
_step
(
0.
),
_index
(
0
)
{}
_min
(
-
maxNumber
()),
_max
(
maxNumber
()),
_step
(
0.
),
_index
(
-
1
)
{}
void
setValue
(
double
value
){
_value
=
value
;
}
void
setValue
(
double
value
){
_value
=
value
;
}
void
setMin
(
double
min
){
_min
=
min
;
}
void
setMin
(
double
min
){
_min
=
min
;
}
void
setMax
(
double
max
){
_max
=
max
;
}
void
setMax
(
double
max
){
_max
=
max
;
}
...
@@ -383,9 +394,10 @@ namespace onelab{
...
@@ -383,9 +394,10 @@ namespace onelab{
// The string class. A string has a mutable "kind": we do not derive
// The string class. A string has a mutable "kind": we do not derive
// specialized classes, because the kind should be changeable at runtime
// specialized classes, because the kind should be changeable at runtime
// (e.g. from a client-dependent mathematical expression to a table of
// (e.g. from a client-dependent mathematical expression to a table of
// values). Kinds currently recognized by Gmsh are: "file". Possible kinds
// values). Kinds currently recognized by Gmsh are: "file". Possible
// could be "complex", "matrix m n", "hostname", client-dependent mathematical
// kinds could be "complex", "matrix m n", "hostname", client-dependent
// expression, onelab mathematical expression (through mathex?), ...
// mathematical expression, onelab mathematical expression (through mathex?),
// ...
class
string
:
public
parameter
{
class
string
:
public
parameter
{
private:
private:
std
::
string
_value
,
_kind
;
std
::
string
_value
,
_kind
;
...
@@ -944,7 +956,10 @@ namespace onelab{
...
@@ -944,7 +956,10 @@ namespace onelab{
{
{
server
::
instance
()
->
registerClient
(
this
);
server
::
instance
()
->
registerClient
(
this
);
}
}
virtual
~
localClient
(){}
virtual
~
localClient
()
{
server
::
instance
()
->
unregisterClient
(
this
);
}
virtual
bool
set
(
const
number
&
p
){
return
_set
(
p
);
}
virtual
bool
set
(
const
number
&
p
){
return
_set
(
p
);
}
virtual
bool
set
(
const
string
&
p
){
return
_set
(
p
);
}
virtual
bool
set
(
const
string
&
p
){
return
_set
(
p
);
}
virtual
bool
set
(
const
function
&
p
){
return
_set
(
p
);
}
virtual
bool
set
(
const
function
&
p
){
return
_set
(
p
);
}
...
...
This diff is collapsed.
Click to expand it.
utils/solvers/c++/solver.cpp
+
1
−
1
View file @
06b0b0f2
...
@@ -28,7 +28,7 @@ int main(int argc, char **argv)
...
@@ -28,7 +28,7 @@ int main(int argc, char **argv)
std
::
vector
<
onelab
::
string
>
strings
;
std
::
vector
<
onelab
::
string
>
strings
;
// try to get the string variable "My
solver/My
string" from the server
// try to get the string variable "My string" from the server
client
->
get
(
strings
,
"My string"
);
client
->
get
(
strings
,
"My string"
);
if
(
strings
.
size
()){
if
(
strings
.
size
()){
std
::
cout
<<
"Got string from server: '"
<<
strings
[
0
].
getValue
()
<<
"'
\n
"
;
std
::
cout
<<
"Got string from server: '"
<<
strings
[
0
].
getValue
()
<<
"'
\n
"
;
...
...
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