NRLib Namespace Reference

Namespaces

namespace  NRLibPrivate
 

Classes

struct  BufferMessage
 
class  ConstantSurface
 
class  EndOfFile
 
class  Exception
 
class  FFTError
 
class  FileFormatError
 
class  Grid
 
class  Grid2D
 
class  Grid4D
 
class  Grid5D
 
class  IndexOutOfRange
 
class  IOError
 
class  JobCanceled
 
class  LasWell
 
class  LogKit
 Kit for logging of messages from program. More...
 
class  LogStream
 Class LogStream is for internal use in LogKit only. More...
 
class  NorsarWell
 
class  RegularSurface
 
class  RegularSurfaceRotated
 
class  RMSWell
 
class  StormContGrid
 
class  StormFaciesGrid
 
class  Surface
 
class  TabularFile
 
class  Volume
 
class  Well
 

Enumerations

enum  Endianess { END_LITTLE_ENDIAN , END_BIG_ENDIAN }
 
enum  GridFileFormat {
  UNKNOWN = -1 , STORM_PETRO_BINARY = 0 , STORM_PETRO_ASCII = 1 , STORM_FACIES_BINARY = 2 ,
  STORM_FACIES_ASCII = 3 , SGRI = 4 , SEGY = 5 , PLAIN_ASCII = 6
}
 
enum  SurfaceFileFormat {
  SURF_UNKNOWN , SURF_IRAP_CLASSIC_ASCII , SURF_STORM_BINARY , SURF_SGRI ,
  SURF_RMS_POINTS_ASCII , SURF_MULT_ASCII
}
 

Functions

void OpenRead (std::ifstream &stream, const std::string &filename, std::ios_base::openmode mode=std::ios_base::in)
 Open file for reading. More...
 
void OpenRead (std::fstream &stream, const std::string &filename, std::ios_base::openmode mode=std::ios_base::in)
 
void OpenWrite (std::ofstream &stream, const std::string &filename, std::ios_base::openmode mode=std::ios_base::out, bool create_dir=true)
 Open file for writing. More...
 
void OpenWrite (std::fstream &stream, const std::string &filename, std::ios_base::openmode mode=std::ios_base::out, bool create_dir=true)
 
void CopyFile (const std::string &from_path, const std::string &to_path, bool allow_overwrite)
 
bool FileExists (const std::string &filename)
 
void CreateDirIfNotExists (const std::string &filename)
 
void RemoveFile (const std::string &filename)
 
unsigned long long FindFileSize (const std::string &filename)
 Finds the size of a file. Throws IOError if file not found. More...
 
int FindGridFileType (const std::string &filename)
 Find type of file, for 3D grid files. More...
 
void DiscardRestOfLine (std::istream &stream, int &line_num, bool throw_if_non_whitespace)
 Reads and discard all characters until and including next newline. More...
 
std::istream & GetNextNonEmptyLine (std::istream &stream, int &line_num, std::string &line)
 Gets the next line that not only contains whitespace. Returns the stream. Stream will be bad if end-of-file is reached. More...
 
std::string FindLastNonEmptyLine (std::istream &stream, const std::ios::pos_type &max_line_len=1000)
 Returns last non-empty line in file. Stream will be at end of file. More...
 
void SkipComments (std::istream &stream, char comment_token, int &line_num)
 Returns next line that not only contains whitespace, or starts with the given comment token. More...
 
bool CheckEndOfFile (std::istream &stream)
 Check if end of file is reached. Discards all whitespace before end of file or next token. More...
 
std::istream & ReadNextToken (std::istream &stream, std::string &s, int &line)
 Read next white-space seperated token from file. Updates line number when new line is read in. If end of file is reached the state of stream is set to eof. If ReadNextToken is called with a stream that is not good, the state is set to fail. More...
 
template<typename T >
ReadNext (std::istream &stream, int &line)
 Gets next token from file, and parses it as type T Might be relatively slow, due to typechecking, and counting line numbers. More...
 
void ReadNextQuoted (std::istream &stream, char quote, std::string &s, int &line)
 Reads the next, possibly quoted, string. More...
 
