List.cpp 830 B

12345678910111213141516171819202122232425262728293031
  1. // Copyright Benoit Blanchon 2014
  2. // MIT License
  3. //
  4. // Arduino JSON library
  5. // https://github.com/bblanchon/ArduinoJson
  6. #include "../../include/ArduinoJson/Internals/List.hpp"
  7. #include "../../include/ArduinoJson/Internals/PlacementNew.hpp"
  8. #include "../../include/ArduinoJson/JsonPair.hpp"
  9. #include "../../include/ArduinoJson/JsonVariant.hpp"
  10. using namespace ArduinoJson;
  11. using namespace ArduinoJson::Internals;
  12. template <typename T>
  13. int List<T>::size() const {
  14. int nodeCount = 0;
  15. for (node_type *node = _firstNode; node; node = node->next) nodeCount++;
  16. return nodeCount;
  17. }
  18. template <typename T>
  19. Node<T> *List<T>::createNode() {
  20. if (!_buffer) return NULL;
  21. void *ptr = _buffer->alloc(sizeof(node_type));
  22. return ptr ? new (ptr) node_type() : NULL;
  23. }
  24. template class List<JsonPair>;
  25. template class List<JsonVariant>;