DatabaseConnectionID.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /* -*- C++ -*- */
  2. /****************************************************************************
  3. ** Copyright (c) 2001-2014
  4. **
  5. ** This file is part of the QuickFIX FIX Engine
  6. **
  7. ** This file may be distributed under the terms of the quickfixengine.org
  8. ** license as defined by quickfixengine.org and appearing in the file
  9. ** LICENSE included in the packaging of this file.
  10. **
  11. ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  12. ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  13. **
  14. ** See http://www.quickfixengine.org/LICENSE for licensing information.
  15. **
  16. ** Contact ask@quickfixengine.org if any conditions of this licensing are
  17. ** not clear to you.
  18. **
  19. ****************************************************************************/
  20. #ifndef FIX_DATABASECONNECTIONID_H
  21. #define FIX_DATABASECONNECTIONID_H
  22. #ifdef _MSC_VER
  23. #pragma warning( disable : 4503 4355 4786 4290 )
  24. #endif
  25. #include <string>
  26. #include <map>
  27. namespace FIX
  28. {
  29. class DatabaseConnectionID
  30. {
  31. public:
  32. DatabaseConnectionID
  33. ( const std::string& database, const std::string& user,
  34. const std::string& password, const std::string& host, short port )
  35. : m_database( database ), m_user( user ), m_password( password ),
  36. m_host( host ), m_port( port ) {}
  37. friend bool operator<( const DatabaseConnectionID&, const DatabaseConnectionID& );
  38. friend bool operator==( const DatabaseConnectionID&, const DatabaseConnectionID& );
  39. friend bool operator!=( const DatabaseConnectionID&, const DatabaseConnectionID& );
  40. const std::string& getDatabase() const
  41. { return m_database; }
  42. const std::string& getUser() const
  43. { return m_user; }
  44. const std::string& getPassword() const
  45. { return m_password; }
  46. const std::string& getHost() const
  47. { return m_host; }
  48. short getPort() const
  49. { return m_port; }
  50. private:
  51. std::string m_database;
  52. std::string m_user;
  53. std::string m_password;
  54. std::string m_host;
  55. short m_port;
  56. };
  57. inline bool operator<( const DatabaseConnectionID& lhs, const DatabaseConnectionID& rhs )
  58. {
  59. if ( lhs.m_database < rhs.m_database )
  60. return true;
  61. else if ( rhs.m_database < lhs.m_database )
  62. return false;
  63. else if ( lhs.m_user < rhs.m_user )
  64. return true;
  65. else if ( rhs.m_user < lhs.m_user )
  66. return false;
  67. else if ( lhs.m_password < rhs.m_password )
  68. return true;
  69. else if ( rhs.m_password < lhs.m_password )
  70. return false;
  71. else if ( lhs.m_host < rhs.m_host )
  72. return true;
  73. else if ( rhs.m_host < lhs.m_host )
  74. return false;
  75. else if ( lhs.m_port < rhs.m_port )
  76. return true;
  77. else if ( rhs.m_port < lhs.m_port )
  78. return false;
  79. else
  80. return false;
  81. }
  82. inline bool operator==( const DatabaseConnectionID& lhs, const DatabaseConnectionID& rhs )
  83. {
  84. return ( ( lhs.m_database == rhs.m_database ) &&
  85. ( lhs.m_user == rhs.m_user ) &&
  86. ( lhs.m_password == rhs.m_password ) &&
  87. ( lhs.m_host == rhs.m_host ) &&
  88. ( lhs.m_port == rhs.m_port ));
  89. }
  90. inline bool operator!=( const DatabaseConnectionID& lhs, const DatabaseConnectionID& rhs )
  91. {
  92. return !( lhs == rhs );
  93. }
  94. }
  95. #endif