ContRap-Core
Data Structures | Typedefs | Enumerations | Functions | Variables

crp Namespace Reference

The namespace crp is the namespace for all ContRap core components and libraries. More...

Data Structures

class  Block
 Class Block represents blocks in the control flow structure. More...
class  Call
 Class Call is a command which calls a function. More...
class  CallBack
 Class CallBack is a base class for call-back functions. More...
class  Class
 Class Class represents the memory layout the static members in a ContRap class. More...
class  CMakeFolder
 Class CMakeFolder represents a folder with a ContRap CMake file. More...
class  Command
 Class Command is the base interface for all ContRap commands. More...
class  ArgCommand
 Class ArgCommand is a command which has a list of arguments. More...
class  Assignment
 Class Assignment represents assignments of identifiers. More...
class  Declaration
 Class declaration is represents a list of assignments or identifiers, where each of them declares a local identifier. More...
class  Selector
 Class Selector represents nested scope or class selection commands. More...
class  Load
 Class Load represents the load command for libraries. More...
class  Statement
 Class Statement represents system commands, which should not be overloaded by the user. More...
class  Conditional
 Class Conditional represents conditional branches. More...
class  Console
 Class Console implements the console stream communication with a process. More...
class  Engine
 Class Engine is a combination of a parser and an interpreter. More...
class  Executable
 Class Executable composes an expression, an engine and an evaluation scope. More...
class  Error
 Class Error is the main error class thrown. More...
class  EoFError
 Class EoFError is an error thrown by the parser in case of the input end. More...
class  Interrupt
 Exception Interrupt is an exception thrown by the code if a break is requested. More...
class  Abort
 Exception Abort is thrown within a procedure to indicate that it is not usable with the given arguments. More...
class  Quit
 Exception Quit is a message thrown by the code if a quit is requested. More...
class  Stop
 Exception Stop is a message thrown by the code if a interpreter stop is requested. More...
class  Option
 Class Option represents an option to call in a function. More...
class  AtomicFunction
 Class AtomicFunction is the base interface for ContRap atomic functions. More...
class  ExternalFunction
 Class ExternalFunction encapsulates the external function type as an object. More...
class  InternalFunction
 Class InternalFunction represents a function defined with the ContRap language. More...
class  Function
 Class Function is the main structure for representing polymorphic functions of ContRap. More...
class  Identifier
 Class Identifier is an object which represents identifiers. More...
class  Parameter
 Class Parameter is an identifier type for representing parameters of functions. More...
class  Instance
 Class Instance represents an instance of a ContRap native class. More...
class  State
 Class State describes the state of the ContRap interpreter. More...
class  Return
 Class Return is the exception thrown by a procedure when returning to the caller. More...
class  Break
 Class Break is the exception thrown by within a loop when needed to break it. More...
class  Interpreter
 Class Interpreter implements the command interpreter of ContRap. More...
class  Library
 Class Library is a library descriptor. More...
class  List
 Class List represents list objects. More...
class  ListRef
 Class ListRef is a reference to list entries. More...
class  LoggerMessage
 Class LoggerMessage represents a message with type, string, and sender. More...
class  Logger
 Logger collects logging messages and returns them to a desired target on demand. More...
class  ModuleInfo
 Class ModuleInfo is used to describe module properties at runtime. More...
class  Object
 Class Object is the interface for all ContRap objects. More...
class  ObjectFactory
 Object factory provides an interface for instantiating objects from a string holding the type. More...
class  Options
 Class Options implements a singleton options container. More...
struct  Operator
 Class Operator defines the properties of an operator. More...
class  Parser
 Class Parser implements the parser of ContRap commands. More...
class  PluginManager
 Class PluginManager implements a singleton plugin library management interface. More...
class  MetaInfo
 Class MetaInfo contains objects meta-information. More...
class  Finalizer
 Class Finalizer is a pair of an object pointer and the corresponding destructor. More...
class  DPtr
 Class DPtr is a base weak typed class for smart pointers. More...
class  RefPtr
 Class RefPtr is an internal pointer class which implements the reference counter. More...
class  SPtr
 Class SPtr is a template typed reference counting pointer. More...
class  Scope
 Class Scope defines a relation between identifier names and their values within name scopes. More...
class  Serializer
 Class Serializer is a weak typed representation of objects for sending them through a serial stream. More...
class  Socket
 Class Socket is a platform independent socket implementation. More...
class  ClientSocket
 Class ClientSocket is a platform independent client socket. More...
class  ServerSocket
 Class ServerSocket is a platform independent server socket implementation. More...
class  StringTokenizer
 Class StringTokenizer implements a decomposition of a string into tokens separated by a set of delimiters. More...
class  Template
 Class Template is the base interface class for template objects. More...
class  Mutex
 Class Mutex is a platform-independent mutex wrapper. More...
class  WaitCondition
 Class WaitCondition implements a wait condition variable. More...
class  Thread
 Class Thread implements a user level thread. More...
class  EvalThread
 Class EvalThread is a thread, which evaluates an expression. More...
class  Timer
 Timer is a platform independent timer class. More...
class  String
 Class String is the wrapped class for strings. More...
class  XMLDataPool
 Class XMLDataPool is a query class object for XML-trees. More...
class  XMLGlyphPrinter
 Class XMLGlyphPrinter is an abstract glyph printing interface. More...
class  XMLLayoutBox
 Class XMLLayoutBox is an atomic layout item. More...
class  XMLRule
 Class XMLRule is a descriptor of complex drawing objects like tables, lists, etc. More...
class  XMLLayout
 Class XMLLayout is an abstract text layouter and printer of XML-formatted texts. More...
class  XMLError
 Class XMLError is the base class for all XML errors. More...
