Add Dirk Luetjen's ssphys libraries and command-line tool
[vss2svn.git] / ssphys / SSPhysLib / SSNameObject.h
blobeff1c9c3ad0fae512006f78c7641142a821faaae
1 // SSNameObject.h: interface for the SSNameObject class.
2 //
3 //////////////////////////////////////////////////////////////////////
5 #if !defined(AFX_SSNAMEOBJECT_H__8116FB34_17A5_40BB_829F_28413D2A00DA__INCLUDED_)
6 #define AFX_SSNAMEOBJECT_H__8116FB34_17A5_40BB_829F_28413D2A00DA__INCLUDED_
8 #if _MSC_VER > 1000
9 #pragma once
10 #endif // _MSC_VER > 1000
12 #include "SSObject.h"
13 #include "SSFiles.h"
16 //------------------------------------------------------------------------------
17 class SSNameObject : public SSObject
19 public:
20 typedef std::map<short, std::string>::const_iterator const_iterator;
21 typedef std::map<short, std::string>::size_type size_type;
23 SSNameObject (SSRecordPtr pRecord);
25 const_iterator begin () const { return m_NamesMap.begin (); }
26 const_iterator end () const { return m_NamesMap.end (); }
27 size_type size () const { return m_NamesMap.size (); }
29 std::string GetName (short id);
31 virtual void Accept (ISSObjectVisitor& rVisitor, const ISSContext* pCtx = NULL) const { rVisitor.Apply (*this, pCtx); }
33 void ToXml (XMLNode* pParent) const;
34 void Dump (std::ostream& os) const;
36 protected:
37 void Init (SSRecordPtr pRecord);
39 std::map<short, std::string> m_NamesMap;
42 //------------------------------------------------------------------------------
43 class SSNamesCache
45 public:
46 SSNamesCache ()
47 : m_pFile (NULL)
51 ~SSNamesCache ()
53 delete m_pFile;
56 void SetFile (SSNamesCacheFile* pFile)
58 m_pFile = pFile;
61 std::string GetName (short flag, long offset, int cp=0)
63 if (!m_pFile)
64 return "";
66 SSRecordPtr pRecord = m_pFile->GetRecord (offset);
67 SSNameObject names (pRecord);
68 return names.GetName (flag << 3 | 2);
71 private:
72 SSNamesCacheFile* m_pFile;
76 #endif // !defined(AFX_SSNAMEOBJECT_H__8116FB34_17A5_40BB_829F_28413D2A00DA__INCLUDED_)