I am fairly new to this library, and ORM in general. I know tools like EntityFramework can generate a database from your objects, and can generate code from a database. Can ODB for C++ do anything similar? If not, are there libraries that can do such, for C++? Thanks in advance
Yes, ODB can generate database schema (i.e., DDL statements) for your C++ object model. You can have it either as a separate .sql file or embed it into the C++ code and create the schema programmatically from your application.
See the --generate-schema and --schema-format options in the ODB Compiler Manual.
Related
I need to do some research in MDA/MDD to find Open-Source-Tools which will help me to develop code-generators and transformators.
But there are only a few tools which are actually supported. Do I search in the wrong direction?
Do You know open source tools for MDA/MDD?
Greetings Dominic
I found andromda, Eclipse Modelling Framework and a few tools like plantuml, which help to create diagrams .
My plan is to read diagrams with plantuml and convert them with emf to code and the reverse way.
Telosys could be a solution to your need (https://doc.telosys.org/)
Telosys has its own DSL to define the models (based on text files with a simple grammar), see https://doc.telosys.org/dsl-model
A Telosys model can be used to generate any kind of target language (including PlantUML) but Telosys cannot parse PlantUML files, so the input model must be a Telosys model (or a database schema if you create the model from a relational DB).
I have installed a software in my system and I have a lot of data from client in it. All the files which are inside DB folder of this software are with extensions for each individual party.
I want to to use these files to get converted to a MySqli Database.
Sample file from DB folder can be download from here
I have tried understanding for firebird service which this software uses to connect with these database files to get the things.
I want to extract database and import it inside MySqli (PhpMyAdmin)
The linked file seems to be a renamed Firebird database with structure version ODS 11.2 which corresponds to Firebird 2.5.x line.
For making a quick peep into the database you can use
IBSurgeon First Aid -- http://ib-aid.com
IB Expert (the Database Explorer feature) -- http://ibexpert.net
Free mode of FirstAID would let you peep into the data, but not extract it out, probably not even scroll ALL the tables. It also would most probably ignore all database structures that are not tables (UDF functions, procedures, VIEWs, auto-computed columns in tables) - afterall it is just low-level format parser, not an SQL engine.
IB Expert has as a non-commercial Personal edition, but it probably does not include DB Exp, however you may try a trial period of full version. However IBE's DBExp would probably also only show basic structures of the database, maybe it would be enough.
Alternatively you can install Firebird 2.5.8 - either a standalone version or maybe embedded (a set of DLLs used instead of FB server process) if your application can use it, then use any DB IDE suit to explore it. Most often mentioned for Firebird would be IBExpert, FlameRobin, Firebird Maestro or any other. Then you would be able to try different SQL queries, including SPs, VIEWs and UDF-functions if there were any registered for the database and actually used.
BTW IBExpert comes bundled with FB 2.5 Embedded, which one can use to open the database file.
After you figure out the format, you can either export required data into some intermediate format like CSV (for example: http://fbutils.sourceforge.net/ ) or use your C++ application (though why would anyone develop web-application in C++) using libraries like IB++ or OLE DB, etc. Maybe it would be better to just use the Firebird server and original DB files from PHP or what would you write the application in.
Is there a c++ library which provides SQL like syntax to filter/query for specific objects based upon their Getters/Properties ? Im looking for something similar to this http://www.thomasfrank.se/sqlike.html (thats for JS/AS) but written in C++. Requirements would be crossplattform, lightweight and (not a must but) hopefully not using boost.
E.g. i have implemented a scripting engine for my c++ code - my scripts can add callbacks to my C++ Objects. Now instead of writing a script for each object (actor) i wanted to apply it for all objects based upon a filter.
So in my script i would have something like
manager:AddListener("select name="SomeName" and age > 10 or weight < 10",SomeEvent,MyScriptFunc)
When a new Object is created, i would look through all listeners - if this objects property matches the configured one, i add it (e.g. object has property name=somename and age is above 10)
Currently i just identify my objects by a unique identifier (ID) - but i want to be more flexible when i apply the same event listeners to similar objects.
So basically, it would already be enough if there is a libary who creates a filter object from some string query.
You can try SQLite:
SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine. SQLite is the most widely deployed SQL database engine in the world. The source code for SQLite is in the public domain.
You can create an in memory database to hold the C++ object attributes that you wish to query on:
sqlite3_open(":memory:", &db);
Then you can use the One-Step Query Execution Interface to actually perform the queries.
To populate the database, you could use an IDL to describe your objects, and your IDL parser would create the C++ interface header files and the code to populate the database.
I wrote a C++/QT application that uses a mysql database for its data. It's using the mysql++ library. I now want it to be able to export and import its data to/from files.
I could write an own file format, but I'd like to elude this efford, if possible.
Is there an easy possibility to export a mysql table into a file and to reimport this file with C++?
I heard of sqlite, but as far as I read, migrating from mysql++ to sqlite is not that easy, because it includes a switch of the complete database backend.
You can use "LOAD DATA " and "SELECT ... INTO OUTFILE"
That should have great performance. You may not use the outfiles further as easily as you want.
The best way to export/import data from/to a database is xml files.
I am working in Ubuntu. I have a .h file with a class and a lot of nested classes. I would like to create an XML file from an object. Can someone please give me a library that creates XML files, serializes, and deserializes objects? I am compiling with g++.
Try libxml2.
But it seems like you want to serialize and desirialize an object from and to XML. Boost::serialization might come in handy. it also supports serialization from and to XML.
Here you can find an example for Boost::serialization with XML.
If you want to handle XML in C++ you may have a look at these projects
http://xmlsoft.org/
http://www.grinninglizard.com/tinyxml/
http://xerces.apache.org/xerces-c/
It doesn't serialize with XML (which I consider a feature, personally), but Google protocol buffers does a good job of serializing (in a binary format) objects that are defined in the .proto language.
You may want to explore the XML Data Binding. The main idea is that given an xml schema the data binding software generates a class hierarchy corresponding to the schema, and the code to serialize / unserialize (called marshal / unmarshal). There are several tools that can do this, gsoap is a free one, xmlSpy is one of the commercial ones.
What you describe is an XML data binding for C++. There are several tools for what you want to do, see e.g. XML Data Binding Tools. I've used gSOAP for several C++ projects, including starting from C++ files with classes which is really nice (other tools force you to start from XML schemas or WSDLs). With gSOAP I have been able to generate XML schemas and XML, see e.g. map C/C++ types to XML schema.
A super-lightweight, simple xml library is pugixml.
Though keep in mind that C++ does not have the reflection capabilities that .NET has. No library will generate the serialization/deserialization code for you (which I guess you hoped for).