[geos-devel] Why WKBConstants is a namespace?
strk at refractions.net
strk at refractions.net
Mon Mar 20 08:17:54 EST 2006
Ok for the enum, as long as full qualification remains:
WKBConstant::whatever
--strk;
On Mon, Mar 20, 2006 at 02:05:27PM +0100, Mateusz Å?oskot wrote:
> strk at refractions.net wrote:
> >On Mon, Mar 20, 2006 at 01:13:32PM +0100, Mateusz Ã
?oskot wrote:
> >
> >>Why WKBConstants is a namespace instead of enum?
> >
> >
> >It was a namespace in Java (an interface):
> >
> >public interface WKBConstants {
> > int wkbXDR = 0;
> > int wkbNDR = 1;
> >
> > int wkbPoint = 1;
> > int wkbLineString = 2;
> > int wkbPolygon = 3;
> > int wkbMultiPoint = 4;
> > int wkbMultiLineString = 5;
> > int wkbMultiPolygon = 6;
> > int wkbGeometryCollection = 7;
> >}
> >
> >As you can see an enum won't be able to hold wkbPoint
> >and wkbNDR with the same value.
>
> Why?
> AFAIK it will be able.
>
> C++ Standard says in "7.2 Enumeration declarations":
>
> "If the first enumerator has no initializer, the value of
> the corresponding constant is zero. An enumerator-definition without an
> initializer gives the enumerator the value
> obtained by increasing the value of the previous enumerator by one.
>
> [ Example:
> enum { a , b , c =0 };
> enum { d , e , f=e +2 };
> defines a, c, and d to be zero, b and e to be 1, and f to be 3.
> âend example]"
>
> As you can see:
> enum { a , b , c =0 };
>
> is equivalent of:
>
> enum { a = 0, b = 0, c = 0 };
>
> >Also, it might grow including flags for dimensionality
> >and SRID presence or whatever ends up being a WKB
> >constant.
>
> Yes, but those would be placed to separate enums.
>
> It will also provide better type-safety in some cases.
>
> Cheers
> --
> Mateusz Åoskot
> http://mateusz.loskot.net
> _______________________________________________
> geos-devel mailing list
> geos-devel at geos.refractions.net
> http://geos.refractions.net/mailman/listinfo/geos-devel
--
----------------------------------------------------------------------
State-collected Geographic Data is public property !
Reject the INSPIRE directive.
Sign the petition: http://petition.publicgeodata.org
More information about the geos-devel
mailing list