Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7737469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:00:24+00:00 2026-06-01T08:00:24+00:00

I was able to save my data onto disk using boost serialization. However, I

  • 0

I was able to save my data onto disk using boost serialization. However, I was unable to retrieve back the data. Would you please show me what did I do wrong?

Thank you,

Below are my codes

void nDB::save_macros(string filename) {
    std::ofstream ofs(filename.c_str(), std::ios::out | std::ios::binary);
    //assert(ofs.good());
    boost::archive::binary_oarchive oa(ofs);
    oa << this;
}

void nDB::load_macros(string filename) {
    std::ifstream ifs(filename.c_str());
    //assert(ifs.good());
    boost::archive::binary_iarchive ia(ifs);
    nDB *db = new nDB;
    ia >> db;
    *this = *db;
}

Below is my serialization instantiation

template<class Archive>
void nDB::serialize(Archive &ar, const unsigned int version) {
    boost::unordered_map<string,macro*,myhash,cmp_str>::iterator M_IT;
    boost::unordered_map<string,layer*,myhash,cmp_str>::iterator L_IT;
    for (L_IT = _LAYERS.begin();L_IT != _LAYERS.end();L_IT++) {
        string tmpstr = L_IT->first;
        //ar & L_IT->first;
        ar & tmpstr;
        ar & *(L_IT->second);
    }
    for (M_IT = _MACROS.begin();M_IT != _MACROS.end();M_IT++) {
       string tmpstr = M_IT->first;
       //ar & M_IT->first;
       ar & tmpstr;
       ar & *(M_IT->second);
    }
}

Below are my run result saving run:

Insert macro mac1 into database OK!
Insert macro mac2 into database OK!
Insert macro mac3 into database OK!
Insert port P1 OK!
Insert port P2 OK!
Insert port P2 OK!
Insert port P3 OK!
Insert port P1 OK!
Insert port P3 OK!
Layer mac3 is found
Macro mac3 has these port:
Port P3 is found
Port P1 is found
Port P3 of macro mac3 has use CLOCK and dir INOUT
Port P1 of macro mac3 has use POWER and dir OUTPUT

Below is my result loading run

ERROR:: Could not find macro mac3 in database

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T08:00:26+00:00Added an answer on June 1, 2026 at 8:00 am

    I think you’re doing too much in your nDB::serialize method.

    Boost Serialize will happily serialize your maps for you, if you just provide serialize methods for your macro and layer classes. Once you’ve written those, you should be able to simplify the given method to something like this:

    template<class Archive>
    void nDB::serialize(Archive &ar, const unsigned int version) {
      ar & _LAYERS;
      ar & _MACROS;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am able to save the data to database using the save command. But
I would like to be able to save the QNetworkReply to a QString/QByteArray. In
I would like to be able to call save() on a backbone model and
I want to be able to save a data stream which i am returning
As per title. I want to be able to save some data in a
I have successful able to save data in User and Profile model, the problem
I would like to save data in cookies (user name, email address, etc...) but
I want to be able to save any C# object in a single column
I wonder if there is a plugin that is able to save the current
I created a DTS package. Someone else wants to be able to save it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.