OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Member Functions | Private Attributes | Friends | List of all members
ossimRpfPathnameRecord Class Reference

#include <ossimRpfPathnameRecord.h>

Public Member Functions

 ossimRpfPathnameRecord ()
 default constructor More...
 
 ossimRpfPathnameRecord (const ossimRpfPathnameRecord &obj)
 copy constructor More...
 
const ossimRpfPathnameRecordoperator= (const ossimRpfPathnameRecord &rhs)
 assignment operator More...
 
void clearFields ()
 
ossimErrorCode parseStream (std::istream &in, ossimByteOrder byteOrder)
 
void writeStream (std::ostream &out)
 Write method. More...
 
std::ostream & print (std::ostream &out) const
 
ossimString getPathname () const
 
void setPathName (const ossimString &path)
 Set the pathname and length from string size. More...
 

Private Attributes

ossim_uint16 m_length
 
ossimString m_pathname
 

Friends

std::ostream & operator<< (std::ostream &out, const ossimRpfPathnameRecord &data)
 

Detailed Description

Definition at line 19 of file ossimRpfPathnameRecord.h.

Constructor & Destructor Documentation

◆ ossimRpfPathnameRecord() [1/2]

ossimRpfPathnameRecord::ossimRpfPathnameRecord ( )

default constructor

Definition at line 22 of file ossimRpfPathnameRecord.cpp.

23  :
24  m_length(0),
25  m_pathname("")
26 {
27 }

◆ ossimRpfPathnameRecord() [2/2]

ossimRpfPathnameRecord::ossimRpfPathnameRecord ( const ossimRpfPathnameRecord obj)

copy constructor

Definition at line 29 of file ossimRpfPathnameRecord.cpp.

30  :
31  m_length(obj.m_length),
33 {
34 }

Member Function Documentation

◆ clearFields()

void ossimRpfPathnameRecord::clearFields ( )

Definition at line 46 of file ossimRpfPathnameRecord.cpp.

References m_length, and m_pathname.

Referenced by parseStream().

47 {
48  m_length = 0;
49  m_pathname = "";
50 }

◆ getPathname()

ossimString ossimRpfPathnameRecord::getPathname ( ) const

Definition at line 111 of file ossimRpfPathnameRecord.cpp.

References m_pathname.

112 {
113  return m_pathname;
114 }

◆ operator=()

const ossimRpfPathnameRecord & ossimRpfPathnameRecord::operator= ( const ossimRpfPathnameRecord rhs)

assignment operator

Definition at line 36 of file ossimRpfPathnameRecord.cpp.

References m_length, and m_pathname.

37 {
38  if ( this != &rhs )
39  {
40  m_length = rhs.m_length;
41  m_pathname = rhs.m_pathname;
42  }
43  return *this;
44 }

◆ parseStream()

ossimErrorCode ossimRpfPathnameRecord::parseStream ( std::istream &  in,
ossimByteOrder  byteOrder 
)

Definition at line 52 of file ossimRpfPathnameRecord.cpp.

References ossim::byteOrder(), clearFields(), ossimEndian::getSystemEndianType(), m_length, m_pathname, ossimErrorCodes::OSSIM_ERROR, ossimErrorCodes::OSSIM_OK, and ossimEndian::swap().

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 }
static const ossimErrorCode OSSIM_OK
OSSIM_DLL ossimByteOrder byteOrder()
Definition: ossimCommon.cpp:54
static const ossimErrorCode OSSIM_ERROR
ossimByteOrder getSystemEndianType() const
Definition: ossimEndian.h:78
void swap(ossim_sint8 &)
Definition: ossimEndian.h:26

◆ print()

std::ostream & ossimRpfPathnameRecord::print ( std::ostream &  out) const

Definition at line 104 of file ossimRpfPathnameRecord.cpp.

References m_length, and m_pathname.

Referenced by operator<<().

105 {
106  out << "length: " << m_length
107  << "\npathname: " << m_pathname << std::endl;
108  return out;
109 }

◆ setPathName()

void ossimRpfPathnameRecord::setPathName ( const ossimString path)

Set the pathname and length from string size.

Parameters
pathPath like: ./N03E030

Definition at line 116 of file ossimRpfPathnameRecord.cpp.

References m_length, m_pathname, and ossimString::size().

117 {
118  m_pathname = path;
119  m_length = static_cast<ossim_uint16>( path.size() );
120 }
unsigned short ossim_uint16
std::string::size_type size() const
Definition: ossimString.h:405

◆ writeStream()

void ossimRpfPathnameRecord::writeStream ( std::ostream &  out)

Write method.

Parameters
outStream to write to.

Definition at line 81 of file ossimRpfPathnameRecord.cpp.

References ossimString::c_str(), ossimEndian::getSystemEndianType(), m_length, m_pathname, OSSIM_BIG_ENDIAN, ossimString::size(), and ossimEndian::swap().

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 }
std::string::size_type size() const
Definition: ossimString.h:405
ossimByteOrder getSystemEndianType() const
Definition: ossimEndian.h:78
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
void swap(ossim_sint8 &)
Definition: ossimEndian.h:26

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  out,
const ossimRpfPathnameRecord data 
)
friend

Definition at line 17 of file ossimRpfPathnameRecord.cpp.

18 {
19  return data.print(out);
20 }
std::ostream & print(std::ostream &out) const

Member Data Documentation

◆ m_length

ossim_uint16 ossimRpfPathnameRecord::m_length
private

◆ m_pathname

ossimString ossimRpfPathnameRecord::m_pathname
private

The documentation for this class was generated from the following files: