فهرست منبع

new Capitalized function. Will be used in the VTK Tcl wrapper for example (in a more portable way).

Sebastien Barre 24 سال پیش
والد
کامیت
abfa5238ca
2فایلهای تغییر یافته به همراه21 افزوده شده و 0 حذف شده
  1. 15 0
      Source/cmSystemTools.cxx
  2. 6 0
      Source/cmSystemTools.h

+ 15 - 0
Source/cmSystemTools.cxx

@@ -316,6 +316,21 @@ bool cmSystemTools::FileExists(const char* filename)
 }
 }
 
 
 
 
+// Return a capitalized string (i.e the first letter is uppercased, all other
+// are lowercased)
+std::string cmSystemTools::Capitalized(std::string& s)
+{
+  std::string n;
+  n.resize(s.size());
+  n[0] = toupper(s[0]);
+  for (size_t i = 1; i < s.size(); i++)
+    {
+    n[i] = tolower(s[i]);
+    }
+  return n;
+}  
+
+
 // convert windows slashes to unix slashes \ with /
 // convert windows slashes to unix slashes \ with /
 void cmSystemTools::ConvertToUnixSlashes(std::string& path)
 void cmSystemTools::ConvertToUnixSlashes(std::string& path)
 {
 {

+ 6 - 0
Source/cmSystemTools.h

@@ -78,6 +78,12 @@ public:
    */
    */
   static std::string EscapeSpaces(const char*);
   static std::string EscapeSpaces(const char*);
   
   
+  /**
+   * Return a capitalized string (i.e the first letter is uppercased, all other
+   * are lowercased).
+   */
+  static std::string Capitalized(std::string&);
+  
   /**
   /**
    * Replace Windows file system slashes with Unix-style slashes.
    * Replace Windows file system slashes with Unix-style slashes.
    */
    */