Belle II Software light-2406-ragdoll
CppOrPyList Class Reference

Wrapper class for a list of strings to either be held in a std::vector or in a python list. More...

#include <Configuration.h>

Public Member Functions

boost::python::list & ensurePy ()
 Return the python list version.
 
std::vector< std::string > & ensureCpp ()
 Return the C++ vector version.
 
void append (const std::string &element)
 Append an element to whatever representation we currently have.
 
void prepend (const std::string &element)
 Prepend an element to whatever representation we currently have.
 
void shallowCopy (const boost::python::object &source)
 shallow copy all elements of the source object into the python representation.
 

Private Attributes

std::variant< std::vector< std::string >, boost::python::list > m_value
 Store either a std::vector or a python list of strings.
 

Detailed Description

Wrapper class for a list of strings to either be held in a std::vector or in a python list.

It's basically a std::variant with some convenince members to convert between the two representations.

This is necessary as python lists can only exist after Py_Initialize() and before Py_Finalize() and since we want this configuration class to work also in command line tools we need to be able to use std::vector unless python functions are called.

Definition at line 30 of file Configuration.h.

Member Function Documentation

◆ ensureCpp()

std::vector< std::string > & ensureCpp ( )

Return the C++ vector version.

Convert if necessary

◆ ensurePy()

boost::python::list & ensurePy ( )

Return the python list version.

Convert if necessary

◆ shallowCopy()

void shallowCopy ( const boost::python::object &  source)

shallow copy all elements of the source object into the python representation.

Also converts to python representation

Member Data Documentation

◆ m_value

std::variant<std::vector<std::string>, boost::python::list> m_value
private

Store either a std::vector or a python list of strings.

Definition at line 45 of file Configuration.h.


The documentation for this class was generated from the following file: