Карта сайта Kansoftware
НОВОСТИУСЛУГИРЕШЕНИЯКОНТАКТЫ
Разработка программного обеспечения

Quick Start

Boost , ,

Quick Start

Предварительная обработка сВолнаочень настраиваемая. Вы должны определить несколько вариантов, чтобы контролировать его. Вот несколько вариантов, которые вы можете определить:

 включают пути поиска, определяющие, где искать файлы, которые должны быть включены с#include <...>и#include ..директивы
 Какие макросы предопределить и какие из предопределенных макросов не определить
 Включить ли какое-либо из нескольких расширений на C++ Стандартные (например, для вариадиков и плацебо-маркеров)

Вы можете получить доступ ко всем этим параметрам обработки через усилитель::wave::contextобъект. Таким образом, вы должны представить один объект такого типа, чтобы использовать. Библиотека. (Для получения дополнительной информации о классе шаблонов контекста, пожалуйста, обратитесь к ссылке на классздесь.) Чтобы инстанцировать усилие::wave::contextобъект, вы должны предоставить по крайней мере два параметра шаблона: тип итератора основного входного потока для использования и тип итератора лексера для использования в качестве источника токенов для двигателя предварительной обработки.

Do not instantiate the main preprocessing iterators yourself. Get them from the boost::wave::context object instead. The following code snippet is taken from the quick_start sample, which shows a minimal usage scenario for Wave.

    // The following preprocesses a given input file.
    // Open the file and read it into a string variable
    std::ifstream instream("input.cpp");
    std::string input(
        std::istreambuf_iterator<char>(instream.rdbuf()),
        std::istreambuf_iterator<char>());
    // The template boost::wave::cpplexer::lex_token<> is the  
    // token type to be used by the Wave library.
    // This token type is one of the central types throughout 
    // the library, because it is a template parameter to some 
    // of the public classes and templates and it is returned 
    // from the iterators.
    // The template boost::wave::cpplexer::lex_iterator<> is
    // the lexer iterator to use as the token source for the
    // preprocessing engine. In this case this is parametrized
    // with the token type.
    typedef boost::wave::cpplexer::lex_iterator<
            boost::wave::cpplexer::lex_token<> >
        lex_iterator_type;
    typedef boost::wave::context<
            std::string::iterator, lex_iterator_type>
        context_type;
    context_type ctx(input.begin(), input.end(), "input.cpp");

    // At this point you may want to set the parameters of the
    // preprocessing as include paths and/or predefined macros.
        ctx.add_include_path("...");
        ctx.add_macro_definition(...);

    // Get the preprocessor iterators and use them to generate 
    // the token sequence.
    context_type::iterator_type first = ctx.begin();
    context_type::iterator_type last = ctx.end();
    // The input stream is preprocessed for you during iteration
// over [first, last)
while (first != last) { std::cout << (*first).get_value(); ++first; }

The constructor of the boost::wave::context object can take a pair of arbitrary iterator types (at least input_iterator type iterators) to the input stream, which must supply the data to be processed. The third parameter supplies a filename, which is reported in the preprocessor output to indicate the current context. Note though, that this filename is used only as long as no #include or #line directives are encountered, which in turn will alter the current reported filename.

The iteration over the preprocessed tokens is relatively straightforward. Just get the starting and the ending iterators from the context object (maybe after initializing some include search paths) and you are done! Dereferencing the iterator will return the preprocessed tokens generated on the fly from the input stream. (To get further information about the token type, you may want to look here.)


Статья Quick Start раздела может быть полезна для разработчиков на c++ и boost.




Материалы статей собраны из открытых источников, владелец сайта не претендует на авторство. Там где авторство установить не удалось, материал подаётся без имени автора. В случае если Вы считаете, что Ваши права нарушены, пожалуйста, свяжитесь с владельцем сайта.



:: Главная :: ::


реклама


©KANSoftWare (разработка программного обеспечения, создание программ, создание интерактивных сайтов), 2007
Top.Mail.Ru

Время компиляции файла: 2024-08-30 11:47:00
2025-05-20 05:58:55/0.0076999664306641/1