Esempio n. 1
0
    ancestor_iterator(boost::iterator_range<ParentIterator> r)
        :parent_it(r.begin()), parent_end(r.end()), depth(0) {
        if (parent_it != parent_end) {
            c.reset(new typename super::value_type(*parent_it));
            find_next_parent();
        }

    };
 void found_object(boost::iterator_range<Iterator> m) {
     std::string s(m.begin(), m.end());
     cout << "Found object name :" << s <<endl;
     method.is_object=true;
     iface_objects.push_back( s );
     method.name = s;
     cout << method << endl;
 }
Esempio n. 3
0
        explicit variable(boost::iterator_range<Iterator> const& token) :
            _position(token.begin().position())
        {
            // Remove the $ from the name
            auto it = token.begin();
            ++it;
            _name.assign(it, token.end());

            validate_name();
        }
 inline bool string_generate(OutputIterator& sink
   , boost::iterator_range<Iterator> const& r, CharEncoding, Tag)
 {
     Iterator end = r.end();
     for (Iterator it = r.begin(); it != end; ++it)
     {
         *sink = spirit::char_class::convert<CharEncoding>::to(Tag(), *it);
         ++sink;
     }
     return detail::sink_is_good(sink);
 }
Esempio n. 5
0
 attribute_iterator(boost::iterator_range<ParentIterator> r)
     :parent_it(r.begin()), parent_end(r.end()) {
     if (parent_it != parent_end) {
         auto attributes = (*parent_it).attributes();
         attribute_it = attributes.begin();
         attribute_end = attributes.end();
         if (attribute_it == attribute_end) {
             go_to_next();
         }
     }
 }
 inline bool string_generate(OutputIterator& sink
   , boost::iterator_range<Iterator> const& r)
 {
     Iterator end = r.end();
     for (Iterator it = r.begin(); it != end; ++it)
     {
         *sink = *it;
         ++sink;
     }
     return detail::sink_is_good(sink);
 }
Esempio n. 7
0
    descendant_iterator(boost::iterator_range<ParentIterator> r)
        :parent_it(r.begin()), parent_end(r.end()), depth(0) {
        if (parent_it != parent_end) {
            c.reset(new typename super::value_type(*parent_it));
            if (c->has_children()) {
                c->first_child();
                depth++;
            } else {
                find_next_leaf();
            }
        }

    };
Esempio n. 8
0
        explicit regex(boost::iterator_range<Iterator> const& token) :
            _position(token.begin().position())
        {
            auto start = token.begin();
            auto end = token.end();

            if (start != end) {
                ++start;
            }

            // Move the end to the position before the closing / character
            auto last = start;
            for (auto current = start; current != end; ++current) {
                last = current;
            }
            _value.assign(start, last);
        }
Esempio n. 9
0
			static boost::tuple< boost::iterator_range<InputIterator>, size_t >
			apply(unsigned long& v, boost::iterator_range<InputIterator> const& input){
				
				auto iter = input.begin();
				auto const& end = input.end();

				unsigned char * raw_int = reinterpret_cast<unsigned char*>(&v);
				unsigned char const * const raw_int_end = raw_int+sizeof(v);

				while(raw_int!=raw_int_end){

					if( iter==end ) STCRYPT_THROW_EXCEPTION( sio::exception::underflow() );

					*raw_int = *iter;
					++iter;
					++raw_int;
				}

				return boost::make_tuple( boost::make_iterator_range(iter, end), sizeof(unsigned long) );

			}
Esempio n. 10
0
			static boost::tuple< boost::iterator_range<InputIterator>, size_t >
			apply(unsigned char (&v)[N], boost::iterator_range<InputIterator> const& input){

					auto iter = input.begin();
					auto const& end = input.end();

					unsigned char * out_cur = reinterpret_cast<unsigned char*>(&v);
					unsigned char const * const out_end = out_cur+sizeof(v);

					while(out_cur !=out_end){

						if( iter==end ) STCRYPT_THROW_EXCEPTION( sio::exception::underflow() );

						*out_cur = *iter;
						++iter;
						++out_cur;
					}

					return boost::make_tuple( boost::make_iterator_range(iter, end), sizeof(v) );

			}