template<typename I >
void WriteAsciiArray (std::ostream &stream, I begin, I end, int n_per_line=6)
 Writes array. More...
 
template<typename I >
ReadAsciiArray (std::istream &stream, I begin, size_t n, int &line)
 Gets sequence with elements of type T from input stream. Might be relatively slow, due to typechecking, and counting line numbers. More...
 
template<typename I >
ReadAsciiArrayFast (std::istream &stream, I begin, size_t n)
 Gets sequence with elements of type T from input stream. Does no type checking, and does not count line numbers. More...
 
template<typename I >
ReadAsciiArrayFastRestOfFile (std::istream &stream, I begin, size_t n)
 Gets sequence with elements of type T from input stream. Does no type checking, and does not count line numbers. Reads the rest of the file, and does no type checking at all. If a double is attempted read as an int, the first integer part of the double is read, while the fraction part is discarded. For int, float or double this function is 10x as fast as GetAsciiArrayFast on Windows. More...
 
void WriteBinaryShort (std::ostream &stream, short s, Endianess number_representation=END_BIG_ENDIAN)
 Write a 2-byte integer to a binary file. More...
 
short ReadBinaryShort (std::istream &stream, Endianess number_representation=END_BIG_ENDIAN)
 Read a 2-byte integer from a binary file. More...
 
template<typename I >
void WriteBinaryShortArray (std::ostream &stream, I begin, I end, Endianess number_representation=END_BIG_ENDIAN)
 Write an array of binary 2-byte integers. More...
 
template<typename I >
ReadBinaryShortArray (std::istream &stream, I begin, size_t n, Endianess number_representation=END_BIG_ENDIAN)
 Read an array of binary 2-byte integers. More...
 
void WriteBinaryInt (std::ostream &stream, int i, Endianess number_representation=END_BIG_ENDIAN)
 Write a 4-byte integer to a binary file. More...
 
int ReadBinaryInt (std::istream &stream, Endianess number_representation=END_BIG_ENDIAN)
 Read a 4-byte integer from a binary file. More...
 
template<typename I >
void WriteBinaryIntArray (std::ostream &stream, I begin, I end, Endianess number_representation=END_BIG_ENDIAN)
 Write an array of binary 4-byte integers. More...
 
template<typename I >
ReadBinaryIntArray (std::istream &stream, I begin, size_t n, Endianess number_representation=END_BIG_ENDIAN)
 Read an array of binary 4-byte integers. More...
 
void WriteBinaryFloat (std::ostream &stream, float f, Endianess number_representation=END_BIG_ENDIAN)
 Write a 4-byte float on standard IEEE format. More...
 
float ReadBinaryFloat (std::istream &stream, Endianess number_representation=END_BIG_ENDIAN)
 Read a 4-byte float on standard IEEE format. More...
 
template<typename I >
void WriteBinaryFloatArray (std::ostream &stream, I begin, I end, Endianess number_representation=END_BIG_ENDIAN)
 Write an array of 4-byte floats on standard IEEE format. More...
 
template<typename I >
ReadBinaryFloatArray (std::istream &stream, I begin, size_t n, Endianess number_representation=END_BIG_ENDIAN)
 Read an array of 4-byte floats on standard IEEE format. More...
 
void WriteBinaryDouble (std::ostream &stream, double d, Endianess number_representation=END_BIG_ENDIAN)
 Write a 8-byte float on standard IEEE format. More...
 
double ReadBinaryDouble (std::istream &stream, Endianess number_representation=END_BIG_ENDIAN)
 Read a 8-byte float on standard IEEE format. More...
 
template<typename I >
void WriteBinaryDoubleArray (std::ostream &stream, I begin, I end, Endianess number_representation=END_BIG_ENDIAN)
 Write an array of 8-byte floats on standard IEEE format. More...
 
template<typename I >
ReadBinaryDoubleArray (std::istream &stream, I begin, size_t n, Endianess number_representation=END_BIG_ENDIAN)
 Read an array of 8-byte floats on standard IEEE format. More...
 
void WriteBinaryIbmFloat (std::ostream &stream, float f, Endianess number_representation=END_BIG_ENDIAN)
 Write a 4-byte float on standard IEEE format. More...
 
