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 9287209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T19:36:54+00:00 2026-06-18T19:36:54+00:00

I’m serializing some data coming off of two different branches of a project. The

  • 0

I’m serializing some data coming off of two different branches of a project. The data is outputted in text archive form using boost::serialization. Since a diff is to be made between the two serialized files, I’m also adding some debug messages into the serialized files between each serialized part, as to better see the point at which a difference in the output may occur.

Here is a broad overview of the code I’m currently using:

std::ofstream ofs("./SomeFile.txt"); // for brevity's sake, no actual path used
{
  boost::archive::text_oarchive oa(ofs);
  std::string debug_str;

  debug_str = "\n\nPart 1\n";
  oa & debug_str;

  // ... some other serialized parts ...

  debug_str = "\n\nPart 145\n";
  oa << debug_str;
}

You can notice that I first thought that the used operator (& vs <<) made a difference in output, yet it doesn’t, I get the following text file :

22 serialization::archive 7 9 [CRLF]
[CRLF]
Part 1 [CRLF]
 11 [CRLF]
[CRLF]
Part 145 [CRLF]

The 22 serialization::archive 7 part is a standard Boost serialization header, identifying the type of archive I guess. Afterwards comes the part I would like to have removed, namely 9 – after a bit of goose chasing I figured out that the 9 is the length of the "\n\nPart1\n" string!

Is this expected behaviour or is there a way of circumventing this output? In the case of other actual records, there is no apparent use of other such “control codes”, marking length or such.

It would be useful to add some debug output, yet because the lengths of the said debug strings may differ (since heavy refactoring occured on one of the branches), the diff yields some false positives.

Any thoughts would be appreciated, thanks!

  • 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-18T19:36:55+00:00Added an answer on June 18, 2026 at 7:36 pm

    I doubt this is possible.

    The problem you face here is that the textual output need be parsed back to be deserialized. There are two main ways of structuring textual output so it can be parsed back easily:

    • length-prefixed strings
    • special characters (with escape codes)

    For example, in an xml archive the tags are surrounded with < and > and you cannot use those characters yourself, instead using escaped codes &lt; and &gt; respectively. On the other hand, if you look at the Redis format you will see things like 13$Hello, World! where the length of the record is a string of digits, followed by $, followed by the actual record.

    The former way (length-prefixed strings) is much more efficient, but much less human writable.

    From the Boost::Serialization documentation, I see two different “human-readable” archives:

    • boost::text_[i/o]archive uses the length-prefixed string (it seems)
    • boost::xml_[i/o]archive uses the xml representation

    You might want to switch to boost::xml_oarchive.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I've tracked down a weird MySQL problem to the two different ways I was
I have a text area in my form which accepts all possible characters from
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm using an ASP request returning a XML file containing some latin characters. By
I am using jsonparser to parse data and images obtained from json response. When
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I am using JSon response to parse title,date content and thumbnail images and place

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.