1 // Copyright 2020 The Pigweed Authors
3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not
4 // use this file except in compliance with the License. You may obtain a copy of
7 // https://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 // License for the specific language governing permissions and limitations under
21 #include "pw_tokenizer/config.h"
22 #include "pw_tokenizer/internal/argument_types.h"
23 #include "pw_tokenizer/tokenize.h"
28 // Buffer for encoding a tokenized string and arguments.
29 struct EncodedMessage {
30 pw_tokenizer_Token token;
32 PW_TOKENIZER_CFG_ENCODING_BUFFER_SIZE_BYTES - sizeof(token)>
36 static_assert(PW_TOKENIZER_CFG_ENCODING_BUFFER_SIZE_BYTES >=
37 sizeof(pw_tokenizer_Token),
38 "PW_TOKENIZER_CFG_ENCODING_BUFFER_SIZE_BYTES must be at least "
39 "large enough for a token (4 bytes)");
41 static_assert(offsetof(EncodedMessage, args) == sizeof(EncodedMessage::token) &&
42 PW_TOKENIZER_CFG_ENCODING_BUFFER_SIZE_BYTES ==
43 sizeof(EncodedMessage),
44 "EncodedMessage should not have padding bytes between members");
46 // Encodes a tokenized string's arguments to a buffer. The
47 // _pw_tokenizer_ArgTypes parameter specifies the argument types, in place of a
49 size_t EncodeArgs(_pw_tokenizer_ArgTypes types,
51 std::span<uint8_t> output);
53 } // namespace tokenizer