Your comments needed. Argument Identifiers.

This is a discussion on Your comments needed. Argument Identifiers. within the Windows Programming forums, part of the Platform Specific Boards category; I'm writing a library that uses printf style format identifiers to identify var arg types. Currently I've got the following ...

  1. #1
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544

    Your comments needed. Argument Identifiers.

    I'm writing a library that uses printf style format identifiers to identify var arg types. Currently I've got the following list of identifiers. I was wondering if anyone had any suggestions about changing any of them.

    Code:
    'd' = 4 byte integer (should this be i)
    'u' = 4 byte usigned integer
    'e' = double (should this be d)
    'B' = BSTR
    'b' = BOOL
    'v' = VARIANT
    'S' = LPWSTR
    's' = LPSTR
    'o' = IDispatch * object
    'O' = IUnknown * object (should this be U)
    't' = time_t
    'T' = SYSTEMTIME * (what should this be)
    'D' = DATE (Variant Date)
    'f' = FILETIME *
    I need to add LPTSTR which will use 'T' so what should I use for SYSTEMTIME? Do you think these identifers would be obvious, it's hard to tell when I have been using them for so long.

    Thanks for your suggestions.

  2. #2
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    I don't see any issues with those identifiers. If other people are to use this function, they will have to learn the new format (ie different from printf's) anyway, so it doesn't really matter what you put. It would of course be best to keep all the printf ones the same, to make learning easier. But remember, there are at least 52 characters to choose from, so you have plenty of room to move.

    If you implement a screen output function, I guess you'll be using a printf() style one ey. Personally, I prefer the ease of stream objects. Maybe you should implement the library as a class or set of classes, that way you could use both streams and old school functions. Eg:

    Code:
    class clsOut
    {
    public:
    	print(LPCTSTR,...); //or however the arg list is done, I forget now
    	clsOut operator << (char *);
    	clsOut operator << (int);
    	clsOut operator << (SYSTEMTIME);
    };
    Dunno, just a thought.
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  3. #3
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Thanks for the ideas! I ended up choosing 'W' for SYSTEMTIME.(for Windows time). I've kept 'd' and 'e' for similarity to printf as you suggest. As for the classes, the library is in C, and I can't yet write C++(I can read it, I should learn to write it sometime) so that will have to be a future project.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. function argument not needed
    By lord in forum C++ Programming
    Replies: 2
    Last Post: 09-16-2008, 05:34 PM
  2. template function argument deduce
    By George2 in forum C++ Programming
    Replies: 2
    Last Post: 03-11-2008, 08:56 PM
  3. removing comments of type '//' and '/*'
    By rohit83.ken in forum C++ Programming
    Replies: 3
    Last Post: 10-20-2007, 02:24 AM
  4. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 09:33 AM
  5. The Art of Writing Comments :: Software Engineering
    By kuphryn in forum C++ Programming
    Replies: 15
    Last Post: 11-23-2002, 04:18 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21