class  XMLParser
 Class XMLParser is an event driven base class to parse XML formatted strings. More...
class  XMLStreamParser
 Class XMLStreamParser is a stream based XML parser for text strings. More...
class  XMLPool
 Class XMLPool is a query class object for XML-trees. More...
class  LayoutBox
 Class LayoutBox is an atomic layout item. More...
class  XMLTextLayout
 Class XMLTextLayout is a layout class to print XML formatted strings to console or to a text file. More...

Typedefs

typedef ModuleInfo *(* InfoFunction )()
 Type definition for a ContRap function.
typedef DPtr(* MetaFunction )(SPtr< List > &arguments, SPtr< List > &options, SPtr< Scope > &scope, Engine *engine)
 Type for external functions.
typedef DPtr(* MapFunction )(DPtr, void *extra)
typedef bool(* DPtrCompare )(const DPtr &left, const DPtr &right)
 Comparison function prototype for dptrs.
typedef bool(* ConstructorFunction )(void *object)
 Prototype for the constructor function.
typedef bool(* CopyFunction )(const void *rvalue, void *lvalue)
 Prototype for the copy function.
typedef bool(* CastFunction )(const void *object)
 Prototype of cast functions.
typedef void(* DestructorFunction )(const void *object)
 Prototype for the destructor function.
typedef std::pair< std::string,
std::string > 
StringPair
 StringPair is a pair of strings.
typedef long long integer_t
 Finite precision integer type.
typedef long double floating_t
 Floating point type.
typedef std::complex< floating_tcomplex_t
 Floating point type.
typedef std::complex< double > complex
typedef std::vector
< std::vector< std::string > > 
UTF8Field

Enumerations

enum  MessageType { DEBUG_MESSAGE = 1, ERROR_MESSAGE = 2, WARNING_MESSAGE = 4, COMMENT_MESSAGE = 8 }
 

Enumerates message types of the logger.

More...
enum  MessageLevel { SHOW_NOTHING = 0, SHOW_ERRORS = 2, SHOW_WARNINGS = 4, SHOW_ALL = 8 }
 

Enumerates debug levels.

More...
enum  PointerMode {
  UNDEFINED, PERSISTENT, INSTANT, DELAYED,
  SOURCE
}
 

Deletion mode enumeration type.

More...

Functions

SPtr< CallEquation (const SPtr< Object > &left, const SPtr< Object > &right)
 Creates an equation from a left-hand side and a right-hand side.
CONTRAP_CORE_API SPtr< Callrequire (const DPtr &object, const std::string &name, const std::string &message)
 Makes a dynamic cast and returns the converted type or an error message if the resulting object is not of the required type.
CONTRAP_CORE_API SPtr< Callcheck (const DPtr &object, const std::string &name)
 Makes a dynamic cast to a call and checks the name of the operator.
CONTRAP_CORE_API std::map
< std::string, DPtr
interpret_options (SPtr< List > options)
 Interprets an options list.
CONTRAP_CORE_API void add_callback (const std::string &name, CallBack *callback)
 Adds a new call-back to the call-back list.
CONTRAP_CORE_API void remove_callback (const std::string &name)
 Removes a call-back from the call-back list.
CONTRAP_CORE_API void process_callbacks ()
 Process call-backs.
CONTRAP_CORE_API std::string console_read_nonblocking ()
 Method for reading from the console without blocking and calling call-backs during the input.
CONTRAP_CORE_API SPtr< Scopeget_nested_class (SPtr< Scope > scope, const std::string &name, bool create)
 Routes to the class which is pointed by an identifier.
CONTRAP_CORE_API void * open_library (const std::string &library, bool local=false, bool lazy=false)
 Opens a dynamic library in local or in global mode.
CONTRAP_CORE_API void * get_function_from_so (const std::string &function, void *handle)
 Platform independent dynamic loader function.
CONTRAP_CORE_API void close_library (void *handle)
 Closes library.
CONTRAP_CORE_API void error (const std::string &message)
 Creates and throws an error message from string.
CONTRAP_CORE_API void warning (const std::string &message, const std::string &sender="Core")
 Generates a warning.
CONTRAP_CORE_API void comment (const std::string &message, const std::string &sender="Core")
 Generates a comment.
CONTRAP_CORE_API void debug (const std::string &message, const std::string &sender="Debugger")
 Generates a comment.
CONTRAP_CORE_API void abort (const std::string &message)
 Creates and throws an abort message from string.
CONTRAP_CORE_API std::vector
< std::string > 
get_files_in_folder (const std::string &path)
 Returns all files in a folder.
CONTRAP_CORE_API std::vector
< std::string > 
get_folder_contents (const std::string &path)
 Returns all files in a folder including directories.
CONTRAP_CORE_API bool directory_exists (const std::string &path)
 Checks if a directory exists.
CONTRAP_CORE_API bool is_symbolic_link (const std::string &path)
 Checks if a file is a symbolic link.
CONTRAP_CORE_API bool file_exists (const std::string &file_name)
 Checks whether a file exists.
CONTRAP_CORE_API int get_file_size (const std::string &file_name)
 Returns the size of a file.
CONTRAP_CORE_API void create_directory (const std::string &path)
 Creates a directory.
CONTRAP_CORE_API std::string to_native_path (const std::string &path)
 Converts a path to the native system path.
CONTRAP_CORE_API std::string to_simple_path (const std::string &path)
 Simplifies a path not to contain trailing or double path delimiters.
CONTRAP_CORE_API bool is_relative_path (const std::string &path)
 Checks if a file path is a relative path or not.
CONTRAP_CORE_API std::string get_name_component (const std::string &path)
 Returns the name component of a file path.
CONTRAP_CORE_API std::string get_path_component (const std::string &file_name)
 Returns the path of a file name by splitting up the last component.
