Skip to content

Commit

Permalink
gff: added GffValue.dup
Browse files Browse the repository at this point in the history
  • Loading branch information
CromFr committed Oct 31, 2023
1 parent 0c476c8 commit b63354d
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions source/nwn/gff.d
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,22 @@ struct GffValue {
return value.get!GffList[index] = rhs;
}

/// Duplicates the GFF value
GffValue dup() const {
JSONValue ret;
final switch(type) with(GffType) {
case Byte, Char, Word, Short, DWord, Int, DWord64, Int64, Float, Double:
return this;
case String: return GffValue(cast(GffString)get!GffString().dup());
case ResRef: return GffValue(cast(GffResRef)get!GffResRef().dup());
case LocString: return GffValue(get!GffLocString().dup());
case Void: return GffValue(get!GffVoid().dup());
case Struct: return GffValue(get!GffStruct().dup());
case List: return GffValue(get!GffList().dup());
case Invalid: assert(0, "No type set");
}
}

/// Converts the stored value into the given type
T to(T)() const {
final switch(type) with(GffType) {
Expand Down

0 comments on commit b63354d

Please sign in to comment.