25 #include <boost/unordered_map.hpp>
29 namespace RobotRaconteur
37 class ROBOTRACONTEUR_CORE_API StringTableEntry
42 MessageStringPtr value;
45 std::vector<uint32_t> table_flags;
48 class ROBOTRACONTEUR_CORE_API StringTable :
private boost::noncopyable
51 StringTable(
bool server);
52 virtual ~StringTable();
54 uint32_t GetCodeForString(MessageStringRef str);
55 bool GetStringForCode(uint32_t code, MessageStringPtr& str);
57 RR_SHARED_PTR<const StringTableEntry> GetEntryForString(MessageStringRef str);
58 RR_SHARED_PTR<const StringTableEntry> GetEntryForCode(uint32_t code);
60 bool AddCode(uint32_t code, MessageStringRef str,
const std::vector<uint32_t>& table_flags);
61 void AddCodesCSV(
const std::string& csv,
const std::vector<uint32_t>& table_flags);
63 void MessageReplaceStringsWithCodes(
const RR_INTRUSIVE_PTR<Message>& m);
64 void MessageReplaceCodesWithStrings(
const RR_INTRUSIVE_PTR<Message>& m);
66 std::vector<uint32_t> GetTableFlags();
67 void SetTableFlags(std::vector<uint32_t> flags);
70 void MessageEntryReplaceStringsWithCodes(
const RR_INTRUSIVE_PTR<MessageEntry>& e,
71 boost::unordered_map<MessageStringPtr, uint32_t>& local_table,
72 uint32_t& next_local_code, uint32_t& table_size);
73 void MessageElementReplaceStringsWithCodes(
const RR_INTRUSIVE_PTR<MessageElement>& e,
74 boost::unordered_map<MessageStringPtr, uint32_t>& local_table,
75 uint32_t& next_local_code, uint32_t& table_size);
76 void MessageEntryReplaceCodesWithStrings(
const RR_INTRUSIVE_PTR<MessageEntry>& e,
77 boost::unordered_map<uint32_t, MessageStringPtr>& local_table);
78 void MessageElementReplaceCodesWithStrings(
const RR_INTRUSIVE_PTR<MessageElement>& e,
79 boost::unordered_map<uint32_t, MessageStringPtr>& local_table);
81 void DoReplaceString(MessageStringPtr& str, uint32_t& code, uint8_t& flags, uint32_t flag_str, uint32_t flag_code,
82 boost::unordered_map<MessageStringPtr, uint32_t>& local_table, uint32_t& next_local_code,
83 uint32_t& table_size);
84 void DoReplaceCode(MessageStringPtr& str, uint32_t& code, uint8_t& flags, uint32_t flag_str, uint32_t flag_code,
85 boost::unordered_map<uint32_t, MessageStringPtr>& local_table);
87 bool AddCode_p(uint32_t code, MessageStringRef str,
const std::vector<uint32_t>& table_flags);
88 void AddCodesCSV_p(
const std::string& csv,
const std::vector<uint32_t>& table_flags);
92 size_t max_entry_count;
96 boost::mutex this_lock;
98 RR_UNORDERED_MAP<uint32_t, RR_SHARED_PTR<StringTableEntry> > code_table;
99 RR_UNORDERED_MAP<MessageStringPtr, RR_SHARED_PTR<StringTableEntry> > string_table;