Is anyone using Boost for regular expressions in BCB6, or can recommend anything else? I've downloaded the latest boost ZIP file a few times, but I can't get it to unzip yet (my PC is probably not in the best state right now). It is a pretty huge library, so if there is anything else smaller that is just regular expressions, that works well with BCB6, I'd like to try that first. I tried http://www.regular-expressions.info/delphi.html also, but it doesn't have any info about BCB support (just Delphi) and it looks like some of the supplied OBJ files have issues with BCB (and no source code to rebuild those).
Edit: After searching the source code and include folders under CBuilder6\ I found out Builder does have built-in support for regex. So another question is, do they work well, and which set of functions/objects should I use for a VCL-based app? I found TRegexp (but no docs for it) and also some PCRE functions under the CRTL help file (but I'd rather use higher level or C++ if all about the same).
The TPerlRegex classes (available at the link you posted above) work fine in C++ Builder. See the section about halfway down the page that refers to older Delphi versions. Best of all, they're free with full Delphi source that will compile in Builder as well.
The components/classes are based on PCRE, and in fact include C source for the .obj files that are used when you compile not to need the DLL, but you can also use it without the .obj files by compiling to require the DLL and distributing the DLL with your app.
The related application to that site, RegexBuddy, can generate strict C-based code for the regexes, or can generate Delphi code (or C++ Builder XE, which can pretty easily be made to work with Builder 6 if you remember that Builder XE is Unicode-based and Builder 6 isn't). (I'm not affiliated with RegexBuddy; I've just been a user since version 1 was released.)
Here's a sample of RegexBuddy 3's C (PCRE) support:
Related
I am new to antlr.
Can somebody provide a working example for any simple grammar in antlr for C++ target. I tried antlrworks and created the lexer and parser. But am not able to proceed while getting it compiled. Searched in codeproject also for a working sample, but dint find any.
I am planning to use Visual Studio 2013. Thanks in advance...
I've used ANTLR3 in a C++ application for years already, but actually used the C target, not C++. The latter proved to be a problem both in terms of compilation speed (for a highly complex parser) and complexity (all based on templates). So I settled on the C target, which is easy to integrate into C++ application. You only need a small C++ wrapper for your app and you will get a really fast parser.
In case of C++ target try this branch: https://github.com/ibre5041/antlr3/tree/master/runtime/Cpp/tests. This is more up to date version, including various performance bug fixes, memory leak fixes and also AST generation.
In the tests directory you find some examples.
Now I'm not sure whether it will work with MSVC 2013, I recall I used some C++11.
It would be best if you compiled the whole tool from these sources, not only the runtime is different, but also generated source codes slightly differ.
No not use Java 8 to compile and run antlr tool. For some mysterious reason JRE8 generates different sources then JRE7, when using the same tool .jar.
When having your grammar compiled (sources are generated), then you have to create, a traits class to be used as "configuration" for generated sources.
I'm trying to write my first game in c++, and I want it to dynamically load everything from files. This includes the enemies, and I was wondering if there was a way to dynamically include their code at runtime, instead of linking the on compile, so that the levels are easily interchangeable. Lua might be an option but I have no clue where to start, and dll seems to be Windows-only (and I wouldn't know where to start there anyway). Can anyone help with this?
tl;dr I want to link in code to my c++ game at runtime.
For the Lua approach you first need to choose the version first. Right now there is the major version 5.1 and 5.2. My previous work was using 5.1 and for my new project I decided to update to 5.2, however I found that my favorite script wrapping tool (SWIG) does not work with 5.2. Just something to decide at the beginning, because you do not want to get a version working and then have to change it.
Lua comes with makefile build environment. My first experience of trying to build on Windows was a bit of a nightmare, did not appear to just run out-of-the-box, so I opted to create my own Visual Studio project at the time, and just include all the .C files in the project. There are two files which need to selectively included/excluded depending on how you intend to compile: lua.c and luac.c. If you are planning to embed Lua in your app, then exclude both of these files; they both contain a main() function and are designed to build console apps. Include all the rest of the C files in your project.
You should be able to compile easy from this point.
When you include the headers of Lua, keep in mind that the functions are C functions so if you are including them from C++ you need to wrap the file inclusion inside of: extern "C" {} - example: C++ Lua 5.1 Issue
Wrapping your interfaces in another topic and there are lots of resources available. My favorite is SWIG but there are lots of options, including hand coding the conversion of your C/C++ -> LUA -> C/C++ code. Would recommend just focusing on getting the first part working first, get the interpreter embedded so that you can run a "hello, world!" script from Lua inside your app.
So going by your requirement of crossplatform use and dynamic linking, what you're probably looking for is an environment like QT which has QLibrary: https://stackoverflow.com/a/9675063/453673
But https://softwareengineering.stackexchange.com/questions/88685/why-arent-more-desktop-apps-written-with-qt
MingW is the open-source equivalent for Visual C++, so it can help you writing code for Windows (though if I had a choice, I'd directly use Visual C++). The way dll's are loaded in Windows is somewhat similar to the way they're loaded in Linux, so you'll be able to write code with #ifdef's to do conditional compilation. I've written one such program a couple of years back.
To load a shared library(always with .so as suffix) under Linux, you could use dlopen(), dlsym() and dlclose()
From my understanding reading this thread from several years ago, somebody once got Protocol Buffers working with Codegear C++ Builder 2007
https://groups.google.com/forum/?fromgroups=#!topic/protobuf/YapO_DqFVvc
The author of the above Builder 2007 version of protobuf uploaded it to a 3rd party URL, however the link to it seems to be long dead, and judging by the discussion and the current state of Protocol Buffers 2.5.0 the fix/change has never been forked from protobuf or merged into the trunk.
Updated:
When using generated code from protoc.exe (2.5.0) for either of the example .proto files, C++ Builder 2007 complains about a multitude of problems, including "duplicate entries" for names in the google::internal namespace (such as google::internal::kEmptyString - it also complains about the std::hash based containers and that memset is an unrecognised symbol.
It took me several days to arrive at a solution, but here's how I managed to get it working in Codegear 2007:
Obtain the C++ Builder version of protobuf https://github.com/saadware/protobuf-cppbuilder - this is based on 2.4.1, so it is a little outdated, but I would guess that it's possible to merge the C++ builder changes into 2.5.0 (or whatever the latest version is). The C++ Builder version of protobuf is for Builder 2009, but it fixes various problems with std::hash, so it's a better starting point than Google's release.
Take a copy of the following .cc files in the ./src/google/protobuf folder and change them to a .cpp extension. There seems to be an issue with the .cbproj format which doesn't like .cc (You will need to add all of these files into your Codegear 2007 .cbproj - these are the files required for libprotobuf-lite).
extension_set.cpp
generated_message_util.cpp
message_lite.cpp
repeated_field.cpp
wire_format_lite.cpp
stubs\common.cpp
stubs\once.cpp
io\coded_stream.cpp
io\zero_copy_stream.cpp
io\zero_copy_stream_impl_lite.cpp
As per the thread by 'Dazza' use find-and-replace-in-files (e.g. Notepad++) to rename the google::internal namespace. Note that a case-sensitive find/replace is required because there are occurrences where the name 'Internal' is used for other things. For this step I followed Dazza's suggestion of changing it to google::internals. (Note - this is both for the libprotobuf-lite and for the strings used to make the generated code)
In the generated code strings, search for all occurrences of memset and change them to std::memset (This is primarily for the code generator lib; libprotoc. If you don't do this, every time you re-generate your .proto bindings, C++ builder will be unable to identify memset.
Build protoc.exe using Visual Studio (I couldn't get Protoc.exe to build in Builder, but that shouldn't matter anyway, the code generator only needs to be built once)
Modify the example .proto files use the lite runtime;
option optimise_for = LITE_RUNTIME. Note - reflection capabilities are not available with this option switched on.
Run protoc.exe on your .proto file with --cpp_out. The output file will have a .cc extension - you will need to rename this to .cpp
Add your generated files to your project and build.
(Note- there are still a few warnings outstanding - one complaining about a superfluous & taking the address of a function, and a few others complaining about signed/unsigned comparisons - but at least it builds and seems to work)
I'm a total noob when it comes to linking and building with Visual Studio. I would like to integrate Lua into my C++ console application.
Can someone give a step by step on how to do this from getting the Lua dependencies from lua.org, to actually running a "Hello World from Lua" in VS, and all the steps in between.
Finding something like this online has been very difficult since most require prerequisite knowledge of building Lua and such.
Thanks :)
Start with the Lua for Windows package. It will get you a self-contained batteries included Lua installation. Lua for Windows is not an official distribution, but it is well respected by the Lua user community. You can use its lua.exe to gain experience with the language in a Windows environment, and its rich collection of tested extension modules is also available for use.
If you add its include and lib folders to your VS project configuration, you should be able to compile and link against Lua in short order.
One possible complication is that the LfW distribution is built against VC8's C runtime library. If that becomes a problem, then you can either compile Lua yourself as part of your Solution, or get a known good DLL that matches your specific version of Visual Studio from the Lua Binaries project.
Do remember that if you are using one of the distributed DLLs, it will have been compiled as C, and not C++. That means that you must wrap any references to the Lua include files in extern "C" {...} or you will have problems with linkage.
It really helps to have some experience with VS project configuration and building. In particular, experience with mixing C and C++ in a VS project is very helpful.
I heartily recommend following the advice already given about learning C and C++ and mixing the two together. Once you have that under your belt, you may want to check out LuaBind or LuaPlus for connecting C++ and Lua. You can do it manually (and you probably should, at first, to understand what's going on under the hood), but it's more efficient and cleaner, code-wise, to use one of those binding libraries. For debugging purposes, Decoda is a good choice; it can attach to processes started in VS which contain Lua code you want to check.
I would like to call Perl script files from my c++ program.
I am not sure that the people I will distribute to will have Perl installed.
Basically I'm looking for a .lib file that I can use that has an Apache like distribution license.
You can embed perl into your app.
Perl Embedding by John Quillan
C++ wrapper around Perl C API
I'm currently writing a library for embedding Perl in C++, but it's not finished yet. In any case I would recommend against using the EP library. Not only has it not been maintained for years, but is also has some severe architectural deficiencies and is rather limited in its scope. If you are interested in alpha software you can contact me about it, otherwise I'd advice you to use the raw API.
To call perl from C++ you need to use the API, as someone else mentioned; the basic tutorial is available in the perlxstut documentation.
Note that you will most probably need more than just a ".lib", because you'll need a lot of tiny modules which are located in the "lib" directory of the perl distrib: strict.pm, etc. That's a not a big deal though, I guess; the apache example you mentioned has the same constraint of delivering some default configuration files etc.
However, to distribute Perl, on Windows (I guess you're on Windows since you mentionned a .lib file), the ActiveState distribution which everyone uses might cause some licensing headache. It's not really clear to me, but it seems like you cannot redistribute ActivePerl in a commercial product. Note that, if you want to embed Perl in a C++ program, you might have to recompile it anyway, to have the same compilation flags on Perl and on your program.