OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimNitfDataExtensionSegmentV2_0.cpp
Go to the documentation of this file.
1 //*******************************************************************
2 // Copyright (C) 2000 ImageLinks Inc.
3 //
4 // License: See top level LICENSE.txt file.
5 //
6 // Author: Garrett Potts
7 //
8 // Description: Nitf support class
9 //
10 //********************************************************************
11 // $Id: ossimNitfDataExtensionSegmentV2_0.cpp 22429 2013-10-02 12:53:06Z gpotts $
12 
13 #include <iostream>
15 
19 
23 
26 {
27  out << "theFilePartType: " << data.theFilePartType
28  << "\ntheUniqueDataExtTypeId: " << data.theUniqueDataExtTypeId
29  << "\ntheVersionDataFieldDef: " << data.theVersionDataFieldDef
30  << "\ntheDataExtSecurityClass: " << data.theDataExtSecurityClass
31  << "\ntheDataExtCodewords: " << data.theDataExtCodewords
32  << "\ntheDataExtControlAndHand: " << data.theDataExtControlAndHand
33  << "\ntheDataExtReleasingInst: " << data.theDataExtReleasingInst
34  << "\ntheDataExtClassAuthority: " << data.theDataExtClassAuthority
35  << "\ntheDataExtSecurityConNum: " << data.theDataExtSecurityConNum
36  << "\ntheDataExtSecurityDowngrade: " << data.theDataExtSecurityDowngrade
37  << "\ntheDataExtDowngradingEvent: " << data.theDataExtDowngradingEvent
38  << std::endl;
39 
40  return out;
41 }
42 
44 {
45  clearFields();
46 }
47 
49 {
50 }
51 
53 {
54  if(in)
55  {
56  clearFields();
57 
58  in.read(theIdentSecurityChunk.theFilePartType, 2); // 2 byte alpha
59  in.read(theIdentSecurityChunk.theUniqueDataExtTypeId, 25); // 25 byte alpha numeric
60  in.read(theIdentSecurityChunk.theVersionDataFieldDef, 2); // 2 byte numeric
61  in.read(theIdentSecurityChunk.theDataExtSecurityClass, 1); // 1 byte alpha
62  in.read(theIdentSecurityChunk.theDataExtCodewords, 40); // 40 byte alpha numeric
63  in.read(theIdentSecurityChunk.theDataExtControlAndHand, 40); // 40 byte alpha numeric
64  in.read(theIdentSecurityChunk.theDataExtReleasingInst, 40); // 40 byte alpha numeric
65  in.read(theIdentSecurityChunk.theDataExtClassAuthority, 20); // 20 byte alph num
66  in.read(theIdentSecurityChunk.theDataExtSecurityConNum, 20); // 20 byte alpha num
67  in.read(theIdentSecurityChunk.theDataExtSecurityDowngrade, 6); // 6 byte alpha num
69  {
70  in.read(theIdentSecurityChunk.theDataExtDowngradingEvent, 40); // 40 byte alpha num
71  }
72 
75  desTag = desTag.trim().upcase();
76  const bool overflow = (desTag == "REGISTERED EXTENSIONS" ||
77  desTag == "CONTROLLED EXTENSIONS");
78 
79  if (overflow&&in.good())
80  {
81  in.read(theOverflowedHeaderType, 6);
82  in.read(theDataItemOverflowed, 3);
83  }
85  // look to see if there is any data and if so read the tag
86  // to see what it is
88  if (length > 0)
89  {
90  theUserDefinedSubheaderFields.resize(length);
91  in.read(reinterpret_cast<char*>(&theUserDefinedSubheaderFields.front()), theUserDefinedSubheaderFields.size());
92  }
93 
94  if (dataLength != 0)
95  {
96  if (overflow)
97  {
98  istream::pos_type dataBegin = in.tellg();
99  istream::pos_type endData = dataBegin + static_cast<istream::pos_type>(dataLength);
100  while (in.good()&&(in.tellg() < endData))
101  {
103  tag.parseStream(in);
104  theTagList.push_back(tag);
105  }
106  if(!in.good()) in.clear();
107  in.seekg(dataBegin);
108  }
109  theData.resize(dataLength);
110  in.read(reinterpret_cast<char*>(&theData.front()), theData.size());
111  }
112  }
113 }
114 
116 {
117 
118  memset(theIdentSecurityChunk.theFilePartType, ' ', 2); // 2 byte alpha
119  memset(theIdentSecurityChunk.theUniqueDataExtTypeId, ' ', 25); // 25 byte alpha numeric
120  memset(theIdentSecurityChunk.theVersionDataFieldDef, ' ', 2); // 2 byte numeric
121  memset(theIdentSecurityChunk.theDataExtSecurityClass, ' ', 1); // 1 byte alpha
122  memset(theIdentSecurityChunk.theDataExtCodewords, ' ', 40); // 40 byte alpha numeric
123  memset(theIdentSecurityChunk.theDataExtControlAndHand, ' ', 40); // 40 byte alpha numeric
124  memset(theIdentSecurityChunk.theDataExtReleasingInst, ' ', 40); // 40 byte alpha numeric
125  memset(theIdentSecurityChunk.theDataExtClassAuthority, ' ', 20); // 20 byte alph num
126  memset(theIdentSecurityChunk.theDataExtSecurityConNum, ' ', 20); // 20 byte alpha num
127  memset(theIdentSecurityChunk.theDataExtSecurityDowngrade, ' ', 6); // 6 byte alpha num
128  memset(theIdentSecurityChunk.theDataExtDowngradingEvent, ' ', 40); // 40 byte alpha num
129  memset(theOverflowedHeaderType, ' ', 6);
130  memset(theDataItemOverflowed, ' ', 3);
132 
133  theIdentSecurityChunk.theFilePartType[2] = '\0'; // 2 byte alpha
134  theIdentSecurityChunk.theUniqueDataExtTypeId[25] = '\0'; // 25 byte alpha numeric
135  theIdentSecurityChunk.theVersionDataFieldDef[2] = '\0'; // 2 byte numeric
136  theIdentSecurityChunk.theDataExtSecurityClass[1] = '\0'; // 1 byte alpha
137  theIdentSecurityChunk.theDataExtCodewords[40] = '\0'; // 40 byte alpha numeric
138  theIdentSecurityChunk.theDataExtControlAndHand[40] = '\0'; // 40 byte alpha numeric
139  theIdentSecurityChunk.theDataExtReleasingInst[40] = '\0'; // 40 byte alpha numeric
140  theIdentSecurityChunk.theDataExtClassAuthority[20] = '\0'; // 20 byte alph num
141  theIdentSecurityChunk.theDataExtSecurityConNum[20] = '\0'; // 20 byte alpha num
142  theIdentSecurityChunk.theDataExtSecurityDowngrade[6] = '\0'; // 6 byte alpha num
143  theIdentSecurityChunk.theDataExtDowngradingEvent[40] = '\0'; // 40 byte alpha num
144  theOverflowedHeaderType[6] = '\0';
145  theDataItemOverflowed[3] = '\0';
147 
149  theData.clear();
150  theTagList.clear();
151 }
152 
153 
155 {
156  out << "theIdentSecurityChunk: "
158  << "\ntheOverflowedHeaderType: "
160  << "\ntheDataItemOverflowed: "
162  << "\ntheLengthOfUserDefinedSubheaderFields: "
164  << "\ntag count: "
165  << theTagList.size() << std::endl;
166  return out;
167 }
168 
170 {
171  ossimProperty* property = 0;
172  if (name == DE_KW)
173  {
175  }
176  else if (name == DESTAG_KW)
177  {
179  }
180  else if (name == DESVER_KW)
181  {
183  }
184  else if (name == DECLAS_KW)
185  {
187  }
188  else if (name == DESCODE_KW)
189  {
191  }
192  else if (name == DESCTLH_KW)
193  {
195  }
196  else if (name == DESREL_KW)
197  {
199  }
200  else if (name == DESCAUT_KW)
201  {
203  }
204  else if (name == DESCTLN_KW)
205  {
207  }
208  else if (name == DESDWNG_KW)
209  {
211  }
212  else if (name == DESDEVT_KW)
213  {
215  }
216  else if (name == DESOFLW_KW)
217  {
218  property = new ossimStringProperty(name, ossimString(theOverflowedHeaderType).trim());
219  }
220  else if (name == DESITEM_KW)
221  {
222  property = new ossimStringProperty(name, ossimString(theDataItemOverflowed).trim());
223  }
224  else if (name == DESSHL_KW)
225  {
227  }
228  else if (name == DESSHF_KW)
229  {
231  }
232  else if (name == DESDATA_KW)
233  {
234  // Only valid if setTagList has not been called on this object.
235  property = new ossimBinaryDataProperty(name, theData);
236  }
237 
238  return property;
239 }
240 
241 void ossimNitfDataExtensionSegmentV2_0::getPropertyNames(std::vector<ossimString>& propertyNames)const
242 {
244  propertyNames.push_back(DESTAG_KW);
245  propertyNames.push_back(DESDWNG_KW);
246  propertyNames.push_back(DESDEVT_KW);
247 }
ossimNitfDataExtIdentSecurityChunkV2_0 theIdentSecurityChunk
std::vector< ossimNitfTagInformation > theTagList
std::ostream & operator<<(std::ostream &out, const ossimNitfDataExtIdentSecurityChunkV2_0 &data)
static ossimString upcase(const ossimString &aString)
Definition: ossimString.cpp:34
virtual void parseStream(std::istream &in, ossim_uint64 dataLength)
virtual void parseStream(ossim::istream &in)
void getPropertyNames(std::vector< ossimString > &propertyNames) const
ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
virtual void getPropertyNames(std::vector< ossimString > &propertyNames) const
unsigned long long ossim_uint64
ossimString trim(const ossimString &valueToTrim=ossimString(" \\)) const
this will strip lead and trailing character passed in.
std::vector< unsigned char > theUserDefinedSubheaderFields
std::basic_istream< char > istream
Base class for char input streams.
Definition: ossimIosFwd.h:20
long toLong() const
toLong&#39;s deprecated, please use the toInts...
virtual std::ostream & print(std::ostream &out) const
Generic print method.
#define RTTI_DEF1(cls, name, b1)
Definition: ossimRtti.h:485
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23