Table_and_Strings.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /* Table_and_Strings.cpp
  2. *
  3. * Copyright (C) 2018 David Weenink
  4. *
  5. * This code is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * This code is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this work. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include "Table_and_Strings.h"
  19. autoStrings Table_column_to_Strings (Table me, integer columnNumber) {
  20. try {
  21. Table_checkSpecifiedColumnNumberWithinRange (me, columnNumber);
  22. autoStrings thee = Thing_new (Strings);
  23. thy strings = autostring32vector (my rows.size);
  24. thy numberOfStrings = 0;
  25. for (integer irow = 1; irow <= my rows.size; irow ++) {
  26. thy strings [irow] = Melder_dup (Table_getStringValue_Assert (me, irow, columnNumber));
  27. thy numberOfStrings ++;
  28. }
  29. return thee;
  30. } catch (MelderError) {
  31. Melder_throw (U"A Strings could not be created from the column in the Table.");
  32. }
  33. }
  34. /* End of file Table_and_Strings.cpp */