float ReadBinaryIbmFloat (std::istream &stream, Endianess number_representation=END_BIG_ENDIAN)
 Read a 4-byte float on standard IEEE format. More...
 
template<typename I >
void WriteBinaryIbmFloatArray (std::ostream &stream, I begin, I end, Endianess number_representation=END_BIG_ENDIAN)
 Write an array of 4-byte floats on standard IEEE format. More...
 
template<typename I >
ReadBinaryIbmFloatArray (std::istream &stream, I begin, size_t n, Endianess number_representation=END_BIG_ENDIAN)
 Read an array of 4-byte floats on standard IEEE format. More...
 
bool IgnoreComment (std::ifstream &file, char chin)
 
int Seek (FILE *file, long long offset, int origin)
 Seek to given position in file, works for large files. More...
 
void ParseInt16BE (const char *buffer, short &ui)
 Parse unsigned 32-bit integer from big-endian buffer. More...
 
void ParseInt32BE (const char *buffer, int &ui)
 Parse unsigned 32-bit integer from big-endian buffer. More...
 
void ParseUInt16BE (const char *buffer, unsigned short &ui)
 Parse unsigned 32-bit integer from big-endian buffer. More...
 
void ParseUInt32BE (const char *buffer, unsigned int &ui)
 Parse unsigned 32-bit integer from big-endian buffer. More...
 
void ParseIEEEFloatBE (const char *buffer, float &f)
 Parse IEEE single-precision float from big-endian buffer. More...
 
void ParseIBMFloatBE (const char *buffer, float &f)
 Parse IEEE double-precision float from big-endian buffer. More...
 
template<>
std::string ReadNext< std::string > (std::istream &stream, int &line)
 
std::vector< std::stringGetTokens (const std::string &s)
 
std::vector< std::stringGetQuotedTokens (const std::string &s)
 
template<typename T >
bool IsType (const std::string &s)
 
template<typename T >
ParseType (const std::string &s)
 
template<>
std::string ParseType< std::string > (const std::string &s)
 
template<typename T >
std::string ToString (const T obj, int precision=-99999)
 
template<typename I >
ParseAsciiArrayFast (std::string &s, I begin, size_t n)
 Not safe. Replaces whitespace in s with \0. More...
 
std::string GetPath (const std::string &filename)
 Get the path from a full file name. More...
 
std::string GetStem (const std::string &filename)
 Get the stem of the filename (filename without path and extension) More...
 
std::string GetExtension (const std::string &filename)
 Get filename extension. More...
 
std::string RemovePath (const std::string &filename)
 Get file name only (no path) from full file name. More...
 
std::string PrependDir (const std::string &prefix, const std::string &str)
 
std::string ReplaceExtension (const std::string &filename, const std::string &extension)
 Replace file extension. More...
 
std::string AddExtension (const std::string &filename, const std::string &extension)
 Add an extension to the filename. More...
 
void Substitute (std::string &text, const std::string &out, const std::string &in)
 In string text replace all occurences odf string "out" with string "in". More...
 
std::string Uppercase (const std::string &text)
 Return uppercase of input string. More...
 
bool IsNumber (const std::string &s)
 
std::string Chomp (const std::string &s)
 
std::string Whitespace ()
 String with different kinds of whitespace characters. More...
 
SurfaceFileFormat FindSurfaceFileType (const std::string &filename)
 Find type of file. More...
 
std::string GetSurfFormatString (SurfaceFileFormat format)
 String describing file format. More...
 
template<class A >
void ReadStormBinarySurf (const std::string &filename, RegularSurface< A > &surface)
 
template<class A >
void ReadIrapClassicAsciiSurf (const std::string &filename, RegularSurface< A > &surface, double &angle)
 
template<class A >
void ReadSgriSurf (const std::string &filename, RegularSurface< A > &surface, double &angle)
 
std::vector< RegularSurfaceRotated< float > > ReadMultipleSgriSurf (const std::string &filename, const std::vector< std::string > &labels)
 
template<class A >
void ReadMulticolumnAsciiSurf (std::string filename, RegularSurface< A > &surface, double x_ref, double y_ref, double lx, double ly, int *ilxl_area, double il0_ref, double xl0_ref)
 