CONTRAP_CORE_API std::string relative_path (const std::string &reference, const std::string relative)
 Creates a path relative to a given path.
CONTRAP_CORE_API std::string make_temporary_file ()
 Makes a temporary file name.
CONTRAP_CORE_API bool read_file (const std::string &file_name, std::string &contents)
 Reads a file to a string.
CONTRAP_CORE_API bool write_file (const std::string &file_name, const std::string &contents)
 Writes a string to a file.
CONTRAP_CORE_API time_t time_of_last_change (const std::string &file_name)
 Returns the date of last file change.
CONTRAP_CORE_API std::vector
< std::string > 
break_paths (const std::string &paths)
 Breaks a ":"-separeted list of paths into a vector.
CONTRAP_CORE_API std::string is_library_path (const std::string &path)
 Returns a non-empty string if the file path is a path to a ContRap library.
CONTRAP_CORE_API std::string type_hash (const std::string &type)
 Type hash function, which returns a hash of a type used to compare function interfaces efficiently.
CONTRAP_CORE_API void dummy_destructor (void *)
 Dummy destructor function which does nothing.
CONTRAP_CORE_API bool add_extend (XMLDataPool *pool, const std::string &base_class, const std::string &super_class)
 Adds a class extend definition.
CONTRAP_CORE_API MetaInfoget_global_meta_info (const char *type_name)
 Returns the meta info for a type.
CONTRAP_CORE_API SPtr< Scopeget_nested_scope (SPtr< Scope > scope, const std::string &name, bool create)
 Routes to the scope which is pointed by an identifier.
std::string encode_hexadecimal (const char *array, size_t size)
 Converts a byte array to a string with hexadecimal numbers.
void decode_hexadecimal (const std::string &code, char *buffer)
 Decodes a string with hexadecimal numbers to a byte array.
template<typename T >
round (const T &x)
 Rounding function.
template<class T >
T * v2a (std::vector< T > &vector)
 Converts a vector to a C array.
template<class T >
T * v2a (std::vector< T > *vector)
 Converts a vector to a C array.
template<class T >
void clear_vector (std::vector< T > *vector)
 Deletes all the entries from a vector and clears the vector.
template<class T >
void clear_vector (std::vector< T > &vector)
 Deletes all the entries from a vector and clears the vector.
CONTRAP_CORE_API std::string trim (const std::string &string)
 Converts a string not to have leading, tail or subsequent.
CONTRAP_CORE_API std::string trimlr (const std::string &string)
 Converts a string not to have leading or tail subsequent.
CONTRAP_CORE_API std::string up (const std::string &string)
 Converts a string to upper case.
CONTRAP_CORE_API std::string low (const std::string &string)
 Converts a string to lower case.
CONTRAP_CORE_API std::string b2s (const bool value)
 Converts an boolean to a string.
CONTRAP_CORE_API std::string p2s (const void *pointer)
 Converts an pointer to a string.
CONTRAP_CORE_API std::string i2s (integer_t value)
 Converts an integer to a string.
CONTRAP_CORE_API std::string d2s (floating_t value, size_t decimal=0)
 Converts a double to a string.
CONTRAP_CORE_API floating_t s2d (const std::string &value)
 Converts a string to a double.
CONTRAP_CORE_API integer_t s2i (const std::string &value)
 Converts a string to an int.
CONTRAP_CORE_API integer_t s2ih (const std::string &value)
 Converts a string in hexadecimal representation to an int.
CONTRAP_CORE_API bool is_number (const std::string &value)
 Checks if the string is a number.
CONTRAP_CORE_API bool is_float (const std::string &value)
 Checks if the string is a floating point number.
CONTRAP_CORE_API bool is_hex (const std::string &value)
 Checks if the string is a hexdecimal number.
CONTRAP_CORE_API bool starts_with (const std::string &string, const std::string &start)
 Checks if a string starts with a certain phrase.
CONTRAP_CORE_API bool matches (const std::string &text, size_t position, const std::string &phrase)
 Checks if a string matches with a certain phrase a the given position.
CONTRAP_CORE_API bool ends_with (const std::string &string, const std::string &end)
 Checks if a string ends with a certain phrase.
CONTRAP_CORE_API std::string underscore_string (const std::string &input)
 Creates a new string from an input string, where each non-letter or number is replaced by "_".
CONTRAP_CORE_API std::string remove_comments (const std::string &string)
 Throws away all characters after a hash symbol.
CONTRAP_CORE_API std::string remove_invisible_symbols (const std::string &input)
 Removes all invisible and non ASCII symbols.
CONTRAP_CORE_API std::string insert_line_breaks (const std::string &input, int length)
 Inserts new lines into a string to ensure the text the given length in each line.
CONTRAP_CORE_API std::string escape_symbol (const std::string &string, char symbol, const std::string &escape)
 Escapes each occurrence of the given symbol.
CONTRAP_CORE_API std::string replace (const std::string &string, const std::string &query, const std::string &replace)
 Replaces a single query.
CONTRAP_CORE_API std::string multiple_replace (const std::string &string, const std::vector< std::string > &queries, const std::vector< std::string > &replace)
 Replaces a multiple set of queries one after another.
CONTRAP_CORE_API std::string trim_size (const std::string &input, int length)
 Trims a string to the given length by removing inner symbols and inserting a ...
CONTRAP_CORE_API std::vector
< std::string > 
break_string (const std::string &input)
 Creates an array of strings separated by the exactly the selector ':' excluding ':=' and '::'.
CONTRAP_CORE_API std::vector
< double > 
break_string (const std::string &input, const std::string &delimiters)
 Creates a double array from a string with given separators.
