A C++ DAL / ORM code generation framework
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
2.8 KiB

  1. /*
  2. WORM - a DAL/ORM code generation framework
  3. Copyright (C) 2011 Erik Winn <sidewalksoftware@gmail.com>
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. #include "wsqlreferencedkey.h"
  16. #include "wsqldatatype.h"
  17. namespace WSql
  18. {
  19. /*! \class WSqlReferencedKey
  20. * \brief WSqlReferencedKey provides an abstraction of a referenced column in a database
  21. *
  22. * This class provides a generic interface to a column referenced by a foreign key in databases
  23. * including information about tables and columns to which the foreign key refers and the
  24. * information about the refering key, column and table.
  25. *
  26. * \ingroup WSql
  27. * \sa WSqlForeignKey
  28. */
  29. WSqlReferencedKey::WSqlReferencedKey ( const WSql::WSqlForeignKey &fk )
  30. {
  31. _referingKey = fk;
  32. }
  33. WSqlReferencedKey::WSqlReferencedKey ( const WSqlReferencedKey &other )
  34. {
  35. _referingKey = other._referingKey;
  36. }
  37. WSqlReferencedKey::~WSqlReferencedKey()
  38. {
  39. }
  40. WSqlReferencedKey &WSqlReferencedKey::operator= ( const WSqlReferencedKey &other )
  41. {
  42. _referingKey = other._referingKey;
  43. return *this;
  44. }
  45. bool WSqlReferencedKey::operator== ( const WSqlReferencedKey &other ) const
  46. {
  47. return _referingKey == other._referingKey;
  48. }
  49. std::string WSqlReferencedKey::referingClassName() const
  50. {
  51. return WSqlDataType::tableNameToClass ( _referingKey.tableName() );
  52. }
  53. std::string WSqlReferencedKey::referingClassNamePlural() const
  54. {
  55. return WSqlDataType::toPlural ( referingClassName() );
  56. }
  57. void WSqlReferencedKey::dump() const
  58. {
  59. std::cerr << "************** Referenced Key: **************" << std::endl;
  60. std::cerr << "columnName()" << columnName() << std::endl;
  61. std::cerr << "tableName()" << tableName() << std::endl;
  62. std::cerr << "schemaName()" << schemaName() << std::endl;
  63. std::cerr << "referingKeyName()" << referingKeyName() << std::endl;
  64. std::cerr << "referingColumnName()" << referingColumnName() << std::endl;
  65. std::cerr << "referingTableName()" << referingTableName() << std::endl;
  66. std::cerr << "referingSchemaName()" << referingSchemaName() << std::endl;
  67. std::cerr << "referingClassName()" << referingClassName() << std::endl;
  68. std::cerr << "referingClassNamePlural()" << referingClassNamePlural() << std::endl;
  69. std::cerr << "*****************************************" << std::endl;
  70. }
  71. }//namespace WSql