template<class A >
void WriteIrapClassicAsciiSurf (const RegularSurface< A > &surf, double angle, const std::string &filename)
 
template<class A >
void WriteStormBinarySurf (const RegularSurface< A > &surf, const std::string &filename)
 
bool FindMulticolumnAsciiLine (const std::string &filename, int &header_start_line)
 
template<typename A >
void BlockWell (const NRLib::Well &well, const A &grid, NRLib::Well &blocked_well)
 

Variables

const double MULT_IRAP_MISSING = -999.25
 
const double IRAP_MISSING = 9999900.0
 
const double STORM_MISSING = -999.0
 

Enumeration Type Documentation

◆ Endianess

Enumerator
END_LITTLE_ENDIAN 
END_BIG_ENDIAN 

◆ GridFileFormat

Enumerator
UNKNOWN 
STORM_PETRO_BINARY 
STORM_PETRO_ASCII 
STORM_FACIES_BINARY 
STORM_FACIES_ASCII 
SGRI 
SEGY 
PLAIN_ASCII 

◆ SurfaceFileFormat

Enumerator
SURF_UNKNOWN 
SURF_IRAP_CLASSIC_ASCII 
SURF_STORM_BINARY 
SURF_SGRI 
SURF_RMS_POINTS_ASCII 
SURF_MULT_ASCII 

Function Documentation

◆ AddExtension()

std::string NRLib::AddExtension ( const std::string filename,
const std::string extension 
)

Add an extension to the filename.

◆ BlockWell()

template<typename A >
void NRLib::BlockWell ( const NRLib::Well well,
const A &  grid,
NRLib::Well blocked_well 
)

Block the well into the grid. Possible grids to use are StormContGrid and StormFaciesGrid

References index, string, exprtk::details::x(), and exprtk::details::z.

◆ CheckEndOfFile()

bool NRLib::CheckEndOfFile ( std::istream &  stream)

Check if end of file is reached. Discards all whitespace before end of file or next token.

Returns
True if end of file is reached, else false.

Referenced by ReadIrapClassicAsciiSurf(), ReadMulticolumnAsciiSurf(), and ReadStormBinarySurf().

◆ Chomp()

std::string NRLib::Chomp ( const std::string s)

◆ CopyFile()

void NRLib::CopyFile ( const std::string from_path,
const std::string to_path,
bool  allow_overwrite 
)

◆ CreateDirIfNotExists()

void NRLib::CreateDirIfNotExists ( const std::string filename)

◆ DiscardRestOfLine()

void NRLib::DiscardRestOfLine ( std::istream &  stream,
int &  line_num,
bool  throw_if_non_whitespace 
)

Reads and discard all characters until and including next newline.

Parameters
throw_if_non_whitespaceIf true, throw exception if non-whitespace character is encountered.

Referenced by ReadMulticolumnAsciiSurf(), and ReadStormBinarySurf().

◆ FileExists()

bool NRLib::FileExists ( const std::string filename)

◆ FindFileSize()

unsigned long long NRLib::FindFileSize ( const std::string filename)

Finds the size of a file. Throws IOError if file not found.

Returns
Size of file in bytes.

◆ FindGridFileType()

int NRLib::FindGridFileType ( const std::string filename)

Find type of file, for 3D grid files.

◆ FindLastNonEmptyLine()

std::string NRLib::FindLastNonEmptyLine ( std::istream &  stream,
const std::ios::pos_type &  max_line_len = 1000 
)

Returns last non-empty line in file. Stream will be at end of file.

Note
Does not work on Windows for files larger than 2 GB. (Uses seekg + tellg)

◆ FindMulticolumnAsciiLine()

bool NRLib::FindMulticolumnAsciiLine ( const std::string filename,
int &  header_start_line 
)

◆ FindSurfaceFileType()

SurfaceFileFormat NRLib::FindSurfaceFileType ( const std::string filename)

◆ GetExtension()

std::string NRLib::GetExtension ( const std::string filename)

Get filename extension.

◆ GetNextNonEmptyLine()