CONTRAP_CORE_API std::vector
< std::string > 
break_strings (const std::string &input, const std::string &delimiters)
 Creates an array of strings separated by the given delimiter.
CONTRAP_CORE_API bool string_to_range (const std::string &input, double &min, double &max, const std::string &delimiter="..")
 Interprets a string as a range separated by a given delimiter symbol ('..' by default)
CONTRAP_CORE_API std::vector
< std::string > 
get_cpp_error (const std::string &input)
 Finds compiler error messages for the GNU C++ compiler.
CONTRAP_CORE_API std::string replace_tokens (const std::string &input, const std::string &query, const std::string &replacement, const std::string &delimiters)
 Replaces in a given string occurrences of a query string, which are tokens with respect to a given set of delimiters.
CONTRAP_CORE_API std::string to_rich_text (const std::string &text)
 Prepares the string for meta-ritch text output.
CONTRAP_CORE_API std::string to_cpp_text (const std::string &text)
 Prepares a string for printing to a C++ file.
CONTRAP_CORE_API size_t find_delimiter (const std::string &text)
 Returns the position of a single ":" from the beginning in the string or std::string::npos.
CONTRAP_CORE_API int count_occurrences (const std::string &text, const std::string &query)
 Counts the number of occurrences of a substring in the string.
CONTRAP_CORE_API std::string get_current_directory ()
 Returns the current directory.
CONTRAP_CORE_API std::string get_home_directory ()
 Returns the path to the home directory (which is meant to be the user space to store local ContRap information)
CONTRAP_CORE_API const
std::string & 
get_contrap_install_path ()
 Returns the installation path of ContRap.
CONTRAP_CORE_API std::string get_environment_variable (const std::string &variable)
 Returns the environment variable with the given name.
CONTRAP_CORE_API void sleep_ms (int time)
 Suspends the process for a given number of milliseconds.
CONTRAP_CORE_API void set_user_signal (void(*callback)(int))
 Sets the callback for the user level interrupt.
template<class C , class T >
SPtr< C > cast (const SPtr< T > &object)
 Casts a smart pointer to a different type.
template<class C , class T >
SPtr< C > abort_cast (const SPtr< T > &object, const std::string &message="Invalid cast")
 Casts a smart pointer to a different type.
template<class C , class T >
SPtr< C > hard_cast (const SPtr< T > &object, const std::string &message="Invalid type cast")
 Casts a smart pointer to a different type.
template<class T >
SPtr< T > cast (const DPtr &object)
 Casts a data pointer to a smart pointer.
template<class T >
SPtr< T > abort_cast (const DPtr &object, const std::string &message="Invalid type cast")
 Casts a data pointer to a smart pointer.
template<class T >
SPtr< T > hard_cast (const DPtr &object, const std::string &message)
 Casts a data pointer to a smart pointer.
CONTRAP_CORE_API std::string to_xml (const std::string &message)
 Encodes a message to XML format by escaping all XML-tags.
CONTRAP_CORE_API std::string from_xml (const std::string &message)
 Decodes a message with escaped XML-charactes back to normal text.

Variables

std::ostringstream out
 Stream for intermediate result output.
const Operator internal_operators []
 List of built in operators.

Detailed Description

The namespace crp is the namespace for all ContRap core components and libraries.

Namespace crp encapsulates all classes and methods used within ContRap.


Typedef Documentation

typedef bool(* crp::CastFunction)(const void *object)

Prototype of cast functions.

A cast function returns true if the given object can be dynamically casted to some fixed class provided that the objects are from the same hierarchy.

Parameters:
objectObject to cast to
Returns:
True if the object can be casted to the given type.
typedef std::complex<double> crp::complex
typedef std::complex<floating_t> crp::complex_t

Floating point type.

typedef bool(* crp::ConstructorFunction)(void *object)

Prototype for the constructor function.

This function takes a pointer to a pre-allocated memory of the object and initializes this memory with valid values.

This function is only needed for structures.

Parameters:
objectPre-allocated not initialized memory
Returns:
True if initialization was correct
typedef bool(* crp::CopyFunction)(const void *rvalue, void *lvalue)

Prototype for the copy function.

This functions are used to copy an lvalue to an rvalue. An implementation of the assign function knows the type of the object assigned.

Parameters:
rvaluePointer to an object to copy
lvaluePre-allocated initialized memory
Returns:
True if the copy procedure was sucessful
typedef void(* crp::DestructorFunction)(const void *object)

Prototype for the destructor function.

The destructor deletes the given object.

typedef bool(* crp::DPtrCompare)(const DPtr &left, const DPtr &right)

Comparison function prototype for dptrs.

Parameters:
leftLeft element
rightRight element
Returns:
True if the elements are equal with respect to some criterium
typedef long double crp::floating_t

Floating point type.

Type definition for a ContRap function.

typedef long long crp::integer_t

Finite precision integer type.

typedef DPtr(* crp::MapFunction)(DPtr, void *extra)
typedef DPtr(* crp::MetaFunction)(SPtr< List > &arguments, SPtr< List > &options, SPtr< Scope > &scope, Engine *engine)

Type for external functions.

typedef std::pair<std::string, std::string> crp::StringPair

StringPair is a pair of strings.

typedef std::vector<std::vector<std::string> > crp::UTF8Field

Enumeration Type Documentation

Enumerates debug levels.

Enumerator:
SHOW_NOTHING 
SHOW_ERRORS 
SHOW_WARNINGS 
SHOW_ALL 

Enumerates message types of the logger.

Enumerator:
DEBUG_MESSAGE 
ERROR_MESSAGE 
WARNING_MESSAGE 
COMMENT_MESSAGE 

Deletion mode enumeration type.

Enumerator:
UNDEFINED 

Undefined mode should not be set by pointers.

