Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 1 year ago.
Improve this question
pimpl idiom allows to reduce compilation dependencies in projects and have binary compatibility at the same time.
In other words you can change private implementation of a class without the need to recompile client's code.
Where can I find examples of such approach? Do you know any open source libraries or apps that uses it?
I know about QT and Poco:
D-Pointer - Qt Wiki
poco/IPAddress.h at develop · pocoproject/poco (but is this correct to include 'impl' header file in the 'public' header file? Any change in that private impl will cause recompilation).
Where can I find examples of such approach? Do you know any open
source libraries or apps that uses it?
Qt. Specific module example: QGraphicsItem.cpp, filled with d_ptr. Private part interface. The whole thing with both public and private modules.
A private implementation makes a lot of sense in case of porting the whole library/framework to a different platform. You just put a different files for implementation in while keeping the public interface as is. And the implementation is accessible via d_ptr->.
For the curious: non-Qt Pimpl C++ 11 example.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I am currently looking for a JSON-RPC library that implements the 2.0 specification and is, or at least can be easily adapted to be, transport-agnostic, implemented in c++ and have as few dependencies as possible.
In my search for it, I already looked for on the obvious places and the more comprehensive collections below:
http://json-rpc.org/wiki/implementations (outdated info)
https://en.wikipedia.org/wiki/JSON-RPC
Header-only / standard c++11 implementation, for a quick drop in a new project, that can be used on different platforms is a plus!
Please note that I am not looking for a recommendation on which one is best or not, as I can most likely judge that myself. What I am asking is if anybody else know about a library that meet those technical requirements above, or at least already found a way to work around those requirements using an implementation that is public available.
Thank you.
After a lot of digging, the closest I could find that meet those requirement, specifically the one to be able to be adapted to be transport-agnostic was:
https://github.com/erijo/xsonrpc
It is still not a header-only implementation, and it has some external dependencies that makes it cumbersome to compile/use on different platforms and projects, but it was still the closest one I could find.
I might adapt this one to make it 100% in compliance with the original requirements of my question. Will update the question when I do so.
UPDATE
Using xsonrpc as a starting point, I put together an implementation that satisfy all those requirements and published as an opensource project:
https://github.com/uskr/jsonrpc-lean - include-only, transport-agnostic JSON-RPC 2.0 client/server implementation
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
Can anybody point me to an open source C++ project(preferably not a lib), where policy based design is extensively used?
Well, I suppose that any C++ application using the STL containers (parameterized by an Allocator and, sometimes, a Comparator) extensively use Policy-Based design. It's been a corner stone of the STL even seen it saw the light at SGI.
The obvious one by Alexandrescu: Loki
It's being actively developed.
any project that is using boost :-) http://www.boost.org/community/generic_programming.html#policy
if you mean initiating policy-based objects, than it would be a lot of projects that use boost. For example, http://programmingexamples.net/wiki/CPP/Boost/BGL/DijkstraDirected
or you can look at big projects on github https://github.com/search?q=%23include+%3Cboost%2Fgraph%2Fgraph_traits.hpp%3E&type=Code&ref=searchresults
if you mean defining policy-based object, than most of the use cases would be libraries. The reason for that is that if somethings needs a lot of customization and can be generalized, it becomes a library (even if for internal use). If you just writing a straightforward program that doesn't need customization of objects and poly-morphism, than it wouldn't use much of policy-based design.
for those, you can also search on github, trying out some common policy-based syntaxes.
In my scientific work, I use boost's odeint library that relies on policies. When I code, i start with a specialized hamiltonian, than I generalize it with policies and it basically becomes a library that I use in many other projects.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
I am developing some c++ code, but having code separated in to .h and .cpp is driving me mad, as it is slowing down re-factoring.
Is there a tool that lets one work on a single file. An editor that just hides the truth, or a per-processor that takes a single file and produces the two files .cpp and .h
clarification:
I want a single file per compilation unit (like Java, C♯, Eiffel). I will still have to have #include in files to include the headers of other modules. (but then Java and c♯ have import and using).
clarification 2:
Things are easier if everything that should be together is together.
i.e. one and only one file per class.
There's Lzz. I haven't tried it, but it seems like what you're looking for.
Whatever tool you try to use to do this will only hide some of the complexity or make your code C++-unlike and that will in turn make it harder for others to read/maintain.
I recommend that you just learn and get used to the compilation model of the language rather than fighting it. Deciding what goes into the header and/or the implementation is not an automated process, but rather part of the design and tools cannot design for you. Any automated tool to do that will end up generating a less than perfect result, probably longer compile times and/or leaking implementation details to the users of your headers.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
I am writing an application in which I need to be able to browse for an existing file and to create a new one. I need to create user interface for that. Is there any good cross-platform free library to help me do that?
If you're not already using a cross-platform UI library, then it doesn't make a lot of sense to introduce a dependency upon a huge library just to display a file dialog.
Since recommendations for a cross-platform UI library have already been hashed out repeatedly in other questions (use the search feature to find them if you're interested) and are probably off-topic anyway,
I'm going to take the liberty of assuming that such is not your question.
Therefore, the answer is that no, there is no reliable, cross-platform way of creating a file dialog. Each platform provides a different interface/API for this, so you'll need to write code to detect the current platform and then display the dialog as instructed by each platform's documentation.
You can do this either at run-time (if you want to have a single binary), or at compile-time by using conditional compilation (#if statements).
This is basically all that any UI library would be doing, and for such a simple requirement (a single feature) it makes sense to me at least to just do that work yourself.
You can give wxWidgets a try, a GUI library in C++, free, open-source,... and work with the native graphics libraries.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
I am currently developing a game which simulates an operating system. Therefore i need an ingame filesystem. Currently, i am using zziplib to be able to load files from a zip archive, however this is a readonly "filesystem" and i need a way to write new files and serialize them afterwards (and deserializing them during the next execution)! Are there any useful libraries out there in the wild to be used or should i write one for myself based on any ones?
This is probably one of the places where using a simple database as a filesystem makes sens.
Use something like sqlite to store the data (with paths as keys, blobs as data, or something like that).
One of the advantages of doing this is that you don't actually have to worry about the storage, and you can use existing database tools to view/edit the data "offline" rather than having to write your own. (Plus you can store other game info in there as well.)
You might check out PicoStorage and Embedded File System in C++. I haven't directly used either but I've looked at them both. Embedded File System does have a dependency which could be a show stopper -- it requires Qt to be linked in. Perhaps that could be removed, but it uses it mainly for QString and QFile (and would have no reason to require the UI).
Update, 9 years later: As commented, the above links no longer work. This alternative link for PicoStorage may be viable (I was able to download the source from there but I've made no effort to validate it) but I cannot locate a modern equivalent for EFS.
My six pence on top of the answers above. SolFS (now CBFS Storage) and CodebaseFS provide virtual file system capabilities; both have an API for C/C++ and appear to do exactly what you are asking about. Still... the scale of your task is not clear for me. Does your game need to manage dozens, hundreds, zounds, ... of files? What are the sizes of those files? Etc, etc. I would raise these questions before looking for an appropriate solution.