亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? tutorial.qbk

?? C++的一個好庫。。。現(xiàn)在很流行
?? QBK
?? 第 1 頁 / 共 5 頁
字號:
[library python
    [version 1.0]
    [authors [de Guzman, Joel], [Abrahams, David]]
    [copyright 2002 2003 2004 2005 Joel de Guzman, David Abrahams]
    [category inter-language support]
    [purpose
        Reflects C++ classes and functions into Python
    ]
    [license
        Distributed under the Boost Software License, Version 1.0.
        (See accompanying file LICENSE_1_0.txt or copy at
        <ulink url="http://www.boost.org/LICENSE_1_0.txt">
            http://www.boost.org/LICENSE_1_0.txt
        </ulink>)
    ]
]

[/ QuickBook Document version 0.9 ]

[def __note__       [$images/note.png]]
[def __alert__      [$images/alert.png]]
[def __tip__        [$images/tip.png]]
[def :-)            [$images/smiley.png]]
[def __jam__        [$images/jam.png]]

[section QuickStart]

The Boost Python Library is a framework for interfacing Python and
C++. It allows you to quickly and seamlessly expose C++ classes
functions and objects to Python, and vice-versa, using no special
tools -- just your C++ compiler. It is designed to wrap C++ interfaces
non-intrusively, so that you should not have to change the C++ code at
all in order to wrap it, making Boost.Python ideal for exposing
3rd-party libraries to Python. The library's use of advanced
metaprogramming techniques simplifies its syntax for users, so that
wrapping code takes on the look of a kind of declarative interface
definition language (IDL).

[h2 Hello World]

Following C/C++ tradition, let's start with the "hello, world". A C++
Function:

    char const* greet()
    {
       return "hello, world";
    }

can be exposed to Python by writing a Boost.Python wrapper:

    #include <boost/python.hpp>
    using namespace boost::python;

    BOOST_PYTHON_MODULE(hello)
    {
        def("greet", greet);
    }

That's it. We're done. We can now build this as a shared library. The
resulting DLL is now visible to Python. Here's a sample Python session:

[python]

    >>> import hello
    >>> print hello.greet()
    hello, world

[c++]