PERSISTENT 

The contents of persistent pointers are not deleted at all.

INSTANT 

The contents of instant pointers are deleted immediately after the reference counter goes to zero.

DELAYED 

The contents of delayed pointers are queued for deletion and deleted at some suitable point.

SOURCE 

Source pointers behave like the persistent pointers, but additionally indicate to the smart pointer to check the source reference pointer.


Function Documentation

CONTRAP_CORE_API void crp::abort ( const std::string &  message)

Creates and throws an abort message from string.

Parameters:
messageError message
template<class C , class T >
SPtr<C> crp::abort_cast ( const SPtr< T > &  object,
const std::string &  message = "Invalid cast" 
)

Casts a smart pointer to a different type.

If the cast does not succeed an abort is produced.

On success you can directly use the resulting pointer, since it is guaranteed that it is non-zero.

Parameters:
objectObject to cast to.
messageError message thrown if no cast is possible.
Returns:
Object of new type or an invalid pointer.
template<class T >
SPtr<T> crp::abort_cast ( const DPtr &  object,
const std::string &  message = "Invalid type cast" 
)

Casts a data pointer to a smart pointer.

If the cast does not succeed an abort is produced.

On success you can directly use the resulting pointer, since it is guaranteed that it is non-zero.

Parameters:
objectData pointer object.
messageError message thrown if no cast is possible.
Returns:
Object of new type or an invalid pointer.
CONTRAP_CORE_API void crp::add_callback ( const std::string &  name,
CallBack *  callback 
)

Adds a new call-back to the call-back list.

Parameters:
nameName of the call-back
callbackPointer to the call-back instance
CONTRAP_CORE_API bool crp::add_extend ( XMLDataPool *  pool,
const std::string &  base_class,
const std::string &  super_class 
)

Adds a class extend definition.

The super class is added on start to the super class list of the base class.

Parameters:
poolPool which describes the library
base_classBase class name
super_classSuper class class
CONTRAP_CORE_API std::string crp::b2s ( const bool  value)

Converts an boolean to a string.

Parameters:
valueBoolean value
Returns:
The same value as a string
CONTRAP_CORE_API std::vector<std::string> crp::break_paths ( const std::string &  paths)

Breaks a ":"-separeted list of paths into a vector.

Parameters:
pathsString with paths
Returns:
Vector of corresponding single paths
CONTRAP_CORE_API std::vector<std::string> crp::break_string ( const std::string &  input)

Creates an array of strings separated by the exactly the selector ':' excluding ':=' and '::'.

Parameters:
inputInput string
Returns:
Vector of strings
CONTRAP_CORE_API std::vector<double> crp::break_string ( const std::string &  input,
const std::string &  delimiters 
)

Creates a double array from a string with given separators.

Parameters:
inputInput string
delimitersPossible delimiters
Returns:
List of values
CONTRAP_CORE_API std::vector<std::string> crp::break_strings ( const std::string &  input,
const std::string &  delimiters 
)

Creates an array of strings separated by the given delimiter.

Parameters:
inputInput string
delimitersPossible delimiters
Returns:
List of values
template<class C , class T >
SPtr<C> crp::cast ( const SPtr< T > &  object)

Casts a smart pointer to a different type.

Parameters:
objectObject pointer to cast.
Returns:
Object of new type or an invalid pointer.
template<class T >
SPtr<T> crp::cast ( const DPtr &  object)

Casts a data pointer to a smart pointer.

Parameters:
objectData pointer object
Returns:
Object of new type or an invalid pointer.
CONTRAP_CORE_API SPtr<Call> crp::check ( const DPtr &  object,
const std::string &  name 
)

Makes a dynamic cast to a call and checks the name of the operator.

Parameters:
objectObject under consideration
nameName of the operator
Returns:
Pointer to a call statement or a zero pointer if the object is not a call or not of given type.
template<class T >
void crp::clear_vector ( std::vector< T > *  vector)

Deletes all the entries from a vector and clears the vector.

Parameters:
vectorVector of the given type
template<class T >
void crp::clear_vector ( std::vector< T > &  vector)

Deletes all the entries from a vector and clears the vector.

Parameters:
vectorVector of the given type
CONTRAP_CORE_API void crp::close_library ( void *  handle)

Closes library.

Parameters:
handleHandle to the library
CONTRAP_CORE_API void crp::comment ( const std::string &  message,
const std::string &  sender = "Core" 
)

Generates a comment.

Parameters:
messageComment message.
senderSender instance (may be also logical).
CONTRAP_CORE_API std::string crp::console_read_nonblocking ( )

Method for reading from the console without blocking and calling call-backs during the input.

Returns:
Resulting string or empty string if nothing was read.
CONTRAP_CORE_API int crp::count_occurrences ( const std::string &  text,
const std::string &  query 
)

Counts the number of occurrences of a substring in the string.

Parameters:
textInput string
queryQuery string
Returns:
Number of occurrences of query in the text string
CONTRAP_CORE_API void crp::create_directory ( const std::string &  path)

Creates a directory.

Parameters:
pathPath to the directory
CONTRAP_CORE_API std::string crp::d2s ( floating_t  value,
size_t  decimal = 0 
)

Converts a double to a string.

Parameters:
valueDouble value
decimalDecimal points (default zero value means auto)
Returns:
The same value as a string
CONTRAP_CORE_API void crp::debug ( const std::string &  message,
const std::string &  sender = "Debugger" 
)

Generates a comment.

Parameters:
messageComment message.
senderSender instance (may be also logical).
void crp::decode_hexadecimal ( const std::string &  code,
char *  buffer 
)

Decodes a string with hexadecimal numbers to a byte array.

The size of the buffer must be at least the half of the input string length.

