Jump to content

  • Log In with Google      Sign In   
  • Create Account


- - - - -

What happened to string::split?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 iforce2d   Members   -  Reputation: 218

Like
1Likes
Like

Posted 09 March 2013 - 12:52 PM

The docs and change notes say that the string class should have a split(string delimiter) function, but I can't find any trace of it in the current source code... just wondering what happened to it.

 

http://www.angelcode.com/angelscript/sdk/docs/manual/doc_datatypes_strings.html

http://www.angelcode.com/angelscript/changes.php

 

For now I am using this:

string[] split(string str, string delimiter) 
{
	string[] parts;
	int startPos = 0;
	while (true) {
		int index = str.findFirst(delimiter, startPos);
		if ( index == -1 ) {
			parts.insertLast( str.substr(startPos) );
			break;
		}
		else {
			parts.insertLast( str.substr(startPos, index - startPos) );
			startPos = index + delimiter.length;
		}
	}
	return parts;
}


Sponsor:

#2 Andreas Jonsson   Moderators   -  Reputation: 3227

Like
1Likes
Like

Posted 09 March 2013 - 04:52 PM

The split method is implemented in add_on/scriptstdstring/scriptstdstring_utils.cpp. 

 

In order to use it in the scripts you must register it with RegisterStdStringUtils(engine). This call must be done after the string and the script array have been registered.


AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#3 iforce2d   Members   -  Reputation: 218

Like
0Likes
Like

Posted 10 March 2013 - 02:19 AM

oh... not sure how I managed to miss that. Thanks!






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS