OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimNitfInfo.cpp
Go to the documentation of this file.
1 //---
2 //
3 // License: MIT
4 //
5 // Description: NITF Info object.
6 //
7 //---
8 // $Id$
9 
14 
15 #include <ostream>
16 #include <sstream>
17 #include <memory>
18 
20  : m_nitfFile(0)
21 {
22 }
23 
25 {
26  m_nitfFile.reset();
27 }
28 
30 {
31  bool result = false;
32 
33  std::string connectionString = file.c_str();
34  std::shared_ptr<ossim::istream> str = ossim::StreamFactoryRegistry::instance()->
35  createIstream( file.c_str(), std::ios_base::in|std::ios_base::binary);
36 
37  if ( str )
38  {
39  result = open(str, connectionString);
40  }
41  return result;
42 }
43 
44 bool ossimNitfInfo::open(std::shared_ptr<ossim::istream>& str,
45  const std::string& connectionString)
46 {
47  bool result = false;
48  if ( str )
49  {
50  m_nitfFile = std::make_shared<ossimNitfFile>();
51  result = m_nitfFile->parseStream(ossimFilename(connectionString), *str);
52  }
53  return result;
54 }
55 
57 {
58  if ( m_nitfFile )
59  {
60  std::string prefix;
61  m_nitfFile->print(out, prefix, getProcessOverviewFlag());
62  }
63  return out;
64 }
65 
66 
68  ossim_uint32 entryIndex)const
69 {
70  // Do a print to a memory stream.
72  m_nitfFile->print( out, entryIndex );
73 
74  std::istringstream in( out.str() );
75 
76  // Give the result to the keyword list.
77  return kwl.parseStream( in );
78 }
virtual std::ostream & print(std::ostream &out) const
Print method.
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35
Represents serializable keyword/value map.
std::shared_ptr< ossimNitfFile > m_nitfFile
Definition: ossimNitfInfo.h:66
virtual bool open(const ossimFilename &file)
open method.
static StreamFactoryRegistry * instance()
ossimNitfInfo()
default constructor
virtual ~ossimNitfInfo()
virtual destructor
bool getProcessOverviewFlag() const
Method to get the overview flag.
unsigned int ossim_uint32
virtual bool parseStream(ossim::istream &is, bool ignoreBinaryChars)
deprecated method
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string&#39;s contents...
Definition: ossimString.h:396
std::basic_istringstream< char > istringstream
Class for char input memory streams.
Definition: ossimIosFwd.h:32
virtual bool getKeywordlist(ossimKeywordlist &kwl, ossim_uint32 entryIndex) const
Method to dump info to a keyword list.
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23