OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimRpfPathnameRecord.cpp
Go to the documentation of this file.
1 //*******************************************************************
2 // License: See top level LICENSE.txt file.
3 //
4 // Author: Garrett Potts
5 //
6 // Description: Rpf support class.
7 //
8 //********************************************************************
9 // $Id: ossimRpfPathnameRecord.cpp 16997 2010-04-12 18:53:48Z dburken $
10 
11 #include <istream>
12 #include <ostream>
14 #include <ossim/base/ossimEndian.h>
16 
18 {
19  return data.print(out);
20 }
21 
23  :
24  m_length(0),
25  m_pathname("")
26 {
27 }
28 
30  :
31  m_length(obj.m_length),
32  m_pathname(obj.m_pathname)
33 {
34 }
35 
37 {
38  if ( this != &rhs )
39  {
40  m_length = rhs.m_length;
41  m_pathname = rhs.m_pathname;
42  }
43  return *this;
44 }
45 
47 {
48  m_length = 0;
49  m_pathname = "";
50 }
51 
53 {
54  if(in)
55  {
56  ossimEndian anEndian;
57 
58  clearFields();
59  in.read((char*)&m_length, 2);
60 
61  if(anEndian.getSystemEndianType() != byteOrder)
62  {
63  anEndian.swap(m_length);
64  }
65 
66  char *temp = new char[m_length+1];
67  in.read((char*)temp, m_length);
68  temp[m_length] = '\0';
69  m_pathname = temp;
70 
71  delete [] temp;
72  }
73  else
74  {
76  }
77 
79 }
80 
82 {
83  ossimEndian anEndian;
84  if( anEndian.getSystemEndianType() != OSSIM_BIG_ENDIAN )
85  {
86  // Always write big endian.
87  anEndian.swap(m_length);
88  }
89 
90  out.write((char*)&m_length, 2);
91 
92  if( anEndian.getSystemEndianType() != OSSIM_BIG_ENDIAN )
93  {
94  // Swap back to native.
95  anEndian.swap(m_length);
96  }
97 
98  if(m_pathname.size() >= m_length)
99  {
100  out.write(m_pathname.c_str(), m_length);
101  }
102 }
103 
105 {
106  out << "length: " << m_length
107  << "\npathname: " << m_pathname << std::endl;
108  return out;
109 }
110 
112 {
113  return m_pathname;
114 }
115 
117 {
118  m_pathname = path;
119  m_length = static_cast<ossim_uint16>( path.size() );
120 }
ossim_int32 ossimErrorCode
ossimErrorCode parseStream(std::istream &in, ossimByteOrder byteOrder)
static const ossimErrorCode OSSIM_OK
OSSIM_DLL ossimByteOrder byteOrder()
Definition: ossimCommon.cpp:54
static const ossimErrorCode OSSIM_ERROR
unsigned short ossim_uint16
std::ostream & operator<<(std::ostream &out, const ossimRpfPathnameRecord &data)
std::string::size_type size() const
Definition: ossimString.h:405
ossimRpfPathnameRecord()
default constructor
ossimByteOrder
ossimByteOrder getSystemEndianType() const
Definition: ossimEndian.h:78
std::basic_istream< char > istream
Base class for char input streams.
Definition: ossimIosFwd.h:20
void setPathName(const ossimString &path)
Set the pathname and length from string size.
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
const ossimRpfPathnameRecord & operator=(const ossimRpfPathnameRecord &rhs)
assignment operator
void swap(ossim_sint8 &)
Definition: ossimEndian.h:26
void writeStream(std::ostream &out)
Write method.
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23
std::ostream & print(std::ostream &out) const