From da990b2966d7c881acb5e336e2810c62f6f263ad Mon Sep 17 00:00:00 2001
From: Shon Ferguson <shonferg@users.sourceforge.net>
Date: Sat, 3 Jun 2006 22:02:24 +0000
Subject: [PATCH] Created new GetIDString function for Ref's << operator to
 call.

---
 Ref.h               | 2 +-
 obj/NiObject.cpp    | 6 ++++++
 obj/NiObject.h      | 3 +++
 obj/NiObjectNET.cpp | 7 +++++++
 obj/NiObjectNET.h   | 2 ++
 5 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/Ref.h b/Ref.h
index 88a0ccd3..4e7b6d9a 100644
--- a/Ref.h
+++ b/Ref.h
@@ -153,7 +153,7 @@ bool Ref<T>::operator!=(const Ref & ref) const {
 template <class T>
 ostream & operator<<(ostream & os, const Ref<T> & ref) {
 	if (ref._object)
-		os << ref._object << "(" << ref._object->GetType().GetTypeName() << ")";
+		os << ref->GetIDString();
 	else
 		os << "NULL";
 	return os;
diff --git a/obj/NiObject.cpp b/obj/NiObject.cpp
index 1355b011..781a52e5 100644
--- a/obj/NiObject.cpp
+++ b/obj/NiObject.cpp
@@ -58,3 +58,9 @@ list<NiObjectRef> NiObject::GetLinks() {
 	return list<NiObjectRef>();
 }
 
+/*! Used to format a human readable string that includes the type of the object */
+string NiObject::GetIDString() {
+	stringstream out;
+	out << this << "(" << this->GetType().GetTypeName() << ")";
+	return out.str();
+}
\ No newline at end of file
diff --git a/obj/NiObject.h b/obj/NiObject.h
index ecea0262..1814d39e 100644
--- a/obj/NiObject.h
+++ b/obj/NiObject.h
@@ -100,6 +100,9 @@ public:
 	 */
 	virtual string asString( bool verbose = false ) const;
 
+	/*! Formats a human readable string that includes the type of the object */
+	virtual string GetIDString();
+
 	/*!
 	 * Used to retrieve all blocks that the current block is linked to through <i>all</i> attributes.
 	 * \return A list of references to blocks that this attribute links its owner block to.
diff --git a/obj/NiObjectNET.cpp b/obj/NiObjectNET.cpp
index 8ee93091..03fec1cd 100644
--- a/obj/NiObjectNET.cpp
+++ b/obj/NiObjectNET.cpp
@@ -36,3 +36,10 @@ void NiObjectNET::SetName( string & new_name ) {
 	name = new_name;
 }
 
+/*! Used to format a human readable string that includes the type of the object */
+string NiObjectNET::GetIDString() {
+	stringstream out;
+	out << NiObject::GetIDString() << " {" << name << "}";
+	return out.str();
+}
+
diff --git a/obj/NiObjectNET.h b/obj/NiObjectNET.h
index 52f701ac..1d8753ec 100644
--- a/obj/NiObjectNET.h
+++ b/obj/NiObjectNET.h
@@ -28,6 +28,8 @@ public:
 	virtual void Read( istream& in, list<uint> & link_stack, unsigned int version );
 	virtual void Write( ostream& out, map<NiObjectRef,uint> link_map, unsigned int version ) const;
 	virtual string asString( bool verbose = false ) const;
+	/*! Formats a human readable string that includes the type and name of the object */
+	virtual string GetIDString();
 	virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version );
 	
 	string GetName();
-- 
GitLab