Add Dirk Luetjen's ssphys libraries and command-line tool
[vss2svn.git] / ssphys / SSPhysLib / SSName.cpp
blob5dce1458120fa4afb1c87528a61fdbf96427a144
1 // SSName.cpp: implementation of the SSName class.
2 //
3 //////////////////////////////////////////////////////////////////////
5 #include "stdafx.h"
6 #include "SSName.h"
7 //#include "SSDatabase.h"
10 //////////////////////////////////////////////////////////////////////
11 // Construction/Destruction
12 //////////////////////////////////////////////////////////////////////
14 SSName::SSName(SSNAME ssname, SSNamesCache* pNameService)
15 : m_ssName (ssname),
16 m_pNamesService (pNameService)
18 // if (!m_pNamesService && SSDatabase::GetCurrentDatabase ())
19 // m_pNamesService = SSDatabase::GetCurrentDatabase ()->GetNamesService ();
22 SSName::~SSName()
27 //---------------------------------------------------------------------------
28 long SSName::GetOffset () const
30 return m_ssName.nsmap;
33 //---------------------------------------------------------------------------
34 std::string SSName::GetType () const
36 switch (m_ssName.flags)
38 case 0:
39 return "file";
40 case 1:
41 return "project";
43 return "type unknown";
46 //---------------------------------------------------------------------------
47 std::string SSName::GetFullName () const
49 std::string name = m_ssName.name;
50 if (m_pNamesService && m_ssName.nsmap != NULL)
52 std::string altName = m_pNamesService->GetName (m_ssName.flags, m_ssName.nsmap);
53 if (!altName.empty ())
54 name = altName;
56 return name;
59 //---------------------------------------------------------------------------
60 std::ostream& operator<<(std::ostream& os, const SSName& ssname)
62 os << ssname.GetFullName ();
64 return os;
67 // ---------------------------------------------------------------
68 void SSName::ToXml (XMLNode* pParent, std::string name /*= "SSName"*/)
70 std::stringstream stream;
71 stream << GetOffset ();
72 AttribMap map;
73 map["type"] = GetType ();
74 map["offset"] = stream.str();
75 XMLElement node (pParent, name, map, GetFullName ());