From 2fb45f3f5aaff609693b52fce1e3efe6c45601f5 Mon Sep 17 00:00:00 2001 From: Marcus O'Flaherty Date: Fri, 13 Dec 2024 14:07:53 +0000 Subject: [PATCH 1/3] add insertion operator << definition to Store class --- src/Store/Store.cpp | 16 +++++++++++++++- src/Store/Store.h | 5 ++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/Store/Store.cpp b/src/Store/Store.cpp index d08a5ef..79d4004 100644 --- a/src/Store/Store.cpp +++ b/src/Store/Store.cpp @@ -1,6 +1,6 @@ #include "Store.h" -using namespace ToolFramework; +namespace ToolFramework { Store::Store(){} @@ -211,3 +211,17 @@ bool Store::Destring(std::string key){ return true; } + +std::ostream& operator<<(std::ostream& stream, const Store& s){ + stream<<"{"; + bool first=true; + for(auto it=s.m_variables.begin(); it!=s.m_variables.end(); ++it){ + if (!first) stream<<","; + stream<<"\""<first<<"\":"<< it->second<<" "; + first=false; + } + stream<<"}"; + return stream; +} + +} diff --git a/src/Store/Store.h b/src/Store/Store.h index 696ca64..89c0fe8 100644 --- a/src/Store/Store.h +++ b/src/Store/Store.h @@ -215,6 +215,8 @@ namespace ToolFramework{ } + friend std::ostream& operator<<(std::ostream &stream, const Store &s); + std::map::iterator begin() { return m_variables.begin(); } std::map::iterator end() { return m_variables.end(); } @@ -227,6 +229,7 @@ namespace ToolFramework{ }; -} +} // end ToolFramework namespace + #endif From 58d396ef265cb2d0eb2105d607a9a918d7ee1282 Mon Sep 17 00:00:00 2001 From: brichards64 Date: Fri, 13 Dec 2024 15:19:16 +0000 Subject: [PATCH 2/3] Update Store.cpp --- src/Store/Store.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Store/Store.cpp b/src/Store/Store.cpp index 79d4004..2eaade9 100644 --- a/src/Store/Store.cpp +++ b/src/Store/Store.cpp @@ -216,8 +216,8 @@ std::ostream& operator<<(std::ostream& stream, const Store& s){ stream<<"{"; bool first=true; for(auto it=s.m_variables.begin(); it!=s.m_variables.end(); ++it){ - if (!first) stream<<","; - stream<<"\""<first<<"\":"<< it->second<<" "; + if (!first) stream<<", "; + stream<<"\""<first<<"\":"<< it->second; first=false; } stream<<"}"; From 695dcfc210b9dabdce9902ffffef4ef209ca2ee5 Mon Sep 17 00:00:00 2001 From: Marcus O'Flaherty Date: Fri, 13 Dec 2024 15:22:13 +0000 Subject: [PATCH 3/3] second comma update --- src/Store/Store.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Store/Store.h b/src/Store/Store.h index 89c0fe8..49526cc 100644 --- a/src/Store/Store.h +++ b/src/Store/Store.h @@ -204,8 +204,8 @@ namespace ToolFramework{ stream<<"{"; bool first=true; for (std::map::iterator it=m_variables.begin(); it!=m_variables.end(); ++it){ - if (!first) stream<<","; - stream<<"\""<first<<"\":"<< it->second<<" "; + if (!first) stream<<", "; + stream<<"\""<first<<"\":"<< it->second; first=false; }