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
f1193df0
Commit
f1193df0
authored
Oct 19, 2006
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added support for std::map
parent
5aba8834
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
0 deletions
+24
-0
src/script/value.hpp
src/script/value.hpp
+24
-0
No files found.
src/script/value.hpp
View file @
f1193df0
...
@@ -170,6 +170,28 @@ class ScriptCollection : public ScriptValue {
...
@@ -170,6 +170,28 @@ class ScriptCollection : public ScriptValue {
const
Collection
*
value
;
const
Collection
*
value
;
};
};
// ----------------------------------------------------------------------------- : Collections : maps
/// Script value containing a map like collection
template
<
typename
Collection
>
class
ScriptMap
:
public
ScriptValue
{
public:
inline
ScriptMap
(
const
Collection
*
v
)
:
value
(
v
)
{}
virtual
ScriptType
type
()
const
{
return
SCRIPT_OBJECT
;
}
virtual
String
typeName
()
const
{
return
_
(
"collection"
);
}
virtual
ScriptValueP
getMember
(
const
String
&
name
)
const
{
Collection
::
const_iterator
it
=
value
->
find
(
name
);
if
(
it
!=
value
->
end
())
{
return
toScript
(
it
->
second
);
}
else
{
throw
ScriptError
(
_
(
"Collection has no member "
)
+
name
);
}
}
private:
/// Store a pointer to a collection, collections are only ever used for structures owned outside the script
const
Collection
*
value
;
};
// ----------------------------------------------------------------------------- : Objects
// ----------------------------------------------------------------------------- : Objects
/// Script value containing an object (pointer)
/// Script value containing an object (pointer)
...
@@ -199,6 +221,8 @@ ScriptValueP toScript(const Color& v);
...
@@ -199,6 +221,8 @@ ScriptValueP toScript(const Color& v);
inline
ScriptValueP
toScript
(
bool
v
)
{
return
v
?
script_true
:
script_false
;
}
inline
ScriptValueP
toScript
(
bool
v
)
{
return
v
?
script_true
:
script_false
;
}
template
<
typename
T
>
template
<
typename
T
>
inline
ScriptValueP
toScript
(
const
vector
<
T
>*
v
)
{
return
new_intrusive1
<
ScriptCollection
<
vector
<
T
>
>
>
(
v
);
}
inline
ScriptValueP
toScript
(
const
vector
<
T
>*
v
)
{
return
new_intrusive1
<
ScriptCollection
<
vector
<
T
>
>
>
(
v
);
}
template
<
typename
K
,
typename
V
>
inline
ScriptValueP
toScript
(
const
map
<
K
,
V
>*
v
)
{
return
new_intrusive1
<
ScriptMap
<
map
<
K
,
V
>
>
>
(
v
);
}
template
<
typename
T
>
template
<
typename
T
>
inline
ScriptValueP
toScript
(
const
shared_ptr
<
T
>&
v
)
{
return
new_intrusive1
<
ScriptObject
<
T
>
>
(
v
);
}
inline
ScriptValueP
toScript
(
const
shared_ptr
<
T
>&
v
)
{
return
new_intrusive1
<
ScriptObject
<
T
>
>
(
v
);
}
...
...
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