Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #74588

Re: The C Containers library

From Ian Collins <ian-news@hotmail.com>
Newsgroups comp.lang.c
Subject Re: The C Containers library
Date 2015-11-02 10:46 +1300
Message-ID <d9nfheF6ovuU3@mid.individual.net> (permalink)
References <n14lk4$hmh$1@dont-email.me> <d9m56rF6ovuU1@mid.individual.net> <n14rmt$8c7$1@dont-email.me>

Show all headers | View raw


jacobnavia wrote:
> Le 01/11/2015 10:43, Ian Collins a écrit :
>> jacobnavia wrote:
>>> I posted  yesterday a pointer to a pure C package, that allows any C
>>> programmer to enjoy the samelevel of abstraction than C++. In the post
>>> there were two small errors that allowed some people to just say "It
>>> doesn't compile" and leave it there, even if the errors are VERY easy to
>>> fix.
>>
>> While your library is sound, to justify your same level of abstraction
>> as C++ claim, you would have to show how easy it is to repeat the
>> process with something other than strings.  Start with something simple
>> like a file of Foo records, where Foo is:
>>
>> struct Foo
>> {
>>     int a;
>>     int b;
>>     int c;
>> };
>>
>> Being able to work with generic types is where the flexibility of the
>> C++ containers lies.
>>
>
> Yes, that is why the C containers library provides a "template" file
> with all the code for some containers like lists, vectors, strings, so
> that they are generic.
>
> You define a small parameter file, and the C preprocessor will do the rest.
>
> Let's suppose that you want to define a vector for the "size_t" type.
>
>
>     1 #include "containers.h"
>     2 #undef DATA_TYPE
>     3 #define DATA_TYPE size_t
>     4 #include "vectorgen.c"
>
>
> You will get a bunch of functions defined that you can put in a library.
> The interface function table will be iDATA_TYPEVectorInterface, where
> "DATA_TYPE" is the name of your data type, in this case size_t.
>
> So, you call the interface with
>
> isize_tVectorInterface.Add(...)
>
> Since you have all the source code you can use other naming conventions.

That makes sense.

Can you define ordering and I/O functions for user defined types with 
this mechanism?

-- 
Ian Collins

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

The C Containers library jacobnavia <jacob@jacob.remcomp.fr> - 2015-11-01 10:24 +0100
  Re: The C Containers library Ian Collins <ian-news@hotmail.com> - 2015-11-01 22:43 +1300
    Re: The C Containers library jacobnavia <jacob@jacob.remcomp.fr> - 2015-11-01 12:08 +0100
      Re: The C Containers library Ian Collins <ian-news@hotmail.com> - 2015-11-02 10:46 +1300
        Re: The C Containers library jacobnavia <jacob@jacob.remcomp.fr> - 2015-11-01 23:10 +0100
  Re: The C Containers library gazelle@shell.xmission.com (Kenny McCormack) - 2015-11-01 10:57 +0000
  Re: The C Containers library Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-11-01 10:57 +0000
    Re: The C Containers library Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-11-01 03:30 -0800
      Re: The C Containers library Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-11-01 16:36 +0000
        Re: The C Containers library Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-11-01 10:04 -0800
          Re: The C Containers library Ian Collins <ian-news@hotmail.com> - 2015-11-02 07:23 +1300
            Re: The C Containers library Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-11-01 13:25 -0800
            Re: The C Containers library supercat@casperkitty.com - 2015-11-01 15:44 -0800
          Re: The C Containers library Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-11-01 23:50 +0000
            Re: The C Containers library Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-11-02 01:19 -0800
              Re: The C Containers library Ian Collins <ian-news@hotmail.com> - 2015-11-02 22:33 +1300
                Re: The C Containers library Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-11-02 02:04 -0800
  Re: The C Containers library Keith Thompson <kst-u@mib.org> - 2015-11-01 12:04 -0800
    Re: The C Containers library Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2015-11-01 15:41 -0500
      Re: The C Containers library Keith Thompson <kst-u@mib.org> - 2015-11-01 13:26 -0800
        Re: The C Containers library Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2015-11-01 16:50 -0500

csiph-web