[:['[*Next stop... Building your Hello World module from start to finish...]]]

[endsect]
[section:hello Building Hello World]

[h2 From Start To Finish]

Now the first thing you'd want to do is to build the Hello World module and
try it for yourself in Python. In this section, we shall outline the steps
necessary to achieve that. We shall use the build tool that comes bundled
with every boost distribution: [*bjam].

[blurb __note__ [*Building without bjam]\n\n
    Besides bjam, there are of course other ways to get your module built.
    What's written here should not be taken as "the one and only way".
    There are of course other build tools apart from [^bjam].\n\n
    Take note however that the preferred build tool for Boost.Python is bjam.
    There are so many ways to set up the build incorrectly. Experience shows
    that 90% of the "I can't build Boost.Python" problems come from people
    who had to use a different tool.
]

We shall skip over the details. Our objective will be to simply create the
hello world module and run it in Python. For a complete reference to
building Boost.Python, check out: [@../../../building.html building.html].
After this brief ['bjam] tutorial, we should have built two DLLs:

* boost_python.dll
* hello.pyd

if you are on Windows, and

* libboost_python.so
* hello.so

if you are on Unix.

The tutorial example can be found in the directory:
[^libs/python/example/tutorial]. There, you can find:

* hello.cpp
* Jamfile

The [^hello.cpp] file is our C++ hello world example. The [^Jamfile] is a
minimalist ['bjam] script that builds the DLLs for us.

Before anything else, you should have the bjam executable in your boost
directory or somewhere in your path such that [^bjam] can be executed in
the command line. Pre-built Boost.Jam executables are available for most
platforms. The complete list of Bjam executables can be found
[@http://sourceforge.net/project/showfiles.php?group_id=7586 here].

[h2 Let's Jam!]
__jam__

Here is our minimalist Jamfile:

[pre
# This is the top of our own project tree
project-root ;

import python ;

extension hello                     # Declare a Python extension called hello
:   hello.cpp                       # source
    # requirements and dependencies for Boost.Python extensions
    <template>@boost/libs/python/build/extension
    ;
]

First, we need to specify our location. You may place your project anywhere.
[^project-root] allows you to do that.

[pre
project-root ;
]

By doing so, you'll need a Jamrules file. Simply copy the one in the 
[@../../../../example/tutorial/Jamrules example/tutorial directory] and tweak 
the [^path-global BOOST_ROOT] to where your boost root directory is. The file
has [@../../../../example/tutorial/Jamrules detailed instructions] you can follow.

Then we will import the definitions needed by Python modules:

[pre
import python ;
]

Finally we declare our [^hello] extension:

[pre
extension hello                     # Declare a Python extension called hello
:   hello.cpp                       # source

    # requirements and dependencies for Boost.Python extensions
    <template>@boost/libs/python/build/extension
    ;
]

The last part tells BJam that we are depending on the Boost Python Library.

[h2 Running bjam]

['bjam] is run using your operating system's command line interpreter.

[:Start it up.]

Make sure that the environment is set so that we can invoke the C++
compiler. With MSVC, that would mean running the [^Vcvars32.bat] batch
file. For instance:

[pre
C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools\vsvars32.bat
]

Some environment variables will have to be setup for proper building of our
Python modules. Example:

[pre
set PYTHON_ROOT=c:/dev/tools/python
set PYTHON_VERSION=2.2
]

The above assumes that the Python installation is in [^c:/dev/tools/python]
and that we are using Python version 2.2. You'll have to tweak these
appropriately.

[blurb __tip__ Be sure not to include a third number, e.g. [*not]  "2.2.1",
even if that's the version you have.]

Take note that you may also do that through the Jamrules file we put in
our project as detailed above. The file
has [@../../../../example/tutorial/Jamrules detailed instructions] you 
can follow.

Now we are ready... Be sure to [^cd] to [^libs/python/example/tutorial]
where the tutorial [^"hello.cpp"] and the [^"Jamfile"] is situated.

Finally:

    bjam -sTOOLS=vc-7_1

We are again assuming that we are using Microsoft Visual C++ version 7.1. If
not, then you will have to specify the appropriate tool. See
[@../../../../../../tools/build/index.html Building Boost Libraries] for
further details.

It should be building now:

[pre
cd C:\dev\boost\libs\python\example\tutorial
bjam -sTOOLS=msvc
...patience...
...found 1703 targets...
...updating 40 targets...
]

And so on... Finally:

[pre
Creating library bin\boost\libs\python\build\boost_python.dll\vc-7_1\debug\th
reading-multi\boost_python.lib and object bin\boost\libs\python\build\boost_pyth
on.dll\vc-7_1\debug\threading-multi\boost_python.exp
vc-C++ bin\tutorial\hello.pyd\vc-7_1\debug\threading-multi\hello.obj
hello.cpp
vc-Link bin\tutorial\hello.pyd\vc-7_1\debug\threading-multi\hello.pyd bin\tutori
al\hello.pyd\vc-7_1\debug\threading-multi\hello.lib
   Creating library bin\tutorial\hello.pyd\vc-7_1\debug\threading-multi\hello.li
b and object bin\tutorial\hello.pyd\vc-7_1\debug\threading-multi\hello.exp
...updated 31 targets...
]

If all is well, you should now have:

* boost_python.dll
* hello.pyd

if you are on Windows, and

* libboost_python.so
* hello.so

if you are on Unix.

[^boost_python.dll] and [^hello.pyd] can be found somewhere in your project's
[^bin] directory. After a successful build, you can just link in these DLLs with 
the Python interpreter. In Windows for example, you can simply put these libraries 
inside the directory where the Python executable is.

You may now fire up Python and run our hello module:

[python]

    >>> import hello
    >>> print hello.greet()
    hello, world

[c++]

[:[*There you go... Have fun!]]

[endsect]
[section:exposing Exposing Classes]

Now let's expose a C++ class to Python.

Consider a C++ class/struct that we want to expose to Python:

    struct World
    {
        void set(std::string msg) { this->msg = msg; }
        std::string greet() { return msg; }
        std::string msg;
    };

We can expose this to Python by writing a corresponding Boost.Python
C++ Wrapper:

    #include <boost/python.hpp>
    using namespace boost::python;

    BOOST_PYTHON_MODULE(hello)
    {
        class_<World>("World")
            .def("greet", &World::greet)
            .def("set", &World::set)
        ;
    }

Here, we wrote a C++ class wrapper that exposes the member functions
[^greet] and [^set]. Now, after building our module as a shared library, we
may use our class [^World] in Python. Here's a sample Python session:

[python]

    >>> import hello
    >>> planet = hello.World()
    >>> planet.set('howdy')
    >>> planet.greet()
    'howdy'

[section Constructors]

Our previous example didn't have any explicit constructors.
Since [^World] is declared as a plain struct, it has an implicit default
constructor. Boost.Python exposes the default constructor by default,
which is why we were able to write

    >>> planet = hello.World()

We may wish to wrap a class with a non-default constructor. Let us
build on our previous example:

[c++]

    struct World
    {
        World(std::string msg): msg(msg) {} // added constructor
        void set(std::string msg) { this->msg = msg; }
        std::string greet() { return msg; }
        std::string msg;
    };

This time [^World] has no default constructor; our previous
wrapping code would fail to compile when the library tried to expose
it. We have to tell [^class_<World>] about the constructor we want to
expose instead.

    #include <boost/python.hpp>
    using namespace boost::python;

    BOOST_PYTHON_MODULE(hello)
    {
        class_<World>("World", init<std::string>())
            .def("greet", &World::greet)
            .def("set", &World::set)
        ;
    }

[^init<std::string>()] exposes the constructor taking in a
[^std::string] (in Python, constructors are spelled
"[^"__init__"]").

We can expose additional constructors by passing more [^init<...>]s to
the [^def()] member function. Say for example we have another World
constructor taking in two doubles:

    class_<World>("World", init<std::string>())
        .def(init<double, double>())
        .def("greet", &World::greet)
        .def("set", &World::set)
    ;

On the other hand, if we do not wish to expose any constructors at
all, we may use [^no_init] instead:

    class_<Abstract>("Abstract", no_init)

This actually adds an [^__init__] method which always raises a
Python RuntimeError exception.

[endsect]
[section Class Data Members]

Data members may also be exposed to Python so that they can be
accessed as attributes of the corresponding Python class. Each data
member that we wish to be exposed may be regarded as [*read-only] or
[*read-write].  Consider this class [^Var]:

    struct Var
    {
        Var(std::string name) : name(name), value() {}
        std::string const name;
        float value;
    };

Our C++ [^Var] class and its data members can be exposed to Python:

    class_<Var>("Var", init<std::string>())
        .def_readonly("name", &Var::name)
        .def_readwrite("value", &Var::value);

Then, in Python, assuming we have placed our Var class inside the namespace
hello as we did before:

[python]

    >>> x = hello.Var('pi')
    >>> x.value = 3.14

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久国产乱子精品免费女| 懂色av一区二区三区免费观看 | 7777精品伊人久久久大香线蕉 | 91在线观看污| 日韩精品一区在线观看| 一区二区激情小说| 国产一级精品在线| 欧美日韩二区三区| 一二三四社区欧美黄| 国产精品小仙女| 精品盗摄一区二区三区| 首页综合国产亚洲丝袜| 欧美在线免费播放| 亚洲男人的天堂网| 91一区二区在线观看| 中文字幕一区二区三区不卡 | 国内精品国产成人国产三级粉色| 欧美巨大另类极品videosbest | 欧美一区二区三区在线观看视频| 亚洲精品国产精品乱码不99| 国产精品18久久久久久久网站| 日韩一级高清毛片| 日韩激情一区二区| 日韩一区二区中文字幕| 午夜精品福利久久久| 欧美日韩www| 亚洲成人午夜影院| 欧美日韩和欧美的一区二区| 亚洲国产综合91精品麻豆| 91福利视频久久久久| 亚洲久草在线视频| 欧美性生活久久| 亚洲一区免费观看| 91精品婷婷国产综合久久| 五月婷婷欧美视频| 欧美电影免费观看高清完整版| 日韩精品一级中文字幕精品视频免费观看| 欧美视频一区二| 天天色图综合网| 日韩精品一区国产麻豆| 国产精品99久久久久| 国产精品女主播av| 色婷婷亚洲综合| 日日噜噜夜夜狠狠视频欧美人| 欧美精品乱人伦久久久久久| 蜜桃av噜噜一区| 久久久不卡影院| 91视频观看视频| 香港成人在线视频| 精品国产污网站| 成人av电影免费在线播放| 亚洲人成在线播放网站岛国| 欧美日韩高清一区二区不卡| 久久99精品久久久| 亚洲丝袜自拍清纯另类| 欧美人妖巨大在线| 国产精品小仙女| 亚洲影院理伦片| 欧美电视剧在线看免费| 白白色亚洲国产精品| 午夜精品一区二区三区电影天堂| 精品国产sm最大网站免费看| 成人av手机在线观看| 日韩经典一区二区| 国产精品妹子av| 在线不卡一区二区| 成人免费视频app| 午夜婷婷国产麻豆精品| 久久精品男人天堂av| 欧美三级在线播放| 不卡一区中文字幕| 秋霞成人午夜伦在线观看| 国产精品视频免费| 日韩精品综合一本久道在线视频| 99国产精品久久久久久久久久久| 美洲天堂一区二卡三卡四卡视频| 1区2区3区精品视频| 日韩一卡二卡三卡| 欧美亚洲精品一区| 不卡电影一区二区三区| 捆绑调教美女网站视频一区| 亚洲一区二区四区蜜桃| 国产偷国产偷亚洲高清人白洁| 欧美精品乱码久久久久久按摩 | 国产成人亚洲精品青草天美| 午夜欧美电影在线观看| 亚洲欧洲日韩综合一区二区| 精品国产三级a在线观看| 欧美日高清视频| 99久久精品国产一区| 经典三级一区二区| 奇米精品一区二区三区在线观看一| 综合在线观看色| 欧美韩国日本综合| 久久久99免费| 欧美一卡2卡三卡4卡5免费| 91视频在线看| 成人一道本在线| 国产在线乱码一区二区三区| 免费欧美高清视频| 视频一区免费在线观看| 亚洲成人av一区二区三区| 亚洲欧美另类图片小说| 国产精品国产三级国产aⅴ原创| 国产网红主播福利一区二区| 久久免费视频一区| 日韩精品专区在线影院重磅| 日韩欧美亚洲另类制服综合在线| 欧美日韩国产一区| 欧美日韩精品一区二区三区蜜桃| 欧美三级一区二区| 欧美日本免费一区二区三区| 欧美日韩国产首页| 91精品久久久久久蜜臀| 91麻豆精品国产自产在线观看一区 | 麻豆精品一区二区| 麻豆精品久久精品色综合| 美女网站在线免费欧美精品| 蜜桃一区二区三区在线观看| 久久99精品一区二区三区三区| 麻豆精品在线视频| 国产精品88888| 99久久久精品| 欧美视频一区二区三区在线观看| 欧美美女直播网站| 日韩视频免费观看高清完整版 | 黄网站免费久久| 国产成人亚洲精品青草天美| av高清不卡在线| 色吧成人激情小说| 欧美在线观看视频在线| 日韩一级片在线播放| 日本一区二区三区久久久久久久久不| 国产亚洲综合在线| 亚洲欧美日韩国产综合| 五月天激情小说综合| 国内一区二区视频| 成人av免费在线| 制服丝袜亚洲色图| 国产日韩欧美精品综合| 亚洲美女电影在线| 久久精品免费看| 91色.com| 日韩欧美国产麻豆| 国产精品久久久久影院色老大| 一区二区三区在线看| 免费高清成人在线| 成人福利在线看| 欧美一级欧美一级在线播放| 国产日韩综合av| 首页国产欧美久久| 不卡的电影网站| 日韩欧美国产综合一区| 日韩理论片在线| 国产综合一区二区| 欧美三级欧美一级| 亚洲国产精品传媒在线观看| 性欧美大战久久久久久久久| 国产91在线看| 欧美伦理影视网| 成人免费在线视频观看| 狠狠色2019综合网| 欧美日韩国产综合一区二区三区| 中文字幕精品—区二区四季| 三级影片在线观看欧美日韩一区二区| 成人av在线影院| 久久这里只有精品首页| 亚洲一卡二卡三卡四卡无卡久久| 国产精品 日产精品 欧美精品| 91精品综合久久久久久| 一区二区在线观看不卡| 成人97人人超碰人人99| 精品电影一区二区三区| 图片区小说区国产精品视频| 91麻豆免费观看| 国产精品网站在线观看| 精品在线免费视频| 欧美一级艳片视频免费观看| 亚洲成人在线免费| 在线看不卡av| 亚洲三级在线看| bt欧美亚洲午夜电影天堂| 国产欧美一区二区精品久导航| 毛片av中文字幕一区二区| 在线播放中文字幕一区| 亚洲成人www| 欧美剧情片在线观看| 亚洲成人av中文| 欧美日本高清视频在线观看| 一区二区三区不卡视频| 色8久久人人97超碰香蕉987| 国产精品不卡一区| 成人性生交大片免费看中文| 久久婷婷色综合| 国产在线国偷精品免费看| 日韩欧美国产三级电影视频| 美女一区二区在线观看| 精品少妇一区二区三区视频免付费 | 亚洲国产美国国产综合一区二区| 欧洲日韩一区二区三区|