344 |
344 |
345 // ------------------------------------------------------------------------------------------------- |
345 // ------------------------------------------------------------------------------------------------- |
346 // |
346 // |
347 |
347 |
348 template<typename T> |
348 template<typename T> |
349 class List : public Container<T, std::deque<T> > |
|
350 { |
|
351 public: |
|
352 typedef Container<T, std::deque<T> > Super; |
|
353 |
|
354 List(){} |
|
355 |
|
356 List (int numvalues) : |
|
357 Super (numvalues) {} |
|
358 |
|
359 List (const Super& other) : |
|
360 Super (other) {} |
|
361 }; |
|
362 |
|
363 // ------------------------------------------------------------------------------------------------- |
|
364 // |
|
365 |
|
366 template<typename T> |
|
367 class Vector : public Container<T, std::vector<T> > |
349 class Vector : public Container<T, std::vector<T> > |
368 { |
350 { |
369 public: |
351 public: |
370 typedef Container<T, std::vector<T> > Super; |
352 typedef Container<T, std::vector<T> > Super; |
371 |
353 |
397 { |
379 { |
398 return data(); |
380 return data(); |
399 } |
381 } |
400 }; |
382 }; |
401 |
383 |
402 class ByteArray : public Vector<unsigned char> |
384 using ByteArray = std::vector<unsigned char>; |
403 { |
385 class String quote(const ByteArray& bytes); |
404 public: |
|
405 ByteArray(std::initializer_list<unsigned char> initializerList); |
|
406 |
|
407 template<typename ...Args> |
|
408 ByteArray(Args&& ...args); |
|
409 |
|
410 class String quote() const; |
|
411 }; |
|
412 |
|
413 /*! |
|
414 * \brief Constructs a byte array by passing all arguments to Vector<unsigned char>'s constructor. |
|
415 * \param args Arguments to pass. |
|
416 */ |
|
417 template<typename ...Args> |
|
418 ByteArray::ByteArray(Args&& ...args) : |
|
419 Vector<unsigned char>(args...) {} |
|
420 |
386 |
421 template<typename T> |
387 template<typename T> |
422 T splice(const T& container, int start, int end, int step = 1) |
388 T splice(const T& container, int start, int end, int step = 1) |
423 { |
389 { |
424 start = clamp(start, 0, static_cast<int>(container.size())); |
390 start = clamp(start, 0, static_cast<int>(container.size())); |