Search Results

Search found 2064 results on 83 pages for 'boost spirit lex'.

Page 14/83 | < Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >

  • How to add a property to a module in boost::python?

    - by Checkers
    You can add a property to a class using a getter and a setter (in a simplistic case): class<X>("X") .add_property("foo", &X::get_foo, &X::set_foo); But how to add a property to a module itself (not a class)? There is scope().attr("globalAttr") = ??? something ??? and def("globalAttr", ??? something ???); I can add global functions and objects of my class using the above two ways, but can't seem to add properties the same way as in classes.

    Read the article

  • CSV parser in C++

    - by User1
    All I need is a good CSV file parser for C++. At this point it can really just be a comma-delimited parser (ie don't worry about escaping new lines and commas). The main need is a line-by-line parser that will return a vector for the next line each time the method is called. I found this article which looks quite promising: http://www.boost.org/doc/libs/1_35_0/libs/spirit/example/fundamental/list_parser.cpp I've never used Boost's Spirit, but am willing to try it. Is it overkill/bloated or is it fast and efficient? Does anyone have faster algorithms using STL or anything else? Thanks!

    Read the article

  • Linking with Boost error

    - by drhorrible
    I just downloaded and ran the boost installer for version 1.42 (from boostpro.com), and set up my project according to the getting started guide. However, when I build the program, I get this linker error: LINK : fatal error LNK1104: cannot open file 'libboost_program_options-vc90-mt-gd-1_42.lib' The build log adds this (I've replaced project-specific paths with *'s): Creating temporary file "******\Debug\RSP00001252363252.rsp" with contents [ /OUT:"*********.exe" /INCREMENTAL /LIBPATH:"C:\Program Files\boost\boost_1_42_0\lib" /MANIFEST /MANIFESTFILE:"Debug\hw6.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"********\Debug\***.pdb" /SUBSYSTEM:CONSOLE /DYNAMICBASE /NXCOMPAT /MACHINE:X86 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ".\Debug\****.obj" ".\Debug\****.exe.embed.manifest.res" ] Creating command line "link.exe @********\Debug\RSP00001252363252.rsp /NOLOGO /ERRORREPORT:PROMPT" I've also emailed [email protected] (with a message very similar to this), but I thought maybe so would be faster.

    Read the article

  • Basic Boost Regex question

    - by shuttle87
    I'm trying to write some c++ code that tests if a string is in a particular format. In this program there is a height followed by some decimal numbers: for example "height 123.45" or "height 12" would return true but "SomeOtherString 123.45" would return false. My first attempt at this was to write the following: string action; cin >> action; boost::regex EXPR( "^height \\d*(\\.\\d{1,2})?$/" ) ;//height format regex bool height_format_matches = boost::regex_match( action, EXPR ) ; if(height_format_matches==true){ \\do some stuff } However height_format_matches never seemed to be true. Any help is greatly appreciated!

    Read the article

  • Boost asio async vs blocking reads, udp speed/quality

    - by Dolphin
    I have a quick and dirty proof of concept app that I wrote in C# that reads high data rate multicast UDP packets from the network. For various reasons the full implementation will be written in C++ and I am considering using boost asio. The C# version used a thread to receive the data using blocking reads. I had some problems with dropped packets if the computer was heavily loaded (generally with processing those packets in another thread). What I would like to know is if the async read operations in boost (which use overlapped io in windows) will help ensure that I receive the packets and/or reduce the cpu time needed to receive the packets. The single thread doing blocking reads is pretty straightforward, using the async reads seems like a step up in complexity, but I think it would be worth it if it provided higher performance or dropped fewer packets on a heavily loaded system. Currently the data rate should be no higher than 60Mb/s.

    Read the article

  • How to use boost::crc?

    - by Andreas Bonini
    I want to use boost::crc so that it works exactly like PHP's crc32() function. I tried reading the horrible documentation and many headaches later I haven't made any progress. Apparently I have to do something like: int GetCrc32(const string& my_string) { return crc_32 = boost::crc<bits, TruncPoly, InitRem, FinalXor, ReflectIn, ReflectRem>(my_string.c_str(), my_string.length()); } bits should be 32.. What the other things are is a mystery. A little help? ;)

    Read the article

  • Pointer argument to boost python

    - by piotr
    What's the best way to make a function that has pointer as argument work with boost python? I see there are many possibilities for return values in the docs, but I don't know how to do it with arguments. void Tesuto::testp(std::string* s) { if (!s) cout << " NULL s" << endl; else cout << s << endl; } >>> t.testp(None) NULL s >>> >>> s='test' >>> t.testp(s) Traceback (most recent call last): File "<stdin>", line 1, in <module> Boost.Python.ArgumentError: Python argument types in Tesuto.testp(Tesuto, str) did not match C++ signature: testp(Tesuto {lvalue}, std::string*) >>>

    Read the article

  • Boost C++ Singleton error LNK2001: unresolved external symbol "private: static long Nsp::HL::flag" (

    - by Soós Roland
    I try to create a multi-threaded singleton pattern class. Header: class HL{ public: static HL* getInstance(); ......... private: static HL* instance; static boost::once_flag flag; HL(); static void initOnce(); } CPP: HL* HL::instance = NULL; HL* HL::getInstance(){ if(instance == NULL){ boost::call_once(flag, initOnce); } return instance; } void HL::initOnce(){ instance = new HL(); } I get this error: error LNK2001: unresolved external symbol "private: static long Nsp::HL::flag" (?flag@HL@Nsp@@0JA) What's wrong?

    Read the article

  • Boost::Thread or fork() : Multithreaded HTTP Proxy

    - by osmano807
    I'm testing boost::thread on a system. It happens that I needed to act as a fork(), because one thread modifies the other variables, even member variables of class I do the project using fork() or is there some alternative still using boost::thread? Basically I run this program in Linux and maybe FreeBSD. It is an http proxy,accept() in main thread, and a function that accepts a class (where there is the file descriptor socket) in a secondary thread that makes the service. Is there a better way to implement a proxy?

    Read the article

  • boost pool_alloc

    - by mr grumpy
    Why is the boost::fast_pool_allocator built on top of a singleton pool, and not a separate pool per allocator instance? Or to put it another way, why only provide that, and not the option of having a pool per allocator? Would having that be a bad idea? I have a class that internally uses about 10 different boost::unordered_map types. If I'd used the std::allocator then all the memory would go back to the system when it called delete, whereas now I have to call release_memory on many different allocator types at some point. Would I be stupid to roll my own allocator that uses pool instead of singleton_pool? thanks

    Read the article

  • How to reduce compilation times with Boost Asio

    - by Artyom
    Boost.Asio is great library but it has one huge drawback -- extreamly slow compilation times. A simple implementation (really simple) of HTTP protocol (about 1k lines of code) requires about 13.5s to compile under GCC 4.4! I tryed to use PCH but it does not improve compilation times too much (about 1s. only). So are there any tutorials on how to make Boost.Asio compilation times faster? For example what headers should I exactly include for what class. I use for example: io_service, tcp::ip::sockets, tcp::ip::acceptor, deadline_timer, buffers and few functions like async_read, async_write. Any suggestions? P.S.: I do use pimpl whenever I can.

    Read the article

  • Have boost effect on lucene/compass field search.

    - by PeterP
    Hi there, In our compass mapping, we're boosting "better" documents to push them up in the list of search results. Something like this: <boost name="boostFactor" default="1.0"/> <property name="name"><meta-data>name</meta-data></property> While this works fine for fulltext search, it does not when doing a field search, e.g. the boost is ignored when searching something like name:Peter Is there any way to enable boosting for field searches? Thanks for your help and sorry if this is a dumb question - I am new to Lucene/Compass. Best regards, Peter

    Read the article

  • boost multi_index_container and erase performance

    - by rjoshi
    I have a boost multi_index_container declared as below which is indexed by hash_unique id(unsigned long) and hash_non_unique transaction id(long). Insertion and retrieval of elements is fast but when I delete elements, it is much slower. I was expecting it to be constant time as key is hashed. e.g To erase elements from container for 10,000 elements, it takes around 2.53927016 seconds for 15,000 elements, it takes around 7.137100068 seconds for 20,000 elements, it takes around 21.391720757 seconds Is it something I am missing or is it expected behavior? class Session { public: Session() { //increment unique id static unsigned long counter = 0; boost::mutex::scoped_lock guard(mx); counter++; m_nId = counter; } unsigned long GetId() { return m_nId; } long GetTransactionHandle(){ return m_nTransactionHandle; } .... private: unsigned long m_nId; long m_nTransactionHandle; boost::mutext mx; .... }; typedef multi_index_container< Session*, indexed_by< hashed_unique< mem_fun<Session,unsigned long,&Session::GetId> >, hashed_non_unique< mem_fun<Session,unsigned long,&Session::GetTransactionHandle> > > //end indexed_by > SessionContainer; typedef SessionContainer::nth_index<0>::type SessionById; int main() { ... SessionContainer container; SessionById *pSessionIdView = &get<0>(container); unsigned counter = atoi(argv[1]); vector<Session*> vSes(counter); //insert for(unsigned i = 0; i < counter; i++) { Session *pSes = new Session(); container.insert(pSes); vSes.push_back(pSes); } timespec ts; lock_settime(CLOCK_PROCESS_CPUTIME_ID, &ts); //erase for(unsigned i = 0; i < counter; i++) { pSessionIdView->erase(vSes[i]->getId()); delete vSes[i]; } lock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts); std::cout << "Total time taken for erase:" << ts.tv_sec << "." << ts.tv_nsec << "\n"; return (EXIST_SUCCESS); }

    Read the article

  • Boost 1.4.0, "assert" identifier not found

    - by Adam Haile
    I'm trying to compile an old project that was originally written for linux on windows. It uses boost 1.4.0, and whenever I compile it throws error C3961: "assert" : identifier not found. I'm using Visual Studio 208 SP1 When I drill down into assert.hpp it includes this: # include <assert.h> // .h to support old libraries w/o <cassert> - effect is the same # define BOOST_ASSERT(expr) assert(expr) BOOST_ASSERT is actually what's failing, and VS doesn't seem to recognize assert() even though assert.h is obviously included. As far as I can tell, all the fails are in files that are part of boost, not my own code, but it throws about 1200 of them. Any ideas how to fix this?

    Read the article

  • Adding Boost Library to a C++ project in Windows Eclipse

    - by kingrichard2005
    I recently installed the Boost Library on Windows using the installer, I'm trying to link to the library in Eclipse but am not having any luck. I tried going through Project Properties - C/C++ Build - Settings - MinGW C++ Linker - Libraries and add the reference "boost_filesystem" according to this website: http://www.ferdychristant.com/blog//archive/DOMM-76JN6N , but I think that only applies to Unix variants. Everytime I compile I get the error: "cannot find -lboost_filesystem" . I've scoured the net, but cannot find a way to properly use Boost in Eclipse under a Windows platform. Any help or suggestions are appreciated.

    Read the article

  • How to build boost foreach cycle

    - by Ockonal
    Hi guys! I have some abstract class called IClass (has pure virtual function). There are some classes which inherit IClass: CFirst, CSecond. I want to add objects of classes which inherit into boost::ptr_vector: class IClass { virtual void someFunc() = 0; }; class CFirst : public IClass { }; class CSecond : public IClass { }; boost::ptr_vector<IClass> objectsList; objectsList.push_back(new CFirst()); objectsList.push_back(new CSecond()); And now my goal is to call function (which is declarated in IClass) from all objects in objectsList. I'd prefer to use BOOST_FOREACH: foreach(IClass tempObj, objectsList) { tempObj.someFunc(); } The problem is that IClass - abstract class, so I can't make instance of it for the foreach-cycle. What should I do?

    Read the article

  • C++ Mock/Test boost::asio::io_stream - based Asynch Handler

    - by rbellamy
    I've recently returned to C/C++ after years of C#. During those years I've found the value of Mocking and Unit testing. Finding resources for Mocks and Units tests in C# is trivial. WRT Mocking, not so much with C++. I would like some guidance on what others do to mock and test Asynch io_service handlers with boost. For instance, in C# I would use a MemoryStream to mock an IO.Stream, and am assuming this is the path I should take here. C++ Mock/Test best practices boost::asio::io_service Mock/Test best practices C++ Async Handler Mock/Test best practices I've started the process with googlemock and googletest.

    Read the article

  • Boost::Archive causing weird linker error.

    - by Dallin Wellington
    Does anyone have a clue why those two lines would cause that linker error? std::ifstream ifs("filename.file"); boost::archive::binary_iarchive iarchv( ifs ); Error 8 fatal error LNK1104: cannot open file 'F:\dev\project\build\win32-unit\tests\Debug\framework_core_tests.lib' ramework_core_tests framework_core_tests The same happens with any Boost::Archive type. Its trying to link against a library of the same name as my executable for some reason when that project doesn't nor never existed and is not defined as a library to link against in my project files.

    Read the article

  • C++ boost or STL `y += f(x)` type algorithm

    - by aaa
    hello. I know I can do this y[i] += f(x[i]) using transform with two input iterators. however it seems somewhat counterintuitive and more complicated than for loop. Is there a more natural way to do so using existing algorithm in boost or Stl. I could not find clean equivalent. here is transform (y = y + a*x): using boost::lambda; transform(y.begin(), y.end(), x.begin(), y.begin(), (_1 + scale*_2); // I thought something may exist: transform2(x.begin(), x.end(), y.begin(), (_2 + scale*_1); // it does not, so no biggie. I will write wrapper Thanks

    Read the article

  • boost::enable_if class template method

    - by aaa
    I got class with template methods that looks at this: struct undefined {}; template<typename T> struct is_undefined : mpl::false_ {}; template<> struct is_undefined<undefined> : mpl::true_ {}; template<class C> struct foo { template<class F, class V> typename boost::disable_if<is_undefined<C> >::type apply(const F &f, const V &variables) { } template<class F, class V> typename boost::enable_if<is_undefined<C> >::type apply(const F &f, const V &variables) { } }; apparently, both templates are instantiated, resulting in compile time error. is instantiation of template methods different from instantiation of free functions? I have fixed this differently, but I would like to know what is up. Thank you

    Read the article

  • How to use the boost lexical_cast library for just for checking input

    - by Inverse
    I use the boost lexical_cast library for parsing text data into numeric values quite often. In several situations however, I only need to check if values are numeric; I don't actually need or use the conversion. So, I was thinking about writing a simple function to test if a string is a double: template<typename T> bool is_double(const T& s) { try { boost::lexical_cast<double>(s); return true; } catch (...) { return false; } } My question is, are there any optimizing compilers that would drop out the lexical_cast here since I never actually use the value? Is there a better technique to use the lexical_cast library to perform input checking?

    Read the article

  • boost variant static_visitor problem picking correct function

    - by Steve
    I'm sure I'm having a problem with template resolution here, but I'm not sure why I'm having the problem. I have a static visitor I'm passing to boost variant where i've had to do template specialization for certain cases. The case for everything except for MyClass should throw in the static_visitor below. Unfortunately, when the visitor is applied to pull a MyClass out, it selects the most generic case rather than the exact match. I would type each case explicitly, but that will be rather long. So, why is the compiler resolving the most generic case over the exact match, and is there anyway to fix it template<> class CastVisitor<MyClass>:public boost::static_visitor<MyClass> { public: template<typename U> MyClass operator()(const U & i) const { throw std::exception("Unable to cast"); } MyClass operator()(const MyClass& i) { return i; } };

    Read the article

  • Boost: Although compiled, missing lib

    - by Jonathan
    I've compiled Boost and am using it in a Visual C++ project. At some point, I started getting the following error: 1>LINK : fatal error LNK1104: cannot open file 'libboost_filesystem-vc100-mt-sgd-1_45.lib' AFAIK I have the linker configuration set correctly. I've searched for the lib and the closest I found was: libboost_filesystem-vc100-mt-gd-1_45.lib (Notice the missing 's') What does the missing 's' represent? What do these similar yet different libs stand for? How come I'm missing it although I've compiled all of Boost?

    Read the article

< Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >