cstring 1.0.0-dev cstring: ^1.0.0-dev copied to clipboard
Char support + Native bindings for a few <cstring> functions.
dart_cstring #
Native bindings for a few <cstring>
functions, also includes char support.
Installation #
dependencies:
cstring: ^1.0.0-dev
Usage #
Strings #
import "package:cstring/cstring.dart";
main() {
var greeting = new Cstring("Hello, world!");
// strncmp
bool saysHi = greeting.compareN(new Cstring("Hello"), 5) == 0;
// strcmp
print(saysHi = "foo");
// Also static
print(Cstring.strncmp("A", "B", 1));
}
Chars #
import "package:cstring/cstring.dart";
class SomeLexer {
List<Token> tokens = [];
void scan(String text) {
// Automatically takes first char of string
Char ch = new Char(text);
// isdigit, isalnum, isalpha
if (ch.isDigit())
tokens.add(new Token("NUMBER", ch.value));
}
}