CLI interface to medialist (fossil mirror)
修訂 | bc4b0d898957d1591387d00c295d52a91e9d40e3 (tree) |
---|---|
時間 | 2023-03-11 19:04:34 |
作者 | mio <stigma@disr...> |
Commiter | mio |
change _ml_get_header_positions return type to size_t[2][6] to address deprecation
FossilOrigin-Name: bec009a226c8297fc7ffb05cb0f149d26fd34953f3ee4961658ba25248fc32b0
@@ -797,7 +797,7 @@ MediaListItem ml_fetch_item(MediaList* list, size_t id) | ||
797 | 797 | if (false == found) |
798 | 798 | throw new MLException(MLError.itemNotFound); |
799 | 799 | |
800 | - int[2][6] headerPositions = _ml_get_header_positions(list); | |
800 | + size_t[2][6] headerPositions = _ml_get_header_positions(list); | |
801 | 801 | |
802 | 802 | string[] sections = line.strip().split("\t"); |
803 | 803 | size_t titleIndex = 0; |
@@ -807,7 +807,7 @@ MediaListItem ml_fetch_item(MediaList* list, size_t id) | ||
807 | 807 | size_t endIndex = 0; |
808 | 808 | size_t lastIndex = 0; |
809 | 809 | |
810 | - foreach(int[2] header; headerPositions) { | |
810 | + foreach(const ref header; headerPositions) { | |
811 | 811 | switch(header[0]) { |
812 | 812 | case MLHeaders.title: |
813 | 813 | titleIndex = header[1]; |
@@ -944,7 +944,7 @@ MediaListItem[] ml_fetch_items(MediaList* list, size_t[] ids ...) | ||
944 | 944 | bool pastHeader = false; |
945 | 945 | MediaListItem[] items; |
946 | 946 | |
947 | - int[2][6] headerPositions = _ml_get_header_positions(list); | |
947 | + size_t[2][6] headerPositions = _ml_get_header_positions(list); | |
948 | 948 | size_t titleIndex = 0; |
949 | 949 | size_t progressIndex = 0; |
950 | 950 | size_t statusIndex = 0; |
@@ -952,7 +952,7 @@ MediaListItem[] ml_fetch_items(MediaList* list, size_t[] ids ...) | ||
952 | 952 | size_t endIndex = 0; |
953 | 953 | size_t lastIndex = 0; |
954 | 954 | |
955 | - foreach(size_t idx, int[2] header; headerPositions) { | |
955 | + foreach(const ref header; headerPositions) { | |
956 | 956 | switch(header[0]) { |
957 | 957 | case MLHeaders.title: |
958 | 958 | titleIndex = header[1]; |
@@ -1017,7 +1017,8 @@ MediaListItem[] ml_fetch_items(MediaList* list, size_t[] ids ...) | ||
1017 | 1017 | /// See_Also: |
1018 | 1018 | /// ml_fetch_item, ml_fetch_all |
1019 | 1019 | /// |
1020 | -MediaListItem[] ml_fetch_items(MediaList* list, out MLError err, size_t[] ids ...) nothrow | |
1020 | +MediaListItem[] ml_fetch_items(MediaList* list, out MLError err, | |
1021 | + size_t[] ids ...) nothrow | |
1021 | 1022 | { |
1022 | 1023 | import core.stdc.errno : errno, EACCES; |
1023 | 1024 |
@@ -1069,7 +1070,7 @@ MediaListItem[] ml_fetch_all(MediaList* list) | ||
1069 | 1070 | bool pastHeader = false; |
1070 | 1071 | MediaListItem[] items; |
1071 | 1072 | |
1072 | - int[2][6] headerPositions = _ml_get_header_positions(list); | |
1073 | + size_t[2][6] headerPositions = _ml_get_header_positions(list); | |
1073 | 1074 | size_t titleIndex = 0; |
1074 | 1075 | size_t progressIndex = 0; |
1075 | 1076 | size_t statusIndex = 0; |
@@ -1077,7 +1078,7 @@ MediaListItem[] ml_fetch_all(MediaList* list) | ||
1077 | 1078 | size_t endIndex = 0; |
1078 | 1079 | size_t lastIndex = 0; |
1079 | 1080 | |
1080 | - foreach (int[2] header; headerPositions) | |
1081 | + foreach (const ref header; headerPositions) | |
1081 | 1082 | { |
1082 | 1083 | switch (header[0]) |
1083 | 1084 | { |
@@ -1248,7 +1249,7 @@ private MLError _ml_add(MediaList* list, string[] args) | ||
1248 | 1249 | if (true == list.isOpen) |
1249 | 1250 | return MLError.fileAlreadyOpen; |
1250 | 1251 | |
1251 | - int[2][6] headerPositions = _ml_get_header_positions(list); | |
1252 | + size_t[2][6] headerPositions = _ml_get_header_positions(list); | |
1252 | 1253 | int currentIndent = 0; |
1253 | 1254 | |
1254 | 1255 | list.isOpen = true; |
@@ -1256,7 +1257,7 @@ private MLError _ml_add(MediaList* list, string[] args) | ||
1256 | 1257 | |
1257 | 1258 | File listFile = File(list.filePath, "a"); |
1258 | 1259 | |
1259 | - foreach(const ref int[2] headerPosition; headerPositions) { | |
1260 | + foreach(const ref headerPosition; headerPositions) { | |
1260 | 1261 | while (currentIndent < headerPosition[1]) { |
1261 | 1262 | listFile.write("\t"); |
1262 | 1263 | currentIndent += 1; |
@@ -1442,7 +1443,7 @@ private MLError _ml_update(MediaList* list, string[] args) | ||
1442 | 1443 | File tempFile = File(tempFilePath, "w+"); |
1443 | 1444 | scope(exit) remove(tempFilePath); |
1444 | 1445 | |
1445 | - int[2][6] headerPositions = _ml_get_header_positions(list); | |
1446 | + size_t[2][6] headerPositions = _ml_get_header_positions(list); | |
1446 | 1447 | size_t titleIndex = 0; |
1447 | 1448 | size_t progressIndex = 0; |
1448 | 1449 | size_t statusIndex = 0; |
@@ -1450,7 +1451,7 @@ private MLError _ml_update(MediaList* list, string[] args) | ||
1450 | 1451 | size_t endDateIndex = 0; |
1451 | 1452 | size_t lastUpdatedIndex = 0; |
1452 | 1453 | |
1453 | - foreach (ref header; headerPositions) { | |
1454 | + foreach (const ref header; headerPositions) { | |
1454 | 1455 | switch (header[0]) { |
1455 | 1456 | case MLHeaders.title: |
1456 | 1457 | titleIndex = header[1]; |
@@ -1582,7 +1583,7 @@ private enum MLHeaders | ||
1582 | 1583 | lastUpdated = 5 |
1583 | 1584 | } |
1584 | 1585 | |
1585 | -private int[2][6] _ml_get_header_positions(MediaList* list) | |
1586 | +private size_t[2][6] _ml_get_header_positions(MediaList* list) | |
1586 | 1587 | { |
1587 | 1588 | list.isOpen = true; |
1588 | 1589 | scope(exit) list.isOpen = false; |
@@ -1601,7 +1602,7 @@ private int[2][6] _ml_get_header_positions(MediaList* list) | ||
1601 | 1602 | * We keep the tab indent so we don't mess up any other programs or custom |
1602 | 1603 | * configurations. |
1603 | 1604 | */ |
1604 | - int[2][6] headerPositions = -1; | |
1605 | + size_t[2][6] headerPositions = -1; | |
1605 | 1606 | int arrayPosition = 0; |
1606 | 1607 | |
1607 | 1608 | while ((line = f.readln) !is null) { |
@@ -1612,7 +1613,7 @@ private int[2][6] _ml_get_header_positions(MediaList* list) | ||
1612 | 1613 | /* first non-comment/non-configuration line is the header */ |
1613 | 1614 | string[] sections = line.strip().split("\t"); |
1614 | 1615 | |
1615 | - foreach(int idx, ref string section; sections) { | |
1616 | + foreach(idx, ref string section; sections) { | |
1616 | 1617 | switch(section.toLower) |
1617 | 1618 | { |
1618 | 1619 | case "title": |