Esempio n. 11
0
// callback to receive reply from server
// reply - pointer to reply string
// cv - pointer to condition variable to notify sender with
void response_callback_with_reply(boost::iterator_range<char const *> const &a,
                                  boost::system::error_code const &error_code,
                                  std::string *reply,
                                  std::condition_variable *cv)
{
    if (!error_code) {
        //std::unique_lock<std::mutex> scoped_lock(reply_mutex);
        reply->append(a.begin());
    } else {
        if (error_code == boost::asio::error::eof) {
            // notify request sender with condition variable about transfer finish
            cv->notify_all();
        }
    }
}
void unpackAndUncompressInteger(
        const boost::iterator_range<detail::ByteSequence::const_iterator>&
                range,
        Integer& value) {
    unsigned char* valuePointer = reinterpret_cast<unsigned char*>(&value);
    detail::ByteSequence::const_iterator iterator = range.begin();
    const unsigned char& size = *iterator;
    ++iterator;
    constexpr unsigned char maxSize = static_cast<unsigned char>(sizeof(value));
    unsigned char leadingZeroBytes = maxSize - size;
    PackedValue packedValue;
    unsigned char* valueArray =
            reinterpret_cast<unsigned char*>(&packedValue) + leadingZeroBytes;
    std::copy(iterator, iterator + size, valueArray);
    //value = static_cast<Integer>(packedValue - getOffset<Integer>());
}
    std::size_t unpackAndUnshiftInteger(
            const boost::iterator_range<detail::ByteSequence::const_iterator>&
                    range,
            Integer& value) {
        PackedValue packedValue = boost::endian::big_to_native(
                *reinterpret_cast<const PackedValue*>(&*range.begin()));

        if (packedValue >= getOffsetZero<PackedValue>()) {
            value = static_cast<Integer>(
                    packedValue - getOffset<Integer, PackedValue>());
        } else {
            value = static_cast<Integer>(packedValue) -
                    getOffset<Integer, PackedValue>();
        }

        return sizeof(value);
    }
Esempio n. 14
0
typename std::iterator_traits<It>::value_type operator()() { return *(r_.begin() + (rand_r(&seed_) % r_.size())); }
Esempio n. 15
0
    void found_arg_desc(boost::iterator_range<Iterator> m) {
        std::string s(m.begin(), m.end());
//        cout << "Found arg desc :" << s <<endl;
        bf::get<1>(method.args.back()) = s;
    }
Esempio n. 16
0
    void found_arg(boost::iterator_range<Iterator> m) {
        std::string s(m.begin(), m.end());
//        cout << "Found arg :" << s <<endl;
        method.args.push_back( arg_desc_type(s,"") );
    }
Esempio n. 17
0
    void found_desc(boost::iterator_range<Iterator> m) {
        std::string s(m.begin(), m.end());
//        cout << "Found description :" << s <<endl;
        method.description = s;
    }
Esempio n. 18
0
Parser::Parser(boost::iterator_range<ByteBuffer::const_iterator> range) :
    Parser(range.begin(), range.end())
{
}
Esempio n. 19
0
 result_type operator() (boost::iterator_range<Iterator> const& range) const
 { return !range.empty(); }
Esempio n. 20
0
 explicit type(boost::iterator_range<Iterator> const& token) :
     _position(token.begin().position()),
     _name(token.begin(), token.end())
 {
 }
Esempio n. 21
0
    void found_completion(boost::iterator_range<Iterator> m) {
        std::string s(m.begin(), m.end());
//        cout << "Found C/C++ function :" << s <<endl;
        method.completion = s;
    }
Esempio n. 22
0
    void found_caller(boost::iterator_range<Iterator> m) {
        std::string s(m.begin(), m.end());
//        cout << "Found C++ caller :" << s <<endl;
        method.caller = s;
    }
Esempio n. 23
0
    std::string a("wangBing");
    boost::to_upper(a);
    std::cout << a << std::endl;
    std::string b = boost::to_lower_copy(a);
    std::cout << a << " " << b << std::endl;

    std::cout << "---------erase---------" << std::endl;
    a = "wangbing hehe   wangbing   ";
    boost::erase_first(a, "hehe");
    std::cout << a << std::endl;

    std::cout << "---------find---------" << std::endl;
    a = "wangbing hehe   wangbing   b1234_";
    boost::regex rx("b[0-9]+_");
    b = "hehe";
    boost::iterator_range< std::string::iterator> it = boost::find_first(a, b);
    std::cout << (it.end() - it.begin()) << " " << std::string(it.begin(), it.end()) << std::endl;
    it = boost::find_regex(a, rx);
    std::cout << (it.end() - it.begin()) << " " << std::string(it.begin(), it.end()) << std::endl;
    
    std::cout << "---------predicate---------" << std::endl;
    a = "wangbing hehe   wangbing   b1234_";
    if(boost::starts_with(a, "wangbing")) {
        std::cout << "hehe" << std::endl;
    }

    std::cout << "---------replace---------" << std::endl;
    a = "wangbing hehe   wangbing   b1234_";
    std::string re = boost::replace_first_copy(a, "wangbing", "WANGBING");
    std::cout << re << std::endl << a << std::endl;