WPILibC++ 2025.2.1
Loading...
Searching...
No Matches
NetworkTableValue.h
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
7#include <stdint.h>
8
9#include <cassert>
10#include <concepts>
11#include <initializer_list>
12#include <memory>
13#include <span>
14#include <string>
15#include <string_view>
16#include <utility>
17#include <vector>
18
19#include "ntcore_c.h"
20
21namespace nt {
22
23// Forward declare here to avoid circular dependency on ntcore_cpp.h
24int64_t Now();
25
26#if __GNUC__ >= 13
27#pragma GCC diagnostic push
28#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
29#endif
30
31/**
32 * A network table entry value.
33 * @ingroup ntcore_cpp_api
34 */
35class Value final {
36 struct private_init {};
37
38 public:
40 m_val.type = NT_UNASSIGNED;
41 m_val.last_change = 0;
42 m_val.server_time = 0;
43 }
44
45 Value(NT_Type type, size_t size, int64_t time, const private_init&)
46 : Value{type, size, time == 0 ? Now() : time, 1, private_init{}} {}
47
48 Value(NT_Type type, size_t size, int64_t time, int64_t serverTime,
49 const private_init&)
50 : m_size{size} {
51 m_val.type = type;
52 m_val.last_change = time;
53 m_val.server_time = serverTime;
54 switch (type) {
56 m_val.data.arr_boolean.arr = nullptr;
57 break;
59 m_val.data.arr_int.arr = nullptr;
60 break;
61 case NT_FLOAT_ARRAY:
62 m_val.data.arr_float.arr = nullptr;
63 break;
64 case NT_DOUBLE_ARRAY:
65 m_val.data.arr_double.arr = nullptr;
66 break;
67 case NT_STRING_ARRAY:
68 m_val.data.arr_string.arr = nullptr;
69 break;
70 default:
71 break;
72 }
73 }
74
75 explicit operator bool() const { return m_val.type != NT_UNASSIGNED; }
76
77 /**
78 * Get the data type.
79 *
80 * @return The type.
81 */
82 NT_Type type() const { return m_val.type; }
83
84 /**
85 * Get the data value stored.
86 *
87 * @return The type.
88 */
89 const NT_Value& value() const { return m_val; }
90
91 /**
92 * Get the creation time of the value, in local time.
93 *
94 * @return The time, in the units returned by nt::Now().
95 */
96 int64_t last_change() const { return m_val.last_change; }
97
98 /**
99 * Get the creation time of the value, in local time.
100 *
101 * @return The time, in the units returned by nt::Now().
102 */
103 int64_t time() const { return m_val.last_change; }
104
105 /**
106 * Get the approximate in-memory size of the value in bytes. This is zero for
107 * values that do not require additional memory beyond the memory of the Value
108 * itself.
109 *
110 * @return The size in bytes.
111 */
112 size_t size() const { return m_size; }
113
114 /**
115 * Set the local creation time of the value.
116 *
117 * @param time The time.
118 */
119 void SetTime(int64_t time) { m_val.last_change = time; }
120
121 /**
122 * Get the creation time of the value, in server time.
123 *
124 * @return The server time.
125 */
126 int64_t server_time() const { return m_val.server_time; }
127
128 /**
129 * Set the creation time of the value, in server time.
130 *
131 * @param time The server time.
132 */
133 void SetServerTime(int64_t time) { m_val.server_time = time; }
134
135 /**
136 * @{
137 * @name Type Checkers
138 */
139
140 /**
141 * Determine if entry value contains a value or is unassigned.
142 *
143 * @return True if the entry value contains a value.
144 */
145 bool IsValid() const { return m_val.type != NT_UNASSIGNED; }
146
147 /**
148 * Determine if entry value contains a boolean.
149 *
150 * @return True if the entry value is of boolean type.
151 */
152 bool IsBoolean() const { return m_val.type == NT_BOOLEAN; }
153
154 /**
155 * Determine if entry value contains an integer.
156 *
157 * @return True if the entry value is of integer type.
158 */
159 bool IsInteger() const { return m_val.type == NT_INTEGER; }
160
161 /**
162 * Determine if entry value contains a float.
163 *
164 * @return True if the entry value is of float type.
165 */
166 bool IsFloat() const { return m_val.type == NT_FLOAT; }
167
168 /**
169 * Determine if entry value contains a double.
170 *
171 * @return True if the entry value is of double type.
172 */
173 bool IsDouble() const { return m_val.type == NT_DOUBLE; }
174
175 /**
176 * Determine if entry value contains a string.
177 *
178 * @return True if the entry value is of string type.
179 */
180 bool IsString() const { return m_val.type == NT_STRING; }
181
182 /**
183 * Determine if entry value contains a raw.
184 *
185 * @return True if the entry value is of raw type.
186 */
187 bool IsRaw() const { return m_val.type == NT_RAW; }
188
189 /**
190 * Determine if entry value contains a boolean array.
191 *
192 * @return True if the entry value is of boolean array type.
193 */
194 bool IsBooleanArray() const { return m_val.type == NT_BOOLEAN_ARRAY; }
195
196 /**
197 * Determine if entry value contains an integer array.
198 *
199 * @return True if the entry value is of integer array type.
200 */
201 bool IsIntegerArray() const { return m_val.type == NT_INTEGER_ARRAY; }
202
203 /**
204 * Determine if entry value contains a float array.
205 *
206 * @return True if the entry value is of float array type.
207 */
208 bool IsFloatArray() const { return m_val.type == NT_FLOAT_ARRAY; }
209
210 /**
211 * Determine if entry value contains a double array.
212 *
213 * @return True if the entry value is of double array type.
214 */
215 bool IsDoubleArray() const { return m_val.type == NT_DOUBLE_ARRAY; }
216
217 /**
218 * Determine if entry value contains a string array.
219 *
220 * @return True if the entry value is of string array type.
221 */
222 bool IsStringArray() const { return m_val.type == NT_STRING_ARRAY; }
223
224 /** @} */
225
226 /**
227 * @{
228 * @name Type-Safe Getters
229 */
230
231 /**
232 * Get the entry's boolean value.
233 *
234 * @return The boolean value.
235 */
236 bool GetBoolean() const {
237 assert(m_val.type == NT_BOOLEAN);
238 return m_val.data.v_boolean != 0;
239 }
240
241 /**
242 * Get the entry's integer value.
243 *
244 * @return The integer value.
245 */
246 int64_t GetInteger() const {
247 assert(m_val.type == NT_INTEGER);
248 return m_val.data.v_int;
249 }
250
251 /**
252 * Get the entry's float value.
253 *
254 * @return The float value.
255 */
256 float GetFloat() const {
257 assert(m_val.type == NT_FLOAT);
258 return m_val.data.v_float;
259 }
260
261 /**
262 * Get the entry's double value.
263 *
264 * @return The double value.
265 */
266 double GetDouble() const {
267 assert(m_val.type == NT_DOUBLE);
268 return m_val.data.v_double;
269 }
270
271 /**
272 * Get the entry's string value.
273 *
274 * @return The string value.
275 */
276 std::string_view GetString() const {
277 assert(m_val.type == NT_STRING);
278 return {m_val.data.v_string.str, m_val.data.v_string.len};
279 }
280
281 /**
282 * Get the entry's raw value.
283 *
284 * @return The raw value.
285 */
286 std::span<const uint8_t> GetRaw() const {
287 assert(m_val.type == NT_RAW);
288 return {m_val.data.v_raw.data, m_val.data.v_raw.size};
289 }
290
291 /**
292 * Get the entry's boolean array value.
293 *
294 * @return The boolean array value.
295 */
296 std::span<const int> GetBooleanArray() const {
297 assert(m_val.type == NT_BOOLEAN_ARRAY);
298 return {m_val.data.arr_boolean.arr, m_val.data.arr_boolean.size};
299 }
300
301 /**
302 * Get the entry's integer array value.
303 *
304 * @return The integer array value.
305 */
306 std::span<const int64_t> GetIntegerArray() const {
307 assert(m_val.type == NT_INTEGER_ARRAY);
308 return {m_val.data.arr_int.arr, m_val.data.arr_int.size};
309 }
310
311 /**
312 * Get the entry's float array value.
313 *
314 * @return The float array value.
315 */
316 std::span<const float> GetFloatArray() const {
317 assert(m_val.type == NT_FLOAT_ARRAY);
318 return {m_val.data.arr_float.arr, m_val.data.arr_float.size};
319 }
320
321 /**
322 * Get the entry's double array value.
323 *
324 * @return The double array value.
325 */
326 std::span<const double> GetDoubleArray() const {
327 assert(m_val.type == NT_DOUBLE_ARRAY);
328 return {m_val.data.arr_double.arr, m_val.data.arr_double.size};
329 }
330
331 /**
332 * Get the entry's string array value.
333 *
334 * @return The string array value.
335 */
336 std::span<const std::string> GetStringArray() const {
337 assert(m_val.type == NT_STRING_ARRAY);
338 return *static_cast<std::vector<std::string>*>(m_storage.get());
339 }
340
341 /** @} */
342
343 /**
344 * @{
345 * @name Factory functions
346 */
347
348 /**
349 * Creates a boolean entry value.
350 *
351 * @param value the value
352 * @param time if nonzero, the creation time to use (instead of the current
353 * time)
354 * @return The entry value
355 */
356 static Value MakeBoolean(bool value, int64_t time = 0) {
357 Value val{NT_BOOLEAN, 0, time, private_init{}};
358 val.m_val.data.v_boolean = value;
359 return val;
360 }
361
362 /**
363 * Creates an integer entry value.
364 *
365 * @param value the value
366 * @param time if nonzero, the creation time to use (instead of the current
367 * time)
368 * @return The entry value
369 */
370 static Value MakeInteger(int64_t value, int64_t time = 0) {
371 Value val{NT_INTEGER, 0, time, private_init{}};
372 val.m_val.data.v_int = value;
373 return val;
374 }
375
376 /**
377 * Creates a float entry value.
378 *
379 * @param value the value
380 * @param time if nonzero, the creation time to use (instead of the current
381 * time)
382 * @return The entry value
383 */
384 static Value MakeFloat(float value, int64_t time = 0) {
385 Value val{NT_FLOAT, 0, time, private_init{}};
386 val.m_val.data.v_float = value;
387 return val;
388 }
389
390 /**
391 * Creates a double entry value.
392 *
393 * @param value the value
394 * @param time if nonzero, the creation time to use (instead of the current
395 * time)
396 * @return The entry value
397 */
398 static Value MakeDouble(double value, int64_t time = 0) {
399 Value val{NT_DOUBLE, 0, time, private_init{}};
400 val.m_val.data.v_double = value;
401 return val;
402 }
403
404 /**
405 * Creates a string entry value.
406 *
407 * @param value the value
408 * @param time if nonzero, the creation time to use (instead of the current
409 * time)
410 * @return The entry value
411 */
412 static Value MakeString(std::string_view value, int64_t time = 0) {
413 auto data = std::make_shared<std::string>(value);
414 Value val{NT_STRING, data->capacity(), time, private_init{}};
415 val.m_val.data.v_string.str = const_cast<char*>(data->c_str());
416 val.m_val.data.v_string.len = data->size();
417 val.m_storage = std::move(data);
418 return val;
419 }
420
421 /**
422 * Creates a string entry value.
423 *
424 * @param value the value
425 * @param time if nonzero, the creation time to use (instead of the current
426 * time)
427 * @return The entry value
428 */
429 template <std::same_as<std::string> T>
430 static Value MakeString(T&& value, int64_t time = 0) {
431 auto data = std::make_shared<std::string>(std::forward<T>(value));
432 Value val{NT_STRING, data->capacity(), time, private_init{}};
433 val.m_val.data.v_string.str = const_cast<char*>(data->c_str());
434 val.m_val.data.v_string.len = data->size();
435 val.m_storage = std::move(data);
436 return val;
437 }
438
439 /**
440 * Creates a raw entry value.
441 *
442 * @param value the value
443 * @param time if nonzero, the creation time to use (instead of the current
444 * time)
445 * @return The entry value
446 */
447 static Value MakeRaw(std::span<const uint8_t> value, int64_t time = 0) {
448 auto data =
449 std::make_shared<std::vector<uint8_t>>(value.begin(), value.end());
450 Value val{NT_RAW, data->capacity(), time, private_init{}};
451 val.m_val.data.v_raw.data = const_cast<uint8_t*>(data->data());
452 val.m_val.data.v_raw.size = data->size();
453 val.m_storage = std::move(data);
454 return val;
455 }
456
457 /**
458 * Creates a raw entry value.
459 *
460 * @param value the value
461 * @param time if nonzero, the creation time to use (instead of the current
462 * time)
463 * @return The entry value
464 */
465 template <std::same_as<std::vector<uint8_t>> T>
466 static Value MakeRaw(T&& value, int64_t time = 0) {
467 auto data = std::make_shared<std::vector<uint8_t>>(std::forward<T>(value));
468 Value val{NT_RAW, data->capacity(), time, private_init{}};
469 val.m_val.data.v_raw.data = const_cast<uint8_t*>(data->data());
470 val.m_val.data.v_raw.size = data->size();
471 val.m_storage = std::move(data);
472 return val;
473 }
474
475 /**
476 * Creates a boolean array entry value.
477 *
478 * @param value the value
479 * @param time if nonzero, the creation time to use (instead of the current
480 * time)
481 * @return The entry value
482 */
483 static Value MakeBooleanArray(std::span<const bool> value, int64_t time = 0);
484
485 /**
486 * Creates a boolean array entry value.
487 *
488 * @param value the value
489 * @param time if nonzero, the creation time to use (instead of the current
490 * time)
491 * @return The entry value
492 */
493 static Value MakeBooleanArray(std::initializer_list<bool> value,
494 int64_t time = 0) {
495 return MakeBooleanArray(std::span(value.begin(), value.end()), time);
496 }
497
498 /**
499 * Creates a boolean array entry value.
500 *
501 * @param value the value
502 * @param time if nonzero, the creation time to use (instead of the current
503 * time)
504 * @return The entry value
505 */
506 static Value MakeBooleanArray(std::span<const int> value, int64_t time = 0);
507
508 /**
509 * Creates a boolean array entry value.
510 *
511 * @param value the value
512 * @param time if nonzero, the creation time to use (instead of the current
513 * time)
514 * @return The entry value
515 */
516 static Value MakeBooleanArray(std::initializer_list<int> value,
517 int64_t time = 0) {
518 return MakeBooleanArray(std::span(value.begin(), value.end()), time);
519 }
520
521 /**
522 * Creates a boolean array entry value.
523 *
524 * @param value the value
525 * @param time if nonzero, the creation time to use (instead of the current
526 * time)
527 * @return The entry value
528 *
529 * @note This function moves the values out of the vector.
530 */
531 static Value MakeBooleanArray(std::vector<int>&& value, int64_t time = 0);
532
533 /**
534 * Creates an integer array entry value.
535 *
536 * @param value the value
537 * @param time if nonzero, the creation time to use (instead of the current
538 * time)
539 * @return The entry value
540 */
541 static Value MakeIntegerArray(std::span<const int64_t> value,
542 int64_t time = 0);
543
544 /**
545 * Creates an integer array entry value.
546 *
547 * @param value the value
548 * @param time if nonzero, the creation time to use (instead of the current
549 * time)
550 * @return The entry value
551 */
552 static Value MakeIntegerArray(std::initializer_list<int64_t> value,
553 int64_t time = 0) {
554 return MakeIntegerArray(std::span(value.begin(), value.end()), time);
555 }
556
557 /**
558 * Creates an integer array entry value.
559 *
560 * @param value the value
561 * @param time if nonzero, the creation time to use (instead of the current
562 * time)
563 * @return The entry value
564 *
565 * @note This function moves the values out of the vector.
566 */
567 static Value MakeIntegerArray(std::vector<int64_t>&& value, int64_t time = 0);
568
569 /**
570 * Creates a float array entry value.
571 *
572 * @param value the value
573 * @param time if nonzero, the creation time to use (instead of the current
574 * time)
575 * @return The entry value
576 */
577 static Value MakeFloatArray(std::span<const float> value, int64_t time = 0);
578
579 /**
580 * Creates a float array entry value.
581 *
582 * @param value the value
583 * @param time if nonzero, the creation time to use (instead of the current
584 * time)
585 * @return The entry value
586 */
587 static Value MakeFloatArray(std::initializer_list<float> value,
588 int64_t time = 0) {
589 return MakeFloatArray(std::span(value.begin(), value.end()), time);
590 }
591
592 /**
593 * Creates a float array entry value.
594 *
595 * @param value the value
596 * @param time if nonzero, the creation time to use (instead of the current
597 * time)
598 * @return The entry value
599 *
600 * @note This function moves the values out of the vector.
601 */
602 static Value MakeFloatArray(std::vector<float>&& value, int64_t time = 0);
603
604 /**
605 * Creates a double array entry value.
606 *
607 * @param value the value
608 * @param time if nonzero, the creation time to use (instead of the current
609 * time)
610 * @return The entry value
611 */
612 static Value MakeDoubleArray(std::span<const double> value, int64_t time = 0);
613
614 /**
615 * Creates a double array entry value.
616 *
617 * @param value the value
618 * @param time if nonzero, the creation time to use (instead of the current
619 * time)
620 * @return The entry value
621 */
622 static Value MakeDoubleArray(std::initializer_list<double> value,
623 int64_t time = 0) {
624 return MakeDoubleArray(std::span(value.begin(), value.end()), time);
625 }
626
627 /**
628 * Creates a double array entry value.
629 *
630 * @param value the value
631 * @param time if nonzero, the creation time to use (instead of the current
632 * time)
633 * @return The entry value
634 *
635 * @note This function moves the values out of the vector.
636 */
637 static Value MakeDoubleArray(std::vector<double>&& value, int64_t time = 0);
638
639 /**
640 * Creates a string array entry value.
641 *
642 * @param value the value
643 * @param time if nonzero, the creation time to use (instead of the current
644 * time)
645 * @return The entry value
646 */
647 static Value MakeStringArray(std::span<const std::string> value,
648 int64_t time = 0);
649
650 /**
651 * Creates a string array entry value.
652 *
653 * @param value the value
654 * @param time if nonzero, the creation time to use (instead of the current
655 * time)
656 * @return The entry value
657 */
658 static Value MakeStringArray(std::initializer_list<std::string> value,
659 int64_t time = 0) {
660 return MakeStringArray(std::span(value.begin(), value.end()), time);
661 }
662
663 /**
664 * Creates a string array entry value.
665 *
666 * @param value the value
667 * @param time if nonzero, the creation time to use (instead of the current
668 * time)
669 * @return The entry value
670 *
671 * @note This function moves the values out of the vector.
672 */
673 static Value MakeStringArray(std::vector<std::string>&& value,
674 int64_t time = 0);
675
676 /** @} */
677
678 friend bool operator==(const Value& lhs, const Value& rhs);
679
680 private:
681 NT_Value m_val = {};
682 std::shared_ptr<void> m_storage;
683 size_t m_size = 0;
684};
685
686#if __GNUC__ >= 13
687#pragma GCC diagnostic pop
688#endif
689
690bool operator==(const Value& lhs, const Value& rhs);
691
692/**
693 * NetworkTable Value alias for similarity with Java.
694 * @ingroup ntcore_cpp_api
695 */
697
698} // namespace nt
A network table entry value.
Definition NetworkTableValue.h:35
static Value MakeStringArray(std::vector< std::string > &&value, int64_t time=0)
Creates a string array entry value.
Value()
Definition NetworkTableValue.h:39
static Value MakeBoolean(bool value, int64_t time=0)
Creates a boolean entry value.
Definition NetworkTableValue.h:356
int64_t server_time() const
Get the creation time of the value, in server time.
Definition NetworkTableValue.h:126
static Value MakeIntegerArray(std::vector< int64_t > &&value, int64_t time=0)
Creates an integer array entry value.
static Value MakeBooleanArray(std::vector< int > &&value, int64_t time=0)
Creates a boolean array entry value.
static Value MakeFloat(float value, int64_t time=0)
Creates a float entry value.
Definition NetworkTableValue.h:384
static Value MakeString(T &&value, int64_t time=0)
Creates a string entry value.
Definition NetworkTableValue.h:430
static Value MakeFloatArray(std::initializer_list< float > value, int64_t time=0)
Creates a float array entry value.
Definition NetworkTableValue.h:587
static Value MakeBooleanArray(std::initializer_list< int > value, int64_t time=0)
Creates a boolean array entry value.
Definition NetworkTableValue.h:516
bool IsValid() const
Determine if entry value contains a value or is unassigned.
Definition NetworkTableValue.h:145
bool IsBooleanArray() const
Determine if entry value contains a boolean array.
Definition NetworkTableValue.h:194
std::span< const int64_t > GetIntegerArray() const
Get the entry's integer array value.
Definition NetworkTableValue.h:306
static Value MakeFloatArray(std::span< const float > value, int64_t time=0)
Creates a float array entry value.
bool IsRaw() const
Determine if entry value contains a raw.
Definition NetworkTableValue.h:187
static Value MakeRaw(std::span< const uint8_t > value, int64_t time=0)
Creates a raw entry value.
Definition NetworkTableValue.h:447
static Value MakeDoubleArray(std::vector< double > &&value, int64_t time=0)
Creates a double array entry value.
bool IsIntegerArray() const
Determine if entry value contains an integer array.
Definition NetworkTableValue.h:201
bool IsDouble() const
Determine if entry value contains a double.
Definition NetworkTableValue.h:173
NT_Type type() const
Get the data type.
Definition NetworkTableValue.h:82
friend bool operator==(const Value &lhs, const Value &rhs)
static Value MakeIntegerArray(std::span< const int64_t > value, int64_t time=0)
Creates an integer array entry value.
float GetFloat() const
Get the entry's float value.
Definition NetworkTableValue.h:256
static Value MakeString(std::string_view value, int64_t time=0)
Creates a string entry value.
Definition NetworkTableValue.h:412
std::span< const float > GetFloatArray() const
Get the entry's float array value.
Definition NetworkTableValue.h:316
int64_t last_change() const
Get the creation time of the value, in local time.
Definition NetworkTableValue.h:96
bool IsDoubleArray() const
Determine if entry value contains a double array.
Definition NetworkTableValue.h:215
static Value MakeBooleanArray(std::span< const int > value, int64_t time=0)
Creates a boolean array entry value.
static Value MakeStringArray(std::initializer_list< std::string > value, int64_t time=0)
Creates a string array entry value.
Definition NetworkTableValue.h:658
bool IsFloat() const
Determine if entry value contains a float.
Definition NetworkTableValue.h:166
static Value MakeRaw(T &&value, int64_t time=0)
Creates a raw entry value.
Definition NetworkTableValue.h:466
bool IsStringArray() const
Determine if entry value contains a string array.
Definition NetworkTableValue.h:222
static Value MakeDoubleArray(std::span< const double > value, int64_t time=0)
Creates a double array entry value.
void SetServerTime(int64_t time)
Set the creation time of the value, in server time.
Definition NetworkTableValue.h:133
double GetDouble() const
Get the entry's double value.
Definition NetworkTableValue.h:266
bool IsInteger() const
Determine if entry value contains an integer.
Definition NetworkTableValue.h:159
const NT_Value & value() const
Get the data value stored.
Definition NetworkTableValue.h:89
static Value MakeFloatArray(std::vector< float > &&value, int64_t time=0)
Creates a float array entry value.
static Value MakeStringArray(std::span< const std::string > value, int64_t time=0)
Creates a string array entry value.
Value(NT_Type type, size_t size, int64_t time, const private_init &)
Definition NetworkTableValue.h:45
std::span< const std::string > GetStringArray() const
Get the entry's string array value.
Definition NetworkTableValue.h:336
static Value MakeDouble(double value, int64_t time=0)
Creates a double entry value.
Definition NetworkTableValue.h:398
int64_t GetInteger() const
Get the entry's integer value.
Definition NetworkTableValue.h:246
std::span< const double > GetDoubleArray() const
Get the entry's double array value.
Definition NetworkTableValue.h:326
std::span< const uint8_t > GetRaw() const
Get the entry's raw value.
Definition NetworkTableValue.h:286
bool IsBoolean() const
Determine if entry value contains a boolean.
Definition NetworkTableValue.h:152
bool IsString() const
Determine if entry value contains a string.
Definition NetworkTableValue.h:180
static Value MakeBooleanArray(std::span< const bool > value, int64_t time=0)
Creates a boolean array entry value.
static Value MakeInteger(int64_t value, int64_t time=0)
Creates an integer entry value.
Definition NetworkTableValue.h:370
bool GetBoolean() const
Get the entry's boolean value.
Definition NetworkTableValue.h:236
size_t size() const
Get the approximate in-memory size of the value in bytes.
Definition NetworkTableValue.h:112
bool IsFloatArray() const
Determine if entry value contains a float array.
Definition NetworkTableValue.h:208
Value(NT_Type type, size_t size, int64_t time, int64_t serverTime, const private_init &)
Definition NetworkTableValue.h:48
std::string_view GetString() const
Get the entry's string value.
Definition NetworkTableValue.h:276
std::span< const int > GetBooleanArray() const
Get the entry's boolean array value.
Definition NetworkTableValue.h:296
static Value MakeBooleanArray(std::initializer_list< bool > value, int64_t time=0)
Creates a boolean array entry value.
Definition NetworkTableValue.h:493
static Value MakeDoubleArray(std::initializer_list< double > value, int64_t time=0)
Creates a double array entry value.
Definition NetworkTableValue.h:622
void SetTime(int64_t time)
Set the local creation time of the value.
Definition NetworkTableValue.h:119
static Value MakeIntegerArray(std::initializer_list< int64_t > value, int64_t time=0)
Creates an integer array entry value.
Definition NetworkTableValue.h:552
int64_t time() const
Get the creation time of the value, in local time.
Definition NetworkTableValue.h:103
NT_Type
NetworkTables data types.
Definition ntcore_c.h:53
@ NT_DOUBLE
Definition ntcore_c.h:56
@ NT_BOOLEAN
Definition ntcore_c.h:55
@ NT_DOUBLE_ARRAY
Definition ntcore_c.h:60
@ NT_STRING
Definition ntcore_c.h:57
@ NT_FLOAT_ARRAY
Definition ntcore_c.h:66
@ NT_INTEGER
Definition ntcore_c.h:63
@ NT_BOOLEAN_ARRAY
Definition ntcore_c.h:59
@ NT_FLOAT
Definition ntcore_c.h:64
@ NT_STRING_ARRAY
Definition ntcore_c.h:61
@ NT_INTEGER_ARRAY
Definition ntcore_c.h:65
@ NT_UNASSIGNED
Definition ntcore_c.h:54
@ NT_RAW
Definition ntcore_c.h:58
int64_t Now()
Returns monotonic current time in 1 us increments.
NetworkTables (ntcore) namespace.
Definition ntcore_cpp.h:36
bool operator==(const Value &lhs, const Value &rhs)
NetworkTables Entry Value.
Definition ntcore_c.h:135
enum NT_Type type
Definition ntcore_c.h:136
int64_t last_change
Definition ntcore_c.h:137
int64_t server_time
Definition ntcore_c.h:138
uint8_t * data
Definition ntcore_c.h:146