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
a3476266
Commit
a3476266
authored
Mar 24, 2011
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
working towards the future: a unified Value type, that stores a ScriptValueP
parent
54b10b19
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
85 additions
and
0 deletions
+85
-0
src/data/field.cpp
src/data/field.cpp
+67
-0
src/data/field.hpp
src/data/field.hpp
+18
-0
No files found.
src/data/field.cpp
View file @
a3476266
...
@@ -303,3 +303,70 @@ void mark_dependency_member(const IndexMap<FieldP,ValueP>& value, const String&
...
@@ -303,3 +303,70 @@ void mark_dependency_member(const IndexMap<FieldP,ValueP>& value, const String&
(
*
it
)
->
fieldP
->
dependent_scripts
.
add
(
dep
);
(
*
it
)
->
fieldP
->
dependent_scripts
.
add
(
dep
);
}
}
}
}
// ----------------------------------------------------------------------------- : AnyValue
ValueP
AnyValue
::
clone
()
const
{
return
intrusive
(
new
AnyValue
(
fieldP
,
value
));
}
String
AnyValue
::
toString
()
const
{
return
value
->
toString
();
}
void
AnyValue
::
reflect
(
GetDefaultMember
&
reflector
)
{
reflector
.
handle
(
value
);
}
void
AnyValue
::
reflect
(
GetMember
&
reflector
)
{
// nothing
}
ScriptValueP
parse_script_value
(
String
const
&
str
)
{
// possible values:
// * "quoted string" # a string
// * 123.456 # a number
// * fileref("quoted-string") # reference to a file in the set
// * rgb(123,123,123) # a color
// * nil # nil
// * true/false # a boolean
return
script_nil
;
}
void
AnyValue
::
reflect
(
Reader
&
reflector
)
{
if
(
reflector
.
formatVersion
()
<
200001
)
{
// in older versions, the format was based on the type of the field
Field
*
field
=
fieldP
.
get
();
if
(
dynamic_cast
<
BooleanField
*>
(
field
))
{
// boolean field: boolean "yes" or "no"
bool
x
;
reflector
.
handle
(
x
);
value
=
to_script
(
x
);
}
else
if
(
dynamic_cast
<
TextField
*>
(
field
)
||
dynamic_cast
<
ChoiceField
*>
(
field
))
{
// text, choice fields: string
String
str
;
reflector
.
handle
(
str
);
value
=
to_script
(
str
);
}
else
if
(
dynamic_cast
<
ColorField
*>
(
field
))
{
// color field: color
Color
x
;
reflector
.
handle
(
x
);
value
=
to_script
(
x
);
}
else
if
(
dynamic_cast
<
ImageField
*>
(
field
))
{
// image, symbol fields: string that is a filename in the set
String
str
;
reflector
.
handle
(
str
);
value
=
intrusive
(
new
ScriptLocalFileName
(
str
));
}
else
if
(
dynamic_cast
<
InfoField
*>
(
field
))
{
// this should never happen, since info fields were not saved
}
}
else
{
// in the new system, the type is stored in the file.
String
str
;
reflector
.
handle
(
str
);
value
=
parse_script_value
(
str
);
}
}
void
AnyValue
::
reflect
(
Writer
&
reflector
)
{
if
(
!
fieldP
->
save_value
)
return
;
// TODO
reflector
.
handle
(
value
->
toString
());
}
src/data/field.hpp
View file @
a3476266
...
@@ -306,5 +306,23 @@ inline String type_name(const Value&) {
...
@@ -306,5 +306,23 @@ inline String type_name(const Value&) {
void
mark_dependency_member
(
const
IndexMap
<
FieldP
,
ValueP
>&
value
,
const
String
&
name
,
const
Dependency
&
dep
);
void
mark_dependency_member
(
const
IndexMap
<
FieldP
,
ValueP
>&
value
,
const
String
&
name
,
const
Dependency
&
dep
);
// ----------------------------------------------------------------------------- : Value (new style)
/// A Value object that can hold something of 'any' type
class
AnyValue
:
public
Value
{
public:
inline
AnyValue
(
FieldP
const
&
field
,
ScriptValueP
const
&
value
=
script_nil
)
:
Value
(
field
),
value
(
value
)
{}
/// The actual value
ScriptValueP
value
;
virtual
ValueP
clone
()
const
;
virtual
String
toString
()
const
;
typedef
ScriptValueP
ValueType
;
DECLARE_REFLECTION_VIRTUAL
();
};
// ----------------------------------------------------------------------------- : EOF
// ----------------------------------------------------------------------------- : EOF
#endif
#endif
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