Parameters:
codeEncoded string
bufferBuffer with the resulting code
CONTRAP_CORE_API bool crp::directory_exists ( const std::string &  path)

Checks if a directory exists.

Parameters:
pathPath to the directory
Returns:
True if path points to a directory and the directory exists
CONTRAP_CORE_API void crp::dummy_destructor ( void *  )

Dummy destructor function which does nothing.

std::string crp::encode_hexadecimal ( const char *  array,
size_t  size 
)

Converts a byte array to a string with hexadecimal numbers.

Parameters:
arrayByte array
sizeSize of the array
Returns:
String with the array encoded in hexadecimal numbers.
CONTRAP_CORE_API bool crp::ends_with ( const std::string &  string,
const std::string &  end 
)

Checks if a string ends with a certain phrase.

Parameters:
stringString to check
endEnd of the string
SPtr<Call> crp::Equation ( const SPtr< Object > &  left,
const SPtr< Object > &  right 
)

Creates an equation from a left-hand side and a right-hand side.

Parameters:
leftLeft-hand side
rightRoght-hand side
CONTRAP_CORE_API void crp::error ( const std::string &  message)

Creates and throws an error message from string.

Parameters:
messageError message.
CONTRAP_CORE_API std::string crp::escape_symbol ( const std::string &  string,
char  symbol,
const std::string &  escape 
)

Escapes each occurrence of the given symbol.

Parameters:
stringString to check
symbolSymbol to escape
escapeEscape expression
Returns:
Changed string
CONTRAP_CORE_API bool crp::file_exists ( const std::string &  file_name)

Checks whether a file exists.

Parameters:
file_nameName of the file
Returns:
True iff the file exists
CONTRAP_CORE_API size_t crp::find_delimiter ( const std::string &  text)

Returns the position of a single ":" from the beginning in the string or std::string::npos.

Parameters:
textInput string
Returns:
Position of ":"
CONTRAP_CORE_API std::string crp::from_xml ( const std::string &  message)

Decodes a message with escaped XML-charactes back to normal text.

Parameters:
messageMessage with XML-characters
Returns:
Encoded message
CONTRAP_CORE_API const std::string& crp::get_contrap_install_path ( )

Returns the installation path of ContRap.

The path is given by a compile-time constant but can be overwritten by the environment variable CONTRAP_INSTALL_PATH.

This function is a short form for getting the path from the singleton option instance.

Returns:
Installation path of ContRap
CONTRAP_CORE_API std::vector<std::string> crp::get_cpp_error ( const std::string &  input)

Finds compiler error messages for the GNU C++ compiler.

Parameters:
inputInput string
Returns:
Strings containing the error source and the error line separated by a ":"
CONTRAP_CORE_API std::string crp::get_current_directory ( )

Returns the current directory.

Returns:
Current directory
CONTRAP_CORE_API std::string crp::get_environment_variable ( const std::string &  variable)

Returns the environment variable with the given name.

Parameters:
variableName of the environment variable
CONTRAP_CORE_API int crp::get_file_size ( const std::string &  file_name)

Returns the size of a file.

Parameters:
file_nameName of the file
CONTRAP_CORE_API std::vector<std::string> crp::get_files_in_folder ( const std::string &  path)

Returns all files in a folder.

Parameters:
pathPath to a directory
Returns:
All files including directoris in the folder
CONTRAP_CORE_API std::vector<std::string> crp::get_folder_contents ( const std::string &  path)

Returns all files in a folder including directories.

Parameters:
pathPath to a directory
Returns:
All files including directoris in the folder
CONTRAP_CORE_API void* crp::get_function_from_so ( const std::string &  function,
void *  handle 
)

Platform independent dynamic loader function.

Dynamic loader automatically constructs the correct library name for the given operation system.

Parameters:
functionFunction name to search for
handleAddress of the opened library if successful or zero pointer
Returns:
Void pointer to the function or zero if no function was found
CONTRAP_CORE_API MetaInfo* crp::get_global_meta_info ( const char *  type_name)

Returns the meta info for a type.

CONTRAP_CORE_API std::string crp::get_home_directory ( )

Returns the path to the home directory (which is meant to be the user space to store local ContRap information)

Returns:
Home directory
CONTRAP_CORE_API std::string crp::get_name_component ( const std::string &  path)

Returns the name component of a file path.

Parameters:
pathPath to a file or directory
Returns:
Name component
CONTRAP_CORE_API SPtr<Scope> crp::get_nested_class ( SPtr< Scope >  scope,
const std::string &  name,
bool  create 
)

Routes to the class which is pointed by an identifier.

Parameters:
scopeScope under consideration
nameName of a scope referenced with respect to the current scope
createIf set to true all scopes are created by overwriting the existing scope values
Returns:
Class addressed by the identifier
CONTRAP_CORE_API SPtr<Scope> crp::get_nested_scope ( SPtr< Scope >  scope,
const std::string &  name,
bool  create 
)

Routes to the scope which is pointed by an identifier.

Parameters:
scopeScope under consideration
nameName of a scope referenced with respect to the current scope
createIf set to true all scopes are created by overwriting the existing scope values
Returns:
Scope addressed by the identifier
CONTRAP_CORE_API std::string crp::get_path_component ( const std::string &  file_name)

Returns the path of a file name by splitting up the last component.

Parameters:
file_nameName of a file
Returns:
Path to the directory containing the file
template<class T >
SPtr<T> crp::hard_cast ( const DPtr &  object,
const std::string &  message 
)

Casts a data pointer to a smart pointer.

If the cast does not succeed, the an error is produced.

On success you can directly use the resulting pointer, since it is guaranteed that it is non-zero.

