Commit 2bed486b authored by thomas.forbriger's avatar thomas.forbriger Committed by thomas.forbriger
Browse files

proceeding with binary output

This is a legacy commit from before 2015-03-01.
It may be incomplete as well as inconsistent.
See COPYING.legacy and README.history for details.


SVN Path:     http://gpitrsvn.gpi.uni-karlsruhe.de/repos/TFSoftware/trunk
SVN Revision: 3049
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 3cb5015f
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: bytesex.cc,v 1.2 2007-06-29 13:50:07 tforb Exp $
* $Id: bytesex.cc,v 1.3 2010-04-30 19:59:34 tforb Exp $
* \author Thomas Forbriger
* \date 29/06/2007
*
......@@ -30,13 +30,14 @@
*
* REVISIONS and CHANGES
* - 29/06/2007 V1.0 Thomas Forbriger
* - 30/04/2010 V1.1 added magic number writing and reading
*
* ============================================================================
*/
#define TF_DATREAD_BYTESEX_CC_VERSION \
"TF_DATREAD_BYTESEX_CC V1.3"
"TF_DATREAD_BYTESEX_CC V1.1"
#define TF_DATREAD_BYTESEX_CC_CVSID \
"$Id: bytesex.cc,v 1.2 2007-06-29 13:50:07 tforb Exp $"
"$Id: bytesex.cc,v 1.3 2010-04-30 19:59:34 tforb Exp $"
#include <datreadxx/bytesex.h>
#include <datreadxx/error.h>
......@@ -101,6 +102,43 @@ namespace datread {
return(result);
} // cpu()
/*----------------------------------------------------------------------*/
//! check magic number in file
Emagic_type file_magic_test(std::istream& is, const char* const cmagic,
const bool& fortranmode)
{
Emagic_type result=magic_nomatch;
IOUnion<int> req_magic, in_magic;
// create requested magic number
req_magic.value=magic(cmagic);
// skip Fortran block size
if (fortranmode) is.read(in_magic.bytes, sizeof(int));
// read magic number and compare
is.read(in_magic.bytes, sizeof(int));
if (in_magic.value == req_magic.value)
{ result=magic_match; }
else if (in_magic.value == swap(req_magic.value))
{ result=magic_swap; }
// skip Fortran block size
if (fortranmode) is.read(in_magic.bytes, sizeof(int));
return(result);
} // file_magic_test()
/*----------------------------------------------------------------------*/
//! write magic number to file
void file_magic_write(std::ostream& os, const char* const cmagic,
const bool& fortranmode)
{
IOUnion<int> ifour, imagic;
ifour.value=sizeof(int);
imagic.value=magic(cmagic);
if (fortranmode) os.write(ifour.bytes, sizeof(int));
os.write(imagic.bytes, sizeof(int));
if (fortranmode) os.write(ifour.bytes, sizeof(int));
} // file_magic_write()
} // namespace util
} // namespace datread
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: bytesex.h,v 1.1 2007-06-29 13:20:52 tforb Exp $
* $Id: bytesex.h,v 1.2 2010-04-30 19:59:34 tforb Exp $
* \author Thomas Forbriger
* \date 29/06/2007
*
......@@ -31,6 +31,7 @@
*
* REVISIONS and CHANGES
* - 29/06/2007 V1.0 Thomas Forbriger
* - 30/04/2010 V1.1 added magic number writing and reading
*
* ============================================================================
*/
......@@ -39,9 +40,9 @@
#ifndef TF_DATREAD_BYTESEX_H_VERSION
#define TF_DATREAD_BYTESEX_H_VERSION \
"TF_DATREAD_BYTESEX_H V1.0"
"TF_DATREAD_BYTESEX_H V1.1"
#define TF_DATREAD_BYTESEX_H_CVSID \
"$Id: bytesex.h,v 1.1 2007-06-29 13:20:52 tforb Exp $"
"$Id: bytesex.h,v 1.2 2010-04-30 19:59:34 tforb Exp $"
// we include fstream, because all function are closely related to file I/O
// and file_magic definitely requires fstream
......@@ -167,6 +168,39 @@ namespace datread {
*/
Ecpu_type cpu();
/*! \brief Check for magic number in file.
*
* \ingroup group_ioswap, bytesex_h
*
* \param is input stream to read from
* \param cmagic 4-byte character sequence representing magic number (most
* restrictive: pass a const pointer to a const char)
* is pointer to character array of size sizeof(int)
* \param fortranmode use Fortran binary I/O if true
* \return The return value tells whether the file matches
*
* The function may have the following return values
* \arg magic_match The file has the requested magic number and the bytesex of
* the data matches that of the system
* \arg magic_swap The file has the requested magic number but byte swapping
* is required for input data
* \arg magic_nomatch The requested magic number was not found in the file
*/
Emagic_type file_magic_test(std::istream& is, const char* const cmagic,
const bool& fortranmode=false);
/*! \brief Write magic number to file.
* \ingroup group_ioswap, bytesex_h
*
* \param os output stream to write to
* \param cmagic 4-byte character sequence representing magic number (most
* restrictive: pass a const pointer to a const char)
* is pointer to character array of size sizeof(int)
* \param fortranmode use Fortran binary I/O if true
*/
void file_magic_write(std::ostream& os, const char* const cmagic,
const bool& fortranmode=false);
} // namespace util
} // namespace datread
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: binary.h,v 1.1 2010-02-24 08:11:30 tforb Exp $
* $Id: binary.h,v 1.2 2010-04-30 19:59:35 tforb Exp $
* \author Thomas Forbriger
* \date 24/02/2010
*
......@@ -40,10 +40,35 @@
#define DATWRITE_BINARY_H_VERSION \
"DATWRITE_BINARY_H V1.0 "
#define DATWRITE_BINARY_H_CVSID \
"$Id: binary.h,v 1.1 2010-02-24 08:11:30 tforb Exp $"
"$Id: binary.h,v 1.2 2010-04-30 19:59:35 tforb Exp $"
namespace datwrite {
/*! \brief binary writing interface
*
* \defgroup binary Write binary data
*/
/*! \brief class to write binary
*
* \ingroup binary
*/
class obinarystream: public odatstream {
public:
typedef odatstream Tbase;
obinarystream(std::ostream& os, const bool& debug=false);
inline virtual ~obinarystream()
{ this->flushwaitingtrace(true); }
static void help(std::ostream& os=std::cout);
protected:
virtual void writefileheader();
virtual void writetrace(const Tdseries& series);
virtual void writetrace(const Tfseries& series);
virtual void writetrace(const Tiseries& series);
private:
static const char* const Mmagic;
}; // class obinarystream
} // namespace datwrite
#endif // DATWRITE_BINARY_H_VERSION (includeguard)
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: binary.cc,v 1.1 2010-02-24 08:11:30 tforb Exp $
* $Id: binary.cc,v 1.2 2010-04-30 19:59:35 tforb Exp $
* \author Thomas Forbriger
* \date 24/02/2010
*
......@@ -36,12 +36,14 @@
#define DATWRITE_BINARY_CC_VERSION \
"DATWRITE_BINARY_CC V1.0 "
#define DATWRITE_BINARY_CC_CVSID \
"$Id: binary.cc,v 1.1 2010-02-24 08:11:30 tforb Exp $"
"$Id: binary.cc,v 1.2 2010-04-30 19:59:35 tforb Exp $"
#include <datwritexx/binary.h>
namespace datwrite {
const char* const obinarystream::Mmagic="TBIN";
} // namespace datwrite
/* ----- END OF binary.cc ----- */
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: bytesex.cc,v 1.4 2010-02-20 22:05:29 tforb Exp $
* $Id: bytesex.cc,v 1.5 2010-04-30 19:59:35 tforb Exp $
* \author Thomas Forbriger
* \date 17/02/2010
*
......@@ -30,13 +30,14 @@
*
* REVISIONS and CHANGES
* - 17/02/2010 V1.0 Thomas Forbriger
* - 30/04/2010 V1.1 added magic number writing and reading
*
* ============================================================================
*/
#define DATWRITE_BYTESEX_CC_VERSION \
"TF_BYTESEX_CC V1.0 "
"TF_BYTESEX_CC V1.1"
#define DATWRITE_BYTESEX_CC_CVSID \
"$Id: bytesex.cc,v 1.4 2010-02-20 22:05:29 tforb Exp $"
"$Id: bytesex.cc,v 1.5 2010-04-30 19:59:35 tforb Exp $"
#include <datwritexx/bytesex.h>
#include <datwritexx/error.h>
......@@ -101,6 +102,43 @@ namespace datwrite {
return(result);
} // cpu()
/*----------------------------------------------------------------------*/
//! check magic number in file
Emagic_type file_magic_test(std::istream& is, const char* const cmagic,
const bool& fortranmode)
{
Emagic_type result=magic_nomatch;
IOUnion<int> req_magic, in_magic;
// create requested magic number
req_magic.value=magic(cmagic);
// skip Fortran block size
if (fortranmode) is.read(in_magic.bytes, sizeof(int));
// read magic number and compare
is.read(in_magic.bytes, sizeof(int));
if (in_magic.value == req_magic.value)
{ result=magic_match; }
else if (in_magic.value == swap(req_magic.value))
{ result=magic_swap; }
// skip Fortran block size
if (fortranmode) is.read(in_magic.bytes, sizeof(int));
return(result);
} // file_magic_test()
/*----------------------------------------------------------------------*/
//! write magic number to file
void file_magic_write(std::ostream& os, const char* const cmagic,
const bool& fortranmode)
{
IOUnion<int> ifour, imagic;
ifour.value=sizeof(int);
imagic.value=magic(cmagic);
if (fortranmode) os.write(ifour.bytes, sizeof(int));
os.write(imagic.bytes, sizeof(int));
if (fortranmode) os.write(ifour.bytes, sizeof(int));
} // file_magic_write()
} // namespace util
} // namespace datwrite
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: bytesex.h,v 1.3 2010-02-17 22:13:29 tforb Exp $
* $Id: bytesex.h,v 1.4 2010-04-30 19:59:35 tforb Exp $
* \author Thomas Forbriger
* \date 17/02/2010
*
......@@ -30,6 +30,7 @@
*
* REVISIONS and CHANGES
* - 17/02/2010 V1.0 Thomas Forbriger
* - 30/04/2010 V1.1 added magic number writing and reading
*
* ============================================================================
*/
......@@ -38,9 +39,9 @@
#ifndef DATWRITE_BYTESEX_H_VERSION
#define DATWRITE_BYTESEX_H_VERSION \
"TF_BYTESEX_H V1.0 "
"TF_BYTESEX_H V1.1"
#define DATWRITE_BYTESEX_H_CVSID \
"$Id: bytesex.h,v 1.3 2010-02-17 22:13:29 tforb Exp $"
"$Id: bytesex.h,v 1.4 2010-04-30 19:59:35 tforb Exp $"
// we include fstream, because all function are closely related to file I/O
// and file_magic definitely requires fstream
......@@ -166,6 +167,39 @@ namespace datwrite {
*/
Ecpu_type cpu();
/*! \brief Check for magic number in file.
*
* \ingroup group_ioswap, bytesex_h
*
* \param is input stream to read from
* \param cmagic 4-byte character sequence representing magic number (most
* restrictive: pass a const pointer to a const char)
* is pointer to character array of size sizeof(int)
* \param fortranmode use Fortran binary I/O if true
* \return The return value tells whether the file matches
*
* The function may have the following return values
* \arg magic_match The file has the requested magic number and the bytesex of
* the data matches that of the system
* \arg magic_swap The file has the requested magic number but byte swapping
* is required for input data
* \arg magic_nomatch The requested magic number was not found in the file
*/
Emagic_type file_magic_test(std::istream& is, const char* const cmagic,
const bool& fortranmode=false);
/*! \brief Write magic number to file.
* \ingroup group_ioswap, bytesex_h
*
* \param os output stream to write to
* \param cmagic 4-byte character sequence representing magic number (most
* restrictive: pass a const pointer to a const char)
* is pointer to character array of size sizeof(int)
* \param fortranmode use Fortran binary I/O if true
*/
void file_magic_write(std::ostream& os, const char* const cmagic,
const bool& fortranmode=false);
} // namespace util
} // namespace datwrite
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: sff.h,v 1.10 2010-02-24 07:53:11 tforb Exp $
* $Id: sff.h,v 1.11 2010-04-30 19:59:35 tforb Exp $
* \author Thomas Forbriger
* \date 11/04/2006
*
......@@ -40,7 +40,7 @@
#define DATWRITE_SFF_H_VERSION \
"TF_SFF_H V1.0 "
#define DATWRITE_SFF_H_CVSID \
"$Id: sff.h,v 1.10 2010-02-24 07:53:11 tforb Exp $"
"$Id: sff.h,v 1.11 2010-04-30 19:59:35 tforb Exp $"
#include<datwritexx/datwrite.h>
#include<datwritexx/reservoir.h>
......@@ -48,7 +48,7 @@
namespace datwrite {
/*! \brief SFF reading interface
/*! \brief SFF writing interface
*
* \defgroup sff Write SFF and GSE data
*/
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: sff.cc,v 1.6 2010-02-24 07:53:11 tforb Exp $
* $Id: sff.cc,v 1.7 2010-04-30 19:59:35 tforb Exp $
* \author Thomas Forbriger
* \date 11/04/2006
*
......@@ -36,7 +36,7 @@
#define DATWRITE_SFF_CC_VERSION \
"DATWRITE_SFF_CC V1.0 "
#define DATWRITE_SFF_CC_CVSID \
"$Id: sff.cc,v 1.6 2010-02-24 07:53:11 tforb Exp $"
"$Id: sff.cc,v 1.7 2010-04-30 19:59:35 tforb Exp $"
#include <datwritexx/sff.h>
#include <datwritexx/util.h>
......@@ -156,7 +156,7 @@ namespace datwrite {
void ogsestream::help(std::ostream& os)
{
os << "This modules write standard GSE data." << std::endl;
os << "This module writes standard GSE data." << std::endl;
os << "Essentially SFF data is written but without normalising"
<< std::endl;
os << "them. Notice that floating point data will by truncated to"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment