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++ Core » S_type and ValueMap
Re: S_type and ValueMap [message #52520 is a reply to message #52519] Tue, 15 October 2019 14:39 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 14261
Registered: November 2005
Ultimate Member
Giorgio wrote on Tue, 15 October 2019 13:54
Hi,
thank you for your suggestion.

This is what I came up with, I post it here for reference and improvements.


[...]
		//S_FILLER s(*vm); Crashes if it contains int or double
		S_FILLER s;
		S_convert(&s,vm);

[...]

	template <class T>
	void S_convert(T * s, ValueMap * vm){
	
		for(int i=0;i<vm->GetCount();i++){
			
			Ref r=s->GetRef(SqlId(vm->GetKey(i)));
			if(r.Is<double>())
				s->Set(SqlId(vm->GetKey(i)),StrDbl(AsString(vm->GetValue(i))));
				
			if(r.Is<int>())
				s->Set(SqlId(vm->GetKey(i)),StrInt(AsString(vm->GetValue(i))));
				
			if(r.Is<String>())
				s->Set(SqlId(vm->GetKey(i)),AsString(vm->GetValue(i)));
		}
		
	}




Why not


template <class T>
void S_convert(T& s, const ValueMap& vm){

?

Mirek
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Doubt about container
Next Topic: [SOLVED] Vector Bug
Goto Forum:
  


Current Time: Mon Jun 16 23:01:47 CEST 2025

Total time taken to generate the page: 0.03712 seconds