Parameters:
objectData pointer object.
messageError message thrown if no cast is possible.
Returns:
Object of new type or an invalid pointer.
template<class C , class T >
SPtr<C> crp::hard_cast ( const SPtr< T > &  object,
const std::string &  message = "Invalid type cast" 
)

Casts a smart pointer to a different type.

If the cast does not succeed an error is produced.

On success you can directly use the resulting pointer, since it is guaranteed that it is non-zero.

Parameters:
objectObject to cast to.
messageError message thrown if no cast is possible.
Returns:
Object of new type or an invalid pointer.
CONTRAP_CORE_API std::string crp::i2s ( integer_t  value)

Converts an integer to a string.

Parameters:
valueInteger value
Returns:
The same value as a string
CONTRAP_CORE_API std::string crp::insert_line_breaks ( const std::string &  input,
int  length 
)

Inserts new lines into a string to ensure the text the given length in each line.

Parameters:
inputInput string
lengthLine length
Returns:
Resulting string
CONTRAP_CORE_API std::map<std::string, DPtr> crp::interpret_options ( SPtr< List >  options)

Interprets an options list.

Parameters:
optionsList of equations, where the left hand side is an identifiert and the right hand side is an object
Returns:
Map from the option names to the corresponding objects
CONTRAP_CORE_API bool crp::is_float ( const std::string &  value)

Checks if the string is a floating point number.

This method assumes that the value is a number.

Parameters:
valueInput string
Returns:
True if the string is a number
CONTRAP_CORE_API bool crp::is_hex ( const std::string &  value)

Checks if the string is a hexdecimal number.

This method assumes that the value is a number.

Parameters:
valueInput string
Returns:
True if the string is a number
CONTRAP_CORE_API std::string crp::is_library_path ( const std::string &  path)

Returns a non-empty string if the file path is a path to a ContRap library.

Parameters:
pathPath to a file
Returns:
Name of the library if the path is valid
CONTRAP_CORE_API bool crp::is_number ( const std::string &  value)

Checks if the string is a number.

Parameters:
valueInput string
Returns:
True if the string is a number
CONTRAP_CORE_API bool crp::is_relative_path ( const std::string &  path)

Checks if a file path is a relative path or not.

Parameters:
pathPath to a file or directory
Returns:
True if the path is relative
CONTRAP_CORE_API bool crp::is_symbolic_link ( const std::string &  path)

Checks if a file is a symbolic link.

Parameters:
pathPath to the file or directory
Returns:
True if path exists and is a symbolic link
CONTRAP_CORE_API std::string crp::low ( const std::string &  string)

Converts a string to lower case.

Parameters:
stringInput string
Returns:
Output string
CONTRAP_CORE_API std::string crp::make_temporary_file ( )

Makes a temporary file name.

Returns:
Temporary file name.
CONTRAP_CORE_API bool crp::matches ( const std::string &  text,
size_t  position,
const std::string &  phrase 
)

Checks if a string matches with a certain phrase a the given position.

Parameters:
textString to check
positionPosition within the text string
phraseStart of the string
CONTRAP_CORE_API std::string crp::multiple_replace ( const std::string &  string,
const std::vector< std::string > &  queries,
const std::vector< std::string > &  replace 
)

Replaces a multiple set of queries one after another.

Queries for which nor replacements are given (e.g. the replace size is too small) are ignored.

Parameters:
stringString to replace
queriesVector of queries
replaceVector of corresponding replacements
Returns:
String with replaced contents
CONTRAP_CORE_API void* crp::open_library ( const std::string &  library,
bool  local = false,
bool  lazy = false 
)

Opens a dynamic library in local or in global mode.

Global mode is the default mode.

According to the new (GCC 3.0 and following) standard on Linux systems, the RTTI is not working properly on cross-defined types when libraries are loaded in local mode. On the other hand, globally loaded libraries do not allow library swapping at runtime, if the library is referenced by more than one other library.

Use local loading if you are working with the library and want to swap the library at runtime with newer version. Then only a rudimentary cast system is available on Linux.

Parameters:
libraryShared library name.
localFlag if the library should be opened locally.
lazyIf set to true the realocation is performed on demand.
Returns:
Void pointer to the function or zero if no function was found.
CONTRAP_CORE_API std::string crp::p2s ( const void *  pointer)

Converts an pointer to a string.

Parameters:
pointerPointer value
Returns:
The same value as a string
CONTRAP_CORE_API void crp::process_callbacks ( )

Process call-backs.

CONTRAP_CORE_API bool crp::read_file ( const std::string &  file_name,
std::string &  contents 
)

Reads a file to a string.

Parameters:
file_nameName of the file
contentsFile contents as a string
Returns:
True if the operation succeeded
CONTRAP_CORE_API std::string crp::relative_path ( const std::string &  reference,
const std::string  relative 
)

Creates a path relative to a given path.

Parameters:
referenceReference path
relativeRelative path
CONTRAP_CORE_API void crp::remove_callback ( const std::string &  name)

Removes a call-back from the call-back list.

Parameters:
nameName of the call-back
CONTRAP_CORE_API std::string crp::remove_comments ( const std::string &  string)

Throws away all characters after a hash symbol.

Parameters:
stringInput string
Modifiedstring with no hashes
CONTRAP_CORE_API std::string crp::remove_invisible_symbols ( const std::string &  input)

Removes all invisible and non ASCII symbols.

Parameters:
inputInput string
Returns:
Modified string
CONTRAP_CORE_API std::string crp::replace ( const std::string &  string,
const std::string &  query,
const std::string &  replace 
)

Replaces a single query.

Parameters:
stringString to replace
queryQuery
replaceReplacements
Returns:
String with replaced contents
CONTRAP_CORE_API std::string crp::replace_tokens ( const std::string &  input,
const std::string &  query,
const std::string &  replacement,
const std::string &  delimiters 
)

