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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:53:31+00:00 2026-06-13T08:53:31+00:00

I bind a UUID value from a SQL SERVER colomn (via Qt Sql module)

  • 0

I bind a UUID value from a SQL SERVER colomn (via Qt Sql module) into a QUuid object.
After that I have to assign it into a in-house uuid object by using a assign function which take a char* as parameter.

QUuid expose several char* as public members, so I have to built a char * of 16 bytes with the several char * QUuid’s members.

namely, copy :

char buff0;
char buff1;
char buff2[2];
char buff3[4];
char buff4[8];

inside

char final[16];

I have used memcpy to do this task like that :

int accu = 0;    
memcpy(final, &buff0, sizeof(buff0)); 
accu += sizeof(buff1);
memcpy(final+accu, &buff1, sizeof(buff1));
accu += sizeof(buff2);
memcpy(final+accu, buff2, sizeof(buff2));
accu += sizeof(buff3);
memcpy(final+accu, buff3, sizeof(buff3));
accu += sizeof(buff4);
memcpy(final+accu, buff4, sizeof(buff4));

but I find this manner of doing not really readable and maintanable.
I’m looking for a more elegant manner to do this task. By elegant I mean with less line of codes and/or less arithmetics.

  • 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-13T08:53:32+00:00Added an answer on June 13, 2026 at 8:53 am

    Here’s a C++11 STL version.

    char* out = final;
    out = std::copy_n(&buff0, 1, out);
    out = std::copy_n(&buff1, 1, out);
    out = std::copy_n(buff2, 2, out);
    out = std::copy_n(buff3, 4, out);
    out = std::copy_n(buff4, 8, out);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I bind a datatable that contains data from a SOAP call. Unfortunately, the call
Is it possible to bind methods from other object in the Router.routes map? I
I have an SQL template where I need to substitute random UUIDs. from string
Possible Duplicate: Bind multiple events to jQuery 'live' method I have the following function:
Can I bind my h:dataTable/rich:dataTable with some Map? I found that h:dataTable can work
Is it possible to bind hover() to document with specified selector so that dynamically
Is it possible to bind a property to value of a setter like this
I'm trying to bind a <ul> element to a property that is an observableArray
I would like to bind a textbox to a property of the window that
My requirements bind me to have multiple rows in a single Details band. Right

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.