diff m_option.h @ 30695:a26f6577d338

Make more option-parsing related function arguments const. Prerequisite for making stream_open filename const in a proper way.
author reimar
date Thu, 25 Feb 2010 22:32:28 +0000
parents c1a3f1bbba26
children 458dbda20fa3
line wrap: on
line diff
--- a/m_option.h	Thu Feb 25 22:29:00 2010 +0000
+++ b/m_option.h	Thu Feb 25 22:32:28 2010 +0000
@@ -68,7 +68,7 @@
 typedef void (*m_opt_default_func_t)(const m_option_t *, const char*);
 
 /// Callback used by m_option_type_func_full options.
-typedef int (*m_opt_func_full_t)(const m_option_t *, const char *, char *);
+typedef int (*m_opt_func_full_t)(const m_option_t *, const char *, const char *);
 
 /// Callback used by m_option_type_func_param options.
 typedef int (*m_opt_func_param_t)(const m_option_t *, const char *);
@@ -198,9 +198,9 @@
 
 /// Option type description
 struct m_option_type {
-  char* name;
+  const char* name;
   /// Syntax description, etc
-  char* comments;
+  const char* comments;
   /// Size needed for the data.
   unsigned int size;
   /// See \ref OptionTypeFlags.
@@ -218,7 +218,7 @@
    *  \return On error a negative value is returned, on success the number of arguments
    *          consumed. For details see \ref OptionParserReturn.
    */
-  int (*parse)(const m_option_t* opt,const char *name, char *param, void* dst, int src);
+  int (*parse)(const m_option_t* opt,const char *name, const char *param, void* dst, int src);
 
   /// Print back a value in string form.
   /** \param opt The option to print.
@@ -241,21 +241,21 @@
    *  \param dst Pointer to the destination memory.
    *  \param src Pointer to the source memory.
    */
-  void (*save)(const m_option_t* opt,void* dst, void* src);
+  void (*save)(const m_option_t* opt,void* dst, const void* src);
 
   /// Set the value in the program (dst) from a save slot.
   /** \param opt The option to copy.
    *  \param dst Pointer to the destination memory.
    *  \param src Pointer to the source memory.
    */
-  void (*set)(const m_option_t* opt,void* dst, void* src);
+  void (*set)(const m_option_t* opt,void* dst, const void* src);
 
   /// Copy the data between two save slots. If NULL and size is > 0 a memcpy will be used.
   /** \param opt The option to copy.
    *  \param dst Pointer to the destination memory.
    *  \param src Pointer to the source memory.
    */
-  void (*copy)(const m_option_t* opt,void* dst, void* src);
+  void (*copy)(const m_option_t* opt,void* dst, const void* src);
   //@}
 
   /// Free the data allocated for a save slot.
@@ -483,7 +483,7 @@
 
 /// Helper to parse options, see \ref m_option_type::parse.
 inline static int
-m_option_parse(const m_option_t* opt,const char *name, char *param, void* dst, int src) {
+m_option_parse(const m_option_t* opt,const char *name, const char *param, void* dst, int src) {
   return opt->type->parse(opt,name,param,dst,src);
 }
 
@@ -498,21 +498,21 @@
 
 /// Helper around \ref m_option_type::save.
 inline static  void
-m_option_save(const m_option_t* opt,void* dst, void* src) {
+m_option_save(const m_option_t* opt,void* dst, const void* src) {
   if(opt->type->save)
     opt->type->save(opt,dst,src);
 }
 
 /// Helper around \ref m_option_type::set.
 inline static  void
-m_option_set(const m_option_t* opt,void* dst, void* src) {
+m_option_set(const m_option_t* opt,void* dst, const void* src) {
   if(opt->type->set)
     opt->type->set(opt,dst,src);
 }
 
 /// Helper around \ref m_option_type::copy.
 inline  static void
-m_option_copy(const m_option_t* opt,void* dst, void* src) {
+m_option_copy(const m_option_t* opt,void* dst, const void* src) {
   if(opt->type->copy)
     opt->type->copy(opt,dst,src);
   else if(opt->type->size > 0)