Update of /cvsroot/playerstage/code/player/libplayercore
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27187/libplayercore

Modified Files:
      Tag: release-2-0-patches
        configfile.cc configfile.h interface_util.cc 
Log Message:
backported client lib stuff from HEAD

Index: interface_util.cc
===================================================================
RCS file: /cvsroot/playerstage/code/player/libplayercore/interface_util.cc,v
retrieving revision 1.13
retrieving revision 1.13.2.1
diff -C2 -d -r1.13 -r1.13.2.1
*** interface_util.cc   7 Apr 2006 21:00:28 -0000       1.13
--- interface_util.cc   9 Jun 2006 01:17:52 -0000       1.13.2.1
***************
*** 74,77 ****
--- 74,78 ----
    {PLAYER_LIMB_CODE, PLAYER_LIMB_STRING},
    {PLAYER_GRAPHICS2D_CODE, PLAYER_GRAPHICS2D_STRING},
+   {PLAYER_GRAPHICS3D_CODE, PLAYER_GRAPHICS3D_STRING},
    {PLAYER_RFID_CODE, PLAYER_RFID_STRING},
    {PLAYER_WSN_CODE, PLAYER_WSN_STRING},

Index: configfile.cc
===================================================================
RCS file: /cvsroot/playerstage/code/player/libplayercore/configfile.cc,v
retrieving revision 1.13
retrieving revision 1.13.2.1
diff -C2 -d -r1.13 -r1.13.2.1
*** configfile.cc       27 Mar 2006 22:21:53 -0000      1.13
--- configfile.cc       9 Jun 2006 01:17:52 -0000       1.13.2.1
***************
*** 444,447 ****
--- 444,453 ----
            return false;
        }
+       else if(strcmp(token, "true") == 0 || strcmp(token, "false") == 0 || 
+               strcmp(token, "yes") == 0  || strcmp(token, "no") == 0) 
+       {
+         ungetc(ch, file);
+         AddToken(TokenBool, token, include);
+       }
        else
        {
***************
*** 964,967 ****
--- 970,974 ----
        case TokenString:
        case TokenOpenTuple:
+       case TokenBool:
          return ParseTokenField(section, index, line);
        default:
***************
*** 1098,1101 ****
--- 1105,1113 ----
          *index = i;
          return true;
+       case TokenBool:
+         field = AddField(section, GetTokenValue(name), *line);
+         AddFieldValue(field, 0, i);
+         *index = i;
+         return true;
        case TokenSpace:
          break;
***************
*** 1515,1518 ****
--- 1527,1565 ----
  }
  
+ ///////////////////////////////////////////////////////////////////////////
+ // Read a boolean
+ bool ConfigFile::ReadBool(int section, const char* name, bool value)
+ {
+   int field = GetField(section, name);
+   if(field < 0) return value;
+   const char* s = GetFieldValue(field, 0);
+   if( strcmp(s, "yes") == 0 || strcmp(s, "true") == 0 || strcmp(s, "1") == 0)
+     return true;
+   else if( strcmp(s, "no") == 0 || strcmp(s, "false") == 0 || strcmp(s, "0") 
== 0)
+     return false;
+   else
+   {
+     printf("player: Warning: error in config file section %d field %s: 
Invalid boolean value.", section, name);
+     return value;
+   }
+ }
+ 
+ ///////////////////////////////////////////////////////////////////////////
+ // Write a boolean
+ void ConfigFile::WriteBool(int section, const char *name, bool value)
+ {
+   char str[4];
+   snprintf(str, sizeof(str), "%s", value ? "yes" : "no");
+   WriteString(section, name, str);
+ }
+ 
+ ///////////////////////////////////////////////////////////////////////////
+ // Write a boolean compatibly
+ void ConfigFile::WriteBool_Compat(int section, const char *name, bool value)
+ {
+   char str[2];
+   snprintf(str, sizeof(str), "%s", value ? "1" : "0");
+   WriteString(section, name, str);
+ }
  
  ///////////////////////////////////////////////////////////////////////////

Index: configfile.h
===================================================================
RCS file: /cvsroot/playerstage/code/player/libplayercore/configfile.h,v
retrieving revision 1.8
retrieving revision 1.8.2.1
diff -C2 -d -r1.8 -r1.8.2.1
*** configfile.h        23 Mar 2006 17:26:08 -0000      1.8
--- configfile.h        9 Jun 2006 01:17:52 -0000       1.8.2.1
***************
*** 192,195 ****
--- 192,209 ----
    public: bool WarnUnused();
  
+   /// @brief Read a boolean value (one of: yes, no, true, false, 1, 0)
+   /// @param section Section to read.
+   /// @param name Field name
+   /// @param value Default value if this field is not present in the file
+   /// @return Returns the field value
+   public: bool ReadBool(int section, const char *name, bool value);
+ 
+   // Write a bool as "yes" or "no"
+   private: void WriteBool(int section, const char* name, bool value);
+ 
+   // Write a bool as "1" or "0" (for backward compatability)
+   private: void WriteBool_Compat(int section, const char* name, bool value);
+ 
+ 
    /// @brief Read a string value
    /// @param section Section to read.
***************
*** 556,560 ****
      {
        TokenComment,
!       TokenWord, TokenNum, TokenString,
        TokenOpenSection, TokenCloseSection,
        TokenOpenTuple, TokenCloseTuple,
--- 570,574 ----
      {
        TokenComment,
!       TokenWord, TokenNum, TokenString, TokenBool,
        TokenOpenSection, TokenCloseSection,
        TokenOpenTuple, TokenCloseTuple,



_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to