GNU social JP
  • FAQ
  • Login
GNU social JPは日本のGNU socialサーバーです。
Usage/ToS/admin/test/Pleroma FE
  • Public

    • Public
    • Network
    • Groups
    • Featured
    • Popular
    • People

Conversation

Notices

  1. Embed this notice
    hazlin no plap pirate (hazlin@shortstacksran.ch)'s status on Sunday, 27-Oct-2024 21:22:00 JST hazlin no plap pirate hazlin no plap pirate
    I am wonder how best to translate this into c++.

    A separate map for each column?
    In conversation Sunday, 27-Oct-2024 21:22:00 JST from shortstacksran.ch permalink

    Attachments


    1. https://shortstacksran.ch/media/c7c7cb38e2c77a0d3ae65de56425bcdb1b7defc59d2250f6cc834367a5484a81.png
    • :ihavenomouth: likes this.
    • Embed this notice
      karna :flipflop: :buffsuki: (karna@poa.st)'s status on Sunday, 27-Oct-2024 21:22:03 JST karna :flipflop: :buffsuki: karna :flipflop: :buffsuki:
      in reply to

      @hazlin idk about c++ but assuming theres enough overlap with c, you could make an enum of possible colors, which acts as index into an array of structs containing your resistor info

      In conversation Sunday, 27-Oct-2024 21:22:03 JST permalink
      :ihavenomouth: likes this.
    • Embed this notice
      karna :flipflop: :buffsuki: (karna@poa.st)'s status on Monday, 28-Oct-2024 02:58:47 JST karna :flipflop: :buffsuki: karna :flipflop: :buffsuki:
      in reply to

      @hazlin ive never used sfml (also I read that acronym as shit fuck my life every time I see it...), is the setup that complicated?

      In conversation Monday, 28-Oct-2024 02:58:47 JST permalink
      :ihavenomouth: likes this.
    • Embed this notice
      hazlin no plap pirate (hazlin@shortstacksran.ch)'s status on Monday, 28-Oct-2024 02:58:48 JST hazlin no plap pirate hazlin no plap pirate
      in reply to
      • karna :flipflop: :buffsuki:
      @karna SFML can do all the font stuff for me xD I am just having fun, trying to do everything from a sprite sheet. Trying to keep things very low level for this first attempt.
      In conversation Monday, 28-Oct-2024 02:58:48 JST permalink
    • Embed this notice
      hazlin no plap pirate (hazlin@shortstacksran.ch)'s status on Monday, 28-Oct-2024 02:58:48 JST hazlin no plap pirate hazlin no plap pirate
      in reply to
      • karna :flipflop: :buffsuki:
      @karna I would also be doing this in plain C, as I have that working... but it was such a pain to get SFML working with C, I worry about other people being able to use it xD
      In conversation Monday, 28-Oct-2024 02:58:48 JST permalink
    • Embed this notice
      hazlin no plap pirate (hazlin@shortstacksran.ch)'s status on Monday, 28-Oct-2024 02:58:49 JST hazlin no plap pirate hazlin no plap pirate
      in reply to
      • karna :flipflop: :buffsuki:
      @karna Also, c++ did not like the utf-8 characters xD I read about it some, and tried to work around it, but it was not having it xD

      A step I skipped was doing the tokenization inside of c++, but I'm not quite sure how to do that. Examples I found of such things, focus on using a single character to split things. But, that isn't quite what I need.

      I need to digest a string, and consume either the next character, or the next group of characters if they match an entry in a list.... a problem for another time?

      Thank you again for the help :D
      In conversation Monday, 28-Oct-2024 02:58:49 JST permalink
    • Embed this notice
      karna :flipflop: :buffsuki: (karna@poa.st)'s status on Monday, 28-Oct-2024 02:58:49 JST karna :flipflop: :buffsuki: karna :flipflop: :buffsuki:
      in reply to
      @hazlin > utf8
      getting out of my depth already..

      > string tokenization
      I'm sure you could write a string parsing and tokenizing function but I'm not sure what standard library tools are available in c++ that might make that easier if you dont want to roll your own
      In conversation Monday, 28-Oct-2024 02:58:49 JST permalink
    • Embed this notice
      karna :flipflop: :buffsuki: (karna@poa.st)'s status on Monday, 28-Oct-2024 02:58:50 JST karna :flipflop: :buffsuki: karna :flipflop: :buffsuki:
      in reply to

      @hazlin Oh nice. Glad its working

      In conversation Monday, 28-Oct-2024 02:58:50 JST permalink
    • Embed this notice
      hazlin no plap pirate (hazlin@shortstacksran.ch)'s status on Monday, 28-Oct-2024 02:58:50 JST hazlin no plap pirate hazlin no plap pirate
      in reply to
      • karna :flipflop: :buffsuki:
      @karna
      The explanation for the, verbose symbol names, is that my, "No Game Engine" workflow, has things passing into and out of inkscape/svg_format.

      And, it was fighting me quite a bit. So, for now, everything is just alphabet ascii strings.
      In conversation Monday, 28-Oct-2024 02:58:50 JST permalink
    • Embed this notice
      hazlin no plap pirate (hazlin@shortstacksran.ch)'s status on Monday, 28-Oct-2024 02:58:51 JST hazlin no plap pirate hazlin no plap pirate
      in reply to
      • karna :flipflop: :buffsuki:
      @karna
      > at least not without compiler extensions

      Maybe the IDE is automagically handling the for me?
      In conversation Monday, 28-Oct-2024 02:58:51 JST permalink

      Attachments


      1. https://shortstacksran.ch/media/592641d4a43d38abfa13d64b6f05f13dc3dd913b9b0ee1f71eb1dc082f4fe624.png
    • Embed this notice
      karna :flipflop: :buffsuki: (karna@poa.st)'s status on Monday, 28-Oct-2024 02:58:52 JST karna :flipflop: :buffsuki: karna :flipflop: :buffsuki:
      in reply to

      @hazlin no problemo. fwiw, yhe term for this sort of initialization of structs is "designated initializer". I did a little digging and saw that c++ is a little more restrictive than c when it comes to how you can use these (see https://en.cppreference.com/w/cpp/language/aggregate_initialization#Designated_initializers ). Also you probably dont need to typedef structs in c++ either

      Note: out-of-order designated initialization, nested designated initialization, mixing of designated initializers and regular initializers, and designated initialization of arrays are all supported in the C programming language, but are not allowed in C++.

      In conversation Monday, 28-Oct-2024 02:58:52 JST permalink

      Attachments

      1. No result found on File_thumbnail lookup.
        Aggregate initialization - cppreference.com
    • Embed this notice
      karna :flipflop: :buffsuki: (karna@poa.st)'s status on Monday, 28-Oct-2024 02:58:52 JST karna :flipflop: :buffsuki: karna :flipflop: :buffsuki:
      in reply to
      • karna :flipflop: :buffsuki:

      @hazlin And the temporary structs being used in the array directly uses "compound literals" which may not be supported in CPP at all (see https://en.cppreference.com/w/c/language/compound_literal ), at least not without compiler extensions

      In conversation Monday, 28-Oct-2024 02:58:52 JST permalink

      Attachments

      1. No result found on File_thumbnail lookup.
        Compound literals (since C99) - cppreference.com
    • Embed this notice
      hazlin no plap pirate (hazlin@shortstacksran.ch)'s status on Monday, 28-Oct-2024 02:58:52 JST hazlin no plap pirate hazlin no plap pirate
      in reply to
      • karna :flipflop: :buffsuki:
      @karna Worry not, it appears to work just fine :D
      In conversation Monday, 28-Oct-2024 02:58:52 JST permalink

      Attachments


      1. https://shortstacksran.ch/media/ce1ec3cc2bb207b9a5930b19e92717c1a0f1cfbade32ca0d6a8ba095f12272d1.png
    • Embed this notice
      karna :flipflop: :buffsuki: (karna@poa.st)'s status on Monday, 28-Oct-2024 02:58:53 JST karna :flipflop: :buffsuki: karna :flipflop: :buffsuki:
      in reply to

      @hazlin For the sake of completeness, this is what I meant. Since I don't think your strings need to be dynamically handled, you could do something like this in C. in C++, your mileage may vary, idk what initializers are supported..

      #include <stdio.h> enum { RES_BLACK, RES_BROWN, RES_RED, RES_ORANGE, RES_YELLOW, RES_GREEN, RES_BLUE, RES_PURPLE, RES_GREY, RES_WHITE, RES_GOLD, RES_SILVER, RES_NO_COLOR, RES_NUM_COLORS }; typedef struct ResInfo { char number; unsigned int rgb[3]; char *tol; char *mag; } ResInfo; ResInfo res_info[] = { [RES_BLACK] = (ResInfo) {.number = '0', .rgb = {0, 0, 0}, .tol = "_.__%", .mag = "Ω"}, [RES_BROWN] = (ResInfo) {.number = '1', .rgb = {200, 113, 55}, .tol = "1.00%", .mag = "0Ω"}, [RES_RED] = (ResInfo) {.number = '2', .rgb = {200, 55, 55}, .tol = "2.00%", .mag = "00Ω"}, [RES_ORANGE] = (ResInfo) {.number = '3', .rgb = {255, 102, 102}, .tol = "_.__%", .mag = "kΩ"}, [RES_YELLOW] = (ResInfo) {.number = '4', .rgb = {255, 255, 0}, .tol = "_.__%", .mag = "0kΩ"}, [RES_GREEN] = (ResInfo) {.number = '5', .rgb = { 0, 128, 0}, .tol = "0.50%", .mag = "00kΩ"}, [RES_BLUE] = (ResInfo) {.number = '6', .rgb = { 50, 50, 255}, .tol = "0.25%", .mag = "MΩ"}, [RES_PURPLE] = (ResInfo) {.number = '7', .rgb = {128, 0, 128}, .tol = "0.10%", .mag = "0MΩ"}, [RES_GREY] = (ResInfo) {.number = '8', .rgb = {128, 128, 128}, .tol = "0.05%", .mag = "_"}, [RES_WHITE] = (ResInfo) {.number = '9', .rgb = {255, 255, 255}, .tol = "_.__%", .mag = "_"}, [RES_GOLD] = (ResInfo) {.number = '_', .rgb = {186, 176, 0}, .tol = "5.00%", .mag = "0mΩ"}, [RES_SILVER] = (ResInfo) {.number = '_', .rgb = {204, 204, 204}, .tol = "10.0%", .mag = "mΩ"}, [RES_NO_COLOR] = (ResInfo) {.number = '_', .rgb = { 0, 0, 0}, .tol = "20.0%", .mag = "_"}, }; int main(void) { for (int i = 0; i < RES_NUM_COLORS; i++) { printf ("number: '%c', rgb: (%3u, %3u, %3u), tol: '%s', mag: '%s'\n", res_info[i].number, res_info[i].rgb[0], res_info[i].rgb[1], res_info[i].rgb[2], res_info[i].tol, res_info[i].mag); } return 0; }
      In conversation Monday, 28-Oct-2024 02:58:53 JST permalink

      Attachments


      1. https://i.poastcdn.org/534850a890422ca09684ce8c614792d95ffc9f1519abc5b10761b0ef45c47c14.png
    • Embed this notice
      hazlin no plap pirate (hazlin@shortstacksran.ch)'s status on Monday, 28-Oct-2024 02:58:53 JST hazlin no plap pirate hazlin no plap pirate
      in reply to
      • karna :flipflop: :buffsuki:
      @karna
      Thank you friend :D

      This syntax feels new to me :O

      I'd been already looking at examples of structs, but hadn't seen anything like this.
      In conversation Monday, 28-Oct-2024 02:58:53 JST permalink
    • Embed this notice
      karna :flipflop: :buffsuki: (karna@poa.st)'s status on Monday, 28-Oct-2024 02:58:54 JST karna :flipflop: :buffsuki: karna :flipflop: :buffsuki:
      in reply to
      • karna :flipflop: :buffsuki:

      @hazlin I think the STL has maps and unordered_maps if you really want to use dictionaries but I dont use c++ so :akarinShrug:

      In conversation Monday, 28-Oct-2024 02:58:54 JST permalink
    • Embed this notice
      hazlin no plap pirate (hazlin@shortstacksran.ch)'s status on Monday, 28-Oct-2024 02:58:54 JST hazlin no plap pirate hazlin no plap pirate
      in reply to
      • karna :flipflop: :buffsuki:
      @karna I appreciate your feedback :D

      I'm just trying to figure out the best way to glew all this data together in c++ xD

      I am going to pre-tokenize the strings into arrays of strings. And, I wasn't sure if that would work well with a struct.

      I was under the impression that they liked... when everything had a known size going into things.

      I guess I could just pick a maximum string array length.
      In conversation Monday, 28-Oct-2024 02:58:54 JST permalink

Feeds

  • Activity Streams
  • RSS 2.0
  • Atom
  • Help
  • About
  • FAQ
  • TOS
  • Privacy
  • Source
  • Version
  • Contact

GNU social JP is a social network, courtesy of GNU social JP管理人. It runs on GNU social, version 2.0.2-dev, available under the GNU Affero General Public License.

Creative Commons Attribution 3.0 All GNU social JP content and data are available under the Creative Commons Attribution 3.0 license.