std::istream & NRLib::GetNextNonEmptyLine ( std::istream &  stream,
int &  line_num,
std::string line 
)

Gets the next line that not only contains whitespace. Returns the stream. Stream will be bad if end-of-file is reached.

◆ GetPath()

std::string NRLib::GetPath ( const std::string filename)

Get the path from a full file name.

Referenced by ReadSgriSurf().

◆ GetQuotedTokens()

std::vector< std::string > NRLib::GetQuotedTokens ( const std::string s)

◆ GetStem()

std::string NRLib::GetStem ( const std::string filename)

Get the stem of the filename (filename without path and extension)

Referenced by ReadIrapClassicAsciiSurf(), ReadMulticolumnAsciiSurf(), ReadSgriSurf(), and ReadStormBinarySurf().

◆ GetSurfFormatString()

std::string NRLib::GetSurfFormatString ( SurfaceFileFormat  format)

String describing file format.

◆ GetTokens()

std::vector< std::string > NRLib::GetTokens ( const std::string s)

◆ IgnoreComment()

bool NRLib::IgnoreComment ( std::ifstream &  file,
char  chin 
)

◆ IsNumber()

bool NRLib::IsNumber ( const std::string s)

◆ IsType()

template<typename T >
bool NRLib::IsType ( const std::string s)

OBS: Negative values are recognized as unsigned integers on Windows. Works OK on Linux. (gcc 4.*)

References exprtk::details::x().

◆ OpenRead() [1/2]

void NRLib::OpenRead ( std::fstream &  stream,
const std::string filename,
std::ios_base::openmode  mode = std::ios_base::in 
)

◆ OpenRead() [2/2]

void NRLib::OpenRead ( std::ifstream &  stream,
const std::string filename,
std::ios_base::openmode  mode = std::ios_base::in 
)

◆ OpenWrite() [1/2]

void NRLib::OpenWrite ( std::fstream &  stream,
const std::string filename,
std::ios_base::openmode  mode = std::ios_base::out,
bool  create_dir = true 
)

◆ OpenWrite() [2/2]

void NRLib::OpenWrite ( std::ofstream &  stream,
const std::string filename,
std::ios_base::openmode  mode = std::ios_base::out,
bool  create_dir = true 
)

Open file for writing.

Parameters
create_dirIf true the directory is created if it does not exist.

Referenced by WriteIrapClassicAsciiSurf(), and WriteStormBinarySurf().

◆ ParseAsciiArrayFast()

template<typename I >
I NRLib::ParseAsciiArrayFast ( std::string s,
begin,
size_t  n 
)

Not safe. Replaces whitespace in s with \0.

References Catch::begin, ParseType(), and string.

Referenced by ReadAsciiArrayFastRestOfFile().

◆ ParseIBMFloatBE()

void NRLib::ParseIBMFloatBE ( const char *  buffer,
float &  f 
)
inline

Parse IEEE double-precision float from big-endian buffer.

References buffer, NRLib::NRLibPrivate::FloatAsInt::f, Ibm2Ieee(), and NRLib::NRLibPrivate::FloatAsInt::ui.

Referenced by ReadBinaryIbmFloatArray().

◆ ParseIEEEFloatBE()

void NRLib::ParseIEEEFloatBE ( const char *  buffer,
float &  f 
)
inline

Parse IEEE single-precision float from big-endian buffer.

References buffer, NRLib::NRLibPrivate::FloatAsInt::f, and NRLib::NRLibPrivate::FloatAsInt::ui.

Referenced by ReadBinaryFloatArray().

◆ ParseInt16BE()

void NRLib::ParseInt16BE ( const char *  buffer,
short &  ui 
)
inline

Parse unsigned 32-bit integer from big-endian buffer.

References buffer.

◆ ParseInt32BE()

void NRLib::ParseInt32BE ( const char *  buffer,
int &  ui 
)
inline

Parse unsigned 32-bit integer from big-endian buffer.

References buffer.

◆ ParseType()

template<typename T >
T NRLib::ParseType ( const std::string s)

OBS: Negative values are recognized as unsigned integers on Windows. Works OK on Linux. (gcc 4.*)

