1 // InfoCommand.cpp: implementation of the CInfoCommand class.
3 //////////////////////////////////////////////////////////////////////
6 #include "InfoCommand.h"
8 #include <SSPhysLib\SSFiles.h>
9 #include <SSPhysLib\SSObject.h>
11 //////////////////////////////////////////////////////////////////////
12 // Construction/Destruction
13 //////////////////////////////////////////////////////////////////////
15 CInfoCommand::CInfoCommand()
17 m_bOnlyRecords (false),
18 m_bAllRecords (false),
19 m_bDisplayAtOffset (false),
25 COptionInfoList
CInfoCommand::GetOptionsInfo () const
27 COptionInfoList options
= CCommand::GetOptionsInfo();
28 options
.push_back (COptionInfo ('a', 'a', "all", "display information about all records", COptionInfo::noArgument
));
29 options
.push_back (COptionInfo ('r', 'r', "records", "display basic information about the records", COptionInfo::noArgument
));
30 options
.push_back (COptionInfo ('o', 'o', "offset", "display record at specific offset", COptionInfo::requiredArgument
));
34 bool CInfoCommand::SetOption (const COption
& option
)
42 m_bOnlyRecords
= true;
45 m_bDisplayAtOffset
= true;
46 m_Offset
= atoi ((const char*) option
.value
);
54 bool CInfoCommand::SetArguments (CArguments
& args
)
57 throw SSException ("no argument");
59 m_PhysFile
= args
.front ();
64 void CInfoCommand::Execute ()
66 std::auto_ptr
<SSRecordFile
> pFile (SSRecordFile::MakeFile (m_PhysFile
));
67 g_pFormatter
->SetFileName (m_PhysFile
);
68 // std::auto_ptr<ISSObjectVisitor> pFormatter (CPhysFormatterFactory::MakeFormatter ());
73 SSRecordPtr pRecord
= pFile
->GetFirstRecord();
78 pRecord
->Dump (std::cout
);
82 std::auto_ptr
<SSObject
> pObject (SSObject::MakeObject(pRecord
));
83 g_pFormatter
->Format (*pObject
);
84 std::cout
<< std::endl
;
86 pRecord
= pFile
->FindNextRecord(pRecord
);
89 else if (m_bDisplayAtOffset
)
91 SSRecordPtr pRecord
= pFile
->GetRecord(m_Offset
);
92 std::auto_ptr
<SSObject
> pObject (SSObject::MakeObject(pRecord
));
93 g_pFormatter
->Format (*pObject
);
96 pFile
->Dump (std::cout
);