============================================================================== Helper class to hold and provide access to the arguments in a javascript function callback.
| 45 | /// Helper class to hold and provide access to the arguments in a javascript |
| 46 | /// function callback. |
| 47 | struct ArgumentList |
| 48 | { |
| 49 | const choc::value::Value* args = nullptr; |
| 50 | size_t numArgs = 0; |
| 51 | |
| 52 | /// Returns the number of arguments |
| 53 | size_t size() const noexcept { return numArgs; } |
| 54 | /// Returns true if there are no arguments |
| 55 | bool empty() const noexcept { return numArgs == 0; } |
| 56 | |
| 57 | /// Returns an argument, or a nullptr if the index is out of range. |
| 58 | const choc::value::Value* operator[] (size_t index) const { return index < numArgs ? args + index : nullptr; } |
| 59 | |
| 60 | /// Gets an argument as a primitive type (or a string). |
| 61 | /// If the index is out of range or the object isn't a suitable type, |
| 62 | /// then the default value provided will be returned instead. |
| 63 | template <typename PrimitiveType> |
| 64 | PrimitiveType get (size_t argIndex, PrimitiveType defaultValue = {}) const; |
| 65 | |
| 66 | /// Standard iterator |
| 67 | const choc::value::Value* begin() const noexcept { return args; } |
| 68 | const choc::value::Value* end() const noexcept { return args + numArgs; } |
| 69 | }; |
| 70 | |
| 71 | //============================================================================== |
| 72 | /** |
nothing calls this directly
no outgoing calls
no test coverage detected