Thread: a C++ library of mine.

  1. #1
    Registered User
    Join Date
    Aug 2003
    Posts
    127

    a C++ library of mine.

    Hi, buddies, I am writing a C++ library, it is an open source software, contains GUI/Threads/TextToken and so on...

    find more information at http://stdex.sourceforge.net

    Are you interesting in implemention of GUI controls?
    hehe..regards.
    Nana C++ Library is a GUI framework that designed to be C++ style, cross-platform and easy-to-use.

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Very nice to see something like this.
    I would be interested in making changes more to VB-like style (ie form.Caption = "something") instead of a function and such.
    Also more of a suggestion - but you can use Option Tree for listboxes and such. Incredibly feature rich.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    >>I would be interested in making changes more to VB-like style (ie form.Caption = "something") instead of a function and such.

    Eww...stick to accessors.

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Get/set for everything is horrible X_X
    Having them as properties is more invigorating.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Quote Originally Posted by Elysia View Post
    Get/set for everything is horrible X_X
    Having them as properties is more invigorating.
    Yeah, but it makes more sense to keep the interface away from the data especially if you are in early stages of a library.

    IIRC when you write a COM object in C++ (and I think the same applies to when you write them in VB) you have to use accessors in the interface you expose that the VB language then hides from the user when it makes those properties accessible.

    Let the users access your data and somewhere down the line you might have to do something like check state before allowing access to that data, but as the data is "on show" your stuck

  6. #6
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Ah yes, I was never suggesting letting users access data directly. No no no.
    It's possible to "emulate" properties using some operators and templates. They act just like data members from the outside, but they are actually fully fledged functions.
    That's similar to what I'm suggesting (I even developed a template for this kind of purpose).
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #7
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Sounds good, but complicated and maybe a bit of a bloat. I'll stick with good old inline accessors!

  8. #8
    Registered User
    Join Date
    Aug 2003
    Posts
    127
    thank you for your suggestion.
    I tried to implement a generic property template, and its object is initialized in the init-list of a class, the property objects are always initilized with 'this' pointer, so compiler gives a warning that using 'this' in init-list, I don't like this warning, so I give up this implementation.

    >>Option Tree for listboxes and such

    All the widgets are own-draw, would you please implement an option tree? :-)
    Nana C++ Library is a GUI framework that designed to be C++ style, cross-platform and easy-to-use.

  9. #9
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by jinhao View Post
    thank you for your suggestion.
    I tried to implement a generic property template, and its object is initialized in the init-list of a class, the property objects are always initilized with 'this' pointer, so compiler gives a warning that using 'this' in init-list, I don't like this warning, so I give up this implementation.
    You can refer to "this" in the initialization list, but you cannot use it to either directly or indirectly reference members which have not yet been constructed. In other words, you can use "this" to access members of the base (if one exists) but not members of the class itself. At least, not members which are not yet constructed.

    The conditions are sufficiently tricky, and compilers are sufficiently buggy, that a wise programmer would not use "this" in the init list. This is why the warning is there.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  10. #10
    Registered User
    Join Date
    Aug 2003
    Posts
    127
    Quote Originally Posted by brewbuck View Post
    You can refer to "this" in the initialization list, but you cannot use it to either directly or indirectly reference members which have not yet been constructed. In other words, you can use "this" to access members of the base (if one exists) but not members of the class itself. At least, not members which are not yet constructed.

    The conditions are sufficiently tricky, and compilers are sufficiently buggy, that a wise programmer would not use "this" in the init list. This is why the warning is there.
    In other words, an proprety object should not use 'this' in the initialization list, because the object refered by this is under constrcution and the object is imcomplete. Although the property object just stores the 'this' while initializing, I gave up this implementation in logic/concept correct.
    Nana C++ Library is a GUI framework that designed to be C++ style, cross-platform and easy-to-use.

  11. #11
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by jinhao View Post
    Although the property object just stores the 'this' while initializing, I gave up this implementation in logic/concept correct.
    I have met with similar designs, and the warning made me feel as you do. In the long run I think it is harmless in this situation, since the stored "this" will not be used until a call to a member, which can only happen after the object is fully constructed. You just have to be sure that the self-pointer is initialized in ALL constructors, including copy constructors -- which means you'll have to write a copy constructor explicitly.

    In the end I also chose to switch to a different design.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  12. #12
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    You can pass this in the initializer list without any danger if the only thing you do with it is store it for later use.

    But I consider property emulation a waste of code and memory. (Yes, the emulation needs one word per property of overhead.)
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  13. #13
    Registered User
    Join Date
    Aug 2003
    Posts
    127
    Quote Originally Posted by CornedBee View Post
    But I consider property emulation a waste of code and memory. (Yes, the emulation needs one word per property of overhead.)
    yes, one property uses at least >=8 bytes, 4 bytes for 'this', 4(>=4) bytes for pointer of member function.
    Nana C++ Library is a GUI framework that designed to be C++ style, cross-platform and easy-to-use.

  14. #14
    Registered User
    Join Date
    Aug 2003
    Posts
    127
    Quote Originally Posted by Elysia View Post
    Get/set for everything is horrible X_X
    Having them as properties is more invigorating.
    get/set is horrible...I avoided this issue by using function overloading.

    form.caption(str); //set the caption of form
    str = form.caption(); //get the caption of from;

    thank you guys, i think we should go on with the discussions. ^_^
    Nana C++ Library is a GUI framework that designed to be C++ style, cross-platform and easy-to-use.

  15. #15
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by jinhao View Post
    yes, one property uses at least >=8 bytes, 4 bytes for 'this', 4(>=4) bytes for pointer of member function.
    The function pointer can be passed via the template declaration instead to save some bytes...
    4 bytes overhead is not much. It's typically what a smart pointer takes (or less).
    I find it acceptable between functionality and overhead/size.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. What's an import library?
    By chiefmonkey in forum C++ Programming
    Replies: 1
    Last Post: 06-19-2009, 05:00 PM
  2. Property Set Library (PSL) - Announcement
    By vultur_gryphus in forum Projects and Job Recruitment
    Replies: 0
    Last Post: 05-29-2008, 06:04 AM
  3. Makefile for a library
    By sirmoreno in forum Linux Programming
    Replies: 5
    Last Post: 06-04-2006, 04:52 AM
  4. very weird .h problem
    By royuco77 in forum C++ Programming
    Replies: 1
    Last Post: 09-11-2005, 07:55 AM
  5. better c string functions
    By samps005 in forum C Programming
    Replies: 8
    Last Post: 11-04-2003, 01:28 PM