[vtk-developers] Const correctness for string methods

Andy Cedilnik andy.cedilnik at kitware.com
Mon Jan 19 08:43:50 EST 2004


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




More information about the vtk-developers mailing list