]> git.sesse.net Git - stockfish/commitdiff
Use string instead of std::string
authorMarco Costalba <mcostalba@gmail.com>
Sun, 10 May 2009 16:58:53 +0000 (17:58 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sun, 10 May 2009 17:38:47 +0000 (18:38 +0100)
And others small code style touches.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/benchmark.cpp
src/color.h
src/material.cpp
src/misc.cpp
src/misc.h
src/move.cpp
src/position.cpp
src/san.cpp
src/ucioption.cpp
src/ucioption.h

index 27517f4fb8e5559d3832a7a3928411182467063a..02037689df0b770b7c07a0d1b347c0de11f362d4 100644 (file)
 #include "thread.h"
 #include "ucioption.h"
 
 #include "thread.h"
 #include "ucioption.h"
 
+using namespace std;
 
 ////
 //// Variables
 ////
 
 
 ////
 //// Variables
 ////
 
-const std::string BenchmarkPositions[] = {
+const string BenchmarkPositions[] = {
   "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
   "r4rk1/1b2qppp/p1n1p3/1p6/1b1PN3/3BRN2/PP3PPP/R2Q2K1 b - - 7 16",
   "4r1k1/ppq3pp/3b4/2pP4/2Q1p3/4B1P1/PP5P/R5K1 b - - 0 20",
   "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
   "r4rk1/1b2qppp/p1n1p3/1p6/1b1PN3/3BRN2/PP3PPP/R2Q2K1 b - - 7 16",
   "4r1k1/ppq3pp/3b4/2pP4/2Q1p3/4B1P1/PP5P/R5K1 b - - 0 20",
@@ -67,25 +68,25 @@ const std::string BenchmarkPositions[] = {
 /// format (default are the BenchmarkPositions defined above).
 /// The analysis is written to a file named bench.txt.
 
 /// format (default are the BenchmarkPositions defined above).
 /// The analysis is written to a file named bench.txt.
 
-void benchmark(const std::string& commandLine) {
+void benchmark(const string& commandLine) {
 
 
-  std::istringstream csVal(commandLine);
-  std::istringstream csStr(commandLine);
-  std::string ttSize, threads, fileName, limitType;
+  istringstream csVal(commandLine);
+  istringstream csStr(commandLine);
+  string ttSize, threads, fileName, limitType;
   int val, secsPerPos, maxDepth, maxNodes;
 
   csStr >> ttSize;
   csVal >> val;
   if (val < 4 || val > 1024)
   {
   int val, secsPerPos, maxDepth, maxNodes;
 
   csStr >> ttSize;
   csVal >> val;
   if (val < 4 || val > 1024)
   {
-      std::cerr << "The hash table size must be between 4 and 1024" << std::endl;
+      cerr << "The hash table size must be between 4 and 1024" << endl;
       Application::exit_with_failure();
   }
   csStr >> threads;
   csVal >> val;
   if (val < 1 || val > THREAD_MAX)
   {
       Application::exit_with_failure();
   }
   csStr >> threads;
   csVal >> val;
   if (val < 1 || val > THREAD_MAX)
   {
-      std::cerr << "The number of threads must be between 1 and " << THREAD_MAX << std::endl;
+      cerr << "The number of threads must be between 1 and " << THREAD_MAX << endl;
       Application::exit_with_failure();
   }
   set_option_value("Hash", ttSize);
       Application::exit_with_failure();
   }
   set_option_value("Hash", ttSize);
@@ -107,30 +108,30 @@ void benchmark(const std::string& commandLine) {
   else
       maxNodes = val;
 
   else
       maxNodes = val;
 
-  std::vector<std::string> positions;
+  vector<string> positions;
 
   if (fileName != "default")
   {
 
   if (fileName != "default")
   {
-      std::ifstream fenFile(fileName.c_str());
+      ifstream fenFile(fileName.c_str());
       if (!fenFile.is_open())
       {
       if (!fenFile.is_open())
       {
-          std::cerr << "Unable to open positions file " << fileName << std::endl;
+          cerr << "Unable to open positions file " << fileName << endl;
           Application::exit_with_failure();
       }
           Application::exit_with_failure();
       }
-      std::string pos;
+      string pos;
       while (fenFile.good())
       {
       while (fenFile.good())
       {
-          std::getline(fenFile, pos);
+          getline(fenFile, pos);
           if (!pos.empty())
               positions.push_back(pos);
       }
       fenFile.close();
   } else
       for (int i = 0; i < 16; i++)
           if (!pos.empty())
               positions.push_back(pos);
       }
       fenFile.close();
   } else
       for (int i = 0; i < 16; i++)
-          positions.push_back(std::string(BenchmarkPositions[i]));
+          positions.push_back(string(BenchmarkPositions[i]));
 
   int startTime = get_system_time();
 
   int startTime = get_system_time();
-  std::vector<std::string>::iterator it;
+  vector<string>::iterator it;
   int cnt = 1;
   int64_t totalNodes = 0;
   for (it = positions.begin(); it != positions.end(); ++it, ++cnt)
   int cnt = 1;
   int64_t totalNodes = 0;
   for (it = positions.begin(); it != positions.end(); ++it, ++cnt)
@@ -138,13 +139,12 @@ void benchmark(const std::string& commandLine) {
       Move moves[1] = {MOVE_NONE};
       int dummy[2] = {0, 0};
       Position pos(*it);
       Move moves[1] = {MOVE_NONE};
       int dummy[2] = {0, 0};
       Position pos(*it);
-      std::cout << "\nProcessing position " << cnt << '/' << positions.size() << std::endl << std::endl;
+      cout << "\nProcessing position " << cnt << '/' << positions.size() << endl << endl;
       if (!think(pos, true, false, 0, dummy, dummy, 0, maxDepth, maxNodes, secsPerPos, moves))
           break;
       totalNodes += nodes_searched();
   }
       if (!think(pos, true, false, 0, dummy, dummy, 0, maxDepth, maxNodes, secsPerPos, moves))
           break;
       totalNodes += nodes_searched();
   }
-  std::cout << "\nProcessing time (ms) " << get_system_time() - startTime << std::endl
-            << "Nodes searched " << totalNodes << std::endl
-            << "Press any key to exit" << std::endl;
-  std::cin >> fileName;
+  cout << "\nProcessing time (ms) " << get_system_time() - startTime
+       << "\nNodes searched " << totalNodes << "\nPress any key to exit" << endl;
+  cin >> fileName;
 }
 }
index 283d59b4f804e732abc4ddbe693f40517bf60557..50c05bd7c1f2c56a2036c92098fdb9cfbe44a230 100644 (file)
@@ -37,7 +37,6 @@ enum Color {
 //// Inline functions
 ////
 
 //// Inline functions
 ////
 
-inline Color operator+ (Color c, int i) { return Color(int(c) + i); }
 inline void operator++ (Color &c, int) { c = Color(int(c) + 1); }
 
 inline Color opposite_color(Color c) {
 inline void operator++ (Color &c, int) { c = Color(int(c) + 1); }
 
 inline Color opposite_color(Color c) {
index 69588c8cd597f79c8413bed432b13f2ebeecb2b4..c1c3c3c27545653737f2865ef193d04ef8f44b55 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "material.h"
 
 
 #include "material.h"
 
+using std::string;
 
 ////
 //// Local definitions
 
 ////
 //// Local definitions
@@ -59,9 +60,9 @@ public:
   EndgameScalingFunctionBase* getESF(Key key, Color* c) const;
 
 private:
   EndgameScalingFunctionBase* getESF(Key key, Color* c) const;
 
 private:
-  void add(const std::string& keyCode, EndgameEvaluationFunctionBase* f);
-  void add(const std::string& keyCode, Color c, EndgameScalingFunctionBase* f);
-  Key buildKey(const std::string& keyCode);
+  void add(const string& keyCode, EndgameEvaluationFunctionBase* f);
+  void add(const string& keyCode, Color c, EndgameScalingFunctionBase* f);
+  Key buildKey(const string& keyCode);
 
   struct ScalingInfo
   {
 
   struct ScalingInfo
   {
@@ -352,7 +353,7 @@ EndgameFunctions::EndgameFunctions() {
   add("KRPKRPP", BLACK, &ScaleKRPKRPP);
 }
 
   add("KRPKRPP", BLACK, &ScaleKRPKRPP);
 }
 
-Key EndgameFunctions::buildKey(const std::string& keyCode) {
+Key EndgameFunctions::buildKey(const string& keyCode) {
 
     assert(keyCode.length() > 0 && keyCode[0] == 'K');
     assert(keyCode.length() < 8);
 
     assert(keyCode.length() > 0 && keyCode[0] == 'K');
     assert(keyCode.length() < 8);
@@ -373,12 +374,12 @@ Key EndgameFunctions::buildKey(const std::string& keyCode) {
     return Position(s.str()).get_material_key();
 }
 
     return Position(s.str()).get_material_key();
 }
 
-void EndgameFunctions::add(const std::string& keyCode, EndgameEvaluationFunctionBase* f) {
+void EndgameFunctions::add(const string& keyCode, EndgameEvaluationFunctionBase* f) {
 
   EEFmap.insert(std::pair<Key, EndgameEvaluationFunctionBase*>(buildKey(keyCode), f));
 }
 
 
   EEFmap.insert(std::pair<Key, EndgameEvaluationFunctionBase*>(buildKey(keyCode), f));
 }
 
-void EndgameFunctions::add(const std::string& keyCode, Color c, EndgameScalingFunctionBase* f) {
+void EndgameFunctions::add(const string& keyCode, Color c, EndgameScalingFunctionBase* f) {
 
   ScalingInfo s = {c, f};
   ESFmap.insert(std::pair<Key, ScalingInfo>(buildKey(keyCode), s));
 
   ScalingInfo s = {c, f};
   ESFmap.insert(std::pair<Key, ScalingInfo>(buildKey(keyCode), s));
index ea872f88aa57fdb126a8ae2121213865f14a1751..ba4da56896fee0bb5b4a9d745d639c3721970e23 100644 (file)
@@ -81,6 +81,8 @@ static const string AppTag  = "";
 //// Variables
 ////
 
 //// Variables
 ////
 
+bool Chess960;
+
 uint64_t dbg_cnt0 = 0;
 uint64_t dbg_cnt1 = 0;
 
 uint64_t dbg_cnt0 = 0;
 uint64_t dbg_cnt1 = 0;
 
index d954f0a3302467d16d3cc7ad9f169ff13ba97149..5c619bb3d679fe73cd230836cb3c6e953bc01081 100644 (file)
 #define Max(x, y) (((x) < (y))? (y) : (x))
 
 
 #define Max(x, y) (((x) < (y))? (y) : (x))
 
 
+////
+//// Variables
+////
+
+extern bool Chess960;
+
+
 ////
 //// Prototypes
 ////
 ////
 //// Prototypes
 ////
index 8118273e48e81c6d0015bd7654c656169353e05a..e7b9257dc6d66c4175f059e9264c46c77987a5b1 100644 (file)
@@ -27,7 +27,6 @@
 #include "move.h"
 #include "piece.h"
 #include "position.h"
 #include "move.h"
 #include "piece.h"
 #include "position.h"
-#include "ucioption.h"
 
 
 ////
 
 
 ////
index 1c1ceed2199eb73c2d4ab4b2620cb34938cbf10d..c121c49734f2eac41f3616af2e5c098c82c93880 100644 (file)
@@ -35,6 +35,8 @@
 #include "san.h"
 #include "ucioption.h"
 
 #include "san.h"
 #include "ucioption.h"
 
+using std::string;
+
 
 ////
 //// Variables
 
 ////
 //// Variables
@@ -63,7 +65,7 @@ Position::Position(const Position& pos) {
   copy(pos);
 }
 
   copy(pos);
 }
 
-Position::Position(const std::string& fen) {
+Position::Position(const string& fen) {
   from_fen(fen);
 }
 
   from_fen(fen);
 }
 
@@ -72,9 +74,9 @@ Position::Position(const std::string& fen) {
 /// string. This function is not very robust - make sure that input FENs are
 /// correct (this is assumed to be the responsibility of the GUI).
 
 /// string. This function is not very robust - make sure that input FENs are
 /// correct (this is assumed to be the responsibility of the GUI).
 
-void Position::from_fen(const std::string& fen) {
+void Position::from_fen(const string& fen) {
 
 
-  static const std::string pieceLetters = "KQRBNPkqrbnp";
+  static const string pieceLetters = "KQRBNPkqrbnp";
   static const Piece pieces[] = { WK, WQ, WR, WB, WN, WP, BK, BQ, BR, BB, BN, BP };
 
   clear();
   static const Piece pieces[] = { WK, WQ, WR, WB, WN, WP, BK, BQ, BR, BB, BN, BP };
 
   clear();
@@ -98,7 +100,7 @@ void Position::from_fen(const std::string& fen) {
           continue;
       }
       size_t idx = pieceLetters.find(fen[i]);
           continue;
       }
       size_t idx = pieceLetters.find(fen[i]);
-      if (idx == std::string::npos)
+      if (idx == string::npos)
       {
            std::cout << "Error in FEN at character " << i << std::endl;
            return;
       {
            std::cout << "Error in FEN at character " << i << std::endl;
            return;
@@ -219,10 +221,10 @@ void Position::from_fen(const std::string& fen) {
 /// Position::to_fen() converts the position object to a FEN string. This is
 /// probably only useful for debugging.
 
 /// Position::to_fen() converts the position object to a FEN string. This is
 /// probably only useful for debugging.
 
-const std::string Position::to_fen() const {
+const string Position::to_fen() const {
 
 
-  static const std::string pieceLetters = " PNBRQK  pnbrqk";
-  std::string fen;
+  static const string pieceLetters = " PNBRQK  pnbrqk";
+  string fen;
   int skip;
 
   for (Rank rank = RANK_8; rank >= RANK_1; rank--)
   int skip;
 
   for (Rank rank = RANK_8; rank >= RANK_1; rank--)
@@ -272,7 +274,7 @@ const std::string Position::to_fen() const {
 
 void Position::print(Move m) const {
 
 
 void Position::print(Move m) const {
 
-  static const std::string pieceLetters = " PNBRQK  PNBRQK .";
+  static const string pieceLetters = " PNBRQK  PNBRQK .";
 
   // Check for reentrancy, as example when called from inside
   // MovePicker that is used also here in move_to_san()
 
   // Check for reentrancy, as example when called from inside
   // MovePicker that is used also here in move_to_san()
@@ -284,7 +286,7 @@ void Position::print(Move m) const {
   std::cout << std::endl;
   if (m != MOVE_NONE)
   {
   std::cout << std::endl;
   if (m != MOVE_NONE)
   {
-      std::string col = (color_of_piece_on(move_from(m)) == BLACK ? ".." : "");
+      string col = (color_of_piece_on(move_from(m)) == BLACK ? ".." : "");
       std::cout << "Move is: " << col << move_to_san(*this, m) << std::endl;
   }
   for (Rank rank = RANK_8; rank >= RANK_1; rank--)
       std::cout << "Move is: " << col << move_to_san(*this, m) << std::endl;
   }
   for (Rank rank = RANK_8; rank >= RANK_1; rank--)
index 3f706b2015f53b1dc7196c7d54a2c6e25dc75a64..ecba7ab31a20b5a7bd77fec2419fc02b7d304820 100644 (file)
@@ -31,6 +31,7 @@
 #include "movepick.h"
 #include "san.h"
 
 #include "movepick.h"
 #include "san.h"
 
+using std::string;
 
 ////
 //// Local definitions
 
 ////
 //// Local definitions
@@ -51,8 +52,8 @@ namespace {
   /// Functions
 
   Ambiguity move_ambiguity(const Position& pos, Move m);
   /// Functions
 
   Ambiguity move_ambiguity(const Position& pos, Move m);
-  const std::string time_string(int milliseconds);
-  const std::string score_string(Value v);
+  const string time_string(int milliseconds);
+  const string score_string(Value v);
 }
 
 
 }
 
 
@@ -64,7 +65,7 @@ namespace {
 /// that the move is a legal move from the position. The return value is
 /// a string containing the move in short algebraic notation.
 
 /// that the move is a legal move from the position. The return value is
 /// a string containing the move in short algebraic notation.
 
-const std::string move_to_san(const Position& pos, Move m) {
+const string move_to_san(const Position& pos, Move m) {
 
   assert(pos.is_ok());
   assert(move_is_ok(m));
 
   assert(pos.is_ok());
   assert(move_is_ok(m));
@@ -76,7 +77,7 @@ const std::string move_to_san(const Position& pos, Move m) {
   to = move_to(m);
   pt = type_of_piece(pos.piece_on(move_from(m)));
 
   to = move_to(m);
   pt = type_of_piece(pos.piece_on(move_from(m)));
 
-  std::string san = "";
+  string san = "";
 
   if (m == MOVE_NONE)
       return "(none)";
 
   if (m == MOVE_NONE)
       return "(none)";
@@ -138,7 +139,7 @@ const std::string move_to_san(const Position& pos, Move m) {
 /// the move is returned.  On failure (i.e. if the string is unparsable, or
 /// if the move is illegal or ambiguous), MOVE_NONE is returned.
 
 /// the move is returned.  On failure (i.e. if the string is unparsable, or
 /// if the move is illegal or ambiguous), MOVE_NONE is returned.
 
-Move move_from_san(const Position& pos, const std::string& movestr) {
+Move move_from_san(const Position& pos, const string& movestr) {
 
   assert(pos.is_ok());
 
 
   assert(pos.is_ok());
 
@@ -166,7 +167,7 @@ Move move_from_san(const Position& pos, const std::string& movestr) {
 
   // Normal moves. We use a simple FSM to parse the san string.
   enum { START, TO_FILE, TO_RANK, PROMOTION_OR_CHECK, PROMOTION, CHECK, END };
 
   // Normal moves. We use a simple FSM to parse the san string.
   enum { START, TO_FILE, TO_RANK, PROMOTION_OR_CHECK, PROMOTION, CHECK, END };
-  static const std::string pieceLetters = "KQRBN";
+  static const string pieceLetters = "KQRBN";
   PieceType pt = NO_PIECE_TYPE, promotion = NO_PIECE_TYPE;
   File fromFile = FILE_NONE, toFile = FILE_NONE;
   Rank fromRank = RANK_NONE, toRank = RANK_NONE;
   PieceType pt = NO_PIECE_TYPE, promotion = NO_PIECE_TYPE;
   File fromFile = FILE_NONE, toFile = FILE_NONE;
   Rank fromRank = RANK_NONE, toRank = RANK_NONE;
@@ -176,7 +177,7 @@ Move move_from_san(const Position& pos, const std::string& movestr) {
   for (size_t i = 0; i < movestr.length(); i++)
   {
       char type, c = movestr[i];
   for (size_t i = 0; i < movestr.length(); i++)
   {
       char type, c = movestr[i];
-      if (pieceLetters.find(c) != std::string::npos)
+      if (pieceLetters.find(c) != string::npos)
           type = 'P';
       else if (c >= 'a' && c <= 'h')
           type = 'F';
           type = 'P';
       else if (c >= 'a' && c <= 'h')
           type = 'F';
@@ -292,11 +293,11 @@ Move move_from_san(const Position& pos, const std::string& movestr) {
 /// length of 80 characters.  After a line break, 'startColumn' spaces are
 /// inserted at the beginning of the new line.
 
 /// length of 80 characters.  After a line break, 'startColumn' spaces are
 /// inserted at the beginning of the new line.
 
-const std::string line_to_san(const Position& pos, Move line[], int startColumn, bool breakLines) {
+const string line_to_san(const Position& pos, Move line[], int startColumn, bool breakLines) {
 
   StateInfo st;
   std::stringstream s;
 
   StateInfo st;
   std::stringstream s;
-  std::string moveStr;
+  string moveStr;
   size_t length = 0;
   size_t maxLength = 80 - startColumn;
   Position p(pos);
   size_t length = 0;
   size_t maxLength = 80 - startColumn;
   Position p(pos);
@@ -325,8 +326,8 @@ const std::string line_to_san(const Position& pos, Move line[], int startColumn,
 /// It is used to write search information to the log file (which is created
 /// when the UCI parameter "Use Search Log" is "true").
 
 /// It is used to write search information to the log file (which is created
 /// when the UCI parameter "Use Search Log" is "true").
 
-const std::string pretty_pv(const Position& pos, int time, int depth,
-                            uint64_t nodes, Value score, Move pv[]) {
+const string pretty_pv(const Position& pos, int time, int depth,
+                       uint64_t nodes, Value score, Move pv[]) {
   std::stringstream s;
 
   // Depth
   std::stringstream s;
 
   // Depth
@@ -396,7 +397,7 @@ namespace {
   }
 
 
   }
 
 
-  const std::string time_string(int milliseconds) {
+  const string time_string(int milliseconds) {
 
     std::stringstream s;
     s << std::setfill('0');
 
     std::stringstream s;
     s << std::setfill('0');
@@ -413,7 +414,7 @@ namespace {
   }
 
 
   }
 
 
-  const std::string score_string(Value v) {
+  const string score_string(Value v) {
 
     std::stringstream s;
 
 
     std::stringstream s;
 
index 25fbe956fc4ab46bcf61eec065cfb2d8e65a63e6..a478a0cb21fcd69578109a661a69b2af8b8d87b4 100644 (file)
 #include "thread.h"
 #include "ucioption.h"
 
 #include "thread.h"
 #include "ucioption.h"
 
-
-////
-//// Variables
-////
-
-bool Chess960;
-
+using std::string;
 
 ////
 //// Local definitions
 
 ////
 //// Local definitions
@@ -53,11 +47,11 @@ namespace {
 
   enum OptionType { SPIN, COMBO, CHECK, STRING, BUTTON };
 
 
   enum OptionType { SPIN, COMBO, CHECK, STRING, BUTTON };
 
-  typedef std::vector<std::string> ComboValues;
+  typedef std::vector<string> ComboValues;
 
   struct Option {
 
 
   struct Option {
 
-    std::string name, defaultValue, currentValue;
+    string name, defaultValue, currentValue;
     OptionType type;
     size_t idx;
     int minValue, maxValue;
     OptionType type;
     size_t idx;
     int minValue, maxValue;
@@ -71,7 +65,7 @@ namespace {
     bool operator<(const Option& o) const { return this->idx < o.idx; }
   };
 
     bool operator<(const Option& o) const { return this->idx < o.idx; }
   };
 
-  typedef std::map<std::string, Option> Options;
+  typedef std::map<string, Option> Options;
 
   ///
   /// Constants
 
   ///
   /// Constants
@@ -155,7 +149,7 @@ namespace {
 
   // stringify converts a value of type T to a std::string
   template<typename T>
 
   // stringify converts a value of type T to a std::string
   template<typename T>
-  std::string stringify(const T& v) {
+  string stringify(const T& v) {
 
      std::ostringstream ss;
      ss << v;
 
      std::ostringstream ss;
      ss << v;
@@ -168,7 +162,7 @@ namespace {
   // type changes a template seems a proper solution.
 
   template<typename T>
   // type changes a template seems a proper solution.
 
   template<typename T>
-  T get_option_value(const std::string& optionName) {
+  T get_option_value(const string& optionName) {
 
       T ret = T();
       if (options.find(optionName) == options.end())
 
       T ret = T();
       if (options.find(optionName) == options.end())
@@ -245,9 +239,7 @@ void print_uci_options() {
           std::cout << " default " << it->defaultValue;
 
       if (it->type == SPIN)
           std::cout << " default " << it->defaultValue;
 
       if (it->type == SPIN)
-          std::cout << " min " << it->minValue
-                    << " max " << it->maxValue;
-
+          std::cout << " min " << it->minValue << " max " << it->maxValue;
       else if (it->type == COMBO)
           for (ComboValues::const_iterator itc = it->comboValues.begin();
               itc != it->comboValues.end(); ++itc)
       else if (it->type == COMBO)
           for (ComboValues::const_iterator itc = it->comboValues.begin();
               itc != it->comboValues.end(); ++itc)
@@ -260,7 +252,7 @@ void print_uci_options() {
 /// get_option_value_bool() returns the current value of a UCI parameter of
 /// type "check".
 
 /// get_option_value_bool() returns the current value of a UCI parameter of
 /// type "check".
 
-bool get_option_value_bool(const std::string& optionName) {
+bool get_option_value_bool(const string& optionName) {
 
   return get_option_value<bool>(optionName);
 }
 
   return get_option_value<bool>(optionName);
 }
@@ -271,7 +263,7 @@ bool get_option_value_bool(const std::string& optionName) {
 /// it could also be used with a "combo" parameter, where all the available
 /// values are integers.
 
 /// it could also be used with a "combo" parameter, where all the available
 /// values are integers.
 
-int get_option_value_int(const std::string& optionName) {
+int get_option_value_int(const string& optionName) {
 
   return get_option_value<int>(optionName);
 }
 
   return get_option_value<int>(optionName);
 }
@@ -280,9 +272,9 @@ int get_option_value_int(const std::string& optionName) {
 /// get_option_value_string() returns the current value of a UCI parameter as
 /// a string. It is used with parameters of type "combo" and "string".
 
 /// get_option_value_string() returns the current value of a UCI parameter as
 /// a string. It is used with parameters of type "combo" and "string".
 
-const std::string get_option_value_string(const std::string& optionName) {
+string get_option_value_string(const string& optionName) {
 
 
-   return get_option_value<std::string>(optionName);
+   return get_option_value<string>(optionName);
 }
 
 
 }
 
 
@@ -290,28 +282,27 @@ const std::string get_option_value_string(const std::string& optionName) {
 /// the function does not check that the new value is legal for the given
 /// parameter: This is assumed to be the responsibility of the GUI.
 
 /// the function does not check that the new value is legal for the given
 /// parameter: This is assumed to be the responsibility of the GUI.
 
-void set_option_value(const std::string& optionName,
-                      const std::string& newValue) {
+void set_option_value(const string& name, const string& value) {
 
   // UCI protocol uses "true" and "false" instead of "1" and "0", so convert
 
   // UCI protocol uses "true" and "false" instead of "1" and "0", so convert
-  // newValue according to standard C++ convention before to store it.
-  std::string v(newValue);
+  // value according to standard C++ convention before to store it.
+  string v(value);
   if (v == "true")
       v = "1";
   else if (v == "false")
       v = "0";
 
   if (v == "true")
       v = "1";
   else if (v == "false")
       v = "0";
 
-  if (options.find(optionName) != options.end())
-      options[optionName].currentValue = v;
+  if (options.find(name) != options.end())
+      options[name].currentValue = v;
   else
   else
-      std::cout << "No such option: " << optionName << std::endl;
+      std::cout << "No such option: " << name << std::endl;
 }
 
 
 /// push_button() is used to tell the engine that a UCI parameter of type
 /// "button" has been selected:
 
 }
 
 
 /// push_button() is used to tell the engine that a UCI parameter of type
 /// "button" has been selected:
 
-void push_button(const std::string& buttonName) {
+void push_button(const string& buttonName) {
 
   set_option_value(buttonName, "true");
 }
 
   set_option_value(buttonName, "true");
 }
@@ -321,7 +312,7 @@ void push_button(const std::string& buttonName) {
 /// been selected since the last time the function was called, in this case
 /// it also resets the button.
 
 /// been selected since the last time the function was called, in this case
 /// it also resets the button.
 
-bool button_was_pressed(const std::string& buttonName) {
+bool button_was_pressed(const string& buttonName) {
 
   if (!get_option_value<bool>(buttonName))
          return false;
 
   if (!get_option_value<bool>(buttonName))
          return false;
index e9f4b15896586f15c518c791e70e248efd7ae9cb..96b83fc53252f1d20724d85bb40a14a126db211f 100644 (file)
 
 #include <string>
 
 
 #include <string>
 
-
-////
-//// Variables
-////
-
-extern bool Chess960;
-
-
 ////
 //// Prototypes
 ////
 
 extern void init_uci_options();
 extern void print_uci_options();
 ////
 //// Prototypes
 ////
 
 extern void init_uci_options();
 extern void print_uci_options();
-extern bool get_option_value_bool(const std::string &optionName);
-extern int get_option_value_int(const std::string &optionName);
-extern const std::string get_option_value_string(const std::string &optionName);
-extern bool button_was_pressed(const std::string &buttonName);
-extern void set_option_value(const std::string &optionName,
-                             const std::string &newValue);
-extern void push_button(const std::string &buttonName);
+extern bool get_option_value_bool(const std::string& optionName);
+extern int get_option_value_int(const std::string& optionName);
+extern std::string get_option_value_string(const std::string& optionName);
+extern bool button_was_pressed(const std::string& buttonName);
+extern void set_option_value(const std::string& optionName,const std::string& newValue);
+extern void push_button(const std::string& buttonName);
 
 
 #endif // !defined(UCIOPTION_H_INCLUDED)
 
 
 #endif // !defined(UCIOPTION_H_INCLUDED)