SP3Stream.cpp
Go to the documentation of this file.
1 //==============================================================================
2 //
3 // This file is part of GNSSTk, the ARL:UT GNSS Toolkit.
4 //
5 // The GNSSTk is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published
7 // by the Free Software Foundation; either version 3.0 of the License, or
8 // any later version.
9 //
10 // The GNSSTk is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with GNSSTk; if not, write to the Free Software Foundation,
17 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
18 //
19 // This software was developed by Applied Research Laboratories at the
20 // University of Texas at Austin.
21 // Copyright 2004-2022, The Board of Regents of The University of Texas System
22 //
23 //==============================================================================
24 
25 //==============================================================================
26 //
27 // This software was developed by Applied Research Laboratories at the
28 // University of Texas at Austin, under contract to an agency or agencies
29 // within the U.S. Department of Defense. The U.S. Government retains all
30 // rights to use, duplicate, distribute, disclose, or release this software.
31 //
32 // Pursuant to DoD Directive 523024
33 //
34 // DISTRIBUTION STATEMENT A: This software has been approved for public
35 // release, distribution is unlimited.
36 //
37 //==============================================================================
38 
44 #include "SP3Stream.hpp"
45 
46 namespace gnsstk
47 {
50  : wroteEOF(false),
51  writingMode(false),
52  lastLine(std::string())
53  {
54  }
55 
56 
58  SP3Stream(const char* filename,
59  std::ios::openmode mode)
60  : FFTextStream(filename, mode)
61  {
62  init(mode);
63  }
64 
65 
68  {
69  close();
70  }
71 
72 
73  void SP3Stream ::
74  close(void)
75  {
76  if (is_open())
77  {
78  try {
79  // if writing, add the final line
80  if(writingMode && !wroteEOF) {
81  (*this) << "EOF\n";
82  wroteEOF = true;
83  }
84  FFTextStream::close();
85  }
86  catch(std::exception& e) {
87  Exception ge(e.what());
88  GNSSTK_THROW(ge);
89  }
90  }
91  }
92 
93 
94  void SP3Stream ::
95  open(const char* filename, std::ios::openmode mode)
96  {
98  init(mode);
99  }
100 
101 
102  void SP3Stream :: init(std::ios::openmode mode)
103  {
104  header = SP3Header();
105  warnings.clear();
106 
107  // for close() later
108  wroteEOF = writingMode = false;
109  if( (mode & std::ios::out) && !(mode & std::ios::in) )
110  writingMode = true;
111  }
112 
113 } // namespace
gnsstk::SP3Stream::writingMode
bool writingMode
True if the stream is open in 'out', not 'in', mode.
Definition: SP3Stream.hpp:90
gnsstk::FFStream::filename
std::string filename
file name
Definition: FFStream.hpp:179
gnsstk::SP3Stream::header
SP3Header header
SP3Header for this file.
Definition: SP3Stream.hpp:88
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
gnsstk::SP3Stream::SP3Stream
SP3Stream()
Default constructor.
Definition: SP3Stream.cpp:49
gnsstk::Exception
Definition: Exception.hpp:151
gnsstk::SP3Stream::~SP3Stream
virtual ~SP3Stream()
destructor; override to force 'close'
Definition: SP3Stream.cpp:67
gnsstk::SP3Stream::open
virtual void open(const char *filename, std::ios::openmode mode)
Definition: SP3Stream.cpp:95
gnsstk::SP3Stream::close
virtual void close(void)
Definition: SP3Stream.cpp:74
gnsstk::FFTextStream::init
void init()
Initialize internal data structures.
Definition: FFTextStream.cpp:97
gnsstk::SP3Header
Definition: SP3Header.hpp:68
gnsstk::SP3Stream::warnings
std::vector< std::string > warnings
warnings produced by reallyGetRecord()s
Definition: SP3Stream.hpp:93
gnsstk::SP3Stream::wroteEOF
bool wroteEOF
True if the final 'EOF' has been read.
Definition: SP3Stream.hpp:89
std
Definition: Angle.hpp:142
SP3Stream.hpp
gnsstk::FFTextStream::open
virtual void open(const char *fn, std::ios::openmode mode)
Overrides open to reset the line number.
Definition: FFTextStream.cpp:80
GNSSTK_THROW
#define GNSSTK_THROW(exc)
Definition: Exception.hpp:366
gnsstk::FFTextStream
Definition: FFTextStream.hpp:63


gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:41