Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
magicseteditor
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
magicseteditor
Commits
d7f6c320
Commit
d7f6c320
authored
Aug 02, 2010
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slightly better error messages when reading an enum value fails: also report the default used
parent
a642b71a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
16 deletions
+25
-16
src/resource/common/expected_locale_keys
src/resource/common/expected_locale_keys
+3
-3
src/util/io/reader.cpp
src/util/io/reader.cpp
+8
-2
src/util/io/reader.hpp
src/util/io/reader.hpp
+14
-11
No files found.
src/resource/common/expected_locale_keys
View file @
d7f6c320
#
This
file
contains
the
keys
expected
to
be
in
MSE
locales
#
This
file
contains
the
keys
expected
to
be
in
MSE
locales
#
It
was
automatically
generated
by
tools
/
locale
/
locale
.
pl
#
It
was
automatically
generated
by
tools
/
locale
/
locale
.
pl
#
Generated
on
Sun
Jan
11
17
:
40
:
25
2009
#
Generated
on
Mon
Aug
2
23
:
18
:
19
2010
action
:
action
:
add
control
point
:
0
add
control
point
:
0
...
@@ -84,10 +84,10 @@ button:
...
@@ -84,10 +84,10 @@ button:
select all: 0
select all: 0
select cards: 0
select cards: 0
select none: 0
select none: 0
spellcheck enabled: 0
show: 0
show: 0
show editing hints: 0
show editing hints: 0
show lines: 0
show lines: 0
spellcheck enabled: 0
symbol gallery: optional, 0
symbol gallery: optional, 0
upgrade group: optional, 0
upgrade group: optional, 0
upgrade package: 0
upgrade package: 0
...
@@ -137,7 +137,7 @@ error:
...
@@ -137,7 +137,7 @@ error:
successful
install
:
optional
,
2
successful
install
:
optional
,
2
unable
to
open
output
file
:
0
unable
to
open
output
file
:
0
unable
to
store
file
:
0
unable
to
store
file
:
0
unrecognized
value
:
1
unrecognized
value
:
2
unsupported
field
type
:
1
unsupported
field
type
:
1
unsupported
fill
type
:
1
unsupported
fill
type
:
1
unsupported
format
:
1
unsupported
format
:
1
...
...
src/util/io/reader.cpp
View file @
d7f6c320
...
@@ -429,14 +429,20 @@ template <> void Reader::handle(FileName& f) {
...
@@ -429,14 +429,20 @@ template <> void Reader::handle(FileName& f) {
// ----------------------------------------------------------------------------- : EnumReader
// ----------------------------------------------------------------------------- : EnumReader
String
EnumReader
::
notDoneErrorMessage
()
const
{
if
(
!
first
)
throw
InternalError
(
_
(
"No first value in EnumReader"
));
return
_ERROR_2_
(
"unrecognized value"
,
read
,
first
);
}
void
EnumReader
::
warnIfNotDone
(
Reader
*
errors_to
)
{
void
EnumReader
::
warnIfNotDone
(
Reader
*
errors_to
)
{
if
(
!
done
)
{
if
(
!
done
)
{
// warning: unknown value
// warning: unknown value
errors_to
->
warning
(
_ERROR_1_
(
"unrecognized value"
,
read
));
errors_to
->
warning
(
notDoneErrorMessage
(
));
}
}
}
}
void
EnumReader
::
errorIfNotDone
()
{
void
EnumReader
::
errorIfNotDone
()
{
if
(
!
done
)
{
if
(
!
done
)
{
throw
ParseError
(
_ERROR_1_
(
"unrecognized value"
,
read
));
throw
ParseError
(
notDoneErrorMessage
(
));
}
}
}
}
src/util/io/reader.hpp
View file @
d7f6c320
...
@@ -268,18 +268,19 @@ void Reader::handle(IndexMap<K,V>& m) {
...
@@ -268,18 +268,19 @@ void Reader::handle(IndexMap<K,V>& m) {
class
EnumReader
{
class
EnumReader
{
public:
public:
inline
EnumReader
(
String
read
)
inline
EnumReader
(
String
read
)
:
read
(
read
),
first
(
true
),
done
(
false
)
{}
:
read
(
read
),
first
(
nullptr
),
done
(
false
)
{}
/// Handle a possible value for the enum, if the name matches the name in the input
/// Handle a possible value for the enum, if the name matches the name in the input
template
<
typename
Enum
>
template
<
typename
Enum
>
inline
void
handle
(
const
Char
*
name
,
Enum
value
,
Enum
&
enum_
)
{
inline
void
handle
(
const
Char
*
name
,
Enum
value
,
Enum
&
enum_
)
{
if
(
!
done
&&
read
==
name
)
{
if
(
!
done
)
{
done
=
true
;
if
(
read
==
name
)
{
first
=
false
;
done
=
true
;
enum_
=
value
;
enum_
=
value
;
}
else
if
(
first
)
{
}
else
if
(
!
first
)
{
first
=
false
;
first
=
name
;
enum_
=
value
;
enum_
=
value
;
}
}
}
}
}
...
@@ -288,9 +289,11 @@ class EnumReader {
...
@@ -288,9 +289,11 @@ class EnumReader {
void
errorIfNotDone
();
void
errorIfNotDone
();
private:
private:
String
read
;
///< The string to match to a value name
String
read
;
///< The string to match to a value name
bool
first
;
///< Has the first (default) value been matched?
Char
const
*
first
;
///< Has the first (default) value been handled? If so, what is its name.
bool
done
;
///< Was anything matched?
bool
done
;
///< Was anything matched?
String
notDoneErrorMessage
()
const
;
};
};
// ----------------------------------------------------------------------------- : EOF
// ----------------------------------------------------------------------------- : EOF
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment