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++ TheIDE » U++ TheIDE: CodeEditor, Assist++, Topic++ » Help VectorMap !!!
Help VectorMap !!! [message #12827] Mon, 19 November 2007 19:38 Go to next message
digodigo is currently offline  digodigo
Messages: 4
Registered: November 2007
Junior Member

I have a problem when I try to use 3 arguments Confused

see my source:

private:
VectorMap<String, String> mHostList;



Hosts::Hosts()
{
	mHostList.Clear();
	
	FileIn fs;
	if (fs.Open(".\\whls.cfg")) {
		while (!fs.IsEof()) {
			String line = fs.GetLine();
			
			int pos = line.Find(';');             
			int pos1 = line.Find(';', pos + 1);
			int pos2 = line.Find(';', pos1 - 1);
			
			if (pos > 0 && pos1 > 0 && pos2 > 0) {
				String id = line.Left(pos);
				
				String ipAddr = line.Mid(pos + 1, pos1 - pos - 1);
				
				
				String port = line.Right(line.GetLength() - pos2 - 1);
				
				
				[B]mHostList.Add(id, ipAddr, port);[/B] // error here !!!
				
			}
		}
		fs.Close();
	}
}




That appears error:

C:\MyApps\MyAplication\hosts.cpp(27) : error C2661: 'AMap<K,T,V,HashFn>::Add' : no overloaded functi
on takes 3 arguments
with
[
K=String,
T=String,
V=Vector<String>,
HashFn=StdHash<String>
]
MyAplication: 1 file(s) built in (0:03.31), 3313 msecs / file, duration = 3438 msecs


help me plz Crying or Very Sad

ps: Sorry for my English... Embarassed

[Updated on: Mon, 19 November 2007 19:40]

Report message to a moderator

Re: Help VectorMap !!! [message #14012 is a reply to message #12827] Wed, 06 February 2008 16:31 Go to previous message
captainc is currently offline  captainc
Messages: 278
Registered: December 2006
Location: New Jersey, USA
Experienced Member
You defined VectorMap with 2 Strings. This means that the key for the VectorMap is a String and the Value of each VectorMap entry is a String. There is no Add function for VectorMap taking 3 arguments. If you want to keep ipAddr and port separate, you have to store a different structure as the value in your VectorMap. Hopefully this example can explain it to you:
// Create the VectorMap and add values:

VectorMap<String, Vector<String>> mHostList;

Vector<String> ipAddrAndPort;
ipAddrAndPort.Add(ipAddr);
ipAddrAndPort.Add(port);

mHostList.Add(id, ipAddrAndPort);

// Get values from VectorMap:

for(int i=0; i<mHostList.GetCount(); ++i){  // Loop through all elements in VectorMap
    String id = mHostList.GetKey(i);  // Get key for this element 
    Vector<String> ipAddrAndPort = mHostList.Get(id); // Get the element itself
    Cout() << id << " -> " << ipAddrAndPort[0] << ":" << ipAddrAndPort[1] << "/n" ; // Output the details
    
}

Hope that helps explain the mechanisms a bit.
Previous Topic: Topic++ : how to add pictures to text
Next Topic: make CodeEditor go to first line with an error automatically [FEATURE REQUEST]
Goto Forum:
  


Current Time: Fri Apr 19 23:28:40 CEST 2024

Total time taken to generate the page: 0.06420 seconds