diff --git a/NIF_Blocks.h b/NIF_Blocks.h index 1957d3a9381a543a078417ea4c825c852cad8421..ddbbd3e8e9615f06c1bb9d8f03692b62da6e91d6 100644 --- a/NIF_Blocks.h +++ b/NIF_Blocks.h @@ -149,7 +149,7 @@ public: index = new_index; } - blk_ref GetLink() { return link; } + blk_ref GetLink() const { return link; } diff --git a/NIF_IO.cpp b/NIF_IO.cpp index e145d6db874330bcd49330fc65207d1e208deb6f..15075a779d561a2ca5ecf143e8203f5dc039104c 100644 --- a/NIF_IO.cpp +++ b/NIF_IO.cpp @@ -315,6 +315,32 @@ void NifStream( float const & val, ostream& out, uint version ) { WriteFloat( va void NifStream( string & val, istream& in, uint version ) { val = ReadString( in ); }; void NifStream( string const & val, ostream& out, uint version ) { WriteString( val, out ); } +//--Link Types--// + +//There is intentionally no function to read directly to blk_ref + +void NifStream( blk_ref const & val, ostream& out, uint version ) { + if ( val.is_null() == false ) { + WriteInt( val->GetBlockNum(), out ); + } else { + WriteInt(-1, out ); + } +} + +//There is intentionally no function to read directly to IBlock * + +void NifStream( IBlock * const & val, ostream& out, uint version ) { + if ( val != NULL ) { + WriteInt( val->GetBlockNum(), out ); + } else { + WriteInt( -1, out ); + } +} + +ostream & operator<<( ostream & out, IBlock * const & val ) { + return out << blk_ref(val); +} + //--Structs--// //HeaderString @@ -856,24 +882,6 @@ ostream & operator<<( ostream & out, PixelLayout const & val ) { }; } -//!!!REMOVE THIS LATER!!!// -void NifStream( IBlock * val, istream& in, uint version ) { - int n; - in.read( (char*)&n, 4 ); - val = 0; // TODO: do something with that n, something like this: - //if ( n == -1 ) - // val = 0; - //else - // val = blk_ref(n); - // BUT: block n may not have been processed yet, so we can't return a pointer... ? they will have to be - // resolved when calling FixLinks()? -}; - -void NifStream( IBlock const * const val, ostream& out, uint version ) { - NifStream( val->GetBlockNum(), out, version ); -}; -//!!!REMOVE THIS LATER!!!// - //The HexString function creates a formatted hex display of the given data for use in printing //a debug string for information that is not understood string HexString( const byte * src, uint len ) { diff --git a/NIF_IO.h b/NIF_IO.h index 85c7d881ddaf55f62b59502c84c455e905cb5c80..1f9da5d648c6b1986dba31a8585795981ff9332a 100644 --- a/NIF_IO.h +++ b/NIF_IO.h @@ -138,6 +138,18 @@ void NifStream( float const & val, ostream& out, uint version = 0 ); void NifStream( string & val, istream& in, uint version = 0 ); void NifStream( string const & val, ostream& out, uint version = 0 ); +//--Link Types--// + +//blk_ref +//There is intentionally no function to read directly to blk_ref +void NifStream( blk_ref const & val, ostream& out, uint version ); +ostream & operator<<( ostream & out, blk_ref const & val ); + +//IBlock * +//There is intentionally no function to read directly to IBlock * +void NifStream( IBlock * const & val, ostream& out, uint version ); +ostream & operator<<( ostream & out, IBlock * const & val ); + //--Structs--// //HeaderString @@ -269,11 +281,6 @@ void NifStream( PixelLayout & val, istream& in, uint version = 0 ); void NifStream( PixelLayout const & val, ostream& out, uint version = 0 ); ostream & operator<<( ostream & out, PixelLayout const & val ); -//!!!REMOVE THIS LATER!!!// -void NifStream( IBlock * val, istream& in, uint version = 0 ); -void NifStream( IBlock const * const val, ostream& out, uint version = 0 ); -//!!!REMOVE THIS LATER!!!// - //--Templates--// //Key<T>