Replaces in a given string occurrences of a query string, which are tokens with respect to a given set of delimiters.

Notice that this differs from a simple replacement.

Parameters:
inputInput string
queryQuery string
replacementReplacement string
delimitersDelimiter srtring
Returns:
Resulting string
CONTRAP_CORE_API SPtr<Call> crp::require ( const DPtr &  object,
const std::string &  name,
const std::string &  message 
)

Makes a dynamic cast and returns the converted type or an error message if the resulting object is not of the required type.

Parameters:
objectObject under consideration
nameName of the operator
messageError message
template<typename T >
T crp::round ( const T &  x)

Rounding function.

Returns:
x Value to round
Rounded value as integer
CONTRAP_CORE_API floating_t crp::s2d ( const std::string &  value)

Converts a string to a double.

Parameters:
valueDouble value
Returns:
The same value as a double
CONTRAP_CORE_API integer_t crp::s2i ( const std::string &  value)

Converts a string to an int.

Parameters:
valueInteger value
Returns:
The same value as a int
CONTRAP_CORE_API integer_t crp::s2ih ( const std::string &  value)

Converts a string in hexadecimal representation to an int.

Parameters:
valueInteger value
Returns:
The same value as a int
CONTRAP_CORE_API void crp::set_user_signal ( void(*)(int)  callback)

Sets the callback for the user level interrupt.

This function is motivated by the fact that there is no user level interrupt on Windows.

Parameters:
callbackCallback function
CONTRAP_CORE_API void crp::sleep_ms ( int  time)

Suspends the process for a given number of milliseconds.

Parameters:
sleepNumber of milliseconds
CONTRAP_CORE_API bool crp::starts_with ( const std::string &  string,
const std::string &  start 
)

Checks if a string starts with a certain phrase.

Parameters:
stringString to check
startStart of the string
CONTRAP_CORE_API bool crp::string_to_range ( const std::string &  input,
double &  min,
double &  max,
const std::string &  delimiter = ".." 
)

Interprets a string as a range separated by a given delimiter symbol ('..' by default)

Parameters:
inputInput string
minStart of the range
maxEnd of the range
delimiterDelimiter symbol, which separates the minimum and the maximum value
Returns:
True if the string describes a range
CONTRAP_CORE_API time_t crp::time_of_last_change ( const std::string &  file_name)

Returns the date of last file change.

Parameters:
file_nameName of the file
Returns:
Data of the last file change
CONTRAP_CORE_API std::string crp::to_cpp_text ( const std::string &  text)

Prepares a string for printing to a C++ file.

Parameters:
textInput string
Returns:
String with
's replaced by quotes and with escaped quotes
CONTRAP_CORE_API std::string crp::to_native_path ( const std::string &  path)

Converts a path to the native system path.

Parameters:
pathPath to convert
Returns:
Converted path
CONTRAP_CORE_API std::string crp::to_rich_text ( const std::string &  text)

Prepares the string for meta-ritch text output.

Parameters:
textInput string
Returns:
Meta ritch text
CONTRAP_CORE_API std::string crp::to_simple_path ( const std::string &  path)

Simplifies a path not to contain trailing or double path delimiters.

Parameters:
pathPath to convert
Returns:
Converted path
CONTRAP_CORE_API std::string crp::to_xml ( const std::string &  message)

Encodes a message to XML format by escaping all XML-tags.

Parameters:
messageMessage to encode
Returns:
Message with relevant symbols escaped
CONTRAP_CORE_API std::string crp::trim ( const std::string &  string)

Converts a string not to have leading, tail or subsequent.

Parameters:
stringInput string
Returns:
Input string without leading, tail, and subsequent white spaces
CONTRAP_CORE_API std::string crp::trim_size ( const std::string &  input,
int  length 
)

Trims a string to the given length by removing inner symbols and inserting a ...

Parameters:
inputInput string
lengthDesired length
Returns:
String of length at most length
CONTRAP_CORE_API std::string crp::trimlr ( const std::string &  string)

Converts a string not to have leading or tail subsequent.

Parameters:
stringInput string
Returns:
Input string without leading or tail white spaces
CONTRAP_CORE_API std::string crp::type_hash ( const std::string &  type)

Type hash function, which returns a hash of a type used to compare function interfaces efficiently.

Parameters:
typeType name
Returns:
Hash of a type
CONTRAP_CORE_API std::string crp::underscore_string ( const std::string &  input)

Creates a new string from an input string, where each non-letter or number is replaced by "_".

Parameters:
inputInput string
Returns:
A string
CONTRAP_CORE_API std::string crp::up ( const std::string &  string)

Converts a string to upper case.

Parameters:
stringInput string
Returns:
Output string
template<class T >
T* crp::v2a ( std::vector< T > *  vector)

Converts a vector to a C array.

Parameters:
vectorVector to convert
Returns:
Pointer to its first element
template<class T >
T* crp::v2a ( std::vector< T > &  vector)

Converts a vector to a C array.

Parameters:
vectorVector to convert
Returns:
Pointer to its first element
CONTRAP_CORE_API void crp::warning ( const std::string &  message,
const std::string &  sender = "Core" 
)

Generates a warning.

Parameters:
messageWarning message.
senderSender instance (may be also logical).
CONTRAP_CORE_API bool crp::write_file ( const std::string &  file_name,
const std::string &  contents 
)

Writes a string to a file.

Parameters:
file_nameName of the file
contentsFile contents as a string
Returns:
True if the operation succeeded

Variable Documentation

List of built in operators.

std::ostringstream crp::out

Stream for intermediate result output.

This stream should be used to drop messages to the user interfaces. In case of the console interface the stream is lead to the standard output.