Serialização wire
Helpers de baixo nível usados por wire::Protocol para montar mensagens de saída.
➕ appendWireToken
Section titled “➕ appendWireToken”Acrescenta um token em out, adicionando aspas e escapes quando tokenNeedsQuotes for true.
📝 Sintaxe
Section titled “📝 Sintaxe”bool appendWireToken(char* out, size_t outCap, size_t& pos, const char* s)🔮 Exemplo
Section titled “🔮 Exemplo”char buf[128];size_t pos = 0;wire::appendWireToken(buf, sizeof(buf), pos, "hello world");// buf == "\"hello world\""⏱ Complexidade
Section titled “⏱ Complexidade”O(|s|).
➕ appendComma
Section titled “➕ appendComma”Acrescenta uma vírgula ao buffer wire em construção.
📝 Sintaxe
Section titled “📝 Sintaxe”bool appendComma(char* buf, size_t cap, size_t& pos)⏱ Complexidade
Section titled “⏱ Complexidade”O(1).
📄 appendListBody
Section titled “📄 appendListBody”Serializa um body de lista nome(b,role,idx,...); em buf.
📝 Sintaxe
Section titled “📝 Sintaxe”bool appendListBody(char* buf, size_t cap, size_t& pos, const char* cmdName, char listMode, char listRole, int idx, const std::vector<const char*>& fields)🔮 Exemplo
Section titled “🔮 Exemplo”char buf[256];size_t pos = 0;wire::appendListBody(buf, sizeof(buf), pos, "param_list", 'b', 's', 0, {"param_a", "42"});// buf == "param_list(b,s,0,param_a,42);"⏱ Complexidade
Section titled “⏱ Complexidade”O(comprimento total dos campos).
📑 appendListHeader
Section titled “📑 appendListHeader”Serializa um header de lista nome(h,role,T,C,B,j); em buf.
📝 Sintaxe
Section titled “📝 Sintaxe”bool appendListHeader(char* buf, size_t cap, size_t& pos, const char* cmdName, char role, int T, int C, int B, int j)🔮 Exemplo
Section titled “🔮 Exemplo”char buf[128];size_t pos = 0;wire::appendListHeader(buf, sizeof(buf), pos, "param_list", 's', 5, 2, 1, 0);// buf == "param_list(h,s,5,2,1,0);"⏱ Complexidade
Section titled “⏱ Complexidade”O(1) (snprintf pequeno e fixo).
📏 listHeaderWireBytes
Section titled “📏 listHeaderWireBytes”Retorna o comprimento em bytes de um header de lista serializado (sem terminador nulo). Usado ao empacotar bodies sob kPackBudget.
📝 Sintaxe
Section titled “📝 Sintaxe”size_t listHeaderWireBytes(const char* cmdName, char role, int T, int C, int B, int j)⏱ Complexidade
Section titled “⏱ Complexidade”O(1).