Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ SQL » Jsonize() in database table structures (S_*) [patch]
Jsonize() in database table structures (S_*) [patch] [message #57138] Mon, 31 May 2021 04:36
zsolt is currently offline  zsolt
Messages: 698
Registered: December 2005
Location: Budapest, Hungary
Contributor
It was missing for me.

uppsrc/Sql/S_info.cpp:
@@ -94,6 +94,15 @@ SqlSet S_info::GetOf(const SqlId& table) const
 	return set;
 }
 
+void S_info::Jsonize(const void *s, JsonIO& io) const
+{
+	for(int i = 0; i < column.GetCount(); i++)
+		if(io.IsLoading())
+			Set(s, i, io.Get(~column.GetKey(i)));
+		else
+			io.Set(~column.GetKey(i), Get(s, i));
+}
+
 void S_info::Init()
 {
 	column.Shrink();


uppsrc/Sql/SqlSchema.h:
@@ -173,6 +173,8 @@ struct S_info {
 	
 	SqlSet   GetSet(const String& prefix) const;
 	SqlSet   GetOf(const SqlId& table) const;
+
+	void     Jsonize(const void *s, JsonIO& io) const;
 	
 	void     Init();
 };


uppsrc/Sql/sch_header.h:
@@ -39,7 +39,7 @@ public: \
 	void                        Set(const Upp::ValueMap& m)                     { return info->Set(this, m); } \
 	\
 	operator                    const S_info&() const                 { return *info; } \
+	void                        Jsonize(JsonIO& io)                   { info->Jsonize(this, io); } \
 	\
 	S_##Table(); \
 	S_##Table(const Upp::ValueMap& m);
Previous Topic: simple example sqlite ref. not working core console
Next Topic: Application with two different databases schema
Goto Forum:
  


Current Time: Fri Jun 21 22:29:10 CEST 2024

Total time taken to generate the page: 0.01521 seconds