daily pastebin goal
44%
SHARE
TWEET

Untitled

a guest Jan 27th, 2016 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*****************************************************************
  2. * Author: Jacob Asmuth
  3. * Project: SocketsServer
  4. * Filename: db_conn_str.cpp
  5. * Date Created: 12/2/2015
  6. * Modifications:
  7. *
  8. ****************************************************************/
  9. #include "db_conn_str.h"
  10.  
  11. //Constructor db_conn_str(string server, string db, string user, string pass)
  12. /*****************************************************************
  13. * Purpose:
  14. *
  15. * Entry:
  16. *
  17. * Exit:
  18. *
  19. ****************************************************************/
  20. db_conn_str::db_conn_str( string server, string db, string user, string pass ): _server( server ), _database( db ), _username( user ), _password( pass )
  21. {
  22. }
  23.  
  24. // format_string()
  25. /*****************************************************************
  26. * Purpose:
  27. *
  28. * Entry:
  29. *
  30. * Exit:
  31. *
  32. ****************************************************************/
  33. string db_conn_str::format_string() const
  34. {
  35.     return _format_string;
  36. }
  37.  
  38. // format_string(const string & format_string)
  39. /*****************************************************************
  40. * Purpose:
  41. *
  42. * Entry:
  43. *
  44. * Exit:
  45. *
  46. ****************************************************************/
  47. void db_conn_str::format_string( const string & format_string )
  48. {
  49.     _format_string = format_string;
  50. }
  51.  
  52. // server()
  53. /*****************************************************************
  54. * Purpose:
  55. *
  56. * Entry:
  57. *
  58. * Exit:
  59. *
  60. ****************************************************************/
  61. string db_conn_str::server() const
  62. {
  63.     return _server;
  64. }
  65.  
  66. // server(const string & server)
  67. /*****************************************************************
  68. * Purpose:
  69. *
  70. * Entry:
  71. *
  72. * Exit:
  73. *
  74. ****************************************************************/
  75. void db_conn_str::server( const string & server )
  76. {
  77.     _server = server;
  78. }
  79.  
  80. // database()
  81. /*****************************************************************
  82. * Purpose:
  83. *
  84. * Entry:
  85. *
  86. * Exit:
  87. *
  88. ****************************************************************/
  89. string db_conn_str::database() const
  90. {
  91.     return _database;
  92. }
  93.  
  94. // database(const string & database)
  95. /*****************************************************************
  96. * Purpose:
  97. *
  98. * Entry:
  99. *
  100. * Exit:
  101. *
  102. ****************************************************************/
  103. void db_conn_str::database( const string & database )
  104. {
  105.     _database = database;
  106. }
  107.  
  108. // username()
  109. /*****************************************************************
  110. * Purpose:
  111. *
  112. * Entry:
  113. *
  114. * Exit:
  115. *
  116. ****************************************************************/
  117. string db_conn_str::username() const
  118. {
  119.     return _username;
  120. }
  121.  
  122. // username(const string & user)
  123. /*****************************************************************
  124. * Purpose:
  125. *
  126. * Entry:
  127. *
  128. * Exit:
  129. *
  130. ****************************************************************/
  131. void db_conn_str::username( const string & user )
  132. {
  133.     _username = user;
  134. }
  135.  
  136. // password()
  137. /*****************************************************************
  138. * Purpose:
  139. *
  140. * Entry:
  141. *
  142. * Exit:
  143. *
  144. ****************************************************************/
  145. string db_conn_str::password() const
  146. {
  147.     return _password;
  148. }
  149.  
  150. // password(const string & pass)
  151. /*****************************************************************
  152. * Purpose:
  153. *
  154. * Entry:
  155. *
  156. * Exit:
  157. *
  158. ****************************************************************/
  159. void db_conn_str::password( const string & pass )
  160. {
  161.     _password = pass;
  162. }
  163.  
  164. // get()
  165. /*****************************************************************
  166. * Purpose:
  167. *
  168. * Entry:
  169. *
  170. * Exit:
  171. *
  172. ****************************************************************/
  173. string db_conn_str::get() const
  174. {
  175.     string t = _format_string;
  176.     replace_all( t, "%DB%", _database );
  177.     replace_all( t, "%SV%", _server );
  178.     replace_all( t, "%USER%", _username );
  179.     replace_all( t, "%PASS%", _password );
  180.     return t;
  181. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top