[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/boostorg/python/python313/test/extract.cpp [Back]  [Original]

// Copyright David Abrahams 2002.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#define BOOST_ENABLE_ASSERT_HANDLER
#include 
#include "test_class.hpp"

using namespace boost::python;

typedef test_class X;

bool extract_bool(object x) { return extract(x); }

boost::python::list extract_list(object x)
{
    extract get_list((x));

    // Make sure we always have the right idea about whether it's a list
    bool is_list_1 = get_list.check();
    bool is_list_2 = PyObject_IsInstance(x.ptr(), (PyObject*)&PyList_Type);
    if (is_list_1 != is_list_2) {
        throw std::runtime_error("is_list_1 == is_list_2 failure.");
    }
    return get_list();
}

char const* extract_cstring(object x)
{
    return extract(x);
}

std::string extract_string(object x)
{
    std::string s = extract(x);
    return s;
}

std::string const& extract_string_cref(object x)
{
#if defined(BOOST_MSVC) && BOOST_MSVC 

Web Proxy Viewer  |  New URL  |  Original Page