Hi,

I would like to be able to use an api for reading/writing to a file database. Basically, I will have to write programs that have recovery (meaning if it shuts down, etc. it has a file/files to recover from). I could attempt to write something myself but if it exists already, I would rather just use it....

Winbatch

Dani AI

Generated

As asked for a portable, file-based API for crash/recovery use and suggested an MFC-based route, note that MFC is a Windows-only framework — so for Solaris+Windows you should look at embedded, serverless engines instead. (MFC overview). (en.wikipedia.org)

If you need SQL (relational) semantics and one-file simplicity, SQLite is the go-to: it is serverless, ACID-compliant, widely portable and embeddable. (SQLite home). (sqlite.org) SQLite explicitly documents transactional crash-safety and describes write-ahead-log (WAL) mode which increases reader/writer concurrency — useful if you expect concurrent processes. (Transactions, WAL). (sqlite.org)

If your data model is key/value (not SQL), consider these cross-platform embedded engines and choose by concurrency/throughput needs and license: Oracle Berkeley DB (mature C/C++ API; note licensing considerations). (Berkeley DB). (oracle.com) LMDB is a compact, memory-mapped MVCC store with excellent read scaling (only one writer at a time but reads don’t block). (). () LevelDB is a simple ordered key/value library from Google and RocksDB is its high-performance fork optimized for fast storage and multicore systems. (LevelDB, RocksDB). (github.com)

Practical checklist: pick SQL vs key/value first; verify builds and ABIs on both Solaris and Windows; test crash/recovery and fsync/wal/ checkpoint behavior on your target filesystem; watch license terms (Berkeley DB) and architecture portability (LMDB file format notes). For simple record persistence you can combine an embedded engine with structured serialization like Protocol Buffers or Boost.Serialization. (protobuf, Boost.Serialization). (oracle.com)

If desired, pick one or two candidates, write small cross-platform prototypes, and run power-failure and concurrency tests on both OSes before committing to an API.

If you use Visual C++, you can use the CRecordSet (and its variants) to do all the file handling for you. It works very well (in my experience) and will save automatically thru the database application.

I am using visual studio .net, so I will look into that, but I was hoping for something more portable, as I also use SUN Solaris

If you are using Visual C++, MFC has a class called CRecordSet (there are variants of this, as well) that handle all the I/O for you. In my experience, they work very well. In fact , your app won't even need a file menu since the database application will save your files for you.

Thanks, but again I'm looking for something using standard c++/cross platform so that I can run it on windows as well as SUN.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.