AtilaCalculatorSoftware  2.3.4
C++ Interface for Atila fem resources files
utilities.h File Reference
#include <cstring>
#include <iostream>
#include <stdexcept>
#include <string>
#include <zlib.h>

Go to the source code of this file.

Macros

#define GZ_BUFFER_SIZE   2000
 Buffer size for gzread uses. More...
 
#define __HERE__   std::string(__FILE__) + ":" + std::to_string(__LINE__)
 Macro to get the current LINE and FILE (format: FILE:LINE) More...
 
#define __THROW__(x)   throw std::runtime_error(std::string("[" + __HERE__ + "] " + x));
 Macro to throw a running error, showing the current line and file (see HERE macro) More...
 
#define __DEBUG__(x)   { }
 
#define __DEBUG_FIELDS__(x)   { }
 
#define __PDEBUG__(x, y)   { }
 
#define GZ_READ_CHECK(FILE, BUFFER, LEN)
 Macro to read a compressed file using gzread (zlib) that returns -1 if the read size is not the expected size. More...
 

Typedefs

typedef char dataFields[10][40]
 

Functions

std::string const & to_string (std::string const &s)
 Allows to use to_string method for elements that are already string. More...
 
template<typename... TArgs>
std::string concat (TArgs const &... args)
 Cast and concatenate parameter pack elements as string. More...
 
unsigned int getFields (gzFile file, char *buffer, dataFields fields)
 Read fields from the given resource file. More...
 

Macro Definition Documentation

◆ __DEBUG__

#define __DEBUG__ (   x)    { }

◆ __DEBUG_FIELDS__

#define __DEBUG_FIELDS__ (   x)    { }

◆ __HERE__

#define __HERE__   std::string(__FILE__) + ":" + std::to_string(__LINE__)

Macro to get the current LINE and FILE (format: FILE:LINE)

◆ __PDEBUG__

#define __PDEBUG__ (   x,
 
)    { }

◆ __THROW__

#define __THROW__ (   x)    throw std::runtime_error(std::string("[" + __HERE__ + "] " + x));

Macro to throw a running error, showing the current line and file (see HERE macro)

◆ GZ_BUFFER_SIZE

#define GZ_BUFFER_SIZE   2000

Buffer size for gzread uses.

◆ GZ_READ_CHECK

#define GZ_READ_CHECK (   FILE,
  BUFFER,
  LEN 
)
Value:
if (static_cast<int>((LEN) * sizeof(*(BUFFER))) != \
gzread((FILE), (BUFFER), (LEN) * sizeof(*(BUFFER)))) \
return (-1);

Macro to read a compressed file using gzread (zlib) that returns -1 if the read size is not the expected size.

Typedef Documentation

◆ dataFields

typedef char dataFields[10][40]

Function Documentation

◆ concat()

template<typename... TArgs>
std::string concat ( TArgs const &...  args)

Cast and concatenate parameter pack elements as string.

Template Parameters
TArgsTypes of the given elements
Parameters
argsElements to stringify and concatenate
Returns
A single string with all the given elements

◆ getFields()

unsigned int getFields ( gzFile  file,
char *  buffer,
dataFields  fields 
)

Read fields from the given resource file.

Parameters
fileresource file to read
bufferZlib reading buffer
fieldsdataFields pointer in which fields will be written
Returns
The size of read data

◆ to_string()

std::string const& to_string ( std::string const &  s)
inline

Allows to use to_string method for elements that are already string.

Parameters
sProvided String
Returns
The same String as provided