mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-14 03:53:35 +08:00
MakeString<> helper template
This commit is contained in:
@@ -1087,6 +1087,19 @@ inline bool operator!=(const R& rhs, const Array<T, ArrayMode, MaxSize>& lhs)
|
||||
return lhs.operator!=(rhs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shortcut for string-like array type instantiation.
|
||||
* The proper way of doing this is actually "template<> using ... = ...", but this feature is not available in
|
||||
* older C++ revisions which the library has to support.
|
||||
*/
|
||||
template <unsigned MaxSize>
|
||||
class MakeString
|
||||
{
|
||||
MakeString(); // This class is not instantiatable.
|
||||
public:
|
||||
typedef Array<IntegerSpec<8, SignednessUnsigned, CastModeSaturate>, ArrayModeDynamic, MaxSize> Type;
|
||||
};
|
||||
|
||||
/**
|
||||
* YAML streamer specification for any Array<>
|
||||
*/
|
||||
|
||||
@@ -37,7 +37,7 @@ public:
|
||||
* This type is used to exchange data chunks with the backend.
|
||||
* It doesn't use any dynamic memory; please refer to the Array<> class for details.
|
||||
*/
|
||||
typedef Array<IntegerSpec<8, SignednessUnsigned, CastModeTruncate>, ArrayModeDynamic, MaxStringLength> String;
|
||||
typedef MakeString<MaxStringLength>::Type String;
|
||||
|
||||
/**
|
||||
* Read one value from the storage.
|
||||
|
||||
+1
-2
@@ -34,8 +34,7 @@ class FileEventTracer : public uavcan::dynamic_node_id_server::IEventTracer
|
||||
/**
|
||||
* This type is used for the path
|
||||
*/
|
||||
typedef uavcan::Array<uavcan::IntegerSpec<8, uavcan::SignednessUnsigned, uavcan::CastModeTruncate>,
|
||||
uavcan::ArrayModeDynamic, MaxPathLength> PathString;
|
||||
typedef uavcan::MakeString<MaxPathLength>::Type PathString;
|
||||
|
||||
PathString path_;
|
||||
|
||||
|
||||
+1
-2
@@ -39,8 +39,7 @@ class FileStorageBackend : public uavcan::dynamic_node_id_server::IStorageBacken
|
||||
/**
|
||||
* This type is used for the path
|
||||
*/
|
||||
typedef uavcan::Array<uavcan::IntegerSpec<8, uavcan::SignednessUnsigned, uavcan::CastModeTruncate>,
|
||||
uavcan::ArrayModeDynamic, MaxPathLength> PathString;
|
||||
typedef uavcan::MakeString<MaxPathLength>::Type PathString;
|
||||
|
||||
PathString base_path;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user