[vtk-developers] Const correctness for string methods

Ken Martin ken.martin at kitware.com
Mon Jan 19 09:10:48 EST 2004


Andy only change the Set methods. Changing the Get methods will cause all
sorts of problems in user's code (and VTK itself) for no real benefit.

Thanks
Ken

> -----Original Message-----
> From: vtk-developers-admin at vtk.org [mailto:vtk-developers-admin at vtk.org]
> On Behalf Of Andy Cedilnik
> Sent: Monday, January 19, 2004 8:44 AM
> To: vtk-developers
> Subject: [vtk-developers] Const correctness for string methods
> 
> Hi All,
> 
> By now you are all used to my header testing nightmare. I am thinking
> about adding another feature to it though. I want it to check for const
> correctness for string methods. Ok, what do I mean by that, I want all
> methods that return string to return "const char*" instead of "char*"
> and all methods that accept string as an argument to accept "const
> char*".
> 
> Some examples of things that will change:
> 
> vtkXMLWriter.h:  int WriteBinaryData(char* data)
> vtkXMLWriter.h:  int WriteBinaryData(char* data, int numWords)
> vtkGenericEnSightReader.h:  char* GetDescription(int n);
> vtkGenericEnSightReader.h:  char* GetComplexDescription(int n);
> vtkGenericEnSightReader.h:  char* GetDescription(int n, int type);
> vtkDataObjectWriter.h:  char *GetFileName();
> vtkDataObjectWriter.h:  void SetHeader(char *header);
> vtkDataObjectWriter.h:  char *GetHeader();
> 
> Also, I would like to change vtkGetStringMacro to return "const char*".
> 
> I don't think anybody should be affected by that, except people that do
> things like:
> 
> char* foo = en->GetDescription(2);
> strcat(foo, "dangerous");
> 
> But all places that do readonly on strings should work without being
> modified.
> 
> Any comments on this?
> 
> 			Andy
> 
> _______________________________________________
> vtk-developers mailing list
> vtk-developers at vtk.org
> http://www.vtk.org/mailman/listinfo/vtk-developers





More information about the vtk-developers mailing list