Advertisement

What happened to string::split?

Started by March 09, 2013 06:52 PM
1 comment, last by zppz 11 years, 9 months ago

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;
}

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

Advertisement

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

This topic is closed to new replies.

Advertisement