Revision: 76956
          http://sourceforge.net/p/brlcad/code/76956
Author:   d_rossberg
Date:     2020-08-26 11:06:09 +0000 (Wed, 26 Aug 2020)
Log Message:
-----------
a C++ core interface for loading database data from an array in RAM

Modified Paths:
--------------
    rt^3/trunk/include/brlcad/MemoryDatabase.h
    rt^3/trunk/src/coreInterface/MemoryDatabase.cpp

Modified: rt^3/trunk/include/brlcad/MemoryDatabase.h
===================================================================
--- rt^3/trunk/include/brlcad/MemoryDatabase.h  2020-08-26 10:54:40 UTC (rev 
76955)
+++ rt^3/trunk/include/brlcad/MemoryDatabase.h  2020-08-26 11:06:09 UTC (rev 
76956)
@@ -44,6 +44,8 @@
         /** The old content of the in-memory database will be discarded.
             The file will be opened for reading only and closed after 
finishing the operation. */
         virtual bool Load(const char* fileName);
+        bool         Load(const void* data,
+                          size_t      dataSize);
         bool         Save(const char* fileName);
 
     private:

Modified: rt^3/trunk/src/coreInterface/MemoryDatabase.cpp
===================================================================
--- rt^3/trunk/src/coreInterface/MemoryDatabase.cpp     2020-08-26 10:54:40 UTC 
(rev 76955)
+++ rt^3/trunk/src/coreInterface/MemoryDatabase.cpp     2020-08-26 11:06:09 UTC 
(rev 76956)
@@ -95,6 +95,32 @@
 }
 
 
+bool MemoryDatabase::Load
+(
+    const void* data,
+    size_t      dataSize
+) {
+    bool ret = false;
+
+    if (!BU_SETJUMP) {
+        rt_i* source = rt_dirbuild_inmem(data, dataSize, 0, 0);
+
+        if (source != 0) {
+            ret = (db_dump(m_wdbp, source->rti_dbip) == 0);
+
+            assert(m_wdbp->dbip == m_rtip->rti_dbip);
+            db_update_ident(m_wdbp->dbip, source->rti_dbip->dbi_title, 
source->rti_dbip->dbi_base2local);
+
+            rt_free_rti(source);
+        }
+    }
+
+    BU_UNSETJUMP;
+
+    return ret;
+}
+
+
 bool MemoryDatabase::Save
 (
     const char* fileName

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to