forked from tonis2/Vulkan.c3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelpers.dart
49 lines (40 loc) · 1.52 KB
/
helpers.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import 'package:xml/xml.dart';
extension SearchMethods on XmlDocument {
XmlElement? findParentNode(String nodeType, String? node_name, {bool hasCategory = false}) {
if (hasCategory) {
return this.findAllElements(nodeType).where((element) => (element.getElement("name")?.innerText == node_name || element.getAttribute("name") == node_name) && element.getAttribute("category") != null).firstOrNull;
}
else {
return this.findAllElements(nodeType).where((element) => (element.getElement("name")?.innerText == node_name || element.getAttribute("name") == node_name)).firstOrNull;
}
}
}
extension ParseMethods on String {
String capitalize() {
return '${this[0].toUpperCase()}${this.toLowerCase().substring(1)}';
}
String formatTypeName() {
var value = this;
value = value.replaceAll("_t", "");
value = value.replaceAll("_", "");
value = value.capitalize();
return value;
}
String capitalizeName() {
return '${this[0].toUpperCase()}${this.substring(1)}';
}
String get C3Name {
bool hasVK = this.toLowerCase().substring(0, 2).contains("vk");
return hasVK ? this.substring(2) : this;
}
String camelCase() {
return '${this[0].toLowerCase()}${this.substring(1)}';
}
String to_bitvalue() {
return "0x${(1 << int.parse(this)).toRadixString(16).padLeft(8, '0')}";
}
String ext_num_enum(String offset, String? dir) {
String newValue = (int.parse(this) - 1).toString();
return "${dir ?? ""}1${newValue.padLeft(6, "0")}${offset.padLeft(3, "0")}";
}
}