boost

Handling utf-8 in Boost.Spirit with utf-32 parser

筅森魡賤 提交于 2021-02-04 16:01:17
问题 I have a similar issue like How to use boost::spirit to parse UTF-8? and How to match unicode characters with boost::spirit? but none of these solve the issue i'm facing. I have a std::string with UTF-8 characters, i used the u8_to_u32_iterator to wrap the std::string and used unicode terminals like this: BOOST_NETWORK_INLINE void parse_headers(std::string const & input, std::vector<request_header_narrow> & container) { using namespace boost::spirit::qi; u8_to_u32_iterator<std::string::const

C++ boost asynchronous timer to run in parallel with program

匆匆过客 提交于 2021-02-04 06:28:48
问题 Note: This is for C++98 I am trying to develop a simple timer/counter that runs in the background of my main program. I haven't used asynchronous timers before, and I have been trying to follow the boost tutorials on how to do this, but they still seem to block my main function. I've slightly modified Timer.3 from the boost website to experiment. Essentially, with the program below what I want to do is: Run main Execute testRun() which counts to 5 At the same time testRun() is counting, print

Numerical Conversion in C/C++

有些话、适合烂在心里 提交于 2021-01-29 18:19:25
问题 I need to convert a C/C++ double to a 64 bit two's complement, where the Radix point is at bit number 19 (inclusive). This means that for the format I want to convert to 0x0000 0000 0010 0000 is the number 1 0xFFFF FFFF FFF0 0000 is the number -1 0x0000 0000 0000 0001 is 0.95 x 10^-6 0xFFFF FFFF FFFF FFFF is -0.95 x 10^-6 So far I've though about using the modf function from the C standard library, but that doesn't really cover my needs. I've also looked at some type conversion classes in

Parsing CSS with Boost.Spirit X3

我与影子孤独终老i 提交于 2021-01-29 06:23:04
问题 I'm attempting to write a (partial) CSS parser using Boost.Spirit X3. I have the (very) basic setup working: const auto declaration_block_def = '{' >> +declaration >> '}'; const auto declaration_def = property >> ':' >> value >> ';'; const auto property_def = +(char_ - ":"); const auto value_def = +(char_ - ";"); Here value is just a simple string parser, and property a symbol table of all the CSS property names to an enum listing all the properties. But now I wonder if I couldn't in some way

Compile error with boost::spirit::x3

拟墨画扇 提交于 2021-01-29 05:14:32
问题 I tried to compile example file with gcc 5.3.1 ( 5.3.1 20160406 (Red Hat 5.3.1-6) (GCC) ), boost 1.61.0. #include <boost/config/warning_disable.hpp> #include <boost/spirit/home/x3.hpp> #include <iostream> // Presented are various ways to attach semantic actions // * Using plain function pointer // * Using simple function object namespace client { namespace x3 = boost::spirit::x3; using x3::_attr; struct print_action { template <typename Context> void operator()(Context const& ctx) const { std

Iterate transition table (boost:msm) in runtime in order to read the associated event to an specific transition

强颜欢笑 提交于 2021-01-29 05:11:37
问题 I am new in MPL and Finite MSM from boost. I would like to iterate the transition table in order to get the associated transition event given 2 the transition states (current, next). I define and I get the transition table (vector50) like this: struct<my_state_machine_>{ (...) struct transition_table : boost::mpl::vector50< a_row < StateA ,eventAB ,StateB ,&my_machine_state_::action>, (...) > {}; }; typedef boost::msm::back::state_machine<my_state_machine_> my_fsm; typedef boost::msm::back:

Boost::process child by id

只愿长相守 提交于 2021-01-29 04:59:42
问题 How I can get child.id() in on_exit function? bp::child c(args, ios, bp::on_exit([&](int e, std::error_code ec) { result = e; ios.stop(); //need c.id(); })); or how I can check in other function if the child is running by id? boost::process::child c(data->id); // doesn't work if (!c.running()) { } 回答1: You can bind whatever extra information you want to your handler. For example, you can declare your handler to take a reference to the child instance: static void exit_handler(bp::child&

boost program options short / long parameter names

£可爱£侵袭症+ 提交于 2021-01-29 04:58:12
问题 I have implemented a routing to print out all of the options that are available in my boost::program_options objects along with their current values by iterating over the po::variable_map . With this I can directly print the long name of the option along with its value. However, I do not know, how to retrieve the short option name from the long option name (i.e. -h from --help). Any suggestions how to do this? 回答1: I remember describing in a recent answer why variable_map is "too late" to

Boost::process child by id

倾然丶 夕夏残阳落幕 提交于 2021-01-29 04:53:28
问题 How I can get child.id() in on_exit function? bp::child c(args, ios, bp::on_exit([&](int e, std::error_code ec) { result = e; ios.stop(); //need c.id(); })); or how I can check in other function if the child is running by id? boost::process::child c(data->id); // doesn't work if (!c.running()) { } 回答1: You can bind whatever extra information you want to your handler. For example, you can declare your handler to take a reference to the child instance: static void exit_handler(bp::child&

boost::interprocess message queue timed_receive() internal procedure

可紊 提交于 2021-01-29 02:28:22
问题 im currently using the timed_receive() method from the boost::interprocess library for receiving data. Since the timing of the received messages will vary I used this method over the receive() method. msgque->timed_receive((void*) &message,sizeof(int),recvd_size,priority, boost::posix_time::ptime(microsec_clock::universal_time()) + boost::posix_time::milliseconds(300)) Question: How does this method know a message is present in the buffer? Is it a polling mechanism or is there a more complex