Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. API Decision

API Decision

Scheduled Pinned Locked Moved ATL / WTL / STL
jsonquestioncsscryptography
2 Posts 2 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Collin Biedenkapp
    wrote on last edited by
    #1

    Hey there guys, I have an almost opinion question. I am writing an instant messenger software, and I am trying to decide on the internal API parsing method. I cannot decide if I want to have a one-size-fits-all method that parses the entire command then returns the specific section I need, or less simple-to-use library of functions that read individual functions. Basically, the command structure is like this: (Let's say you are registering a new connection) REG(##,{your username},{the password salted hash}) My first method would return the username when called as api_GETVALUE(2,"REG(33,username,passwordsalthash)"). If I changed the first argument to 1, it would return 33 (the length). If I did individual functions, I could get the length by calling api_GETLENGTH with the string as a parameter, api_GETUSERNAME for the username, etc. How would you guys do it personally? -- Collin

    L 1 Reply Last reply
    0
    • C Collin Biedenkapp

      Hey there guys, I have an almost opinion question. I am writing an instant messenger software, and I am trying to decide on the internal API parsing method. I cannot decide if I want to have a one-size-fits-all method that parses the entire command then returns the specific section I need, or less simple-to-use library of functions that read individual functions. Basically, the command structure is like this: (Let's say you are registering a new connection) REG(##,{your username},{the password salted hash}) My first method would return the username when called as api_GETVALUE(2,"REG(33,username,passwordsalthash)"). If I changed the first argument to 1, it would return 33 (the length). If I did individual functions, I could get the length by calling api_GETLENGTH with the string as a parameter, api_GETUSERNAME for the username, etc. How would you guys do it personally? -- Collin

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Your first option would have a problem in that you would have a single function that returns either a stirng (or maybe pointer to string) or an integer. But this is not legal in C++, as the compiler cannot distinguish (from return type alone) which one you mean. A better option would be to create a class (or structure) that holds the user information and has methods (getters) that return the relevant properties.

      speaking as ...

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups