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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:18:22+00:00 2026-06-03T20:18:22+00:00

I have strings of data that look like this: b = bool i =

  • 0

I have strings of data that look like this:

b = bool
i = int
sINT: = string whose length is INT followed by a : then the string
m = int message id.

Example:

m133s11:Hello Worldi-57989b0b1b0

This would be:

Message ID 133
String 'Hello World' length 11
int -57989
bool false
bool true
bool false

Is there something in STL that could easily parse this?

  • 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-03T20:18:24+00:00Added an answer on June 3, 2026 at 8:18 pm

    Yep:

    std::stringstream   data("m133s11:Hello Worldi-57989b0b1b0");
    while(parse(data))
    {
       // 1 item was correctly removed from the stream
    }
    
    std::istream& parse(std::istream& data)
    {
        char format;
        data >> format;
    
        switch(format)
        {
            case 'i':   int value;  data >> value;break;
            case 'm':   int id;     data >> id;   break;
            case 'b':   bool value; data >> value; break;
            case 's':
            {
                std::size_t   size;
                char          x = '0';
                data >> size >> x;
                if ((!data) || (x != ':'))
                {   // Something went wrong
                    data.setstate(std::ios_base::iostate::badbit);
                }
                else
                {
                    std::string  value(size, ' ');
                    data.read(&value[0], size);
                }
                break;
            }
        }
        return data;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a bunch of strings in perl that all look like this: 10
I have column that contains strings. The strings in that column look like this:
I have connection strings that look like: Data Source=mydomain.com;Initial Catalog=DB;Integrated Security=True This works from
I have a bunch of strings in php that all look like this: 10
I have a bunch of strings that look, for example, like this: <option value=Spain>Spain</option>
I have to work with strings which may contain Lat/Long data, like this: $query
I have strings which look like this one: (8, 12.25), (13, 15), (16.75, 18.5)
I have datetime strings that look can like any the following: 1 13 2009
I have 2 arrays in PHP that look something like this: $rows = array(11,12,14,14,11,13,12,11);
I have a string of data with the following format: xpos-ypos-zoom (i.e. 8743-12083-15) that

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.