ShlubluLib  v0.5
ShlubluLib is a lightweight, modular, general purpose, open-source C++ library for Linux and Windows.
Namespaces | Typedefs | Functions | Variables
Python.h File Reference
#include <string>
#include <vector>
#include <shlublu/binding/Python_BindingExceptions.h>
#include <shlublu/binding/Python_ObjectHandler.h>

Go to the source code of this file.

Namespaces

 shlublu
 
 shlublu::Python
 

Typedefs

using shlublu::Python::PathEntriesList = std::vector< std::string >
 Path, as a vector of strings.
 
using shlublu::Python::ObjectHandlersList = std::vector< ObjectHandler >
 Parameters list to pass to call() or to functions that create collections.
 
using shlublu::Python::ObjectPointer = PyObject *
 Pointer to scope objects (either imported modules or instances of a class) or callable objects (functions or methods). More...
 
using shlublu::Python::RawCode = std::string
 Plain Python code.
 
using shlublu::Python::Program = std::vector< RawCode >
 Complete program. More...
 

Functions

bool shlublu::Python::isInitialized ()
 Check whether Python is initialized. More...
 
void shlublu::Python::init (std::string const &programName, PathEntriesList const &pythonSysPath=PathEntriesList())
 Initializes Python. More...
 
void shlublu::Python::shutdown ()
 Shuts down Python. More...
 
void shlublu::Python::execute (RawCode const &code)
 Executes raw code. More...
 
void shlublu::Python::execute (Program const &program)
 Executes a program. More...
 
ObjectPointer shlublu::Python::import (std::string const &moduleName)
 Imports a module by its name. More...
 
ObjectPointer shlublu::Python::module (std::string const &moduleName)
 Retrieves a previously imported module. More...
 
ObjectHandler const & shlublu::Python::object (ObjectPointer scope, std::string const &objectName)
 Retrieves an object by its name from a scope pointer. More...
 
ObjectHandler const & shlublu::Python::object (std::string const &moduleName, std::string const &objectName)
 Retrieves an object by its name from a module name. More...
 
ObjectPointer shlublu::Python::callable (ObjectPointer scope, std::string const &callableName, bool forceReload=false)
 Retrieves a callable object (function or method) by its name from a scope pointer. More...
 
ObjectPointer shlublu::Python::callable (std::string const &moduleName, std::string const &callableName, bool forceReload=false)
 Retrieves a callable object (function) by its name from a module name. More...
 
ObjectHandler const & shlublu::Python::call (ObjectPointer callableObject, ObjectHandlersList const &args={}, bool keepArguments=false)
 Calls a callable with the given arguments. More...
 
ObjectHandler shlublu::Python::tuple (ObjectHandlersList const &args={}, bool keepArguments=false)
 Creates a tuple object initialized with the given arguments. More...
 
ObjectHandler shlublu::Python::list (ObjectHandlersList const &args={}, bool keepArguments=false)
 Creates a list object initialized with the given arguments. More...
 
void shlublu::Python::addList (ObjectHandler list, ObjectHandler item, bool keepArg=false)
 Adds an item to the end of a list. More...
 
ObjectHandler shlublu::Python::fromAscii (std::string const &str)
 Converts a string to a UTF-8 CPython string object. More...
 
std::string shlublu::Python::toAscii (ObjectHandler utfStr, bool keepArg=false)
 Converts a UTF-8 CPython string object to a std::string. More...
 
ObjectHandler const & shlublu::Python::keepArgument (ObjectHandler const &object)
 Prevents an object reference from being stolen. More...
 
ObjectHandler const & shlublu::Python::controlArgument (ObjectHandler object)
 Places an CPython object under control of Python. More...
 
void shlublu::Python::forgetArgument (ObjectHandler const &object)
 Get rid of a reference of an object under control. More...
 
void shlublu::Python::beginCriticalSection ()
 Enters a critical section, preventing other threads from entering any Python critical section. More...
 
void shlublu::Python::endCriticalSection ()
 Exits a critical section, allowing other threads to enter a Python critical section. More...
 

Variables

const std::string shlublu::Python::moduleMain
 Main module ("__main__"). More...
 
const std::string shlublu::Python::moduleBuiltins
 Built-ins module ("builtins"). More...
 

Detailed Description

Main file of the Python module. Based on the CPython standard API, this module is intended to make Python integration easier.

See Python namespace documentation for details.