util.h File Reference
#include <string>
#include <vector>
#include <map>
#include <memory>
#include "awkward/common.h"
#include "dlfcn.h"

Go to the source code of this file.

Classes

class  IndexOf< T >
 A contiguous, one-dimensional array of integers used to represent data structures, rather than numerical data in the arrays themselves. More...
 

Namespaces

 awkward
 
 awkward::util
 

Typedefs

using RecordLookup = std::vector< std::string >
 
using RecordLookupPtr = std::shared_ptr< RecordLookup >
 
using Parameters = std::map< std::string, std::string >
 
using TypeStrs = std::map< std::string, std::string >
 

Enumerations

enum  dtype {
  NOT_PRIMITIVE, boolean, int8, int16,
  int32, int64, uint8, uint16,
  uint32, uint64, float16, float32,
  float64, float128, complex64, complex128,
  complex256, datetime64, timedelta64, size
}
 NumPy dtypes that can be interpreted within Awkward C++ (only the primitive, fixed-width types). Non-native-endian types are considered NOT_PRIMITIVE. More...
 
enum  ForthError {
  none, not_ready, is_done, user_halt,
  recursion_depth_exceeded, stack_underflow, stack_overflow, read_beyond,
  seek_beyond, skip_beyond, rewind_beyond, division_by_zero,
  varint_too_big, text_number_missing, quoted_string_missing, enumeration_missing,
  size
}
 Exhaustive list of runtime errors possible in the ForthMachine. More...
 

Functions

dtype name_to_dtype (const std::string &name)
 Returns the name associated with a given dtype. More...
 
const std::string dtype_to_name (dtype dt)
 Returns the name associated with a given dtype. More...
 
dtype format_to_dtype (const std::string &format, int64_t itemsize)
 Convert a NumPy format string and itemsize into a dtype enum. More...
 
const std::string dtype_to_format (dtype dt, const std::string &format="")
 Convert a dtype enum into a NumPy format string. More...
 
int64_t dtype_to_itemsize (dtype dt)
 Convert a dtype enum into an itemsize. More...
 
bool is_integer (dtype dt)
 True if the dtype is a non-boolean integer (signed or unsigned). More...
 
bool is_signed (dtype dt)
 True if the dtype is a signed integer. More...
 
bool is_unsigned (dtype dt)
 True if the dtype is an unsigned integer. More...
 
bool is_real (dtype dt)
 True if the dtype is a non-complex floating point number. More...
 
bool is_complex (dtype dt)
 True if the dtype is a complex number. More...
 
void handle_error (const struct Error &err, const std::string &classname=std::string(""), const Identities *id=nullptr)
 If the Error struct contains an error message (from a cpu-kernel through the C interface), raise that error as a C++ exception. More...
 
std::string quote (const std::string &x)
 Puts quotation marks around a string and escapes the appropriate characters. More...
 
template<typename T >
IndexOf< T > make_starts (const IndexOf< T > &offsets)
 Converts an offsets index (from ListOffsetArray, for instance) into a starts index by viewing it with the last element dropped. More...
 
template<typename T >
IndexOf< T > make_stops (const IndexOf< T > &offsets)
 Converts an offsets index (from ListOffsetArray, for instance) into a stops index by viewing it with the first element dropped. More...
 
RecordLookupPtr init_recordlookup (int64_t numfields)
 Initializes a RecordLookup by assigning each element with a string representation of its field index position. More...
 
int64_t fieldindex (const RecordLookupPtr &recordlookup, const std::string &key, int64_t numfields)
 Returns the field index associated with a key, given a RecordLookup and a number of fields. More...
 
const std::string key (const RecordLookupPtr &recordlookup, int64_t fieldindex, int64_t numfields)
 Returns the key associated with a field index, given a RecordLookup and a number of fields. More...
 
bool haskey (const RecordLookupPtr &recordlookup, const std::string &key, int64_t numfields)
 Returns true if a RecordLookup has a given key; false otherwise. More...
 
const std::vector< std::string > keys (const RecordLookupPtr &recordlookup, int64_t numfields)
 Returns a given RecordLookup as keys or generate anonymous ones form a number of fields. More...
 
bool json_equals (const std::string &myvalue, const std::string &value)
 Returns true if myvalue is equal to value when interpreted as JSON. More...
 
bool parameter_equals (const Parameters &parameters, const std::string &key, const std::string &value)
 Returns true if the value associated with a key in parameters is equal to the specified value. More...
 
bool parameters_equal (const Parameters &self, const Parameters &other, bool check_all)
 Returns true if all key-value pairs in self is equal to all key-value pairs in other. More...
 
void merge_parameters (Parameters &output, const Parameters &input)
 Merges a set of input parameters with output, keeping only those that are common to all sets. More...
 
bool parameter_isstring (const Parameters &parameters, const std::string &key)
 Returns true if the parameter associated with key is a string; false otherwise. More...
 
bool parameter_isname (const Parameters &parameters, const std::string &key)
 Returns true if the parameter associated with key is a string that matches [A-Za-z_][A-Za-z_0-9]*; false otherwise. More...
 
const std::string parameter_asstring (const Parameters &parameters, const std::string &key)
 Returns the parameter associated with key as a string if parameter_isstring; raises an error otherwise. More...
 
std::string gettypestr (const Parameters &parameters, const TypeStrs &typestrs)
 Extracts a custom type string from typestrs if required by one of the parameters or an empty string if there is no match. More...