References name, and exprtk::details::x().

Referenced by ParseAsciiArrayFast().

◆ ParseType< std::string >()

template<>
std::string NRLib::ParseType< std::string > ( const std::string s)

If used in a template function, we may get string ot string parse. Will not work with the version above, so handle special case.

◆ ParseUInt16BE()

void NRLib::ParseUInt16BE ( const char *  buffer,
unsigned short &  ui 
)
inline

Parse unsigned 32-bit integer from big-endian buffer.

References buffer.

Referenced by ReadBinaryShortArray().

◆ ParseUInt32BE()

void NRLib::ParseUInt32BE ( const char *  buffer,
unsigned int &  ui 
)
inline

Parse unsigned 32-bit integer from big-endian buffer.

References buffer.

Referenced by ReadBinaryIntArray().

◆ PrependDir()

std::string NRLib::PrependDir ( const std::string prefix,
const std::string str 
)

Prepend prefix to str. Returns str if prefix is empty, if str is empty or if str is a complete path starting with /. Adds '/' as directory seperator if missing.

◆ ReadAsciiArray()

template<typename I >
I NRLib::ReadAsciiArray ( std::istream &  stream,
begin,
size_t  n,
int &  line 
)

Gets sequence with elements of type T from input stream. Might be relatively slow, due to typechecking, and counting line numbers.

Note
The container must already be big enough to read all n elements.

References Catch::begin.

◆ ReadAsciiArrayFast()

template<typename I >
I NRLib::ReadAsciiArrayFast ( std::istream &  stream,
begin,
size_t  n 
)

Gets sequence with elements of type T from input stream. Does no type checking, and does not count line numbers.

Note
The container must already be big enough to read all n elements.

References Catch::begin, string, and ToString().

Referenced by ReadIrapClassicAsciiSurf().

◆ ReadAsciiArrayFastRestOfFile()

template<typename I >
I NRLib::ReadAsciiArrayFastRestOfFile ( std::istream &  stream,
begin,
size_t  n 
)

Gets sequence with elements of type T from input stream. Does no type checking, and does not count line numbers. Reads the rest of the file, and does no type checking at all. If a double is attempted read as an int, the first integer part of the double is read, while the fraction part is discarded. For int, float or double this function is 10x as fast as GetAsciiArrayFast on Windows.

Note
The container must already be big enough to read all n elements.

References Catch::begin, buffer, Opm::end, ParseAsciiArrayFast(), and string.

◆ ReadBinaryDouble()

double NRLib::ReadBinaryDouble ( std::istream &  stream,
Endianess  number_representation = END_BIG_ENDIAN 
)

Read a 8-byte float on standard IEEE format.

◆ ReadBinaryDoubleArray()

template<typename I >
I NRLib::ReadBinaryDoubleArray ( std::istream &  stream,
begin,
size_t  n,
NRLib::Endianess  number_representation = END_BIG_ENDIAN 
)

Read an array of 8-byte floats on standard IEEE format.

Note
The container must already be big enough to read all n elements.

References Catch::begin, buffer, END_BIG_ENDIAN, END_LITTLE_ENDIAN, NRLib::NRLibPrivate::ParseIEEEDoubleBE(), and NRLib::NRLibPrivate::ParseIEEEDoubleLE().

Referenced by ReadStormBinarySurf().

◆ ReadBinaryFloat()

float NRLib::ReadBinaryFloat ( std::istream &  stream,
Endianess  number_representation = END_BIG_ENDIAN 
)

Read a 4-byte float on standard IEEE format.

◆ ReadBinaryFloatArray()

template<typename I >
I NRLib::ReadBinaryFloatArray ( std::istream &  stream,
begin,
size_t  n,
NRLib::Endianess  number_representation = END_BIG_ENDIAN 
)

Read an array of 4-byte floats on standard IEEE format.

Note
The container must already be big enough to read all n elements.

References Catch::begin, buffer, END_BIG_ENDIAN, END_LITTLE_ENDIAN, ParseIEEEFloatBE(), and NRLib::NRLibPrivate::ParseIEEEFloatLE().

Referenced by ReadSgriSurf().

