Jamoma API  0.6.0.a19
TTValue.h
Go to the documentation of this file.
1 /** @file
2 
3  @ingroup foundationLibrary
4 
5  @brief Provides a common way of representing composite values.
6 
7  @details #TTValue is the primary interface used to pass values to and from methods in Jamoma Core.
8  Methods for a given #TTObject should be passed both an input and output value to complete its operation, while the return is reserved for a #TTErr.
9  @n@n
10  Each #TTValue may be composed of a single element or many elements because it has been defined as a subclass of the C++ standard library's <a href="http://www.cplusplus.com/reference/vector/vector/">vector class</a>.
11  This also enables our class to inherit familiar functions such as size() and from its parent class.
12  @n@n
13  Individual items within the #TTValue are defined by the #TTElement class.
14  These individual elements may be one of the defined types in the #TTDataType enumeration.
15 
16  @author Tim Place, Théo de la Hogue, Nathan Wolek, Julien Rabin, Nils Peters, Trond Lossius
17 
18  @copyright Copyright © 2008, Timothy Place @n
19  This code is licensed under the terms of the "New BSD License" @n
20  http://creativecommons.org/licenses/BSD/
21 */
22 
23 
24 #ifndef __TT_VALUE_H__
25 #define __TT_VALUE_H__
26 
27 #include "TTElement.h"
28 #include <functional>
29 
30 //! [doxygenAppendixC_copyExample]
31 /** @copybrief TTValue.h
32  @copydetails TTValue.h
33 */
34 class TTValue : public TTElementVector {
35 //! [doxygenAppendixC_copyExample]
36 
37 public:
38 
39  /** @brief Constructor for an empty value */
41  {
42  // we reserve 1 because we want to always be assured that there is a memory for at least one element.
43  // it is exceedingly rare that a TTValue will be used empty, and most common that it will have one element.
44  // for speed, it is possible to use abuse TTValue by setting and getting the first element without range or type checking
45  // and even bypassing the setter methods entirely.
46  // in these cases it is critical to be able to rely upon the memory being valid for the first element.
47  reserve(1);
48  }
49 
50  /** @brief Constructor with a single initial element. */
51  template<class T>
52  TTValue(const T& anInitialValue)
53  {
54  resize(1);
55  (*this)[0] = anInitialValue;
56  }
57 
58  /** @brief Specialized constructor for the float64 case because it is so often performance sensitive. */
59  TTValue(const TTFloat64 v)
60  {
61  resize(1);
62  (*this)[0].float64(v);
63  }
64 
65  /** @brief Constructor with two initial elements. */
66  template <class T, class U>
67  TTValue(const T& aFirstElementInitialValue, const U& aSecondElementInitialValue)
68  {
69  resize(2);
70  (*this)[0] = aFirstElementInitialValue;
71  (*this)[1] = aSecondElementInitialValue;
72  }
73 
74  /** @brief Constructor with three initial elements. */
75  template <class T, class U, class V>
76  TTValue(const T& aFirstElementInitialValue, const U& aSecondElementInitialValue, const V& aThirdElementInitialValue)
77  {
78  resize(3);
79  (*this)[0] = aFirstElementInitialValue;
80  (*this)[1] = aSecondElementInitialValue;
81  (*this)[2] = aThirdElementInitialValue;
82  }
83 
84  /** @brief Constructor with four initial elements. */
85  template <class T, class U, class V, class W>
86  TTValue(const T& aFirstElementInitialValue, const U& aSecondElementInitialValue, const V& aThirdElementInitialValue, const W& aFourthElementInitialValue)
87  {
88  resize(4);
89  (*this)[0] = aFirstElementInitialValue;
90  (*this)[1] = aSecondElementInitialValue;
91  (*this)[2] = aThirdElementInitialValue;
92  (*this)[3] = aFourthElementInitialValue;
93  }
94 
95  // force the destructor to be non-virtual
96  // we don't want subclasses of TTValue so it won't be a problem, and this solves linking snafus in some edge cases
97  /** @brief Destructor */
99  {;}
100 
101 
102 private:
103  /** @brief Internal method used by the constructors. */
104  void init();
105 
106  /** @brief Performs a deep copy of the object */
107  inline void copy(const TTValue& obj);
108 
109 
110 public:
111 
112 
113  /** Fast fetch of float64 elements without range/type checking or conversion */
115  {
116  return (*this)[0].float64();
117  }
118 
119  /** Fast assignment of float64 elements without range/type checking or conversion
120  @param v the float to assign to this value.
121  @return a reference to this value object.
122  */
124  {
125  (*this)[0].float64(v);
126  return *this;
127  }
128 
129 
130  /** @brief Clear all values from the vector, leaving with size of 0 */
131  void clear()
132  {
133  TTElementVector::clear();
134  }
135 
136 
137  /** @brief Copy a value starting from an index until another index */
138  void copyRange(const TTValue& obj, TTUInt16 startIndex, TTUInt16 endIndex)
139  {
140  resize(endIndex - startIndex);
141  for (size_t i=0; i<size(); i++)
142  (*this)[i] = obj[startIndex+i];
143  }
144 
145 
146  /** @brief Copy a value starting from an index until the last element */
147  void copyFrom(const TTValue& obj, TTUInt16 index)
148  {
149  copyRange(obj, index, obj.size());
150  }
151 
152 
153  /** @brief Insert another TTValue before the first element.
154  @details
155  The following example code would result in TTValue b having elements ordered <1, 2, 3, ga, bu, zo, meu>:
156  @code{.cpp}
157  TTValue a(1, 2, 3);
158  TTValue b(ga, bu, zo, meu);
159  b.prepend(a);
160  @endcode
161  */
162  void prepend(const TTValue& aValueToPrepend)
163  {
164  TTValue v = aValueToPrepend;
165 
166  v.append(*this);
167  *this = v;
168  }
169 
170 
171  /** @brief Assign a value to TTValue.
172  @details Overwrites current elements.
173  */
174  template<class T>
176  {
177  resize(1);
178  (*this)[0] = value;
179  return *this;
180  }
181 
182  /** @brief Test equality of two values */
183  friend bool operator == (const TTValue& a, const TTValue& b)
184  {
185  if (a.size() == b.size()) {
186  for (size_t i=0; i<a.size(); i++) {
187  if (a[i] != b[i]) {
188  return false;
189  }
190  }
191  return true;
192  }
193  return false;
194  }
195 
196 #if !defined(TT_PLATFORM_WIN) && (!defined(__GNUC__) || defined(__clang__))
197  /** @overload
198  */
199  template<class T>
200  friend bool operator == (const TTValue& a, const T b)
201  {
202  if (a.size() == 1 && a[0] == b)
203  return true;
204  else
205  return false;
206  }
207 #endif
208 
209  /** @brief Get a value from TTValue */
210  template<class T>
211  operator T() const
212  {
213  if (size())
214  return T((*this)[0]);
215  else
216  return T(0);
217  }
218 
219  // TTSymbol needs to be manually wrapped to avoid ambiguity as interpretted by the clang compiler
220  /** @overload
221  */
222  operator TTSymbol() const
223  {
224  if (size())
225  return (*this)[0];
226  else
227  return kTTSymEmpty;
228  }
229 
230  // TTObject needs to be manually wrapped to avoid ambiguity as interpretted by the clang compiler
231  /** @overload
232  */
233  operator TTObject() const
234  {
235  if (size())
236  return (*this)[0];
237  else
238  return TTObject();
239  }
240 
241  /** @brief Insert a single TTElement at the end */
242  template<class T>
243  void append(const T& anElementValueToAppend)
244  {
245  TTElement e(anElementValueToAppend);
246 
247  push_back(e);
248  }
249 
250  /** @brief Insert another TTValue after the last element.
251  @details
252  The following example code would result in TTValue b having elements ordered <ga, bu, zo, meu, 1, 2, 3>:
253  @code{.cpp}
254  TTValue a(1, 2, 3);
255  TTValue b(ga, bu, zo, meu);
256  b.append(a);
257  @endcode
258  */
259  void append(const TTValue& aValueToAppend)
260  {
261  TTUInt32 appendingElementCount = aValueToAppend.size();
262  TTUInt32 oldElementCount = size();
263  TTUInt32 newElementCount = oldElementCount + appendingElementCount;
264 
265  resize(newElementCount);
266 
267  for (TTUInt32 i=0; i<appendingElementCount; i++) {
268  TTElement e = aValueToAppend[i];
269 
270  (*this)[oldElementCount+i] = e;
271  }
272  }
273 
274  /** @brief Clip numerical values between low and high boundaries
275  @param[in] aLowBound Lowest value that should be preserved. Anything lower will be set to this value.
276  @param[in] aHighBound Highest value that should be preserved. Anything higher will be set to this value.
277  @return none
278  */
279  void clip(const TTFloat64& aLowBound, const TTFloat64& aHighBound)
280  {
281  for (TTElementIter i = this->begin(); i != this->end(); i++)
282  i->clip(aLowBound, aHighBound);
283  }
284 
285  /** @brief Clip numerical values below a specified boundary
286  @param[in] aLowBound Lowest value that should be preserved. Anything lower will be set to this value.
287  @return none
288  */
289  void cliplow(const TTFloat64& aLowBound)
290  {
291  for (TTElementIter i = this->begin(); i != this->end(); i++)
292  i->cliplow(aLowBound);
293  }
294 
295  /** @brief Clip numerical values above a specified boundary
296  @param[in] aHighBound Highest value that should be preserved. Anything higher will be set to this value.
297  @return none
298  */
299  void cliphigh(const TTFloat64& aHighBound)
300  {
301  for (TTElementIter i = this->begin(); i != this->end(); i++)
302  i->cliphigh(aHighBound);
303  }
304 
305  /** @brief Fold numerical values to remain between low and high boundaries
306  @param[in] aLowBound Lowest value that should be preserved. Anything lower will be folder.
307  @param[in] aHighBound Highest value that should be preserved. Anything higher will be folded.
308  @return none
309  */
310  void fold(const TTFloat64& aLowBound, const TTFloat64& aHighBound)
311  {
312  for (TTElementIter i = this->begin(); i != this->end(); i++)
313  i->fold(aLowBound, aHighBound);
314  }
315 
316  /** @brief Wrap numerical values to remain between low and high boundaries
317  @param[in] aLowBound Lowest value that should be preserved. Anything lower will be wrapped.
318  @param[in] aHighBound Highest value that should be preserved. Anything higher will be wrapped.
319  @return none
320  */
321  void wrap(const TTFloat64& aLowBound, const TTFloat64& aHighBound)
322  {
323  for (TTElementIter i = this->begin(); i != this->end(); i++)
324  i->wrap(aLowBound, aHighBound);
325  }
326 
327  /** @brief Round float & double elements to the nearest whole number */
328  void round()
329  {
330  for_each(this->begin(), this->end(), std::mem_fun_ref(&TTElement::round));
331  }
332 
333  /** @brief Truncate float & double elements so that only whole number remains */
334  void truncate()
335  {
336  for_each(this->begin(), this->end(), std::mem_fun_ref(&TTElement::truncate));
337  }
338 
339  /** @brief Booleanize numerical elements
340  @details Sets all non-zero numerical elements to true, while those that are zero will be set to false. Changes the #TTDataType of these elements to kTypeBoolean.
341  */
342  void booleanize()
343  {
344  for_each(this->begin(), this->end(), std::mem_fun_ref(&TTElement::booleanize));
345  }
346 
347  /** @brief Return the content as a single string with spaces between elements
348  @param none
349  @return #TTString that contains the content of all elements in the #TTValue
350  */
351  TTString toString(TTBoolean quotes = YES) const
352  {
353  TTString temp;
354 
355  for (size_t i=0; i<size(); i++) {
356  (*this)[i].string(temp, quotes); // get a string for each item
357  if (i < (size()-1)) // add a space between each item, but no space at the end
358  temp.append(" ");
359  }
360 
361  return temp;
362  }
363 
364  // TODO: Could this be DRYer?
365  /** @overload
366  */
367  void toString(TTBoolean quotes = YES)
368  {
369  TTString temp;
370 
371  for (size_t i=0; i<size(); i++) {
372  (*this)[i].string(temp, quotes); // get a string for each item
373  if (i < (size()-1)) // add a space between each item, but no space at the end
374  temp.append(" ");
375  }
376 
377  // now set the value to the new string
378  clear();
379  append(temp);
380  }
381 
382  /** @brief Convert a single string into individual elements using space to divide items
383  @param numberAsSymbol optional #TTBoolean determines whether method leaves numbers as symbols, default is NO
384  @return none
385  */
386  void fromString(TTBoolean numberAsSymbol = NO)
387  {
388  if (at(0).type() != kTypeString) { // if the first element isn't a string
389  clear(); // clear the contents of the value
390  return; // and do nothing else
391  }
392 
393  TTUInt32 n = 0;
394  TTInt32 convertedInt;
395  TTUInt32 convertedUInt;
396  TTFloat32 convertedFloat;
397  std::vector<std::string> strList;
398  std::string str(TTString(at(0)));
399  std::istringstream iss(str);
400 
401  std::copy(
402  std::istream_iterator<std::string>( iss ),
403  std::istream_iterator<std::string>(),
404  back_inserter( strList ) );
405 
406  if (strList.size() < 1) {
407  clear();
408  return;
409  }
410 
411  resize(strList.size());
412 
413  for (unsigned int i = 0; i < strList.size(); ++i) {
414  TTString currentString = strList.at(i).c_str();
415 
416  if (currentString.toTTInt32(convertedInt) && !numberAsSymbol) {
417 
418  at(n) = int(convertedInt);
419  n++;
420  }
421  else if (currentString.toTTUInt32(convertedUInt) && !numberAsSymbol) {
422 
423  at(n) = TTUInt32(convertedUInt);
424  n++;
425  }
426  else if (currentString.toTTFloat32(convertedFloat) && !numberAsSymbol) {
427 
428  at(n) = TTFloat64(convertedFloat); // cast float32 into float64
429  n++;
430  }
431  else {
432  if (currentString.c_str()[0] == '"') {
433  TTString editString = currentString.substr(1, currentString.size()); // don't keep the leading "
434 
435  while (currentString.c_str()[currentString.size()-1] != '"' && (i != (strList.size() - 1))) {
436  i++;
437  currentString = strList.at(i);
438 
439  editString += " ";
440  editString += currentString;
441  }
442 
443  at(n) = TTSymbol(editString.substr(0, editString.size()-1));
444  n++;
445 
446  }
447  else {
448 
449  at(n) = TTSymbol(currentString.c_str());
450  n++;
451  }
452  }
453  }
454 
455  // resize value
456  resize(n);
457  }
458 
459 
460  /** @brief Convert a comma-separated-value string into an array of TTSymbols.
461  @return kTTErrInvalidType if first item is not kTypeString, else kTTErrNone
462  */
464  {
465  if (at(0).type() != kTypeString)
466  return kTTErrInvalidType;
467 
468  const TTString& str = at(0);
469  char* cStr;
470  char* current;
471 
472  clear();
473 
474  cStr = new char[str.size()+1];
475  strncpy(cStr, str.c_str(), str.size()+1);
476 
477  current = strrchr(cStr, ',');
478  while (current) {
479  *current = 0;
480  current++;
481 
482  // Do some basic whitespace stripping from the ends
483  while (*current == ' ')
484  current++;
485  while (current[strlen(current)-1] == ' ')
486  current[strlen(current)-1] = 0;
487 
488  append(TTSymbol(current));
489  current = strrchr(cStr, ',');
490  }
491  append(TTSymbol(cStr));
492  delete[] cStr;
493  return kTTErrNone;
494  }
495 
496 // inherited functions from Vector class
497 
498 #ifdef _DOXY_
499 
500 
501  /** @brief Return the number of elements
502  @details Inherited from the C++ standard library's <a href="http://www.cplusplus.com/reference/vector/vector/">vector class</a>
503  @param none
504  @return number of elements currently in #TTValue
505  */
506  size_type size() const noexcept;
507 
508  /** @brief Change the number of elements
509  @details Inherited from the C++ standard library's <a href="http://www.cplusplus.com/reference/vector/vector/">vector class</a>
510  @param n number of elements for resulting #TTValue
511  @return void
512  */
513  void resize (size_type n);
514 
515 #endif
516 
517 // deprecated functions
518 
519  /** @brief DEPRECATED
520  @deprecated instead, please call the size() method */
521  TT_DEPRECATED( TTUInt16 getSize() const )
522  {
523  return size();
524  }
525 
526  /** @brief DEPRECATED
527  @deprecated instead, please call the resize() method */
528  TT_DEPRECATED( void setSize(const TTUInt16 arg) )
529  {
530  resize(arg);
531  }
532 
533 
534  /** @brief DEPRECATED
535  @deprecated instead, please call TTElement::type() on the element itself.
536  @details
537  Old syntax:
538  @code{.cpp}
539  TTValue v(1,2,3);
540  TTDataType thetype = v.getType(1);
541  @endcode
542  New syntax:
543  @code{.cpp}
544  TTValue v(1,2,3);
545  TTDataType thetype = v[1].type();
546  @endcode
547  */
548  TT_DEPRECATED( TTDataType getType(const TTUInt16 index=0) const )
549  {
550  return at(index).type();
551  }
552 
553 
554  /** @brief DEPRECATED
555  @deprecated instead, please make an assignment using standard C array syntax.
556  @details
557  Old syntax:
558  @code{.cpp}
559  TTValue v;
560  v.set(0, 3.14);
561  @endcode
562  New syntax:
563  @code{.cpp}
564  TTValue v;
565  v[0] = 3.14;
566  @endcode
567  */
568  template<class T>
569  TT_DEPRECATED ( void set(const TTUInt16 index, const T& anElementValue) )
570  {
571  at(index) = anElementValue;
572  }
573 
574  /** @brief DEPRECATED
575  @deprecated instead, please fetch the value of an element using standard C array syntax.
576  @details
577  Old syntax:
578  @code{.cpp}
579  TTValue v(3.14);
580  TTFloat64 mypi;
581  v.get(0, mypi);
582  @endcode
583  New syntax:
584  @code{.cpp}
585  TTValue v(3.14);
586  TTFloat64 mypi;
587  mypi = v[0];
588  @endcode
589  */
590  template<class T>
591  TT_DEPRECATED ( void get(const TTUInt16 index, T& returnedElementValue) const )
592  {
593  returnedElementValue = at(index);
594  }
595 
596  /*
597  TT_DEPRECATED ( void get(const TTUInt16 index, TTObjectBase** value) const )
598  {
599  if (at(index).type() == kTypeObject)
600  *value = at(index);
601  }
602  */
603 
604  TT_DEPRECATED ( void get(const TTUInt16 index, TTPtr* value) const )
605  {
606  if (at(index).type() == kTypePointer)
607  *value = at(index);
608  }
609 
610  TT_DEPRECATED ( void get(const TTUInt16 index, TTString& value) const )
611  {
612  value = (TTString)at(index);
613  }
614 
615 
616  // inlined for speed (e.g. for use in the matrix)
617  /** @brief DEPRECATED
618  @deprecated inlined function formerly used by #TTMatrix or @ref foundationDataspaceLib
619  */
620  TT_DEPRECATED( TTFloat64 getUInt8(TTUInt16 index = 0) const )
621  {
622  return TTUInt8(at(index));
623  }
624 
625  // inlined for speed (e.g. for use in the matrix)
626  /** @copydoc getUInt8()
627  */
628  TT_DEPRECATED( TTFloat64 getInt32(TTUInt16 index = 0) const )
629  {
630  return TTInt32(at(index));
631  }
632 
633  /** @copydoc getUInt8()
634  */
635  TT_DEPRECATED( TTFloat64 getFloat32(TTUInt16 index = 0) const )
636  {
637  return TTFloat32(at(index));
638  }
639 
640  /** @copydoc getUInt8()
641  */
642  TT_DEPRECATED( TTFloat64 getFloat64(TTUInt16 index = 0) const )
643  {
644  return TTFloat64(at(index));
645  }
646 
647  /** @copydoc getUInt8()
648  */
649  TT_DEPRECATED( void getArray(TTUInt8* arrayToFill, TTUInt16 maxSize) const )
650  {
651  for (size_t i=0; i<size(); i++) {
652  if (i == maxSize)
653  break;
654  *(arrayToFill+i) = TTUInt8(at(i));
655  }
656  }
657 
658 
659  /** @overload
660  */
661  TT_DEPRECATED( void getArray(TTInt32* arrayToFill, TTUInt16 maxSize) const )
662  {
663  for (size_t i=0; i<size(); i++) {
664  if (i == maxSize)
665  break;
666  *(arrayToFill+i) = TTInt32(at(i));
667  }
668  }
669 
670 
671  /** @overload
672  */
673  TT_DEPRECATED( void getArray(TTFloat32* arrayToFill, TTUInt16 maxSize) const )
674  {
675  for (size_t i=0; i<size(); i++) {
676  if (i == maxSize)
677  break;
678  *(arrayToFill+i) = TTFloat32(at(i));
679  }
680  }
681 
682 
683  /** @overload
684  */
685  TT_DEPRECATED( void getArray(TTFloat64* arrayToFill, TTUInt16 maxSize) const )
686  {
687  for (size_t i=0; i<size(); i++) {
688  if (i == maxSize)
689  break;
690  *(arrayToFill+i) = TTFloat64(at(i));
691  }
692  }
693 
694 
695 
696 };
697 
698 
699 typedef TTValue* TTValuePtr;
700 typedef TTValue& TTValueRef;
701 typedef const TTValue& TTValueConstRef;
702 
703 // dumb global which is an empty / uninitialized symbol -- you shouldn't use it.
704 // it's only here for backwards compatibility reasons.
705 typedef void* TTNoValue;
706 #define kTTValNONE (TTNoValue(0))
707 
708 #endif // __TT_VALUE_H__
709 
bool TTBoolean
Boolean flag, same as Boolean on the Mac.
Definition: TTBase.h:167
void booleanize()
Booleanize numerical elements.
Definition: TTValue.h:342
std::uint16_t TTUInt16
16 bit unsigned integer
Definition: TTBase.h:176
void fromString(TTBoolean numberAsSymbol=NO)
Convert a single string into individual elements using space to divide items.
Definition: TTValue.h:386
TTFloat64 getInt32(TTUInt16 index=0) const
DEPRECATED.
Definition: TTValue.h:628
TTUInt16 getSize() const
DEPRECATED.
Definition: TTValue.h:521
TTValue(const T &aFirstElementInitialValue, const U &aSecondElementInitialValue, const V &aThirdElementInitialValue, const W &aFourthElementInitialValue)
Constructor with four initial elements.
Definition: TTValue.h:86
TTValue(const T &anInitialValue)
Constructor with a single initial element.
Definition: TTValue.h:52
TTFloat64 float64() const
Fast fetch of float64 elements without range/type checking or conversion.
Definition: TTValue.h:114
TTFloat64 getUInt8(TTUInt16 index=0) const
DEPRECATED.
Definition: TTValue.h:620
TTString toString(TTBoolean quotes=YES) const
Return the content as a single string with spaces between elements.
Definition: TTValue.h:351
friend bool operator==(const TTValue &a, const TTValue &b)
Test equality of two values.
Definition: TTValue.h:183
void getArray(TTFloat64 *arrayToFill, TTUInt16 maxSize) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: TTValue.h:685
void copyFrom(const TTValue &obj, TTUInt16 index)
Copy a value starting from an index until the last element.
Definition: TTValue.h:147
const char * c_str() const
Return a pointer to the internal C-string.
Definition: TTString.h:83
Create and use Jamoma object instances.
Definition: TTObject.h:29
size_type size() const noexcept
Return the number of elements.
TTDataType getType(const TTUInt16 index=0) const
DEPRECATED.
Definition: TTValue.h:548
TTDataType
TTBlue Data Types Enumeration of data types used through out TTBlue, including the TTValue class and ...
Definition: TTBase.h:269
Bad DataType for the context.
Definition: TTBase.h:347
void fold(const TTFloat64 &aLowBound, const TTFloat64 &aHighBound)
Fold numerical values to remain between low and high boundaries.
Definition: TTValue.h:310
TTValue(const T &aFirstElementInitialValue, const U &aSecondElementInitialValue, const V &aThirdElementInitialValue)
Constructor with three initial elements.
Definition: TTValue.h:76
double TTFloat64
64 bit floating point number
Definition: TTBase.h:188
void prepend(const TTValue &aValueToPrepend)
Insert another TTValue before the first element.
Definition: TTValue.h:162
void append(const T &anElementValueToAppend)
Insert a single TTElement at the end.
Definition: TTValue.h:243
void * TTPtr
A generic pointer.
Definition: TTBase.h:248
void setSize(const TTUInt16 arg)
DEPRECATED.
Definition: TTValue.h:528
void cliplow(const TTFloat64 &aLowBound)
Clip numerical values below a specified boundary.
Definition: TTValue.h:289
The TTSymbol class is used to represent a string and efficiently pass and compare that string...
Definition: TTSymbol.h:26
void round()
Round float & double elements to the nearest whole number.
Definition: TTValue.h:328
float TTFloat32
32 bit floating point number
Definition: TTBase.h:187
void getArray(TTFloat32 *arrayToFill, TTUInt16 maxSize) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: TTValue.h:673
void toString(TTBoolean quotes=YES)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: TTValue.h:367
TTErr transformCSVStringToSymbolArray()
Convert a comma-separated-value string into an array of TTSymbols.
Definition: TTValue.h:463
void cliphigh(const TTFloat64 &aHighBound)
Clip numerical values above a specified boundary.
Definition: TTValue.h:299
TTValue()
[doxygenAppendixC_copyExample]
Definition: TTValue.h:40
Individual items found in a TTValue.
Definition: TTElement.h:89
TTString substr(size_t pos=0, size_t n=1) const
Returns a string object with its contents initialized to a substring of the current object...
Definition: TTString.h:342
TTFloat64 getFloat32(TTUInt16 index=0) const
DEPRECATED.
Definition: TTValue.h:635
std::int32_t TTInt32
32 bit signed integer
Definition: TTBase.h:177
void clip(const TTFloat64 &aLowBound, const TTFloat64 &aHighBound)
Clip numerical values between low and high boundaries.
Definition: TTValue.h:279
void clear()
Clear all values from the vector, leaving with size of 0.
Definition: TTValue.h:131
void set(const TTUInt16 index, const T &anElementValue)
DEPRECATED.
Definition: TTValue.h:569
TTValue & operator=(T value)
Assign a value to TTValue.
Definition: TTValue.h:175
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
Definition: TTBase.h:342
void wrap(const TTFloat64 &aLowBound, const TTFloat64 &aHighBound)
Wrap numerical values to remain between low and high boundaries.
Definition: TTValue.h:321
~TTValue()
Destructor.
Definition: TTValue.h:98
std::uint32_t TTUInt32
32 bit unsigned integer
Definition: TTBase.h:178
void append(const TTValue &aValueToAppend)
Insert another TTValue after the last element.
Definition: TTValue.h:259
void append(const char *str, size_t length=0)
Append / Concatenate.
Definition: TTString.h:196
Pointer type.
Definition: TTBase.h:284
size_t size() const
Find out the length of a string.
Definition: TTString.h:144
void getArray(TTUInt8 *arrayToFill, TTUInt16 maxSize) const
DEPRECATED.
Definition: TTValue.h:649
No Error.
Definition: TTBase.h:343
void copyRange(const TTValue &obj, TTUInt16 startIndex, TTUInt16 endIndex)
Copy a value starting from an index until another index.
Definition: TTValue.h:138
TTFloat64 getFloat64(TTUInt16 index=0) const
DEPRECATED.
Definition: TTValue.h:642
The TTString class is used to represent a string.
Definition: TTString.h:34
void truncate()
Truncate float & double elements so that only whole number remains.
Definition: TTValue.h:334
TTValue & float64(TTFloat64 v)
Fast assignment of float64 elements without range/type checking or conversion.
Definition: TTValue.h:123
TTValue(const T &aFirstElementInitialValue, const U &aSecondElementInitialValue)
Constructor with two initial elements.
Definition: TTValue.h:67
String type.
Definition: TTBase.h:285
void resize(size_type n)
Change the number of elements.
void getArray(TTInt32 *arrayToFill, TTUInt16 maxSize) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: TTValue.h:661
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34
Jamoma Foundation class for representing values.
unsigned char TTUInt8
8 bit unsigned integer (char)
Definition: TTBase.h:174
TTValue(const TTFloat64 v)
Specialized constructor for the float64 case because it is so often performance sensitive.
Definition: TTValue.h:59