Contains the source code from the course work throughout my undergraduate Computer Engineering degree at Brigham Young University. There is a mixture of Go, Python, C, C++, Java, VHDL, Verilog, Matlab, Bash, Assembly, etc..
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.

predicate.h 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #ifndef __PREDICATE_H__
  2. #define __PREDICATE_H__
  3. #include "parameter.h"
  4. #include <vector>
  5. #include <iostream>
  6. using namespace std;
  7. class predicate {
  8. public:
  9. string id;
  10. vector<parameter> pred_list;
  11. string toString() {
  12. //schemes
  13. stringstream s;
  14. s << id << "(";
  15. for(unsigned int i = 0; i < pred_list.size(); i++) {
  16. s << pred_list[i].param;
  17. if(i < pred_list.size()-1) {
  18. s << ",";
  19. }
  20. }
  21. s << ")\n";
  22. return s.str();
  23. }
  24. string toString(bool a) {
  25. //facts
  26. stringstream s;
  27. s << id << "(";
  28. for(unsigned int i = 0; i < pred_list.size(); i++) {
  29. s << "'" << pred_list[i].param << "'";
  30. if(i < pred_list.size()-1) {
  31. s << ",";
  32. }
  33. }
  34. s << ").\n";
  35. return s.str();
  36. }
  37. string toString(double a) {
  38. //query
  39. stringstream s;
  40. s << id << "(";
  41. for(unsigned int i = 0; i < pred_list.size(); i++) {
  42. if(pred_list[i].type == "STRING") {
  43. s << "'" << pred_list[i].param << "'";
  44. if(i < pred_list.size()-1) {
  45. s << ",";
  46. }
  47. }
  48. if(pred_list[i].type == "ID") {
  49. s << pred_list[i].param;
  50. if(i < pred_list.size()-1) {
  51. s << ",";
  52. }
  53. }
  54. }
  55. s << ")?\n";
  56. return s.str();
  57. }
  58. string toString(int a) {
  59. //rules
  60. stringstream s;
  61. s << id << "(";
  62. for(unsigned int i = 0; i < pred_list.size(); i++) {
  63. if(pred_list[i].type == "STRING") {
  64. s << "'" << pred_list[i].param << "'";
  65. if(i < pred_list.size()-1) {
  66. s << ",";
  67. }
  68. }
  69. if(pred_list[i].type == "ID") {
  70. s << pred_list[i].param;
  71. if(i < pred_list.size()-1) {
  72. s << ",";
  73. }
  74. }
  75. }
  76. s << ")";
  77. return s.str();
  78. }
  79. };
  80. #endif