◆ ReadBinaryIbmFloat()

float NRLib::ReadBinaryIbmFloat ( std::istream &  stream,
Endianess  number_representation = END_BIG_ENDIAN 
)

Read a 4-byte float on standard IEEE format.

◆ ReadBinaryIbmFloatArray()

template<typename I >
I NRLib::ReadBinaryIbmFloatArray ( std::istream &  stream,
begin,
size_t  n,
NRLib::Endianess  number_representation = END_BIG_ENDIAN 
)

Read an array of 4-byte floats on standard IEEE format.

Note
The container must already be big enough to read all n elements.

References Catch::begin, buffer, END_BIG_ENDIAN, END_LITTLE_ENDIAN, Opm::error, ParseIBMFloatBE(), NRLib::NRLibPrivate::ParseIBMFloatLE(), string, and ToString().

◆ ReadBinaryInt()

int NRLib::ReadBinaryInt ( std::istream &  stream,
Endianess  number_representation = END_BIG_ENDIAN 
)

Read a 4-byte integer from a binary file.

◆ ReadBinaryIntArray()

template<typename I >
I NRLib::ReadBinaryIntArray ( std::istream &  stream,
begin,
size_t  n,
NRLib::Endianess  number_representation = END_BIG_ENDIAN 
)

Read an array of binary 4-byte integers.

Note
The container must already be big enough to read all n elements.

References Catch::begin, buffer, END_BIG_ENDIAN, END_LITTLE_ENDIAN, ParseUInt32BE(), and NRLib::NRLibPrivate::ParseUInt32LE().

◆ ReadBinaryShort()

short NRLib::ReadBinaryShort ( std::istream &  stream,
Endianess  number_representation = END_BIG_ENDIAN 
)

Read a 2-byte integer from a binary file.

◆ ReadBinaryShortArray()

template<typename I >
I NRLib::ReadBinaryShortArray ( std::istream &  stream,
begin,
size_t  n,
NRLib::Endianess  number_representation = END_BIG_ENDIAN 
)

Read an array of binary 2-byte integers.

Note
The container must already be big enough to read all n elements.

References Catch::begin, buffer, END_BIG_ENDIAN, END_LITTLE_ENDIAN, ParseUInt16BE(), and NRLib::NRLibPrivate::ParseUInt16LE().

◆ ReadIrapClassicAsciiSurf()

◆ ReadMulticolumnAsciiSurf()

template<class A >
void NRLib::ReadMulticolumnAsciiSurf ( std::string  filename,
RegularSurface< A > &  surface,
double  x_ref,
double  y_ref,
double  lx,
double  ly,
int *  ilxl_area,
double  il0_ref,
double  xl0_ref 
)

◆ ReadMultipleSgriSurf()

std::vector< RegularSurfaceRotated< float > > NRLib::ReadMultipleSgriSurf ( const std::string filename,
const std::vector< std::string > &  labels 
)

◆ ReadNext()

template<typename T >
T NRLib::ReadNext ( std::istream &  stream,
int &  line 
)

Gets next token from file, and parses it as type T Might be relatively slow, due to typechecking, and counting line numbers.

Exceptions
EndOfFileif end of file is reached.
Exceptionif the token could not be parsed as the given type.

References ReadNextToken(), and string.

◆ ReadNext< std::string >()

template<>
std::string NRLib::ReadNext< std::string > ( std::istream &  stream,
int &  line 
)
inline

References ReadNextToken(), and string.

◆ ReadNextQuoted()

void NRLib::ReadNextQuoted ( std::istream &  stream,
char  quote,
std::string s,
int &  line 
)

Reads the next, possibly quoted, string.

◆ ReadNextToken()

std::istream & NRLib::ReadNextToken ( std::istream &  stream,
std::string s,
int &  line 
)

Read next white-space seperated token from file. Updates line number when new line is read in. If end of file is reached the state of stream is set to eof. If ReadNextToken is called with a stream that is not good, the state is set to fail.

Referenced by ReadNext(), and ReadNext< std::string >().

◆ ReadSgriSurf()

◆ ReadStormBinarySurf()

◆ RemoveFile()

void NRLib::RemoveFile ( const std::string filename)

