Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
Niflib
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
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Grant Kim
Niflib
Commits
ca6ed9cb
Commit
ca6ed9cb
authored
18 years ago
by
Shon Ferguson
Browse files
Options
Downloads
Patches
Plain Diff
Implemented NiObject::Clone.
parent
abffe318
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
obj/NiObject.cpp
+25
-2
25 additions, 2 deletions
obj/NiObject.cpp
obj/NiObject.h
+1
-1
1 addition, 1 deletion
obj/NiObject.h
with
26 additions
and
3 deletions
obj/NiObject.cpp
+
25
−
2
View file @
ca6ed9cb
...
...
@@ -2,6 +2,7 @@
All rights reserved. Please see niflib.h for licence. */
#include
"NiObject.h"
#include
"niflib.h"
using
namespace
Niflib
;
//Definition of TYPE constant
...
...
@@ -64,6 +65,28 @@ string NiObject::GetIDString() {
return
out
.
str
();
}
NiObjectRef
NiObject
::
Clone
(
unsigned
int
version
)
{
throw
runtime_error
(
"Cloning not yet implemented."
);
NiObjectRef
NiObject
::
Clone
(
unsigned
int
version
,
unsigned
int
user_version
)
{
//Create a string stream to temporarily hold the state-save of this block
stringstream
tmp
;
//Create a new object of the same type
NiObjectRef
clone
=
CreateBlock
(
this
->
GetType
().
GetTypeName
()
);
//Dummy map
map
<
NiObjectRef
,
uint
>
link_map
;
//Write this object's data to the stream
this
->
Write
(
tmp
,
link_map
,
version
,
user_version
);
//Dummy stack
list
<
uint
>
link_stack
;
//Read the data back from the stream into the clone
clone
->
Read
(
tmp
,
link_stack
,
version
,
user_version
);
//We don't fix the links, causing the clone to be a copy of all
//data but have none of the linkage of the original.
//return new object
return
clone
;
};
This diff is collapsed.
Click to expand it.
obj/NiObject.h
+
1
−
1
View file @
ca6ed9cb
...
...
@@ -79,7 +79,7 @@ public:
* \return A cloned copy of this block as a new block.
* \sa CreateBlock
*/
NIFLIB_API
NiObjectRef
Clone
(
unsigned
int
version
=
0xFFFFFFFF
);
NIFLIB_API
NiObjectRef
Clone
(
unsigned
int
version
=
0xFFFFFFFF
,
unsigned
int
user_version
=
0
);
/*!
* Summarizes the information contained in this block in English.
...
...
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