bundle.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*****************************************************************************
  2. * Project: dcc
  3. * File: bundle.h
  4. * Purpose: Module to handle the bundle type (array of pointers to strings).
  5. * (C) Cristina Cifuentes
  6. ****************************************************************************/
  7. #pragma once
  8. #include <stdio.h>
  9. #include <vector>
  10. #include <string>
  11. struct strTable : std::vector<std::string>
  12. {
  13. /* Returns the next available index into the table */
  14. size_t nextIdx() {return size();}
  15. public:
  16. void addLabelBundle(int idx, int label);
  17. };
  18. struct bundle
  19. {
  20. public:
  21. void appendCode(const char *format, ...);
  22. void appendCode(const std::string &s);
  23. void appendDecl(const char *format, ...);
  24. void appendDecl(const std::string &);
  25. void init()
  26. {
  27. decl.clear();
  28. code.clear();
  29. }
  30. strTable decl; /* Declarations */
  31. strTable code; /* C code */
  32. int current_indent;
  33. };
  34. extern bundle cCode;
  35. #define lineSize 360 /* 3 lines in the mean time */
  36. //void newBundle (bundle *procCode);
  37. void writeBundle (std::ostream &ios, bundle procCode);
  38. void freeBundle (bundle *procCode);