Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
illuna-minetest
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
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
Illuna-Minetest
illuna-minetest
Commits
a4393438
Commit
a4393438
authored
11 years ago
by
kwolekr
Browse files
Options
Downloads
Patches
Plain Diff
Settings: Add no-exception variants of each get method
parent
458045d4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/settings.h
+123
-4
123 additions, 4 deletions
src/settings.h
with
123 additions
and
4 deletions
src/settings.h
+
123
−
4
View file @
a4393438
...
...
@@ -467,6 +467,7 @@ class Settings
return
n
->
second
;
}
//////////// Get setting
bool
getBool
(
std
::
string
name
)
{
return
is_yes
(
get
(
name
));
...
...
@@ -581,13 +582,19 @@ class Settings
{
size_t
len
=
olen
;
std
::
vector
<
std
::
string
*>
strs_alloced
;
std
::
string
*
str
;
std
::
string
valstr
=
get
(
name
);
std
::
string
*
str
,
valstr
;
char
*
f
,
*
snext
;
size_t
pos
;
try
{
valstr
=
get
(
name
);
}
catch
(
SettingNotFoundException
&
e
)
{
return
false
;
}
char
*
s
=
&
valstr
[
0
];
char
*
buf
=
new
char
[
len
];
char
*
bufpos
=
buf
;
char
*
f
,
*
snext
;
size_t
pos
;
char
*
fmtpos
,
*
fmt
=
&
format
[
0
];
while
((
f
=
strtok_r
(
fmt
,
","
,
&
fmtpos
))
&&
s
)
{
...
...
@@ -737,6 +744,118 @@ class Settings
return
true
;
}
//////////// Try to get value, no exception thrown
bool
tryGet
(
std
::
string
name
,
std
::
string
&
val
)
{
try
{
val
=
get
(
name
);
return
true
;
}
catch
(
SettingNotFoundException
&
e
)
{
return
false
;
}
}
bool
tryGetFlagStr
(
std
::
string
name
,
u32
&
val
,
FlagDesc
*
flagdesc
)
{
try
{
val
=
getFlagStr
(
name
,
flagdesc
);
return
true
;
}
catch
(
SettingNotFoundException
&
e
)
{
return
false
;
}
}
bool
tryGetFloat
(
std
::
string
name
,
float
&
val
)
{
try
{
val
=
getFloat
(
name
);
return
true
;
}
catch
(
SettingNotFoundException
&
e
)
{
return
false
;
}
}
bool
tryGetU16
(
std
::
string
name
,
int
&
val
)
{
try
{
val
=
getU16
(
name
);
return
true
;
}
catch
(
SettingNotFoundException
&
e
)
{
return
false
;
}
}
bool
tryGetU16
(
std
::
string
name
,
u16
&
val
)
{
try
{
val
=
getU16
(
name
);
return
true
;
}
catch
(
SettingNotFoundException
&
e
)
{
return
false
;
}
}
bool
tryGetS16
(
std
::
string
name
,
int
&
val
)
{
try
{
val
=
getU16
(
name
);
return
true
;
}
catch
(
SettingNotFoundException
&
e
)
{
return
false
;
}
}
bool
tryGetS16
(
std
::
string
name
,
s16
&
val
)
{
try
{
val
=
getS16
(
name
);
return
true
;
}
catch
(
SettingNotFoundException
&
e
)
{
return
false
;
}
}
bool
tryGetS32
(
std
::
string
name
,
s32
&
val
)
{
try
{
val
=
getS32
(
name
);
return
true
;
}
catch
(
SettingNotFoundException
&
e
)
{
return
false
;
}
}
bool
tryGetV3F
(
std
::
string
name
,
v3f
&
val
)
{
try
{
val
=
getV3F
(
name
);
return
true
;
}
catch
(
SettingNotFoundException
&
e
)
{
return
false
;
}
}
bool
tryGetV2F
(
std
::
string
name
,
v2f
&
val
)
{
try
{
val
=
getV2F
(
name
);
return
true
;
}
catch
(
SettingNotFoundException
&
e
)
{
return
false
;
}
}
bool
tryGetU64
(
std
::
string
name
,
u64
&
val
)
{
try
{
val
=
getU64
(
name
);
return
true
;
}
catch
(
SettingNotFoundException
&
e
)
{
return
false
;
}
}
//////////// Set setting
bool
setStruct
(
std
::
string
name
,
std
::
string
format
,
void
*
value
)
{
char
sbuf
[
2048
];
...
...
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