◆ RemovePath()

std::string NRLib::RemovePath ( const std::string filename)

Get file name only (no path) from full file name.

◆ ReplaceExtension()

std::string NRLib::ReplaceExtension ( const std::string filename,
const std::string extension 
)

Replace file extension.

Referenced by ReadSgriSurf().

◆ Seek()

int NRLib::Seek ( FILE *  file,
long long  offset,
int  origin 
)

Seek to given position in file, works for large files.

◆ SkipComments()

void NRLib::SkipComments ( std::istream &  stream,
char  comment_token,
int &  line_num 
)

Returns next line that not only contains whitespace, or starts with the given comment token.

Exceptions
EndOfFileif end of file is reached before next non-empty line.

◆ Substitute()

void NRLib::Substitute ( std::string text,
const std::string out,
const std::string in 
)

In string text replace all occurences odf string "out" with string "in".

◆ ToString()

◆ Uppercase()

std::string NRLib::Uppercase ( const std::string text)

Return uppercase of input string.

◆ Whitespace()

std::string NRLib::Whitespace ( )
inline

String with different kinds of whitespace characters.

◆ WriteAsciiArray()

template<typename I >
void NRLib::WriteAsciiArray ( std::ostream &  stream,
begin,
end,
int  n_per_line = 6 
)

Writes array.

References Catch::begin, count, and Opm::end.

◆ WriteBinaryDouble()

void NRLib::WriteBinaryDouble ( std::ostream &  stream,
double  d,
Endianess  number_representation = END_BIG_ENDIAN 
)

Write a 8-byte float on standard IEEE format.

◆ WriteBinaryDoubleArray()

template<typename I >
void NRLib::WriteBinaryDoubleArray ( std::ostream &  stream,
begin,
end,
NRLib::Endianess  number_representation = END_BIG_ENDIAN 
)

◆ WriteBinaryFloat()

void NRLib::WriteBinaryFloat ( std::ostream &  stream,
float  f,
Endianess  number_representation = END_BIG_ENDIAN 
)

Write a 4-byte float on standard IEEE format.

◆ WriteBinaryFloatArray()

template<typename I >
void NRLib::WriteBinaryFloatArray ( std::ostream &  stream,
begin,
end,
NRLib::Endianess  number_representation = END_BIG_ENDIAN 
)

◆ WriteBinaryIbmFloat()

void NRLib::WriteBinaryIbmFloat ( std::ostream &  stream,
float  f,
Endianess  number_representation = END_BIG_ENDIAN 
)

Write a 4-byte float on standard IEEE format.

◆ WriteBinaryIbmFloatArray()

template<typename I >
void NRLib::WriteBinaryIbmFloatArray ( std::ostream &  stream,
begin,
end,
NRLib::Endianess  number_representation = END_BIG_ENDIAN 
)

◆ WriteBinaryInt()

void NRLib::WriteBinaryInt ( std::ostream &  stream,
int  i,
Endianess  number_representation = END_BIG_ENDIAN 
)

Write a 4-byte integer to a binary file.

◆ WriteBinaryIntArray()

template<typename I >
void NRLib::WriteBinaryIntArray ( std::ostream &  stream,
begin,
end,
NRLib::Endianess  number_representation = END_BIG_ENDIAN 
)

◆ WriteBinaryShort()

void NRLib::WriteBinaryShort ( std::ostream &  stream,
short  s,
Endianess  number_representation = END_BIG_ENDIAN 
)

Write a 2-byte integer to a binary file.

◆ WriteBinaryShortArray()

template<typename I >
void NRLib::WriteBinaryShortArray ( std::ostream &  stream,
begin,
end,
NRLib::Endianess  number_representation = END_BIG_ENDIAN 
)

◆ WriteIrapClassicAsciiSurf()

◆ WriteStormBinarySurf()

Variable Documentation

◆ IRAP_MISSING

const double NRLib::IRAP_MISSING = 9999900.0

◆ MULT_IRAP_MISSING

const double NRLib::MULT_IRAP_MISSING = -999.25

◆ STORM_MISSING

const double NRLib::STORM_MISSING = -999.0