Jump to content
  • Advertisement

randydom

Member
  • Content Count

    8
  • Joined

  • Last visited

Community Reputation

1 Neutral

About randydom

  • Rank
    Newbie

Personal Information

  • Interests
    Programming

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. randydom

    c++ use map with struct

    @ Fulcrum.013 many thanks so what do you suggest as an alternative way for achieving the export procedure ?
  2. randydom

    c++ use map with struct

    1- yes it does and it prints the result in the debug window To be honest with you i'm 5/10 with topics such as arrays , pointers and manual memory management .☹️
  3. randydom

    c++ use map with struct

    Ok i tried to re-implement my function so that it exports an array of _UserIdentity in this way : void get_all_users(UserIdentity **_UserIdentity) { std::lock_guard<std::mutex> locker(_locker); for (auto& t : _IdenetyClass) { (*_UserIdentity)->id = t.second.id; (*_UserIdentity)->name = t.second.name; } } So is my new implementation correct please ?
  4. randydom

    c++ use map with struct

    @Zakwayda so many thanks , please can you help in implementing this : std::vector instance locally or the 'UserIdentity **_UserIdentity' , i really appreciate that .
  5. randydom

    c++ use map with struct

    1 : It's just a naming convention ( i'm a delphi programmer and i'm just following the delphi classes naming convention ) that's all . 2 : I'm looping to get all Users's information and store them in the UserIdentity ; something like creating an array of UserIdentity I thought about this : void get_all_users(UserIdentity **_UserIdentity) { // But here i really didnt' know how to // impelent it like with *_UserIdentity } if this implementation is incorrect you're so welcome to fix it and i'll be so thankful .
  6. randydom

    c++ use map with struct

    Thank you , let me explain what i'm trying to achieve : I've a class ( TIdenetyClass ) contains users information ( Name , ID ... etc ) , it's mapped as follows : std::map<int, std::shared_ptr<TIdenetyClass >> _IdenetyClass; so i fill my TIdenetyClass and insert it in the map ; here every things go well . then i want the DLL consumer to be able to get all the users stored in my TIdenetyClass class , But here i don't want to export the class itself but a struct , so each time the consumer want to get all users it will invoke that by /* * Get all users and export them in the UserIdentity struct */ void get_all_users(UserIdentity *_UserIdentity) { // loop and fill my UserIdentity's fields // this will get all current users std::lock_guard<std::mutex> locker(_locker); for (auto& t : _IdenetyClass) { _UserIdentity->id = t.second.id; _UserIdentity->name = t.second.name; } } That's what i'm trying to achieve , the part i'm trying to be sure is correct and optimized is the function void get_all_users thank you .
  7. randydom

    c++ use map with struct

    @ pcmaster So many thanks , can you please help me to fix or optimize this : void Ui_export(UserIdentity *_UserIdentity) { for (auto& t : m_UserIdentities) { _UserIdentity->name = t.first; _UserIdentity->id = t.second; } } PS : I fixed the function name .
  8. Hello every one , please i want to be sure this's the best + optimized way , or even the worst way 🙁 what i want is to be able to export a struct from my DLL . struct UserIdentity { std::string name; int id; }; std::map<std::string, int> m_UserIdentities = { { "Bob", 100 }, { "Jone", 101 }, { "Alice", 102 }, { "Doe", 103 } }; /* * Will be used in a DLL that will export UserIdentity struct * OUT _UserIdentity */ void Ui_export(UserIdentity *_UserIdentity) { for (auto& t : m_UserIdentities) { _UserIdentity->name = t.first; _UserIdentity->id = t.second; } } Regards.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!