summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xMakefile2
-rw-r--r--asm/code_803D110.s96
-rw-r--r--asm/code_8040094.s34
-rw-r--r--asm/code_8041AD0.s14
-rw-r--r--asm/code_80428A0.s170
-rw-r--r--asm/code_8048480.s110
-rw-r--r--asm/code_80521D0.s68
-rw-r--r--asm/code_8057824.s396
-rw-r--r--asm/code_807001C.s358
-rw-r--r--asm/code_80869E4.s2
-rw-r--r--asm/code_8086A3C.s6
-rw-r--r--asm/jirachi_wish.s6
-rw-r--r--data/dungeon/Autopilot/floor_id.json190
-rw-r--r--data/dungeon/Boss3/floor_id.json370
-rw-r--r--data/dungeon/Boss4/floor_id.json208
-rw-r--r--data/dungeon/Boss9/floor_id.json226
-rw-r--r--data/dungeon/BuriedRelic/floor_id.json1792
-rw-r--r--data/dungeon/D50/floor_id.json46
-rw-r--r--data/dungeon/D51/floor_id.json910
-rw-r--r--data/dungeon/D54/floor_id.json550
-rw-r--r--data/dungeon/D61/floor_id.json1792
-rw-r--r--data/dungeon/DarknightRelic/floor_id.json280
-rw-r--r--data/dungeon/DesertRegion/floor_id.json370
-rw-r--r--data/dungeon/DojoRegistration/floor_id.json1252
-rw-r--r--data/dungeon/FantasyStrait/floor_id.json550
-rw-r--r--data/dungeon/FantasyStraitAlt/floor_id.json352
-rw-r--r--data/dungeon/FaroffSea/floor_id.json1360
-rw-r--r--data/dungeon/FieryField/floor_id.json550
-rw-r--r--data/dungeon/FrostyForest/floor_id.json172
-rw-r--r--data/dungeon/FrostyForest/pokemon_found.json368
-rw-r--r--data/dungeon/FrostyGrotto/floor_id.json100
-rw-r--r--data/dungeon/FrostyGrotto/pokemon_found.json94
-rw-r--r--data/dungeon/GrandSea/floor_id.json550
-rw-r--r--data/dungeon/GreatCanyon/floor_id.json226
-rw-r--r--data/dungeon/GreatCanyon/pokemon_found.json568
-rw-r--r--data/dungeon/HowlingForest/floor_id.json280
-rw-r--r--data/dungeon/JoyousTower/floor_id.json1792
-rw-r--r--data/dungeon/LapisCave/floor_id.json262
-rw-r--r--data/dungeon/LapisCave/pokemon_found.json348
-rw-r--r--data/dungeon/LightningField/floor_id.json550
-rw-r--r--data/dungeon/MagmaCavern/floor_id.json424
-rw-r--r--data/dungeon/MagmaCavern/pokemon_found.json782
-rw-r--r--data/dungeon/MagmaCavernPit/floor_id.json64
-rw-r--r--data/dungeon/MagmaCavernPit/pokemon_found.json150
-rw-r--r--data/dungeon/MarvelousSea/floor_id.json370
-rw-r--r--data/dungeon/MeteorCave/floor_id.json370
-rw-r--r--data/dungeon/MtBlaze/floor_id.json226
-rw-r--r--data/dungeon/MtBlaze/pokemon_found.json440
-rw-r--r--data/dungeon/MtBlazePeak/floor_id.json64
-rw-r--r--data/dungeon/MtBlazePeak/pokemon_found.json90
-rw-r--r--data/dungeon/MtFaraway/floor_id.json730
-rw-r--r--data/dungeon/MtFreeze/floor_id.json280
-rw-r--r--data/dungeon/MtFreeze/pokemon_found.json432
-rw-r--r--data/dungeon/MtFreezePeak/floor_id.json100
-rw-r--r--data/dungeon/MtFreezePeak/pokemon_found.json112
-rw-r--r--data/dungeon/MtFreezePeakAlt/floor_id.json82
-rw-r--r--data/dungeon/MtSteel/floor_id.json172
-rw-r--r--data/dungeon/MtSteel/pokemon_found.json376
-rw-r--r--data/dungeon/MtThunder/floor_id.json190
-rw-r--r--data/dungeon/MtThunder/pokemon_found.json600
-rw-r--r--data/dungeon/MtThunderPeak/floor_id.json66
-rw-r--r--data/dungeon/MtThunderPeak/pokemon_found.json118
-rw-r--r--data/dungeon/MurkyCave/floor_id.json352
-rw-r--r--data/dungeon/NorthernRange/floor_id.json460
-rw-r--r--data/dungeon/NorthwindField/floor_id.json550
-rw-r--r--data/dungeon/OddityCave/floor_id.json280
-rw-r--r--data/dungeon/PitfallValley/floor_id.json460
-rw-r--r--data/dungeon/PurityForest/floor_id.json1792
-rw-r--r--data/dungeon/RemainsIsland/floor_id.json370
-rw-r--r--data/dungeon/RockPath/floor_id.json82
-rw-r--r--data/dungeon/SilentChasm/floor_id.json172
-rw-r--r--data/dungeon/SilentChasm/pokemon_found.json632
-rw-r--r--data/dungeon/SilverTrench/floor_id.json1792
-rw-r--r--data/dungeon/SinisterWoods/floor_id.json244
-rw-r--r--data/dungeon/SinisterWoods/pokemon_found.json892
-rw-r--r--data/dungeon/SkyTower/floor_id.json460
-rw-r--r--data/dungeon/SkyTower/pokemon_found.json932
-rw-r--r--data/dungeon/SkyTowerSummit/floor_id.json172
-rw-r--r--data/dungeon/SkyTowerSummit/pokemon_found.json132
-rw-r--r--data/dungeon/SnowPath/floor_id.json82
-rw-r--r--data/dungeon/SolarCave/floor_id.json370
-rw-r--r--data/dungeon/SouthernCavern/floor_id.json910
-rw-r--r--data/dungeon/StormySea/floor_id.json730
-rw-r--r--data/dungeon/ThunderwaveCave/floor_id.json100
-rw-r--r--data/dungeon/ThunderwaveCave/pokemon_found.json200
-rw-r--r--data/dungeon/TinyWoods/floor_id.json64
-rw-r--r--data/dungeon/TinyWoods/pokemon_found.json128
-rw-r--r--data/dungeon/UnownRelic/floor_id.json208
-rw-r--r--data/dungeon/UproarForest/floor_id.json190
-rw-r--r--data/dungeon/WaterfallPond/floor_id.json352
-rw-r--r--data/dungeon/WesternCave/floor_id.json1792
-rw-r--r--data/dungeon/WishCave/floor_id.json1792
-rw-r--r--data/dungeon/WondrousSea/floor_id.json226
-rw-r--r--data/dungeon/WyvernHill/floor_id.json550
-rw-r--r--include/constants/ability.h84
-rw-r--r--include/constants/direction.h16
-rw-r--r--include/constants/dungeon.h106
-rw-r--r--include/constants/dungeon_action.h44
-rw-r--r--include/constants/iq_skill.h31
-rw-r--r--include/constants/move.h474
-rw-r--r--include/constants/status.h124
-rw-r--r--include/constants/tactic.h19
-rw-r--r--include/constants/trap.h28
-rw-r--r--include/constants/type.h25
-rw-r--r--include/dungeon_entity.h277
-rw-r--r--include/dungeon_global_data.h93
-rw-r--r--include/gUnknown_203B418.h47
-rw-r--r--include/item.h19
-rw-r--r--include/map.h61
-rw-r--r--include/pokemon.h19
-rw-r--r--src/code_8040094.c20
-rw-r--r--src/code_8041AD0.c10
-rw-r--r--src/code_8048480.c7
-rw-r--r--src/code_80521D0_1.c63
-rw-r--r--src/code_8057824.c10
-rw-r--r--src/code_8057824_1.c131
-rw-r--r--src/code_80869E4.c25
-rw-r--r--src/code_8086A3C.c42
-rw-r--r--src/debug_menu_mid.c2
-rw-r--r--src/friend_area_action_menu_1.c6
-rw-r--r--src/friend_rescue_1.c8
-rw-r--r--src/items.c154
-rw-r--r--src/kecleon_items_1.c12
-rw-r--r--src/pokemon_mid.c46
-rw-r--r--src/thank_you_wonder_mail.c38
-rw-r--r--src/trade_items_menu.c26
-rw-r--r--src/wonder_mail.c3
-rw-r--r--sym_ewram2.txt2
-rw-r--r--tools/aif2pcm/.gitignore4
-rw-r--r--tools/bin2c/.gitignore2
-rw-r--r--tools/br_ips/.gitignore4
-rw-r--r--tools/dungeonjson/.gitignore2
-rw-r--r--tools/dungeonjson/json11.cpp1572
-rw-r--r--tools/gbafix/.gitignore4
-rw-r--r--tools/gbagfx/.gitignore2
-rw-r--r--tools/jsonproc/.gitignore2
-rw-r--r--tools/jsonproc/inja.hpp7058
-rw-r--r--tools/jsonproc/jsonproc.cpp218
-rw-r--r--tools/jsonproc/nlohmann/json.hpp41684
-rw-r--r--tools/mapjson/.gitignore2
-rw-r--r--tools/mapjson/json11.cpp1572
-rw-r--r--tools/mapjson/mapjson.cpp1076
-rw-r--r--tools/mid2agb/.gitignore2
-rw-r--r--tools/mid2agb/agb.cpp1094
-rw-r--r--tools/mid2agb/error.cpp72
-rw-r--r--tools/mid2agb/main.cpp466
-rw-r--r--tools/mid2agb/midi.cpp1928
-rw-r--r--tools/mid2agb/tables.cpp572
-rw-r--r--tools/preproc/.gitignore2
-rw-r--r--tools/preproc/asm_file.cpp1064
-rw-r--r--tools/preproc/c_file.cpp860
-rw-r--r--tools/preproc/charmap.cpp816
-rw-r--r--tools/preproc/preproc.cpp312
-rw-r--r--tools/preproc/string_parser.cpp710
-rw-r--r--tools/preproc/utf8.cpp184
-rw-r--r--tools/ramscrgen/.gitignore2
-rw-r--r--tools/ramscrgen/elf.cpp544
-rw-r--r--tools/ramscrgen/main.cpp374
-rw-r--r--tools/ramscrgen/sym_file.cpp984
-rw-r--r--tools/rsfont/.gitignore2
-rw-r--r--tools/scaninc/.gitignore2
-rw-r--r--tools/scaninc/asm_file.cpp384
-rw-r--r--tools/scaninc/c_file.cpp614
163 files changed, 54309 insertions, 53029 deletions
diff --git a/Makefile b/Makefile
index 555b7bc..cb565f9 100755
--- a/Makefile
+++ b/Makefile
@@ -39,7 +39,7 @@ REVISION := 0
ifeq ($(OS),Windows_NT)
LIB := ../../tools/agbcc/lib/libc.a ../../tools/agbcc/lib/libgcc.a ../../libagbsyscall/libagbsyscall.a
else
-LIB := -L ../../tools/agbcc/lib -lc -lgcc -L ../../libagbsyscall -lagbsyscall
+LIB := -L ../../tools/agbcc/lib -lc -lgcc -L ../../libagbsyscall -lagbsyscall
endif
diff --git a/asm/code_803D110.s b/asm/code_803D110.s
index 1eb867c..d1936e6 100644
--- a/asm/code_803D110.s
+++ b/asm/code_803D110.s
@@ -3,7 +3,7 @@
.syntax unified
- .text
+ .text
thumb_func_start sub_803D110
sub_803D110:
@@ -504,7 +504,7 @@ sub_803D4AC:
strb r1, [r0]
bx lr
.align 2, 0
-_0803D4C4: .4byte gUnknown_203B418
+_0803D4C4: .4byte gDungeonGlobalData
_0803D4C8: .4byte 0x0001c570
_0803D4CC: .4byte 0x0001c571
thumb_func_end sub_803D4AC
@@ -709,7 +709,7 @@ _0803D644:
bne _0803D644
b _0803D68A
.align 2, 0
-_0803D654: .4byte gUnknown_203B418
+_0803D654: .4byte gDungeonGlobalData
_0803D658: .4byte 0x00000644
_0803D65C: .4byte 0x0001c570
_0803D660: .4byte gUnknown_80F4D8C
@@ -780,7 +780,7 @@ _0803D6E0:
pop {r0}
bx r0
.align 2, 0
-_0803D6F0: .4byte gUnknown_203B418
+_0803D6F0: .4byte gDungeonGlobalData
_0803D6F4: .4byte 0x0001c590
_0803D6F8: .4byte 0x0001c5a8
thumb_func_end sub_803D4D0
@@ -807,7 +807,7 @@ _0803D710:
b _0803D736
.align 2, 0
_0803D720: .4byte 0x00002710
-_0803D724: .4byte gUnknown_203B418
+_0803D724: .4byte gDungeonGlobalData
_0803D728: .4byte 0x0001cd70
_0803D72C:
adds r1, 0x2
@@ -862,7 +862,7 @@ _0803D77A:
b _0803D7EC
.align 2, 0
_0803D784: .4byte 0x00002710
-_0803D788: .4byte gUnknown_203B418
+_0803D788: .4byte gDungeonGlobalData
_0803D78C: .4byte 0x0001c590
_0803D790:
lsls r0, r6, 24
@@ -924,7 +924,7 @@ _0803D7EE:
bx r1
.align 2, 0
_0803D7FC: .4byte 0x00002710
-_0803D800: .4byte gUnknown_203B418
+_0803D800: .4byte gDungeonGlobalData
_0803D804: .4byte 0x0001c5a8
thumb_func_end sub_803D73C
@@ -981,7 +981,7 @@ _0803D85A:
bx r1
.align 2, 0
_0803D868: .4byte 0x0001cd98
-_0803D86C: .4byte gUnknown_203B418
+_0803D86C: .4byte gDungeonGlobalData
thumb_func_end sub_803D808
thumb_func_start sub_803D870
@@ -1048,7 +1048,7 @@ _0803D8D6:
bx r1
.align 2, 0
_0803D8E4: .4byte 0x0001cd9a
-_0803D8E8: .4byte gUnknown_203B418
+_0803D8E8: .4byte gDungeonGlobalData
_0803D8EC: .4byte 0x0001cd98
thumb_func_end sub_803D870
@@ -1078,7 +1078,7 @@ _0803D918:
pop {r0}
bx r0
.align 2, 0
-_0803D920: .4byte gUnknown_203B418
+_0803D920: .4byte gDungeonGlobalData
_0803D924: .4byte 0x000037ec
_0803D928: .4byte 0x0000343c
_0803D92C: .4byte 0x000037e4
@@ -1094,7 +1094,7 @@ sub_803D930:
ldr r4, _0803D944
b _0803D954
.align 2, 0
-_0803D940: .4byte gUnknown_203B418
+_0803D940: .4byte gDungeonGlobalData
_0803D944: .4byte 0x0001cd98
_0803D948:
cmp r0, r6
@@ -1191,7 +1191,7 @@ _0803D9E0:
b _0803DA14
.align 2, 0
_0803D9EC: .4byte 0x00002710
-_0803D9F0: .4byte gUnknown_203B418
+_0803D9F0: .4byte gDungeonGlobalData
_0803D9F4: .4byte 0x000037e4
_0803D9F8: .4byte 0x0000343c
_0803D9FC: .4byte 0x0000343e
@@ -1243,7 +1243,7 @@ _0803DA3A:
bl sub_808E9E4
b _0803DA72
.align 2, 0
-_0803DA54: .4byte gUnknown_203B418
+_0803DA54: .4byte gDungeonGlobalData
_0803DA58: .4byte 0x000037e4
_0803DA5C: .4byte 0x0000343c
_0803DA60:
@@ -1398,7 +1398,7 @@ _0803DB90: .4byte gUnknown_80F6100
_0803DB94: .4byte gDungeonNameBannerFontFile
_0803DB98: .4byte gDungeonNameBannerFont
_0803DB9C: .4byte 0x06000140
-_0803DBA0: .4byte gUnknown_203B418
+_0803DBA0: .4byte gDungeonGlobalData
_0803DBA4: .4byte 0x00000645
_0803DBA8: .4byte 0x00000644
_0803DBAC: .4byte 0xffffe000
@@ -2121,7 +2121,7 @@ _0803E118: .4byte gUnknown_80F61DC
_0803E11C: .4byte gDungeonFileArchive
_0803E120: .4byte 0x0600c000
_0803E124: .4byte gUnknown_202ECA4
-_0803E128: .4byte gUnknown_203B418
+_0803E128: .4byte gDungeonGlobalData
_0803E12C: .4byte gUnknown_80F5F70
_0803E130: .4byte 0x00012a18
_0803E134: .4byte 0x00013554
@@ -2187,7 +2187,7 @@ sub_803E178:
strh r0, [r1]
b _0803E204
.align 2, 0
-_0803E1AC: .4byte gUnknown_203B418
+_0803E1AC: .4byte gDungeonGlobalData
_0803E1B0: .4byte 0x00000644
_0803E1B4: .4byte 0x000037fe
_0803E1B8: .4byte 0x00003a12
@@ -2219,7 +2219,7 @@ _0803E1E0:
movs r1, 0x6
b _0803E202
.align 2, 0
-_0803E1F0: .4byte gUnknown_203B418
+_0803E1F0: .4byte gDungeonGlobalData
_0803E1F4: .4byte 0x00003a12
_0803E1F8:
ldr r0, _0803E20C
@@ -2234,7 +2234,7 @@ _0803E204:
pop {r0}
bx r0
.align 2, 0
-_0803E20C: .4byte gUnknown_203B418
+_0803E20C: .4byte gDungeonGlobalData
_0803E210: .4byte 0x00003a12
thumb_func_end sub_803E178
@@ -2507,7 +2507,7 @@ _0803E448: .4byte 0x000003ff
_0803E44C: .4byte 0x00000fff
_0803E450: .4byte 0x0000fffd
_0803E454: .4byte gUnknown_80F61EC
-_0803E458: .4byte gUnknown_203B418
+_0803E458: .4byte gDungeonGlobalData
_0803E45C: .4byte 0x00018217
_0803E460: .4byte 0x00018218
_0803E464: .4byte gUnknown_202EDC8
@@ -2571,7 +2571,7 @@ sub_803E490:
b _0803E4FC
.align 2, 0
_0803E4D8: .4byte gUnknown_202EDD4
-_0803E4DC: .4byte gUnknown_203B418
+_0803E4DC: .4byte gDungeonGlobalData
_0803E4E0: .4byte 0x0001821a
_0803E4E4: .4byte 0x00018208
_0803E4E8: .4byte 0x000181f0
@@ -2708,7 +2708,7 @@ _0803E5A2:
bx r0
.align 2, 0
_0803E628: .4byte 0x00018208
-_0803E62C: .4byte gUnknown_203B418
+_0803E62C: .4byte gDungeonGlobalData
_0803E630: .4byte 0x000181f0
_0803E634: .4byte 0x000181f2
_0803E638: .4byte 0x000181fc
@@ -2781,7 +2781,7 @@ _0803E6F0: .4byte gUnknown_202EDD4
_0803E6F4: .4byte gUnknown_203B46C
_0803E6F8: .4byte gUnknown_202EDCC
_0803E6FC: .4byte gPlayTimeRef
-_0803E700: .4byte gUnknown_203B418
+_0803E700: .4byte gDungeonGlobalData
_0803E704: .4byte 0x00018213
thumb_func_end sub_803E668
@@ -2884,7 +2884,7 @@ _0803E790:
.align 2, 0
_0803E7B8: .4byte gUnknown_203B40D
_0803E7BC: .4byte gUnknown_202EDC8
-_0803E7C0: .4byte gUnknown_203B418
+_0803E7C0: .4byte gDungeonGlobalData
_0803E7C4: .4byte 0x00018217
thumb_func_end sub_803E748
@@ -2934,7 +2934,7 @@ _0803E806:
.align 2, 0
_0803E820: .4byte gUnknown_203B40D
_0803E824: .4byte gUnknown_202EDC8
-_0803E828: .4byte gUnknown_203B418
+_0803E828: .4byte gDungeonGlobalData
_0803E82C: .4byte 0x00018217
thumb_func_end sub_803E7C8
@@ -3131,7 +3131,7 @@ _0803E96A:
_0803E9A4: .4byte gUnknown_202EE88
_0803E9A8: .4byte gUnknown_80F62AC
_0803E9AC: .4byte gUnknown_202EDC8
-_0803E9B0: .4byte gUnknown_203B418
+_0803E9B0: .4byte gDungeonGlobalData
_0803E9B4: .4byte 0x00018215
_0803E9B8: .4byte 0x0001c06c
_0803E9BC: .4byte gUnknown_202EE8C
@@ -3169,7 +3169,7 @@ _0803E9E6:
pop {r0}
bx r0
.align 2, 0
-_0803EA04: .4byte gUnknown_203B418
+_0803EA04: .4byte gDungeonGlobalData
_0803EA08: .4byte 0x000181e4
_0803EA0C: .4byte gUnknown_202EDC8
thumb_func_end sub_803E9D0
@@ -3272,7 +3272,7 @@ _0803EA92:
_0803EACC: .4byte gUnknown_202EE88
_0803EAD0: .4byte gUnknown_80F62AC
_0803EAD4: .4byte gUnknown_202EDC8
-_0803EAD8: .4byte gUnknown_203B418
+_0803EAD8: .4byte gDungeonGlobalData
_0803EADC: .4byte 0x00018215
_0803EAE0: .4byte 0x0001c06c
_0803EAE4: .4byte gUnknown_202EE8C
@@ -3639,7 +3639,7 @@ _0803ED78:
movs r0, 0x6
b _0803EDCA
.align 2, 0
-_0803EDAC: .4byte gUnknown_203B418
+_0803EDAC: .4byte gDungeonGlobalData
_0803EDB0: .4byte 0x0001820a
_0803EDB4: .4byte gUnknown_202EDE8
_0803EDB8: .4byte 0xfffffc19
@@ -3670,7 +3670,7 @@ _0803EDDA:
bx r0
.align 2, 0
_0803EDE8: .4byte 0x060142c0
-_0803EDEC: .4byte gUnknown_203B418
+_0803EDEC: .4byte gDungeonGlobalData
thumb_func_end sub_803ED30
thumb_func_start sub_803EDF0
@@ -3856,7 +3856,7 @@ _0803EF42:
pop {r0}
bx r0
.align 2, 0
-_0803EF50: .4byte gUnknown_203B418
+_0803EF50: .4byte gDungeonGlobalData
_0803EF54: .4byte 0x000181f0
_0803EF58: .4byte 0x000181f2
_0803EF5C: .4byte 0x00000fff
@@ -3983,7 +3983,7 @@ _0803F056:
ldr r2, [r4]
b _0803F07A
.align 2, 0
-_0803F060: .4byte gUnknown_203B418
+_0803F060: .4byte gDungeonGlobalData
_0803F064: .4byte gUnknown_202EC9C
_0803F068: .4byte 0x0000270f
_0803F06C: .4byte gUnknown_80F6478
@@ -4388,7 +4388,7 @@ _0803F354:
pop {r0}
bx r0
.align 2, 0
-_0803F360: .4byte gUnknown_203B418
+_0803F360: .4byte gDungeonGlobalData
_0803F364: .4byte 0x000181e8
_0803F368: .4byte 0x00018216
_0803F36C: .4byte 0x00018217
@@ -4463,7 +4463,7 @@ sub_803F38C:
pop {r0}
bx r0
.align 2, 0
-_0803F410: .4byte gUnknown_203B418
+_0803F410: .4byte gDungeonGlobalData
_0803F414: .4byte 0x000181e8
_0803F418: .4byte 0x0000ffff
_0803F41C: .4byte 0x00018228
@@ -4521,7 +4521,7 @@ _0803F45A:
lsrs r0, 24
b _0803F49A
.align 2, 0
-_0803F484: .4byte gUnknown_203B418
+_0803F484: .4byte gDungeonGlobalData
_0803F488: .4byte 0x000181e8
_0803F48C: .4byte 0x0001820b
_0803F490: .4byte 0x0001820c
@@ -4550,7 +4550,7 @@ sub_803F4A0:
adds r3, 0x2E
b _0803F4CA
.align 2, 0
-_0803F4B8: .4byte gUnknown_203B418
+_0803F4B8: .4byte gDungeonGlobalData
_0803F4BC: .4byte 0x000181e8
_0803F4C0:
ldr r0, [r2, 0x70]
@@ -4586,7 +4586,7 @@ _0803F4F8:
bx r0
.align 2, 0
_0803F4FC: .4byte 0x00018216
-_0803F500: .4byte gUnknown_203B418
+_0803F500: .4byte gDungeonGlobalData
_0803F504: .4byte 0x0001356c
thumb_func_end sub_803F4A0
@@ -4605,7 +4605,7 @@ sub_803F508:
strb r3, [r0]
b _0803F548
.align 2, 0
-_0803F520: .4byte gUnknown_203B418
+_0803F520: .4byte gDungeonGlobalData
_0803F524: .4byte 0x000181e8
_0803F528: .4byte 0x00018216
_0803F52C:
@@ -4645,7 +4645,7 @@ _0803F566:
bx r0
.align 2, 0
_0803F574: .4byte 0x00018216
-_0803F578: .4byte gUnknown_203B418
+_0803F578: .4byte gDungeonGlobalData
_0803F57C: .4byte 0x0001356c
thumb_func_end sub_803F508
@@ -4717,7 +4717,7 @@ _0803F5D4:
strb r1, [r0]
b _0803F626
.align 2, 0
-_0803F600: .4byte gUnknown_203B418
+_0803F600: .4byte gDungeonGlobalData
_0803F604: .4byte 0x000181e8
_0803F608: .4byte 0x0001820d
_0803F60C: .4byte 0x0001820e
@@ -4937,7 +4937,7 @@ _0803F7A0:
pop {r0}
bx r0
.align 2, 0
-_0803F7B4: .4byte gUnknown_203B418
+_0803F7B4: .4byte gDungeonGlobalData
_0803F7B8: .4byte 0x000135cc
thumb_func_end sub_803F580
@@ -4976,7 +4976,7 @@ _0803F7F4:
bl sub_8005838
b _0803F86A
.align 2, 0
-_0803F800: .4byte gUnknown_203B418
+_0803F800: .4byte gDungeonGlobalData
_0803F804: .4byte 0x000181e8
_0803F808: .4byte 0x0001820b
_0803F80C:
@@ -5130,7 +5130,7 @@ _0803F91E:
strb r0, [r1]
b _0803F984
.align 2, 0
-_0803F92C: .4byte gUnknown_203B418
+_0803F92C: .4byte gDungeonGlobalData
_0803F930: .4byte 0x000181e8
_0803F934: .4byte 0x0001820d
_0803F938: .4byte 0x00018211
@@ -5190,7 +5190,7 @@ sub_803F994:
lsls r0, 8
bx lr
.align 2, 0
-_0803F9A8: .4byte gUnknown_203B418
+_0803F9A8: .4byte gDungeonGlobalData
_0803F9AC: .4byte 0x000181e8
thumb_func_end sub_803F994
@@ -5206,7 +5206,7 @@ sub_803F9B0:
lsls r0, 8
bx lr
.align 2, 0
-_0803F9C4: .4byte gUnknown_203B418
+_0803F9C4: .4byte gDungeonGlobalData
_0803F9C8: .4byte 0x000181e8
thumb_func_end sub_803F9B0
@@ -5257,7 +5257,7 @@ _0803FA14:
bl sub_803F38C
b _0803FA3C
.align 2, 0
-_0803FA24: .4byte gUnknown_203B418
+_0803FA24: .4byte gDungeonGlobalData
_0803FA28: .4byte 0x000181f8
_0803FA2C: .4byte 0x0001356c
_0803FA30: .4byte 0x00018218
@@ -5412,7 +5412,7 @@ _0803FB3A:
pop {r0}
bx r0
.align 2, 0
-_0803FB4C: .4byte gUnknown_203B418
+_0803FB4C: .4byte gDungeonGlobalData
_0803FB50: .4byte 0x000181e8
_0803FB54: .4byte gUnknown_3001018
_0803FB58: .4byte gUnknown_80F6490
@@ -5487,7 +5487,7 @@ _0803FBD2:
movs r6, 0x20
b _0803FBF8
.align 2, 0
-_0803FBE8: .4byte gUnknown_203B418
+_0803FBE8: .4byte gDungeonGlobalData
_0803FBEC: .4byte 0x000181e8
_0803FBF0: .4byte gUnknown_202EDCC
_0803FBF4:
@@ -5613,7 +5613,7 @@ _0803FCB0:
_0803FCE4: .4byte gUnknown_203B46C
_0803FCE8: .4byte gUnknown_202D068
_0803FCEC: .4byte gUnknown_202B038
-_0803FCF0: .4byte gUnknown_203B418
+_0803FCF0: .4byte gDungeonGlobalData
_0803FCF4: .4byte 0x00000645
_0803FCF8: .4byte 0x00000644
_0803FCFC:
diff --git a/asm/code_8040094.s b/asm/code_8040094.s
index 36986ea..21aca6a 100644
--- a/asm/code_8040094.s
+++ b/asm/code_8040094.s
@@ -3,7 +3,7 @@
.syntax unified
- .text
+ .text
thumb_func_start sub_8040150
sub_8040150:
@@ -86,7 +86,7 @@ _080401B0:
pop {r0}
bx r0
.align 2, 0
-_080401EC: .4byte gUnknown_203B418
+_080401EC: .4byte gDungeonGlobalData
_080401F0: .4byte 0x0001822c
_080401F4: .4byte 0x0001ba2c
_080401F8: .4byte gUnknown_203B410
@@ -267,7 +267,7 @@ _08040302:
str r3, [sp, 0x18]
b _0804039C
.align 2, 0
-_0804034C: .4byte gUnknown_203B418
+_0804034C: .4byte gDungeonGlobalData
_08040350: .4byte gUnknown_202EE04
_08040354: .4byte gUnknown_202EE01
_08040358: .4byte 0x00018210
@@ -297,7 +297,7 @@ _08040378:
str r0, [sp, 0x18]
b _0804039C
.align 2, 0
-_08040390: .4byte gUnknown_203B418
+_08040390: .4byte gDungeonGlobalData
_08040394: .4byte 0x00018211
_08040398:
movs r2, 0
@@ -351,7 +351,7 @@ _080403F6:
movs r0, 0x1
b _0804040A
.align 2, 0
-_080403FC: .4byte gUnknown_203B418
+_080403FC: .4byte gDungeonGlobalData
_08040400: .4byte 0x0001356c
_08040404: .4byte gUnknown_202EE00
_08040408:
@@ -392,7 +392,7 @@ _08040426:
b _0804045A
.align 2, 0
_0804044C: .4byte gUnknown_203B410
-_08040450: .4byte gUnknown_203B418
+_08040450: .4byte gDungeonGlobalData
_08040454: .4byte 0x00018214
_08040458:
movs r6, 0xA
@@ -889,7 +889,7 @@ _08040800:
blt _080407C8
b _08040868
.align 2, 0
-_08040814: .4byte gUnknown_203B418
+_08040814: .4byte gDungeonGlobalData
_08040818: .4byte 0x0001bdd0
_0804081C: .4byte 0x0001bdd1
_08040820: .4byte 0x0001bdcc
@@ -1130,7 +1130,7 @@ _080408D2:
bl nullsub_11
b _08040A6A
.align 2, 0
-_080409F4: .4byte gUnknown_203B418
+_080409F4: .4byte gDungeonGlobalData
_080409F8: .4byte 0x00018214
_080409FC: .4byte gUnknown_203B410
_08040A00: .4byte gUnknown_202EE02
@@ -1217,7 +1217,7 @@ _08040A98:
pop {r0}
bx r0
.align 2, 0
-_08040AB4: .4byte gUnknown_203B418
+_08040AB4: .4byte gDungeonGlobalData
_08040AB8: .4byte 0x0001bdd1
thumb_func_end sub_8040A84
@@ -1354,7 +1354,7 @@ _08040B9E:
pop {r0}
bx r0
.align 2, 0
-_08040BA4: .4byte gUnknown_203B418
+_08040BA4: .4byte gDungeonGlobalData
_08040BA8: .4byte 0x0001bdd2
_08040BAC: .4byte 0x0001ba2c
thumb_func_end sub_8040B60
@@ -1657,7 +1657,7 @@ _08040E0E:
ldr r6, [r0]
b _08040E26
.align 2, 0
-_08040E1C: .4byte gUnknown_203B418
+_08040E1C: .4byte gDungeonGlobalData
_08040E20: .4byte 0x000181f8
_08040E24:
adds r6, r7, 0
@@ -1736,7 +1736,7 @@ _08040E6E:
b _08040EF0
.align 2, 0
_08040EB8: .4byte gUnknown_202F224
-_08040EBC: .4byte gUnknown_203B418
+_08040EBC: .4byte gDungeonGlobalData
_08040EC0: .4byte 0x00018204
_08040EC4: .4byte gUnknown_8106A8C
_08040EC8: .4byte gUnknown_202DE30
@@ -1817,7 +1817,7 @@ _08040F52:
bge _08040F52
b _08041026
.align 2, 0
-_08040F70: .4byte gUnknown_203B418
+_08040F70: .4byte gDungeonGlobalData
_08040F74: .4byte 0x00018204
_08040F78: .4byte 0x000003e5
_08040F7C:
@@ -2741,7 +2741,7 @@ _08041644:
movs r5, 0
b _0804167C
.align 2, 0
-_0804166C: .4byte gUnknown_203B418
+_0804166C: .4byte gDungeonGlobalData
_08041670: .4byte 0x000181f2
_08041674:
movs r0, 0x42
@@ -2913,7 +2913,7 @@ sub_804178C:
ldr r6, _080417B8
b _080417C4
.align 2, 0
-_080417B0: .4byte gUnknown_203B418
+_080417B0: .4byte gDungeonGlobalData
_080417B4: .4byte 0x00018204
_080417B8: .4byte 0x000003e7
_080417BC:
@@ -3057,7 +3057,7 @@ _080418C0:
pop {r0}
bx r0
.align 2, 0
-_080418CC: .4byte gUnknown_203B418
+_080418CC: .4byte gDungeonGlobalData
_080418D0: .4byte 0x000135cc
thumb_func_end sub_8041888
@@ -3310,7 +3310,7 @@ _08041AB8: .4byte gUnknown_80F67A8
_08041ABC: .4byte gUnknown_80F67B4
_08041AC0: .4byte gUnknown_80F67C4
_08041AC4: .4byte gUnknown_80F67D4
-_08041AC8: .4byte gUnknown_203B418
+_08041AC8: .4byte gDungeonGlobalData
_08041ACC: .4byte 0x00000676
thumb_func_end sub_80418D4
diff --git a/asm/code_8041AD0.s b/asm/code_8041AD0.s
index be5dbe3..ee181a7 100644
--- a/asm/code_8041AD0.s
+++ b/asm/code_8041AD0.s
@@ -237,7 +237,7 @@ _080423E2:
.align 2, 0
_08042428: .4byte 0xffff0000
_0804242C: .4byte 0x0000ffff
-_08042430: .4byte gUnknown_203B418
+_08042430: .4byte gDungeonGlobalData
_08042434: .4byte 0x000181f2
_08042438: .4byte 0x000003e7
_0804243C:
@@ -334,7 +334,7 @@ _080424A6:
.align 2, 0
_080424EC: .4byte 0xffff0000
_080424F0: .4byte 0x0000ffff
-_080424F4: .4byte gUnknown_203B418
+_080424F4: .4byte gDungeonGlobalData
_080424F8: .4byte 0x000181f2
_080424FC: .4byte 0x000003e7
_08042500:
@@ -508,7 +508,7 @@ _080425CC:
.align 2, 0
_0804264C: .4byte 0xffff0000
_08042650: .4byte 0x0000ffff
-_08042654: .4byte gUnknown_203B418
+_08042654: .4byte gDungeonGlobalData
_08042658: .4byte 0x000181f2
_0804265C: .4byte 0x00000165
_08042660: .4byte gUnknown_80F4448
@@ -560,7 +560,7 @@ _080426AC:
bx r0
.align 2, 0
_080426B8: .4byte 0x000003e5
-_080426BC: .4byte gUnknown_203B418
+_080426BC: .4byte gDungeonGlobalData
_080426C0: .4byte 0x00000644
_080426C4: .4byte 0x00000155
thumb_func_end sub_804267C
@@ -675,7 +675,7 @@ _08042778:
movs r0, 0x1
b _080427A6
.align 2, 0
-_08042794: .4byte gUnknown_203B418
+_08042794: .4byte gDungeonGlobalData
_08042798: .4byte 0x0001820a
_0804279C:
adds r0, r1, 0
@@ -733,7 +733,7 @@ _080427FA:
pop {r0}
bx r0
.align 2, 0
-_08042808: .4byte gUnknown_203B418
+_08042808: .4byte gDungeonGlobalData
_0804280C: .4byte 0x000135cc
_08042810: .4byte gAvailablePokemonNames
_08042814: .4byte gPtrFeralFoundItemMessage
@@ -785,7 +785,7 @@ _0804284A:
bl sub_804151C
b _08042896
.align 2, 0
-_08042874: .4byte gUnknown_203B418
+_08042874: .4byte gDungeonGlobalData
_08042878: .4byte 0x000181f8
_0804287C: .4byte gUnknown_80F682C
_08042880: .4byte 0x000003e5
diff --git a/asm/code_80428A0.s b/asm/code_80428A0.s
index 996e063..b296f06 100644
--- a/asm/code_80428A0.s
+++ b/asm/code_80428A0.s
@@ -3,7 +3,7 @@
.syntax unified
- .text
+ .text
thumb_func_start sub_8042A84
sub_8042A84:
@@ -69,7 +69,7 @@ _08042AF8:
bx r0
.align 2, 0
_08042B00: .4byte 0x0000c7ff
-_08042B04: .4byte gUnknown_203B418
+_08042B04: .4byte gDungeonGlobalData
_08042B08: .4byte 0x000181f2
thumb_func_end sub_8042A84
@@ -386,7 +386,7 @@ _08042D56:
pop {r1}
bx r1
.align 2, 0
-_08042D74: .4byte gUnknown_203B418
+_08042D74: .4byte gDungeonGlobalData
_08042D78: .4byte 0x000181f0
thumb_func_end sub_8042CC0
@@ -465,7 +465,7 @@ _08042DE4:
str r0, [r4, 0x8]
b _08042E14
.align 2, 0
-_08042E04: .4byte gUnknown_203B418
+_08042E04: .4byte gDungeonGlobalData
_08042E08: .4byte 0x000005c4
_08042E0C:
adds r3, 0x10
@@ -500,7 +500,7 @@ _08042E24:
movs r0, 0x1
b _08042E56
.align 2, 0
-_08042E44: .4byte gUnknown_203B418
+_08042E44: .4byte gDungeonGlobalData
_08042E48: .4byte 0x000005c4
_08042E4C:
adds r4, 0x10
@@ -544,7 +544,7 @@ _08042E82:
pop {r0}
bx r0
.align 2, 0
-_08042E90: .4byte gUnknown_203B418
+_08042E90: .4byte gDungeonGlobalData
_08042E94: .4byte 0x000005c4
thumb_func_end sub_8042E5C
@@ -571,7 +571,7 @@ _08042EA6:
pop {r0}
bx r0
.align 2, 0
-_08042EC0: .4byte gUnknown_203B418
+_08042EC0: .4byte gDungeonGlobalData
_08042EC4: .4byte 0x000005c4
thumb_func_end sub_8042E98
@@ -655,7 +655,7 @@ _08042F4A:
pop {r0}
bx r0
.align 2, 0
-_08042F5C: .4byte gUnknown_203B418
+_08042F5C: .4byte gDungeonGlobalData
_08042F60: .4byte 0x000005c4
_08042F64: .4byte 0xffff0000
_08042F68: .4byte 0x0000ffff
@@ -860,7 +860,7 @@ _080430D8:
.align 2, 0
_0804310C: .4byte gUnknown_203B40C
_08043110: .4byte gUnknown_203B41C
-_08043114: .4byte gUnknown_203B418
+_08043114: .4byte gDungeonGlobalData
_08043118: .4byte 0x0001cedb
_0804311C: .4byte gUnknown_203B410
_08043120: .4byte 0x0000064c
@@ -907,7 +907,7 @@ _0804315E:
b _080431AC
.align 2, 0
_0804318C: .4byte 0x00000644
-_08043190: .4byte gUnknown_203B418
+_08043190: .4byte gDungeonGlobalData
_08043194: .4byte 0x00000674
_08043198: .4byte 0x0000067c
_0804319C:
@@ -964,7 +964,7 @@ _080431DC:
.align 2, 0
_08043208: .4byte 0x0000067c
_0804320C: .4byte 0x00ffffff
-_08043210: .4byte gUnknown_203B418
+_08043210: .4byte gDungeonGlobalData
_08043214: .4byte 0x00000644
_08043218: .4byte gUnknown_202DE30
_0804321C: .4byte 0x0000067b
@@ -1038,7 +1038,7 @@ _0804326A:
b _080432F4
.align 2, 0
_080432B4: .4byte gUnknown_80FEC7C
-_080432B8: .4byte gUnknown_203B418
+_080432B8: .4byte gDungeonGlobalData
_080432BC: .4byte 0x00000644
_080432C0: .4byte gUnknown_202DE30
_080432C4: .4byte gUnknown_81002B8
@@ -1284,7 +1284,7 @@ _080434A6:
.align 2, 0
_080434B8: .4byte gPtrFinalChanceMessage
_080434BC: .4byte gUnknown_203B450
-_080434C0: .4byte gUnknown_203B418
+_080434C0: .4byte gDungeonGlobalData
_080434C4: .4byte 0x000037ec
_080434C8: .4byte 0x000037fc
_080434CC: .4byte 0x000037fd
@@ -1369,7 +1369,7 @@ _08043594:
b _080435D4
.align 2, 0
_080435B4: .4byte gUnknown_80F5668
-_080435B8: .4byte gUnknown_203B418
+_080435B8: .4byte gDungeonGlobalData
_080435BC: .4byte 0x00003a10
_080435C0: .4byte gUnknown_202EDC8
_080435C4: .4byte 0x00000644
@@ -1418,7 +1418,7 @@ _080435D4:
bl sub_804AAAC
b _08043648
.align 2, 0
-_0804362C: .4byte gUnknown_203B418
+_0804362C: .4byte gDungeonGlobalData
_08043630: .4byte 0x00017b2c
_08043634: .4byte 0x00017b38
_08043638: .4byte 0x00017b3c
@@ -1465,7 +1465,7 @@ _08043690:
b _080436AC
.align 2, 0
_080436A0: .4byte gUnknown_203B40C
-_080436A4: .4byte gUnknown_203B418
+_080436A4: .4byte gDungeonGlobalData
_080436A8:
bl sub_803E7C8
_080436AC:
@@ -1529,7 +1529,7 @@ _08043728:
strb r0, [r1, 0x5]
b _0804374C
.align 2, 0
-_08043730: .4byte gUnknown_203B418
+_08043730: .4byte gDungeonGlobalData
_08043734: .4byte 0x0000066c
_08043738: .4byte 0x0000066d
_0804373C: .4byte gUnknown_203B450
@@ -1555,7 +1555,7 @@ _0804374C:
bl sub_807E7FC
b _0804377C
.align 2, 0
-_08043774: .4byte gUnknown_203B418
+_08043774: .4byte gDungeonGlobalData
_08043778:
bl sub_8069E8C
_0804377C:
@@ -1783,7 +1783,7 @@ _0804394C:
bl sub_8080B30
b _080439A6
.align 2, 0
-_08043960: .4byte gUnknown_203B418
+_08043960: .4byte gDungeonGlobalData
_08043964: .4byte 0x00003a08
_08043968: .4byte 0x00000654
_0804396C: .4byte 0x00018218
@@ -1821,7 +1821,7 @@ _080439C4:
bl sub_804700C
b _08043AF4
.align 2, 0
-_080439CC: .4byte gUnknown_203B418
+_080439CC: .4byte gDungeonGlobalData
_080439D0: .4byte 0x00000654
_080439D4:
ldrb r0, [r1, 0x11]
@@ -1939,7 +1939,7 @@ _08043ABA:
bl sub_8097FF8
b _080432FC
.align 2, 0
-_08043ACC: .4byte gUnknown_203B418
+_08043ACC: .4byte gDungeonGlobalData
_08043AD0: .4byte 0x0000066e
_08043AD4: .4byte 0x00000645
_08043AD8: .4byte 0x0001cec8
@@ -2019,7 +2019,7 @@ _08043B38:
.align 2, 0
_08043B80: .4byte 0x00000227
_08043B84: .4byte gUnknown_203B40C
-_08043B88: .4byte gUnknown_203B418
+_08043B88: .4byte gDungeonGlobalData
_08043B8C: .4byte 0x0000fffe
_08043B90: .4byte 0x00000644
_08043B94: .4byte 0x0000067c
@@ -2048,7 +2048,7 @@ _08043BA4:
strh r0, [r3]
b _08043BE6
.align 2, 0
-_08043BC8: .4byte gUnknown_203B418
+_08043BC8: .4byte gDungeonGlobalData
_08043BCC:
cmp r0, 0
bne _08043BDC
@@ -2071,7 +2071,7 @@ _08043BE6:
strb r0, [r4]
b _08043C32
.align 2, 0
-_08043BF4: .4byte gUnknown_203B418
+_08043BF4: .4byte gDungeonGlobalData
_08043BF8: .4byte 0x00000674
_08043BFC:
ldr r0, _08043C20
@@ -2174,7 +2174,7 @@ _08043CAC:
pop {r0}
bx r0
.align 2, 0
-_08043CD0: .4byte gUnknown_203B418
+_08043CD0: .4byte gDungeonGlobalData
_08043CD4: .4byte gUnknown_203B41C
thumb_func_end xxx_dungeon_8042F6C
@@ -2237,7 +2237,7 @@ sub_8043D10:
movs r0, 0x2
b _08043D4C
.align 2, 0
-_08043D38: .4byte gUnknown_203B418
+_08043D38: .4byte gDungeonGlobalData
_08043D3C:
bl sub_80441BC
lsls r0, 24
@@ -2302,7 +2302,7 @@ _08043DA0:
movs r0, 0x1
b _08043DAE
.align 2, 0
-_08043DA4: .4byte gUnknown_203B418
+_08043DA4: .4byte gDungeonGlobalData
_08043DA8: .4byte 0x0001358c
_08043DAC:
movs r0, 0
@@ -2446,7 +2446,7 @@ _08043EA0:
bx r0
.align 2, 0
_08043EC0: .4byte 0x00000207
-_08043EC4: .4byte gUnknown_203B418
+_08043EC4: .4byte gDungeonGlobalData
_08043EC8: .4byte 0x0001357c
_08043ECC: .4byte 0x00000676
thumb_func_end sub_8043D60
@@ -2495,7 +2495,7 @@ _08043F20:
ldr r1, _08043F3C
b _08043FAC
.align 2, 0
-_08043F2C: .4byte gUnknown_203B418
+_08043F2C: .4byte gDungeonGlobalData
_08043F30: .4byte gAvailablePokemonNames
_08043F34: .4byte 0x000005f4
_08043F38: .4byte gUnknown_80F89B4
@@ -2822,7 +2822,7 @@ _080441A4:
pop {r0}
bx r0
.align 2, 0
-_080441AC: .4byte gUnknown_203B418
+_080441AC: .4byte gDungeonGlobalData
_080441B0: .4byte 0x00000644
_080441B4: .4byte gTeamInventory_203B460
_080441B8: .4byte gRecruitedPokemonRef
@@ -2844,7 +2844,7 @@ sub_80441BC:
movs r0, 0x1
b _080441E2
.align 2, 0
-_080441D8: .4byte gUnknown_203B418
+_080441D8: .4byte gDungeonGlobalData
_080441DC: .4byte 0x00003a14
_080441E0:
movs r0, 0
@@ -2867,7 +2867,7 @@ sub_80441E8:
movs r0, 0
b _0804420A
.align 2, 0
-_08044200: .4byte gUnknown_203B418
+_08044200: .4byte gDungeonGlobalData
_08044204: .4byte 0x00003a0e
_08044208:
movs r0, 0x1
@@ -2892,7 +2892,7 @@ sub_8044210:
movs r0, 0
b _08044236
.align 2, 0
-_0804422C: .4byte gUnknown_203B418
+_0804422C: .4byte gDungeonGlobalData
_08044230: .4byte 0x00000644
_08044234:
movs r0, 0x1
@@ -2965,7 +2965,7 @@ _080442C6:
pop {r0}
bx r0
.align 2, 0
-_080442CC: .4byte gUnknown_203B418
+_080442CC: .4byte gDungeonGlobalData
thumb_func_end RunDungeon
thumb_func_start xxx_dungeon_80442D0
@@ -3009,7 +3009,7 @@ _0804431A:
b _0804444E
.align 2, 0
_08044320: .4byte gUnknown_80F6860
-_08044324: .4byte gUnknown_203B418
+_08044324: .4byte gDungeonGlobalData
_08044328:
bl sub_8083600
adds r5, r0, 0
@@ -3057,7 +3057,7 @@ _0804435C:
movs r7, 0
b _0804439A
.align 2, 0
-_08044388: .4byte gUnknown_203B418
+_08044388: .4byte gDungeonGlobalData
_0804438C: .4byte 0x0000066c
_08044390: .4byte 0x00000673
_08044394:
@@ -3131,7 +3131,7 @@ _08044400:
movs r7, 0x1
b _08044328
.align 2, 0
-_08044434: .4byte gUnknown_203B418
+_08044434: .4byte gDungeonGlobalData
_08044438:
ldr r0, [r5, 0x70]
adds r0, 0xF8
@@ -3222,7 +3222,7 @@ _080444E2:
pop {r0}
bx r0
.align 2, 0
-_080444E8: .4byte gUnknown_203B418
+_080444E8: .4byte gDungeonGlobalData
_080444EC: .4byte 0x000135cc
_080444F0: .4byte 0x00007fff
thumb_func_end sub_8044454
@@ -3286,7 +3286,7 @@ _08044566:
pop {r0}
bx r0
.align 2, 0
-_0804456C: .4byte gUnknown_203B418
+_0804456C: .4byte gDungeonGlobalData
_08044570: .4byte 0x000135cc
thumb_func_end sub_80444F4
@@ -3384,7 +3384,7 @@ _08044592:
strh r0, [r6]
b _080446A4
.align 2, 0
-_08044634: .4byte gUnknown_203B418
+_08044634: .4byte gDungeonGlobalData
_08044638: .4byte 0x0001357c
_0804463C: .4byte gUnknown_80F6860
_08044640: .4byte 0x0000bfff
@@ -3487,7 +3487,7 @@ _080446D4:
strb r1, [r2]
b _08044760
.align 2, 0
-_08044710: .4byte gUnknown_203B418
+_08044710: .4byte gDungeonGlobalData
_08044714: .4byte 0x0001357c
_08044718:
mov r2, r10
@@ -3617,7 +3617,7 @@ _08044802:
bx r0
.align 2, 0
_08044814: .4byte 0x00000145
-_08044818: .4byte gUnknown_203B418
+_08044818: .4byte gDungeonGlobalData
_0804481C: .4byte 0x0001357c
thumb_func_end sub_8044574
@@ -3793,7 +3793,7 @@ _0804497A:
.align 2, 0
_08044984: .4byte 0x00003fff
_08044988: .4byte 0x00000145
-_0804498C: .4byte gUnknown_203B418
+_0804498C: .4byte gDungeonGlobalData
_08044990: .4byte 0x0001358c
thumb_func_end sub_8044820
@@ -3929,7 +3929,7 @@ _08044A8A:
bx r0
.align 2, 0
_08044A94: .4byte gUnknown_80F6860
-_08044A98: .4byte gUnknown_203B418
+_08044A98: .4byte gDungeonGlobalData
_08044A9C: .4byte 0x000037f8
_08044AA0: .4byte 0x000037f9
_08044AA4: .4byte 0x000037fa
@@ -3961,7 +3961,7 @@ sub_8044AB4:
b _08044AE6
.align 2, 0
_08044ADC: .4byte gUnknown_80F6860
-_08044AE0: .4byte gUnknown_203B418
+_08044AE0: .4byte gDungeonGlobalData
_08044AE4:
adds r4, 0x1
_08044AE6:
@@ -3992,7 +3992,7 @@ _08044B1A:
pop {r0}
bx r0
.align 2, 0
-_08044B20: .4byte gUnknown_203B418
+_08044B20: .4byte gDungeonGlobalData
_08044B24: .4byte 0x000135cc
thumb_func_end sub_8044AB4
@@ -4014,7 +4014,7 @@ sub_8044B28:
strb r1, [r0]
b _08044B76
.align 2, 0
-_08044B48: .4byte gUnknown_203B418
+_08044B48: .4byte gDungeonGlobalData
_08044B4C: .4byte 0x00000654
_08044B50:
ldr r0, [r4]
@@ -4060,7 +4060,7 @@ sub_8044B84:
lsrs r0, 24
b _08044BA2
.align 2, 0
-_08044B9C: .4byte gUnknown_203B418
+_08044B9C: .4byte gDungeonGlobalData
_08044BA0:
movs r0, 0x1
_08044BA2:
@@ -4293,7 +4293,7 @@ _08044D34:
pop {r1}
bx r1
.align 2, 0
-_08044D38: .4byte gUnknown_203B418
+_08044D38: .4byte gDungeonGlobalData
_08044D3C: .4byte 0x0001357c
thumb_func_end sub_8044CC8
@@ -4370,7 +4370,7 @@ sub_8044DA4:
ldr r0, [r2]
bx lr
.align 2, 0
-_08044DC0: .4byte gUnknown_203B418
+_08044DC0: .4byte gDungeonGlobalData
_08044DC4: .4byte 0x0001357c
thumb_func_end sub_8044DA4
@@ -4994,7 +4994,7 @@ _080451DE:
pop {r0}
bx r0
.align 2, 0
-_080451FC: .4byte gUnknown_203B418
+_080451FC: .4byte gDungeonGlobalData
_08045200: .4byte 0x0001357c
_08045204: .4byte 0x0001381c
_08045208: .4byte gUnknown_202EE70
@@ -5046,7 +5046,7 @@ _08045248:
bl sub_806C51C
b _080452A2
.align 2, 0
-_08045274: .4byte gUnknown_203B418
+_08045274: .4byte gDungeonGlobalData
_08045278: .4byte 0x00018210
_0804527C: .4byte 0x0001820a
_08045280: .4byte 0x000135cc
@@ -5149,7 +5149,7 @@ _0804533E:
pop {r0}
bx r0
.align 2, 0
-_08045348: .4byte gUnknown_203B418
+_08045348: .4byte gDungeonGlobalData
_0804534C: .4byte 0x0001357c
_08045350: .4byte 0x0001358c
_08045354: .4byte 0x00003904
@@ -5366,7 +5366,7 @@ _080454C6:
b _080454FE
.align 2, 0
_080454DC: .4byte 0x0000069c
-_080454E0: .4byte gUnknown_203B418
+_080454E0: .4byte gDungeonGlobalData
_080454E4: .4byte 0x0001357c
_080454E8: .4byte 0x00000167
_080454EC: .4byte gUnknown_202EE70
@@ -5559,7 +5559,7 @@ _08045636:
b _08045672
.align 2, 0
_08045650: .4byte 0x00000ebc
-_08045654: .4byte gUnknown_203B418
+_08045654: .4byte gDungeonGlobalData
_08045658: .4byte 0x0001358c
_0804565C: .4byte 0x00000167
_08045660: .4byte gUnknown_202EE76
@@ -5634,7 +5634,7 @@ _080456A2:
adds r0, r4, 0
b _080456FA
.align 2, 0
-_080456E4: .4byte gUnknown_203B418
+_080456E4: .4byte gDungeonGlobalData
_080456E8: .4byte 0x00003908
_080456EC: .4byte 0x0001371c
_080456F0:
@@ -5685,7 +5685,7 @@ sub_8045708:
b _080457C4
.align 2, 0
_08045744: .4byte gUnknown_810ACC0
-_08045748: .4byte gUnknown_203B418
+_08045748: .4byte gDungeonGlobalData
_0804574C: .4byte 0x00003a0e
_08045750:
movs r0, 0x3
@@ -5756,7 +5756,7 @@ _080457C6:
pop {r1}
bx r1
.align 2, 0
-_080457D4: .4byte gUnknown_203B418
+_080457D4: .4byte gDungeonGlobalData
_080457D8: .4byte 0x0001361c
thumb_func_end sub_8045708
@@ -5841,7 +5841,7 @@ _0804584C:
lsrs r0, 24
b _08045882
.align 2, 0
-_08045874: .4byte gUnknown_203B418
+_08045874: .4byte gDungeonGlobalData
_08045878: .4byte 0x000181e8
_0804587C: .4byte 0x0001820f
_08045880:
@@ -5908,7 +5908,7 @@ _080458B4:
ldr r0, [r0]
mov pc, r0
.align 2, 0
-_080458F0: .4byte gUnknown_203B418
+_080458F0: .4byte gDungeonGlobalData
_080458F4: .4byte 0x000181f0
_080458F8: .4byte 0x000181f2
_080458FC: .4byte 0x000181e8
@@ -5957,7 +5957,7 @@ _08045954:
adds r0, 0x25
b _08045920
.align 2, 0
-_0804595C: .4byte gUnknown_203B418
+_0804595C: .4byte gDungeonGlobalData
_08045960: .4byte 0x0001820f
_08045964:
ldr r0, _0804597C
@@ -5972,7 +5972,7 @@ _08045964:
ldrb r0, [r0]
b _0804592E
.align 2, 0
-_0804597C: .4byte gUnknown_203B418
+_0804597C: .4byte gDungeonGlobalData
_08045980: .4byte 0x0001820f
_08045984:
movs r0, 0x1
@@ -6235,7 +6235,7 @@ _08045B4A:
pop {r0}
bx r0
.align 2, 0
-_08045B50: .4byte gUnknown_203B418
+_08045B50: .4byte gDungeonGlobalData
_08045B54: .4byte 0x0001357c
_08045B58: .4byte 0x000135cc
_08045B5C: .4byte 0x0001358c
@@ -6257,7 +6257,7 @@ _08045B6E:
adds r0, r2, 0
b _08045B8C
.align 2, 0
-_08045B78: .4byte gUnknown_203B418
+_08045B78: .4byte gDungeonGlobalData
_08045B7C: .4byte 0x0001357c
_08045B80:
adds r1, 0x4
@@ -6386,7 +6386,7 @@ sub_8045C28:
bge _08045C72
b _08045C76
.align 2, 0
-_08045C64: .4byte gUnknown_203B418
+_08045C64: .4byte gDungeonGlobalData
_08045C68: .4byte 0x0001c57e
_08045C6C:
cmp r6, 0x1
@@ -6422,7 +6422,7 @@ _08045CA2:
pop {r0}
bx r0
.align 2, 0
-_08045CA8: .4byte gUnknown_203B418
+_08045CA8: .4byte gDungeonGlobalData
_08045CAC: .4byte 0x0001c58b
thumb_func_end sub_8045C28
@@ -6496,7 +6496,7 @@ _08045CF6:
movs r0, 0x1
b _08045D58
.align 2, 0
-_08045D34: .4byte gUnknown_203B418
+_08045D34: .4byte gDungeonGlobalData
_08045D38: .4byte 0x00003904
_08045D3C:
movs r0, 0x3
@@ -6677,7 +6677,7 @@ _08045E94:
mov r8, r2
b _08045EC4
.align 2, 0
-_08045EA8: .4byte gUnknown_203B418
+_08045EA8: .4byte gDungeonGlobalData
_08045EAC: .4byte 0x0000065b
_08045EB0: .4byte gTeamInventory_203B460
_08045EB4:
@@ -7025,7 +7025,7 @@ _08046110:
ldr r1, _0804616C
b _0804617E
.align 2, 0
-_08046168: .4byte gUnknown_203B418
+_08046168: .4byte gDungeonGlobalData
_0804616C: .4byte 0x0000068c
_08046170:
adds r0, r6, 0
@@ -7070,7 +7070,7 @@ _080461B6:
pop {r1}
bx r1
.align 2, 0
-_080461BC: .4byte gUnknown_203B418
+_080461BC: .4byte gDungeonGlobalData
_080461C0: .4byte 0x0001361c
_080461C4: .4byte 0x00003904
thumb_func_end sub_80460F8
@@ -7126,7 +7126,7 @@ _080461F2:
adds r2, r1
b _08046248
.align 2, 0
-_08046230: .4byte gUnknown_203B418
+_08046230: .4byte gDungeonGlobalData
_08046234: .4byte 0x0000068c
_08046238:
adds r0, r4, 0
@@ -7174,7 +7174,7 @@ _08046284:
pop {r1}
bx r1
.align 2, 0
-_0804628C: .4byte gUnknown_203B418
+_0804628C: .4byte gDungeonGlobalData
_08046290: .4byte 0x0001361c
_08046294: .4byte 0x00003904
thumb_func_end sub_80461C8
@@ -7327,7 +7327,7 @@ _08046380:
strh r0, [r5, 0x4]
b _08046408
.align 2, 0
-_080463A4: .4byte gUnknown_203B418
+_080463A4: .4byte gDungeonGlobalData
_080463A8: .4byte 0x000181f0
_080463AC: .4byte 0x000181f2
_080463B0: .4byte gUnknown_202EDC0
@@ -7918,7 +7918,7 @@ _08046822:
pop {r0}
bx r0
.align 2, 0
-_08046858: .4byte gUnknown_203B418
+_08046858: .4byte gDungeonGlobalData
_0804685C: .4byte 0x00018210
thumb_func_end sub_8046734
@@ -8460,7 +8460,7 @@ _08046C7C:
.align 2, 0
_08046C90: .4byte gUnknown_80F947C
_08046C94: .4byte 0x00000524
-_08046C98: .4byte gUnknown_203B418
+_08046C98: .4byte gDungeonGlobalData
_08046C9C: .4byte 0x00018210
_08046CA0: .4byte 0x0000053c
_08046CA4: .4byte 0x000004b4
@@ -8564,7 +8564,7 @@ sub_8046D20:
strb r0, [r1, 0x11]
b _08046D68
.align 2, 0
-_08046D5C: .4byte gUnknown_203B418
+_08046D5C: .4byte gDungeonGlobalData
_08046D60: .4byte gUnknown_80FA408
_08046D64:
bl sub_8046D8C
@@ -8586,7 +8586,7 @@ sub_8046D70:
pop {r1}
bx r1
.align 2, 0
-_08046D84: .4byte gUnknown_203B418
+_08046D84: .4byte gDungeonGlobalData
_08046D88: .4byte 0x0000068a
thumb_func_end sub_8046D70
@@ -8751,7 +8751,7 @@ _08046ED4:
.align 2, 0
_08046EDC: .4byte gTeamInventory_203B460
_08046EE0: .4byte sub_80861A8
-_08046EE4: .4byte gUnknown_203B418
+_08046EE4: .4byte gDungeonGlobalData
_08046EE8: .4byte 0x0001356c
_08046EEC: .4byte gUnknown_810531C
_08046EF0: .4byte gUnknown_8105360
@@ -8818,7 +8818,7 @@ _08046F6E:
movs r0, 0
b _08046F7E
.align 2, 0
-_08046F74: .4byte gUnknown_203B418
+_08046F74: .4byte gDungeonGlobalData
_08046F78: .4byte 0x0001357c
_08046F7C:
movs r0, 0x1
@@ -8896,7 +8896,7 @@ _08046FF4:
bx r0
.align 2, 0
_08047000: .4byte gTeamInventory_203B460
-_08047004: .4byte gUnknown_203B418
+_08047004: .4byte gDungeonGlobalData
_08047008: .4byte 0x0001357c
thumb_func_end sub_8046F84
@@ -8958,7 +8958,7 @@ _0804706C:
bx r0
.align 2, 0
_08047078: .4byte gTeamInventory_203B460
-_0804707C: .4byte gUnknown_203B418
+_0804707C: .4byte gDungeonGlobalData
_08047080: .4byte 0x0001357c
thumb_func_end sub_804700C
@@ -9017,7 +9017,7 @@ _080470E2:
b _080470FC
.align 2, 0
_080470E8: .4byte gTeamInventory_203B460
-_080470EC: .4byte gUnknown_203B418
+_080470EC: .4byte gDungeonGlobalData
_080470F0: .4byte 0x0001357c
_080470F4:
adds r5, 0x1
@@ -9285,7 +9285,7 @@ _080472E0:
b _0804744C
.align 2, 0
_080472E8: .4byte 0xfffffdc0
-_080472EC: .4byte gUnknown_203B418
+_080472EC: .4byte gDungeonGlobalData
_080472F0: .4byte 0x00018210
_080472F4: .4byte 0x0001c05e
_080472F8: .4byte gUnknown_80F4448
@@ -9514,7 +9514,7 @@ _080474A6:
b _08047524
.align 2, 0
_080474B8: .4byte 0x00000195
-_080474BC: .4byte gUnknown_203B418
+_080474BC: .4byte gDungeonGlobalData
_080474C0: .4byte 0x0001c05e
_080474C4: .4byte gAvailablePokemonNames
_080474C8: .4byte gUnknown_202DE58
@@ -9962,7 +9962,7 @@ _08047834:
ands r6, r0
b _0804786E
.align 2, 0
-_08047848: .4byte gUnknown_203B418
+_08047848: .4byte gDungeonGlobalData
_0804784C: .4byte 0x00018210
_08047850: .4byte 0x0001c05e
_08047854: .4byte 0x00000195
diff --git a/asm/code_8048480.s b/asm/code_8048480.s
index 61085f7..13289fc 100644
--- a/asm/code_8048480.s
+++ b/asm/code_8048480.s
@@ -222,7 +222,7 @@ sub_804869C:
bl sub_80522F4
b _080486EA
.align 2, 0
-_080486D4: .4byte gUnknown_203B418
+_080486D4: .4byte gDungeonGlobalData
_080486D8: .4byte 0x00000675
_080486DC: .4byte gUnknown_80F4FA8
_080486E0: .4byte gUnknown_80FEAE8
@@ -294,7 +294,7 @@ _08048748:
bl sub_80522F4
b _08048786
.align 2, 0
-_08048770: .4byte gUnknown_203B418
+_08048770: .4byte gDungeonGlobalData
_08048774: .4byte 0x00000675
_08048778: .4byte gUnknown_80F4FAA
_0804877C: .4byte gUnknown_80FEAE8
@@ -640,7 +640,7 @@ _080489F6:
movs r0, 0x1
b _08048A06
.align 2, 0
-_080489FC: .4byte gUnknown_203B418
+_080489FC: .4byte gDungeonGlobalData
_08048A00: .4byte 0x0001357c
_08048A04:
movs r0, 0
@@ -727,7 +727,7 @@ _08048A90:
ldr r0, _08048AAC
b _08048A80
.align 2, 0
-_08048AA4: .4byte gUnknown_203B418
+_08048AA4: .4byte gDungeonGlobalData
_08048AA8: .4byte 0x0000065c
_08048AAC: .4byte gUnknown_80F9BD8
_08048AB0:
@@ -793,7 +793,7 @@ _08048B20:
movs r0, 0x1
b _08048B36
.align 2, 0
-_08048B24: .4byte gUnknown_203B418
+_08048B24: .4byte gDungeonGlobalData
_08048B28: .4byte 0x0001357c
_08048B2C: .4byte gRecruitedPokemonRef
_08048B30: .4byte 0x00008df8
@@ -840,7 +840,7 @@ _08048B4A:
b _08048B8E
.align 2, 0
_08048B84: .4byte 0x00000157
-_08048B88: .4byte gUnknown_203B418
+_08048B88: .4byte gDungeonGlobalData
_08048B8C:
movs r0, 0
_08048B8E:
@@ -926,7 +926,7 @@ _08048C24:
movs r0, 0x1
b _08048C32
.align 2, 0
-_08048C28: .4byte gUnknown_203B418
+_08048C28: .4byte gDungeonGlobalData
_08048C2C: .4byte 0x0001357c
_08048C30:
movs r0, 0
@@ -1970,7 +1970,7 @@ sub_804954C:
ldr r0, [r1]
b _08049588
.align 2, 0
-_0804957C: .4byte gUnknown_203B418
+_0804957C: .4byte gDungeonGlobalData
_08049580: .4byte 0x0000e8c0
_08049584:
ldr r0, _0804958C
@@ -2025,7 +2025,7 @@ _080495D6:
pop {r1}
bx r1
.align 2, 0
-_080495DC: .4byte gUnknown_203B418
+_080495DC: .4byte gDungeonGlobalData
_080495E0: .4byte 0x0000e8c0
thumb_func_end sub_8049590
@@ -2092,7 +2092,7 @@ _08049614:
pop {r0}
bx r0
.align 2, 0
-_08049658: .4byte gUnknown_203B418
+_08049658: .4byte gDungeonGlobalData
_0804965C: .4byte 0x0000e8c0
_08049660: .4byte 0x00003a18
_08049664: .4byte 0x00003a0e
@@ -2190,7 +2190,7 @@ sub_804966C:
.align 2, 0
_08049734: .4byte gUnknown_80F6A04
_08049738: .4byte gUnknown_8108EC0
-_0804973C: .4byte gUnknown_203B418
+_0804973C: .4byte gDungeonGlobalData
_08049740: .4byte 0x00003a0e
_08049744: .4byte gDungeonFileArchive
_08049748: .4byte 0x06008000
@@ -2264,7 +2264,7 @@ _08049794:
_080497E8: .4byte gUnknown_80F6A34
_080497EC: .4byte 0x00012c24
_080497F0: .4byte gUnknown_80F6A40
-_080497F4: .4byte gUnknown_203B418
+_080497F4: .4byte gDungeonGlobalData
_080497F8: .4byte 0x00003a0e
_080497FC: .4byte gDungeonFileArchive
_08049800: .4byte gUnknown_202F18C
@@ -2316,7 +2316,7 @@ sub_8049840:
ldr r0, _0804986C
b _08049874
.align 2, 0
-_08049860: .4byte gUnknown_203B418
+_08049860: .4byte gDungeonGlobalData
_08049864: .4byte 0x00003a0e
_08049868: .4byte gUnknown_203B430
_0804986C: .4byte gUnknown_80F69EC
@@ -2413,7 +2413,7 @@ _080498D0:
add r1, r10
b _08049B68
.align 2, 0
-_08049914: .4byte gUnknown_203B418
+_08049914: .4byte gDungeonGlobalData
_08049918: .4byte 0x00003a0e
_0804991C:
mov r0, r10
@@ -2754,7 +2754,7 @@ _08049B72:
pop {r0}
bx r0
.align 2, 0
-_08049B84: .4byte gUnknown_203B418
+_08049B84: .4byte gDungeonGlobalData
_08049B88: .4byte 0x00012c24
thumb_func_end sub_80498A8
@@ -3289,7 +3289,7 @@ _08049F1C:
adds r2, r6, r0
b _0804A06A
.align 2, 0
-_08049F78: .4byte gUnknown_203B418
+_08049F78: .4byte gDungeonGlobalData
_08049F7C: .4byte 0x00018210
_08049F80: .4byte 0x0001820f
_08049F84: .4byte 0x000181f0
@@ -3686,7 +3686,7 @@ sub_804A1F0:
adds r2, r7, r0
b _0804A356
.align 2, 0
-_0804A284: .4byte gUnknown_203B418
+_0804A284: .4byte gDungeonGlobalData
_0804A288: .4byte 0x00018210
_0804A28C: .4byte 0x0001820f
_0804A290: .4byte 0x000181f0
@@ -4034,7 +4034,7 @@ sub_804A49C:
adds r2, r7, r0
b _0804A5DA
.align 2, 0
-_0804A52C: .4byte gUnknown_203B418
+_0804A52C: .4byte gDungeonGlobalData
_0804A530: .4byte 0x00018210
_0804A534: .4byte 0x0001820f
_0804A538: .4byte gUnknown_80F6A4A
@@ -4415,7 +4415,7 @@ _0804A7AC:
str r1, [sp, 0x38]
b _0804A8FC
.align 2, 0
-_0804A814: .4byte gUnknown_203B418
+_0804A814: .4byte gDungeonGlobalData
_0804A818: .4byte 0x000181f0
_0804A81C: .4byte 0x0001821a
_0804A820: .4byte gUnknown_80F4448
@@ -4749,7 +4749,7 @@ _0804AA78:
bx r0
.align 2, 0
_0804AAA0: .4byte gUnknown_202B038
-_0804AAA4: .4byte gUnknown_203B418
+_0804AAA4: .4byte gDungeonGlobalData
_0804AAA8: .4byte 0x0001821a
thumb_func_end sub_804AA60
@@ -4940,7 +4940,7 @@ _0804ABE4:
pop {r0}
bx r0
.align 2, 0
-_0804AC04: .4byte gUnknown_203B418
+_0804AC04: .4byte gDungeonGlobalData
_0804AC08: .4byte 0x0000270f
_0804AC0C: .4byte 0x0000d8f1
_0804AC10: .4byte 0x000104c4
@@ -4990,7 +4990,7 @@ _0804AC52:
mov r8, r0
b _0804ACA2
.align 2, 0
-_0804AC6C: .4byte gUnknown_203B418
+_0804AC6C: .4byte gDungeonGlobalData
_0804AC70: .4byte 0x00018209
_0804AC74:
lsls r0, r1, 3
@@ -5203,7 +5203,7 @@ _0804ADEE:
bx r1
.align 2, 0
_0804ADFC: .4byte 0x0000fffc
-_0804AE00: .4byte gUnknown_203B418
+_0804AE00: .4byte gDungeonGlobalData
_0804AE04: .4byte 0x000135cc
thumb_func_end sub_804AD34
@@ -5347,7 +5347,7 @@ _0804AF0E:
bx r0
.align 2, 0
_0804AF14: .4byte 0x0000ffef
-_0804AF18: .4byte gUnknown_203B418
+_0804AF18: .4byte gDungeonGlobalData
_0804AF1C: .4byte 0x000135cc
thumb_func_end sub_804AE84
@@ -5392,7 +5392,7 @@ _0804AF5E:
bx r1
.align 2, 0
_0804AF68: .4byte gUnknown_810ACC0
-_0804AF6C: .4byte gUnknown_203B418
+_0804AF6C: .4byte gDungeonGlobalData
_0804AF70: .4byte 0x00003a0e
thumb_func_end sub_804AF20
@@ -5419,7 +5419,7 @@ _0804AF96:
movs r0, 0x1
b _0804AFA6
.align 2, 0
-_0804AF9C: .4byte gUnknown_203B418
+_0804AF9C: .4byte gDungeonGlobalData
_0804AFA0: .4byte 0x00003a0e
_0804AFA4:
movs r0, 0
@@ -5589,7 +5589,7 @@ _0804B09C:
_0804B0E4:
b _0804B2F6
.align 2, 0
-_0804B0E8: .4byte gUnknown_203B418
+_0804B0E8: .4byte gDungeonGlobalData
_0804B0EC: .4byte 0x0001c574
_0804B0F0: .4byte gUnknown_80F6DCC
_0804B0F4: .4byte gDungeonFileArchive
@@ -5692,7 +5692,7 @@ _0804B1C0:
ldr r0, [r0]
mov pc, r0
.align 2, 0
-_0804B1EC: .4byte gUnknown_203B418
+_0804B1EC: .4byte gDungeonGlobalData
_0804B1F0: .4byte 0x00003a08
_0804B1F4: .4byte 0x00003a0c
_0804B1F8: .4byte gUnknown_202F1D0
@@ -5755,7 +5755,7 @@ _0804B280:
adds r0, r1
b _0804B2BC
.align 2, 0
-_0804B290: .4byte gUnknown_203B418
+_0804B290: .4byte gDungeonGlobalData
_0804B294: .4byte 0x00003a08
_0804B298:
mov r0, r8
@@ -5781,7 +5781,7 @@ _0804B2BC:
strb r1, [r0]
b _0804B2F6
.align 2, 0
-_0804B2C4: .4byte gUnknown_203B418
+_0804B2C4: .4byte gDungeonGlobalData
_0804B2C8: .4byte 0x00003a08
_0804B2CC:
mov r0, r8
@@ -6027,7 +6027,7 @@ _0804B498:
_0804B4B4: .4byte gUnknown_202F1A9
_0804B4B8: .4byte gUnknown_202F1D8
_0804B4BC: .4byte 0x0000ffff
-_0804B4C0: .4byte gUnknown_203B418
+_0804B4C0: .4byte gDungeonGlobalData
_0804B4C4: .4byte 0x00003a08
_0804B4C8: .4byte 0x0000e218
_0804B4CC: .4byte 0x0000e21a
@@ -6069,7 +6069,7 @@ _0804B504:
pop {r0}
bx r0
.align 2, 0
-_0804B524: .4byte gUnknown_203B418
+_0804B524: .4byte gDungeonGlobalData
_0804B528: .4byte 0x00003a0a
_0804B52C: .4byte gUnknown_202F1A8
_0804B530: .4byte 0x00013568
@@ -8305,7 +8305,7 @@ _0804C736:
bl sub_804C918
b _0804C782
.align 2, 0
-_0804C73C: .4byte gUnknown_203B418
+_0804C73C: .4byte gDungeonGlobalData
_0804C740: .4byte 0x00013568
_0804C744:
cmp r7, 0x31
@@ -13258,7 +13258,7 @@ _0804EBA2:
pop {r0}
bx r0
.align 2, 0
-_0804EBB4: .4byte gUnknown_203B418
+_0804EBB4: .4byte gDungeonGlobalData
_0804EBB8: .4byte 0x00010882
_0804EBBC: .4byte 0x00010844
_0804EBC0: .4byte 0x00010884
@@ -13651,7 +13651,7 @@ _0804EE6C:
strh r4, [r0, 0x2]
b _0804EED4
.align 2, 0
-_0804EE90: .4byte gUnknown_203B418
+_0804EE90: .4byte gDungeonGlobalData
_0804EE94: .4byte gUnknown_202F1D8
_0804EE98: .4byte 0x0000ffff
_0804EE9C: .4byte gUnknown_202F1AB
@@ -13916,7 +13916,7 @@ _0804F086:
blt _0804F046
b _0804F0C0
.align 2, 0
-_0804F094: .4byte gUnknown_203B418
+_0804F094: .4byte gDungeonGlobalData
_0804F098: .4byte gUnknown_202F1AA
_0804F09C: .4byte gUnknown_202F1AB
_0804F0A0: .4byte 0x00003a0c
@@ -14145,7 +14145,7 @@ _0804F1DE:
bl sub_804F278
b _0804F266
.align 2, 0
-_0804F244: .4byte gUnknown_203B418
+_0804F244: .4byte gDungeonGlobalData
_0804F248: .4byte 0x00003a16
_0804F24C:
movs r0, 0x1
@@ -15795,7 +15795,7 @@ _0804FE96:
pop {r0}
bx r0
.align 2, 0
-_0804FEB4: .4byte gUnknown_203B418
+_0804FEB4: .4byte gDungeonGlobalData
_0804FEB8: .4byte 0x0000e21c
_0804FEBC: .4byte 0x0000ffff
_0804FEC0: .4byte 0x0000e21e
@@ -16253,7 +16253,7 @@ _08050230:
b _08050254
.align 2, 0
_08050234: .4byte 0xffffe3fc
-_08050238: .4byte gUnknown_203B418
+_08050238: .4byte gDungeonGlobalData
_0805023C: .4byte 0x0000e21c
_08050240: .4byte 0x0000e21e
_08050244: .4byte 0x0000fffd
@@ -16501,7 +16501,7 @@ _08050410:
pop {r0}
bx r0
.align 2, 0
-_08050424: .4byte gUnknown_203B418
+_08050424: .4byte gDungeonGlobalData
_08050428: .4byte 0x0000065c
_0805042C: .4byte 0x0000e218
_08050430: .4byte 0x0000e21a
@@ -16538,7 +16538,7 @@ sub_8050438:
b _0805047A
.align 2, 0
_08050470: .4byte 0xffffe3f8
-_08050474: .4byte gUnknown_203B418
+_08050474: .4byte gDungeonGlobalData
_08050478:
adds r7, r1, 0
_0805047A:
@@ -16827,7 +16827,7 @@ _0805068C:
.align 2, 0
_080506A0: .4byte 0x0000e218
_080506A4: .4byte 0x0000e21a
-_080506A8: .4byte gUnknown_203B418
+_080506A8: .4byte gDungeonGlobalData
_080506AC: .4byte 0x00003a08
_080506B0: .4byte gUnknown_80F4DA4
_080506B4: .4byte 0x00001c04
@@ -17991,7 +17991,7 @@ _08050F36:
.align 2, 0
_08050F3C: .4byte 0xfffff8ec
_08050F40: .4byte 0x00007fff
-_08050F44: .4byte gUnknown_203B418
+_08050F44: .4byte gDungeonGlobalData
_08050F48: .4byte 0x0000e21c
_08050F4C: .4byte 0x0000e21e
_08050F50: .4byte gUnknown_202F1D4
@@ -18557,7 +18557,7 @@ _08051350:
orrs r1, r0
b _0805139E
.align 2, 0
-_08051374: .4byte gUnknown_203B418
+_08051374: .4byte gDungeonGlobalData
_08051378: .4byte 0x00013568
_0805137C: .4byte 0x0000e260
_08051380: .4byte 0x0000e262
@@ -18647,7 +18647,7 @@ _08051416:
bx r0
.align 2, 0
_0805142C: .4byte 0x0000fffc
-_08051430: .4byte gUnknown_203B418
+_08051430: .4byte gDungeonGlobalData
_08051434: .4byte 0x00003a0e
thumb_func_end sub_8051288
@@ -18842,7 +18842,7 @@ _08051598:
blt _080514C4
b _08051640
.align 2, 0
-_080515AC: .4byte gUnknown_203B418
+_080515AC: .4byte gDungeonGlobalData
_080515B0: .4byte gUnknown_202F1DC
_080515B4: .4byte 0x00013568
_080515B8: .4byte gUnknown_202F1E1
@@ -19603,7 +19603,7 @@ _08051BF0:
movs r2, 0
b _08051D42
.align 2, 0
-_08051BFC: .4byte gUnknown_203B418
+_08051BFC: .4byte gDungeonGlobalData
_08051C00: .4byte 0x00000684
_08051C04: .4byte 0x00000686
_08051C08: .4byte 0x0000fffc
@@ -19637,7 +19637,7 @@ _08051C20:
b _08051E1A
.align 2, 0
_08051C44: .4byte 0x0000fffc
-_08051C48: .4byte gUnknown_203B418
+_08051C48: .4byte gDungeonGlobalData
_08051C4C: .4byte 0x0000e218
_08051C50: .4byte 0x0000e21a
_08051C54:
@@ -19698,7 +19698,7 @@ _08051C94:
.align 2, 0
_08051CC0: .4byte 0x0000fffc
_08051CC4: .4byte 0x0000fffd
-_08051CC8: .4byte gUnknown_203B418
+_08051CC8: .4byte gDungeonGlobalData
_08051CCC: .4byte 0x0000e21c
_08051CD0: .4byte 0x0000e21e
_08051CD4:
@@ -19817,7 +19817,7 @@ _08051DA4:
strb r1, [r0]
b _08051DDC
.align 2, 0
-_08051DB0: .4byte gUnknown_203B418
+_08051DB0: .4byte gDungeonGlobalData
_08051DB4: .4byte 0x0000068b
_08051DB8:
ldr r2, [r5, 0x4]
@@ -19880,7 +19880,7 @@ _08051E1A:
pop {r1}
bx r1
.align 2, 0
-_08051E2C: .4byte gUnknown_203B418
+_08051E2C: .4byte gDungeonGlobalData
_08051E30: .4byte 0x0000e220
_08051E34: .4byte 0x0000e222
_08051E38: .4byte 0x0000fffc
@@ -19981,7 +19981,7 @@ _08051EC8:
subs r6, 0x15
b _08051FE0
.align 2, 0
-_08051EF0: .4byte gUnknown_203B418
+_08051EF0: .4byte gDungeonGlobalData
_08051EF4: .4byte 0x00003a09
_08051EF8:
mov r2, r9
@@ -20214,7 +20214,7 @@ _0805207A:
bl sub_803E708
b _080520F6
.align 2, 0
-_080520C0: .4byte gUnknown_203B418
+_080520C0: .4byte gDungeonGlobalData
_080520C4: .4byte 0x0000e250
_080520C8: .4byte 0x0000e254
_080520CC: .4byte 0x0000e258
@@ -20377,7 +20377,7 @@ _080521DE:
.align 2, 0
_08052200: .4byte gUnknown_202F1E8
_08052204: .4byte gUnknown_203B434
-_08052208: .4byte gUnknown_203B418
+_08052208: .4byte gDungeonGlobalData
_0805220C: .4byte 0x0001c054
thumb_func_end sub_80521D0
@@ -20438,7 +20438,7 @@ _08052278:
pop {r0}
bx r0
.align 2, 0
-_08052280: .4byte gUnknown_203B418
+_08052280: .4byte gDungeonGlobalData
_08052284: .4byte 0x0001bdd4
_08052288: .4byte gUnknown_80F7AE8
_0805228C: .4byte 0x0001c05f
diff --git a/asm/code_80521D0.s b/asm/code_80521D0.s
index 06bed26..0f709f0 100644
--- a/asm/code_80521D0.s
+++ b/asm/code_80521D0.s
@@ -3,7 +3,7 @@
.syntax unified
- .text
+ .text
thumb_func_start sub_80523A8
sub_80523A8:
@@ -129,7 +129,7 @@ _08052450:
strh r2, [r1]
b _080523FA
.align 2, 0
-_0805249C: .4byte gUnknown_203B418
+_0805249C: .4byte gDungeonGlobalData
_080524A0: .4byte 0x0001c060
_080524A4: .4byte 0x0001c062
_080524A8: .4byte 0x0001c054
@@ -163,7 +163,7 @@ _080524D4:
pop {r0}
bx r0
.align 2, 0
-_080524E4: .4byte gUnknown_203B418
+_080524E4: .4byte gDungeonGlobalData
_080524E8: .4byte 0x0001c064
_080524EC: .4byte 0x0001c06c
thumb_func_end sub_80523A8
@@ -195,7 +195,7 @@ _08052510:
_0805251A:
b _0805267C
.align 2, 0
-_0805251C: .4byte gUnknown_203B418
+_0805251C: .4byte gDungeonGlobalData
_08052520: .4byte 0x0001bdd4
_08052524: .4byte 0x0001c06c
_08052528:
@@ -458,7 +458,7 @@ _08052724:
pop {r0}
bx r0
.align 2, 0
-_0805272C: .4byte gUnknown_203B418
+_0805272C: .4byte gDungeonGlobalData
_08052730: .4byte 0x0001bdd4
_08052734: .4byte 0x0001c06c
_08052738: .4byte 0x0001c060
@@ -523,7 +523,7 @@ _080527A4:
pop {r0}
bx r0
.align 2, 0
-_080527B0: .4byte gUnknown_203B418
+_080527B0: .4byte gDungeonGlobalData
_080527B4: .4byte 0x0001bdd4
_080527B8: .4byte 0x0001c064
_080527BC: .4byte gRealInputs
@@ -605,7 +605,7 @@ _08052844:
b _0805286C
.align 2, 0
_08052858: .4byte gUnknown_203B40C
-_0805285C: .4byte gUnknown_203B418
+_0805285C: .4byte gDungeonGlobalData
_08052860: .4byte 0x0001820a
_08052864: .4byte 0x00000701
_08052868:
@@ -657,7 +657,7 @@ _080528B2:
bl sub_803EAF0
b _080528E4
.align 2, 0
-_080528D0: .4byte gUnknown_203B418
+_080528D0: .4byte gDungeonGlobalData
_080528D4: .4byte 0x0001c05f
_080528D8: .4byte gUnknown_202EE01
_080528DC:
@@ -835,7 +835,7 @@ _08052A3C:
.align 2, 0
_08052A48: .4byte gUnknown_202E5D8
_08052A4C: .4byte gUnknown_80F7B04
-_08052A50: .4byte gUnknown_203B418
+_08052A50: .4byte gDungeonGlobalData
_08052A54:
movs r0, 0x6
ldrsh r1, [r6, r0]
@@ -1055,7 +1055,7 @@ _08052C02:
bl sub_80141E0
b _08052C28
.align 2, 0
-_08052C14: .4byte gUnknown_203B418
+_08052C14: .4byte gDungeonGlobalData
_08052C18: .4byte 0x0001820a
_08052C1C:
movs r2, 0xC0
@@ -1195,7 +1195,7 @@ _08052D20:
pop {r1}
bx r1
.align 2, 0
-_08052D3C: .4byte gUnknown_203B418
+_08052D3C: .4byte gDungeonGlobalData
_08052D40: .4byte 0x0001820a
thumb_func_end sub_8052C68
@@ -1340,7 +1340,7 @@ _08052E46:
_08052E68: .4byte gUnknown_80FF020
_08052E6C: .4byte gUnknown_80FF080
_08052E70: .4byte gUnknown_80FF0D8
-_08052E74: .4byte gUnknown_203B418
+_08052E74: .4byte gDungeonGlobalData
_08052E78: .4byte 0x00000644
_08052E7C: .4byte gUnknown_80FF13C
_08052E80: .4byte gUnknown_80FF1B4
@@ -1484,7 +1484,7 @@ sub_8052F80:
bl PrintFieldMessage
b _08052FB0
.align 2, 0
-_08052F9C: .4byte gUnknown_203B418
+_08052F9C: .4byte gDungeonGlobalData
_08052FA0: .4byte gUnknown_80FF6F8
_08052FA4:
ldr r0, _08052FB4
@@ -1731,7 +1731,7 @@ sub_805317C:
ldrb r0, [r0]
b _0805319E
.align 2, 0
-_08053198: .4byte gUnknown_203B418
+_08053198: .4byte gDungeonGlobalData
_0805319C:
movs r0, 0x3F
_0805319E:
@@ -1780,7 +1780,7 @@ _080531BC:
pop {r0}
bx r0
.align 2, 0
-_080531F0: .4byte gUnknown_203B418
+_080531F0: .4byte gDungeonGlobalData
_080531F4: .4byte 0x0001c073
_080531F8: .4byte 0x0001c070
_080531FC: .4byte 0x0001c072
@@ -1794,7 +1794,7 @@ sub_8053200:
strb r0, [r1, 0xB]
bx lr
.align 2, 0
-_0805320C: .4byte gUnknown_203B418
+_0805320C: .4byte gDungeonGlobalData
thumb_func_end sub_8053200
thumb_func_start sub_8053210
@@ -1842,7 +1842,7 @@ sub_8053210:
mov r1, r12
b _08053282
.align 2, 0
-_08053264: .4byte gUnknown_203B418
+_08053264: .4byte gDungeonGlobalData
_08053268: .4byte 0x0001c070
_0805326C: .4byte 0x0001c071
_08053270: .4byte 0x0001c072
@@ -2065,7 +2065,7 @@ _0805340A:
pop {r0}
bx r0
.align 2, 0
-_08053428: .4byte gUnknown_203B418
+_08053428: .4byte gDungeonGlobalData
_0805342C: .4byte 0x0001c070
thumb_func_end sub_80533A4
@@ -2091,7 +2091,7 @@ _0805344C:
blt _0805344C
b _0805345E
.align 2, 0
-_08053454: .4byte gUnknown_203B418
+_08053454: .4byte gDungeonGlobalData
_08053458: .4byte gUnknown_202F1F8
_0805345C:
subs r1, 0x14
@@ -2197,7 +2197,7 @@ _08053528:
pop {r1}
bx r1
.align 2, 0
-_08053530: .4byte gUnknown_203B418
+_08053530: .4byte gDungeonGlobalData
_08053534: .4byte 0x0001c070
_08053538: .4byte gUnknown_203B084
_0805353C: .4byte gUnknown_202F1F8
@@ -2224,7 +2224,7 @@ _0805355A:
blt _0805355A
b _0805356E
.align 2, 0
-_08053564: .4byte gUnknown_203B418
+_08053564: .4byte gDungeonGlobalData
_08053568: .4byte gUnknown_202F1F8
_0805356C:
subs r4, 0x14
@@ -2319,7 +2319,7 @@ _08053622:
pop {r1}
bx r1
.align 2, 0
-_0805362C: .4byte gUnknown_203B418
+_0805362C: .4byte gDungeonGlobalData
_08053630: .4byte 0x0001c070
_08053634: .4byte gUnknown_203B080
_08053638: .4byte gUnknown_202F1F8
@@ -2498,7 +2498,7 @@ _08053792:
adds r5, r4, 0
b _08053A1C
.align 2, 0
-_080537A4: .4byte gUnknown_203B418
+_080537A4: .4byte gDungeonGlobalData
_080537A8: .4byte 0x00017b30
_080537AC: .4byte 0x00017b3c
_080537B0: .4byte gUnknown_80FCD28
@@ -2575,7 +2575,7 @@ _08053828:
str r3, [sp, 0x2C]
b _08053A1C
.align 2, 0
-_08053844: .4byte gUnknown_203B418
+_08053844: .4byte gDungeonGlobalData
_08053848: .4byte 0x00017b2c
_0805384C: .4byte 0x00017b38
_08053850: .4byte gUnknown_80FCD0C
@@ -6021,7 +6021,7 @@ _08055790:
bl sub_806D010
b _08055826
.align 2, 0
-_080557AC: .4byte gUnknown_203B418
+_080557AC: .4byte gDungeonGlobalData
_080557B0: .4byte 0x00000662
_080557B4: .4byte 0x000003e7
_080557B8: .4byte 0x00017b34
@@ -7182,7 +7182,7 @@ _080560CC:
bl sub_805744C
b _08056142
.align 2, 0
-_08056108: .4byte gUnknown_203B418
+_08056108: .4byte gDungeonGlobalData
_0805610C: .4byte 0x00003a0e
_08056110: .4byte gUnknown_80F5D10
_08056114: .4byte gUnknown_80FECE0
@@ -7844,7 +7844,7 @@ _08056602:
bl sub_800569C
b _08056694
.align 2, 0
-_08056680: .4byte gUnknown_203B418
+_08056680: .4byte gDungeonGlobalData
_08056684: .4byte 0x0001820a
_08056688: .4byte 0xffff0000
_0805668C: .4byte 0x0000ffff
@@ -8226,7 +8226,7 @@ _0805695E:
b _0805697E
.align 2, 0
_0805696C: .4byte gUnknown_81069D4
-_08056970: .4byte gUnknown_203B418
+_08056970: .4byte gDungeonGlobalData
_08056974: .4byte 0x0001c05e
_08056978: .4byte 0x0001820a
_0805697C:
@@ -8293,7 +8293,7 @@ _080569D4:
.align 2, 0
_080569F0: .4byte 0xffff0000
_080569F4: .4byte 0x0000ffff
-_080569F8: .4byte gUnknown_203B418
+_080569F8: .4byte gDungeonGlobalData
_080569FC: .4byte 0x000181f2
_08056A00:
movs r0, 0x18
@@ -8415,7 +8415,7 @@ _08056AC2:
bl sub_8053704
b _08056B22
.align 2, 0
-_08056AF4: .4byte gUnknown_203B418
+_08056AF4: .4byte gDungeonGlobalData
_08056AF8: .4byte 0x0001c05e
_08056AFC:
ldr r0, [sp, 0x20]
@@ -8880,7 +8880,7 @@ _08056E3A:
str r1, [sp, 0x8]
b _08056E86
.align 2, 0
-_08056E74: .4byte gUnknown_203B418
+_08056E74: .4byte gDungeonGlobalData
_08056E78: .4byte 0x000135cc
_08056E7C:
str r4, [sp]
@@ -8983,7 +8983,7 @@ _08056F38:
ble _08056F06
b _08056F64
.align 2, 0
-_08056F40: .4byte gUnknown_203B418
+_08056F40: .4byte gDungeonGlobalData
_08056F44: .4byte 0x000135cc
_08056F48:
cmp r1, 0x70
@@ -9352,7 +9352,7 @@ _080571B8:
ldrh r0, [r0, 0x2]
b _080571DE
.align 2, 0
-_080571D4: .4byte gUnknown_203B418
+_080571D4: .4byte gDungeonGlobalData
_080571D8: .4byte 0x000135cc
_080571DC:
ldr r0, _080571EC
@@ -9436,7 +9436,7 @@ _08057264:
movs r0, 0x1
b _08057276
.align 2, 0
-_08057268: .4byte gUnknown_203B418
+_08057268: .4byte gDungeonGlobalData
_0805726C: .4byte 0x00003a0e
_08057270: .4byte gUnknown_80F5D10
_08057274:
diff --git a/asm/code_8057824.s b/asm/code_8057824.s
index b344d4a..6248afd 100644
--- a/asm/code_8057824.s
+++ b/asm/code_8057824.s
@@ -4,7 +4,7 @@
.syntax unified
.text
-
+
thumb_func_start sub_8057A0C
sub_8057A0C:
push {r4-r7,lr}
@@ -2870,7 +2870,7 @@ _08058F48:
pop {r1}
bx r1
.align 2, 0
-_08058F50: .4byte gUnknown_203B418
+_08058F50: .4byte gDungeonGlobalData
_08058F54: .4byte 0x00018204
thumb_func_end sub_8058F04
@@ -2920,7 +2920,7 @@ _08058F7E:
pop {r1}
bx r1
.align 2, 0
-_08058FB0: .4byte gUnknown_203B418
+_08058FB0: .4byte gDungeonGlobalData
_08058FB4: .4byte 0x00003a0e
_08058FB8: .4byte gUnknown_80F5D10
thumb_func_end sub_8058F58
@@ -3389,7 +3389,7 @@ _0805932E:
pop {r1}
bx r1
.align 2, 0
-_08059338: .4byte gUnknown_203B418
+_08059338: .4byte gDungeonGlobalData
_0805933C: .4byte gUnknown_80FC888
thumb_func_end SkillSwapMoveAction
@@ -3639,7 +3639,7 @@ _0805950E:
pop {r1}
bx r1
.align 2, 0
-_08059518: .4byte gUnknown_203B418
+_08059518: .4byte gDungeonGlobalData
_0805951C: .4byte gUnknown_80F4F42
_08059520: .4byte 0x0000e269
_08059524: .4byte gUnknown_80FCF78
@@ -5562,7 +5562,7 @@ _0805A386:
pop {r1}
bx r1
.align 2, 0
-_0805A38C: .4byte gUnknown_203B418
+_0805A38C: .4byte gDungeonGlobalData
_0805A390: .4byte gUnknown_80FC81C
thumb_func_end sub_805A31C
@@ -5595,7 +5595,7 @@ _0805A3C2:
pop {r1}
bx r1
.align 2, 0
-_0805A3CC: .4byte gUnknown_203B418
+_0805A3CC: .4byte gDungeonGlobalData
_0805A3D0: .4byte gUnknown_80F4F42
_0805A3D4: .4byte 0x0000e268
_0805A3D8: .4byte gUnknown_80FCF7C
@@ -6497,7 +6497,7 @@ _0805AAB8:
pop {r1}
bx r1
.align 2, 0
-_0805AAC8: .4byte gUnknown_203B418
+_0805AAC8: .4byte gDungeonGlobalData
_0805AACC: .4byte 0x00003a08
thumb_func_end sub_805A85C
@@ -6618,7 +6618,7 @@ _0805AB88:
.align 2, 0
_0805ABA8: .4byte gUnknown_80F4E06
_0805ABAC: .4byte gUnknown_80F5978
-_0805ABB0: .4byte gUnknown_203B418
+_0805ABB0: .4byte gDungeonGlobalData
_0805ABB4: .4byte 0x00003a0e
_0805ABB8: .4byte _0805ABBC
.align 2, 0
@@ -6852,7 +6852,7 @@ sub_805AD54:
movs r0, 0x10
b _0805AD92
.align 2, 0
-_0805AD80: .4byte gUnknown_203B418
+_0805AD80: .4byte gDungeonGlobalData
_0805AD84: .4byte 0x0001358c
_0805AD88:
ldr r0, _0805AD98
@@ -6865,7 +6865,7 @@ _0805AD92:
movs r6, 0
b _0805AE0E
.align 2, 0
-_0805AD98: .4byte gUnknown_203B418
+_0805AD98: .4byte gDungeonGlobalData
_0805AD9C: .4byte 0x0001357c
_0805ADA0:
lsls r0, r6, 2
@@ -7353,7 +7353,7 @@ sub_805B0D0:
b _0805B15A
.align 2, 0
_0805B134: .4byte gUnknown_80F561C
-_0805B138: .4byte gUnknown_203B418
+_0805B138: .4byte gDungeonGlobalData
_0805B13C: .4byte 0x00003a0e
_0805B140: .4byte gUnknown_202DFE8
_0805B144: .4byte gUnknown_202DE58
@@ -7573,7 +7573,7 @@ _0805B2AC:
bx r1
.align 2, 0
_0805B2D0: .4byte gUnknown_202F224
-_0805B2D4: .4byte gUnknown_203B418
+_0805B2D4: .4byte gDungeonGlobalData
_0805B2D8: .4byte gUnknown_8106A8C
_0805B2DC: .4byte 0x00018204
_0805B2E0: .4byte gUnknown_80F4F94
@@ -8841,7 +8841,7 @@ _0805BC30:
b _0805BC60
.align 2, 0
_0805BC44: .4byte gTeamInventory_203B460
-_0805BC48: .4byte gUnknown_203B418
+_0805BC48: .4byte gDungeonGlobalData
_0805BC4C: .4byte 0x0001357c
_0805BC50: .4byte gUnknown_80FC8F0
_0805BC54:
@@ -9219,7 +9219,7 @@ EscapeOrbAction:
b _0805BF26
.align 2, 0
_0805BF00: .4byte gAvailablePokemonNames
-_0805BF04: .4byte gUnknown_203B418
+_0805BF04: .4byte gDungeonGlobalData
_0805BF08: .4byte 0x0000066e
_0805BF0C: .4byte gUnknown_80FD4DC
_0805BF10:
@@ -9302,7 +9302,7 @@ _0805BF78:
adds r7, r3, r0
b _0805BFDA
.align 2, 0
-_0805BFA4: .4byte gUnknown_203B418
+_0805BFA4: .4byte gDungeonGlobalData
_0805BFA8: .4byte 0x00018209
_0805BFAC:
ldr r2, _0805C050
@@ -9387,7 +9387,7 @@ _0805C034:
bl sub_8049ED4
b _0805C068
.align 2, 0
-_0805C050: .4byte gUnknown_203B418
+_0805C050: .4byte gDungeonGlobalData
_0805C054: .4byte 0x000104c4
_0805C058: .4byte gUnknown_80FD1B0
_0805C05C:
@@ -9432,7 +9432,7 @@ sub_805C080:
movs r1, 0x10
b _0805C0BA
.align 2, 0
-_0805C0A4: .4byte gUnknown_203B418
+_0805C0A4: .4byte gDungeonGlobalData
_0805C0A8: .4byte 0x0001358c
_0805C0AC:
ldr r0, _0805C11C
@@ -9492,7 +9492,7 @@ _0805C10C:
pop {r1}
bx r1
.align 2, 0
-_0805C11C: .4byte gUnknown_203B418
+_0805C11C: .4byte gDungeonGlobalData
_0805C120: .4byte 0x0001357c
_0805C124: .4byte gUnknown_81004F0
thumb_func_end sub_805C080
@@ -10556,7 +10556,7 @@ _0805CBF0:
b _0805CDEC
.align 2, 0
_0805CC0C: .4byte gUnknown_80F561C
-_0805CC10: .4byte gUnknown_203B418
+_0805CC10: .4byte gDungeonGlobalData
_0805CC14: .4byte 0x00003a0e
_0805CC18:
movs r1, 0x1E
@@ -10723,7 +10723,7 @@ _0805CD20:
ldrb r0, [r0]
b _0805CDEE
.align 2, 0
-_0805CD2C: .4byte gUnknown_203B418
+_0805CD2C: .4byte gDungeonGlobalData
_0805CD30: .4byte 0x0000e277
_0805CD34:
ldr r0, _0805CD40
@@ -10733,7 +10733,7 @@ _0805CD34:
ldrb r0, [r0]
b _0805CDEE
.align 2, 0
-_0805CD40: .4byte gUnknown_203B418
+_0805CD40: .4byte gDungeonGlobalData
_0805CD44: .4byte 0x0000e278
_0805CD48:
adds r0, r2, 0
@@ -10748,7 +10748,7 @@ _0805CD50:
ldrb r0, [r0]
b _0805CDEE
.align 2, 0
-_0805CD5C: .4byte gUnknown_203B418
+_0805CD5C: .4byte gDungeonGlobalData
_0805CD60: .4byte 0x000037fc
_0805CD64:
movs r3, 0x89
@@ -10896,7 +10896,7 @@ _0805CE4C:
bne _0805CEA8
b _0805CB6E
.align 2, 0
-_0805CE54: .4byte gUnknown_203B418
+_0805CE54: .4byte gDungeonGlobalData
_0805CE58: .4byte 0x0001358c
_0805CE5C:
movs r6, 0
@@ -10945,7 +10945,7 @@ _0805CEAA:
pop {r1}
bx r1
.align 2, 0
-_0805CEB0: .4byte gUnknown_203B418
+_0805CEB0: .4byte gDungeonGlobalData
_0805CEB4: .4byte 0x0001357c
thumb_func_end sub_805C498
@@ -11976,7 +11976,7 @@ sub_805D8C8:
bl sub_803E708
bl _0805E2B0
.align 2, 0
-_0805D90C: .4byte gUnknown_203B418
+_0805D90C: .4byte gDungeonGlobalData
_0805D910: .4byte 0x000181e8
_0805D914:
mov r1, r8
@@ -12065,7 +12065,7 @@ _0805D9CA:
b _0805DAEC
.align 2, 0
_0805D9D4: .4byte 0x00000673
-_0805D9D8: .4byte gUnknown_203B418
+_0805D9D8: .4byte gDungeonGlobalData
_0805D9DC: .4byte 0x0000066c
_0805D9E0: .4byte gUnknown_202F22D
_0805D9E4: .4byte gUnknown_202F22C
@@ -12080,7 +12080,7 @@ _0805D9EC:
strb r4, [r0]
b _0805E1AE
.align 2, 0
-_0805DA00: .4byte gUnknown_203B418
+_0805DA00: .4byte gDungeonGlobalData
_0805DA04: .4byte 0x00000673
_0805DA08:
ldr r0, _0805DA14
@@ -12124,7 +12124,7 @@ _0805DA40:
orrs r6, r3
b _0805DAA8
.align 2, 0
-_0805DA58: .4byte gUnknown_203B418
+_0805DA58: .4byte gDungeonGlobalData
_0805DA5C: .4byte 0xffffff00
_0805DA60:
ldr r5, _0805DA78
@@ -12139,7 +12139,7 @@ _0805DA60:
orrs r6, r2
b _0805DAA8
.align 2, 0
-_0805DA78: .4byte gUnknown_203B418
+_0805DA78: .4byte gDungeonGlobalData
_0805DA7C: .4byte 0xffffff00
_0805DA80:
ldr r3, _0805DA98
@@ -12154,7 +12154,7 @@ _0805DA80:
orrs r6, r0
b _0805DAA8
.align 2, 0
-_0805DA98: .4byte gUnknown_203B418
+_0805DA98: .4byte gDungeonGlobalData
_0805DA9C: .4byte 0xffffff00
_0805DAA0:
ldr r0, _0805DAB8
@@ -12322,7 +12322,7 @@ _0805DBDA:
b _0805E1AE
.align 2, 0
_0805DBEC: .4byte gRealInputs
-_0805DBF0: .4byte gUnknown_203B418
+_0805DBF0: .4byte gDungeonGlobalData
_0805DBF4: .4byte 0x00000673
_0805DBF8:
mov r0, r10
@@ -12727,7 +12727,7 @@ _0805DF00: .4byte gRealInputs
_0805DF04: .4byte gUnknown_202F22D
_0805DF08: .4byte 0x01000200
_0805DF0C: .4byte gTeamInventory_203B460
-_0805DF10: .4byte gUnknown_203B418
+_0805DF10: .4byte gDungeonGlobalData
_0805DF14: .4byte 0x0001820a
_0805DF18: .4byte gUnknown_202EE00
_0805DF1C: .4byte 0x00018214
@@ -12797,7 +12797,7 @@ _0805DF82:
.align 2, 0
_0805DFA0: .4byte gUnknown_202EE00
_0805DFA4: .4byte gRealInputs
-_0805DFA8: .4byte gUnknown_203B418
+_0805DFA8: .4byte gDungeonGlobalData
_0805DFAC: .4byte 0x00018214
_0805DFB0: .4byte gUnknown_203B46C
_0805DFB4: .4byte 0x0000066d
@@ -12997,7 +12997,7 @@ _0805E114:
b _0805E1AE
.align 2, 0
_0805E128: .4byte gUnknown_80F8B0C
-_0805E12C: .4byte gUnknown_203B418
+_0805E12C: .4byte gDungeonGlobalData
_0805E130: .4byte 0x00000673
_0805E134:
movs r0, 0x2
@@ -13038,7 +13038,7 @@ _0805E174:
b _0805E1AE
.align 2, 0
_0805E17C: .4byte gRealInputs
-_0805E180: .4byte gUnknown_203B418
+_0805E180: .4byte gDungeonGlobalData
_0805E184: .4byte 0x0000066c
_0805E188:
mov r0, r8
@@ -13106,7 +13106,7 @@ _0805E1E0:
bl sub_803E46C
b _0805E2B0
.align 2, 0
-_0805E210: .4byte gUnknown_203B418
+_0805E210: .4byte gDungeonGlobalData
_0805E214: .4byte 0x0000066d
_0805E218:
movs r0, 0xF
@@ -13167,7 +13167,7 @@ _0805E27E:
b _0805E2B0
.align 2, 0
_0805E294: .4byte gUnknown_202F22D
-_0805E298: .4byte gUnknown_203B418
+_0805E298: .4byte gDungeonGlobalData
_0805E29C:
movs r0, 0xF
bl sub_803E46C
@@ -13187,7 +13187,7 @@ _0805E2B0:
pop {r0}
bx r0
.align 2, 0
-_0805E2C0: .4byte gUnknown_203B418
+_0805E2C0: .4byte gDungeonGlobalData
thumb_func_end sub_805D8C8
thumb_func_start sub_805E2C4
@@ -13416,7 +13416,7 @@ _0805E3B4:
_0805E47A:
b _0805E6AC
.align 2, 0
-_0805E47C: .4byte gUnknown_203B418
+_0805E47C: .4byte gDungeonGlobalData
_0805E480: .4byte 0x000181e8
_0805E484: .4byte gUnknown_202F22C
_0805E488: .4byte 0xffff0000
@@ -13895,7 +13895,7 @@ _0805E85C:
pop {r0}
bx r0
.align 2, 0
-_0805E864: .4byte gUnknown_203B418
+_0805E864: .4byte gDungeonGlobalData
_0805E868: .4byte 0x0000066d
_0805E86C: .4byte 0x0000066c
_0805E870: .4byte gRealInputs
@@ -13975,7 +13975,7 @@ _0805E906:
movs r0, 0
b _0805EC1A
.align 2, 0
-_0805E90C: .4byte gUnknown_203B418
+_0805E90C: .4byte gDungeonGlobalData
_0805E910: .4byte gUnknown_80F4448
_0805E914: .4byte 0x0000066c
_0805E918:
@@ -14141,7 +14141,7 @@ _0805EA42:
b _0805E906
.align 2, 0
_0805EA54: .4byte gUnknown_80F4448
-_0805EA58: .4byte gUnknown_203B418
+_0805EA58: .4byte gDungeonGlobalData
_0805EA5C: .4byte 0x0001820f
_0805EA60:
mov r3, r8
@@ -14179,7 +14179,7 @@ _0805EA94:
bne _0805EAD6
b _0805EAAC
.align 2, 0
-_0805EAA0: .4byte gUnknown_203B418
+_0805EAA0: .4byte gDungeonGlobalData
_0805EAA4: .4byte 0x0001820f
_0805EAA8:
cmp r4, 0
@@ -14642,7 +14642,7 @@ _0805EE1E:
pop {r1}
bx r1
.align 2, 0
-_0805EE2C: .4byte gUnknown_203B418
+_0805EE2C: .4byte gDungeonGlobalData
thumb_func_end sub_805EC4C
thumb_func_start sub_805EE30
@@ -14709,7 +14709,7 @@ _0805EE96:
ldr r0, [r0]
mov pc, r0
.align 2, 0
-_0805EEB0: .4byte gUnknown_203B418
+_0805EEB0: .4byte gDungeonGlobalData
_0805EEB4: .4byte _0805EEB8
.align 2, 0
_0805EEB8:
@@ -14791,7 +14791,7 @@ _0805EF52:
pop {r0}
bx r0
.align 2, 0
-_0805EF5C: .4byte gUnknown_203B418
+_0805EF5C: .4byte gDungeonGlobalData
thumb_func_end sub_805EE30
thumb_func_start sub_805EF60
@@ -14928,7 +14928,7 @@ sub_805F02C:
ldr r0, _0805F05C
b _0805F08E
.align 2, 0
-_0805F058: .4byte gUnknown_203B418
+_0805F058: .4byte gDungeonGlobalData
_0805F05C: .4byte gUnknown_80F9BD8
_0805F060:
movs r0, 0x2
@@ -15143,7 +15143,7 @@ _0805F1F8:
bl sub_800C074
b _0805F240
.align 2, 0
-_0805F208: .4byte gUnknown_203B418
+_0805F208: .4byte gDungeonGlobalData
_0805F20C: .4byte 0x00000137
_0805F210:
bl sub_8083600
@@ -15490,7 +15490,7 @@ _0805F50C:
bl sub_806A2BC
b _0805F72C
.align 2, 0
-_0805F518: .4byte gUnknown_203B418
+_0805F518: .4byte gDungeonGlobalData
_0805F51C: .4byte 0x0001357c
_0805F520: .4byte gUnknown_202F260
_0805F524:
@@ -15606,7 +15606,7 @@ _0805F5EE:
movs r5, 0
b _0805F60A
.align 2, 0
-_0805F600: .4byte gUnknown_203B418
+_0805F600: .4byte gDungeonGlobalData
_0805F604: .4byte 0x0001357c
_0805F608:
adds r5, 0x1
@@ -15632,7 +15632,7 @@ _0805F616:
beq _0805F608
b _0805F676
.align 2, 0
-_0805F634: .4byte gUnknown_203B418
+_0805F634: .4byte gDungeonGlobalData
_0805F638: .4byte 0x0001357c
_0805F63C:
bl sub_805F1AC
@@ -15677,7 +15677,7 @@ _0805F684:
bl sub_8083CE0
b _0805F572
.align 2, 0
-_0805F68C: .4byte gUnknown_203B418
+_0805F68C: .4byte gDungeonGlobalData
_0805F690: .4byte 0x0001357c
_0805F694:
bl sub_805F1AC
@@ -15958,7 +15958,7 @@ _0805F904:
bl ResetUnusedInputStruct
b _0805F240
.align 2, 0
-_0805F91C: .4byte gUnknown_203B418
+_0805F91C: .4byte gDungeonGlobalData
_0805F920:
bl sub_8083600
movs r1, 0
@@ -16264,7 +16264,7 @@ _0805FBCC: .4byte gUnknown_80F9190
_0805FBD0: .4byte gAvailablePokemonNames
_0805FBD4: .4byte gUnknown_80F91A8
_0805FBD8: .4byte gUnknown_80F91C8
-_0805FBDC: .4byte gUnknown_203B418
+_0805FBDC: .4byte gDungeonGlobalData
_0805FBE0: .4byte 0x0001357c
_0805FBE4: .4byte gUnknown_80F91E0
thumb_func_end DrawFieldMenu
@@ -16748,7 +16748,7 @@ _0805FF66:
.align 2, 0
_0805FFA8: .4byte gUnknown_202F240
_0805FFAC: .4byte gTeamInventory_203B460
-_0805FFB0: .4byte gUnknown_203B418
+_0805FFB0: .4byte gDungeonGlobalData
_0805FFB4: .4byte 0x0001357c
_0805FFB8: .4byte gUnknown_202F258
_0805FFBC: .4byte gUnknown_202F248
@@ -17199,7 +17199,7 @@ _08060350: .4byte gUnknown_202F248
_08060354: .4byte gTeamInventory_203B460
_08060358: .4byte gUnknown_202F240
_0806035C: .4byte gRealInputs
-_08060360: .4byte gUnknown_203B418
+_08060360: .4byte gDungeonGlobalData
_08060364: .4byte 0x00018212
_08060368: .4byte gUnknown_202F238
_0806036C:
@@ -17250,7 +17250,7 @@ _080603BE:
pop {r1}
bx r1
.align 2, 0
-_080603D0: .4byte gUnknown_203B418
+_080603D0: .4byte gDungeonGlobalData
_080603D4: .4byte 0x00018212
thumb_func_end sub_805FD74
@@ -17338,7 +17338,7 @@ _08060478: .4byte gUnknown_8106B6C
_0806047C: .4byte gUnknown_202EE10
_08060480: .4byte gUnknown_202F240
_08060484: .4byte gUnknown_202F258
-_08060488: .4byte gUnknown_203B418
+_08060488: .4byte gDungeonGlobalData
_0806048C: .4byte 0x00018212
_08060490: .4byte gUnknown_202F248
_08060494:
@@ -17739,7 +17739,7 @@ _080607D0:
pop {r0}
bx r0
.align 2, 0
-_080607E0: .4byte gUnknown_203B418
+_080607E0: .4byte gDungeonGlobalData
_080607E4: .4byte gUnknown_202F248
_080607E8: .4byte 0x0001357c
_080607EC: .4byte gAvailablePokemonNames
@@ -17950,7 +17950,7 @@ _0806092C:
.align 2, 0
_08060964: .4byte gUnknown_202F238
_08060968: .4byte gUnknown_202EE6C
-_0806096C: .4byte gUnknown_203B418
+_0806096C: .4byte gDungeonGlobalData
_08060970: .4byte 0x0000065b
_08060974: .4byte gTeamInventory_203B460
_08060978:
@@ -18035,7 +18035,7 @@ _08060A0A:
b _08060A42
.align 2, 0
_08060A20: .4byte gUnknown_202F238
-_08060A24: .4byte gUnknown_203B418
+_08060A24: .4byte gDungeonGlobalData
_08060A28: .4byte 0x0000065b
_08060A2C:
movs r0, 0x3C
@@ -18124,7 +18124,7 @@ _08060ABE:
.align 2, 0
_08060AD4: .4byte gTeamInventory_203B460
_08060AD8: .4byte gUnknown_202F238
-_08060ADC: .4byte gUnknown_203B418
+_08060ADC: .4byte gDungeonGlobalData
_08060AE0: .4byte 0x0001357c
_08060AE4: .4byte 0x00000157
_08060AE8:
@@ -18148,7 +18148,7 @@ _08060AE8:
bl sub_8044F5C
b _08060B24
.align 2, 0
-_08060B10: .4byte gUnknown_203B418
+_08060B10: .4byte gDungeonGlobalData
_08060B14: .4byte 0x0000065b
_08060B18: .4byte gTeamInventory_203B460
_08060B1C:
@@ -18294,7 +18294,7 @@ _08060C32:
bl sub_8044F5C
b _08060C68
.align 2, 0
-_08060C50: .4byte gUnknown_203B418
+_08060C50: .4byte gDungeonGlobalData
_08060C54: .4byte 0x0001357c
_08060C58: .4byte gTeamInventory_203B460
_08060C5C: .4byte 0x0000065b
@@ -18524,7 +18524,7 @@ _08060E1A:
pop {r1}
bx r1
.align 2, 0
-_08060E28: .4byte gUnknown_203B418
+_08060E28: .4byte gDungeonGlobalData
_08060E2C: .4byte 0x0000065b
_08060E30: .4byte gTeamInventory_203B460
_08060E34: .4byte 0x0001357c
@@ -18768,7 +18768,7 @@ _08060FE2:
b _08061116
.align 2, 0
_08061018: .4byte gUnknown_202F270
-_0806101C: .4byte gUnknown_203B418
+_0806101C: .4byte gDungeonGlobalData
_08061020: .4byte 0x0001357c
_08061024: .4byte 0x00000157
_08061028: .4byte 0x0000065b
@@ -19141,7 +19141,7 @@ _08061300:
bl strcpy
b _080613EE
.align 2, 0
-_08061318: .4byte gUnknown_203B418
+_08061318: .4byte gDungeonGlobalData
_0806131C: .4byte 0x0001357c
_08061320: .4byte 0x00000157
_08061324: .4byte gUnknown_202F260
@@ -19416,7 +19416,7 @@ _0806155A:
b _08061586
.align 2, 0
_08061560: .4byte gUnknown_202EE6C
-_08061564: .4byte gUnknown_203B418
+_08061564: .4byte gDungeonGlobalData
_08061568: .4byte gUnknown_202EE10
_0806156C: .4byte 0x0001357c
_08061570: .4byte 0x0000065d
@@ -19629,7 +19629,7 @@ _0806171A:
b _08061926
.align 2, 0
_08061720: .4byte gUnknown_202F270
-_08061724: .4byte gUnknown_203B418
+_08061724: .4byte gDungeonGlobalData
_08061728: .4byte 0x0001357c
_0806172C: .4byte gUnknown_202EE10
_08061730: .4byte gRealInputs
@@ -20067,7 +20067,7 @@ _08061AA0:
b _08061AB2
.align 2, 0
_08061AA4: .4byte gUnknown_202F270
-_08061AA8: .4byte gUnknown_203B418
+_08061AA8: .4byte gDungeonGlobalData
_08061AAC: .4byte 0x0001357c
_08061AB0:
movs r0, 0
@@ -22012,7 +22012,7 @@ _08062A38: .4byte gUnknown_8106C18
_08062A3C: .4byte gWhichTextPtr2
_08062A40: .4byte 0xfffffc27
_08062A44: .4byte gUnknown_202EE10
-_08062A48: .4byte gUnknown_203B418
+_08062A48: .4byte gDungeonGlobalData
_08062A4C: .4byte 0x0001357c
_08062A50:
cmp r6, 0x2
@@ -22150,7 +22150,7 @@ _08062B5A:
pop {r1}
bx r1
.align 2, 0
-_08062B6C: .4byte gUnknown_203B418
+_08062B6C: .4byte gDungeonGlobalData
_08062B70: .4byte 0x0001357c
thumb_func_end DrawFieldGiveItemMenu
@@ -22507,7 +22507,7 @@ _08062E10:
movs r4, 0
b _08062E2E
.align 2, 0
-_08062E24: .4byte gUnknown_203B418
+_08062E24: .4byte gDungeonGlobalData
_08062E28: .4byte 0x0001357c
_08062E2C:
adds r4, 0x1
@@ -22540,7 +22540,7 @@ _08062E54:
bl sub_8083CE0
b _08062F32
.align 2, 0
-_08062E64: .4byte gUnknown_203B418
+_08062E64: .4byte gDungeonGlobalData
_08062E68: .4byte 0x0001357c
_08062E6C:
bl sub_805F1AC
@@ -22582,7 +22582,7 @@ _08062EA6:
bl sub_8083CE0
b _08062F32
.align 2, 0
-_08062EB8: .4byte gUnknown_203B418
+_08062EB8: .4byte gDungeonGlobalData
_08062EBC: .4byte 0x0001357c
_08062EC0:
bl sub_805F1AC
@@ -23751,7 +23751,7 @@ sub_80637E8:
pop {r0}
bx r0
.align 2, 0
-_08063828: .4byte gUnknown_203B418
+_08063828: .4byte gDungeonGlobalData
_0806382C: .4byte 0x0001357c
_08063830: .4byte 0x00000119
thumb_func_end sub_80637E8
@@ -24126,7 +24126,7 @@ _08063AEC:
bl sub_80522A8
b _08063B3A
.align 2, 0
-_08063B1C: .4byte gUnknown_203B418
+_08063B1C: .4byte gDungeonGlobalData
_08063B20: .4byte 0x0001357c
_08063B24: .4byte gUnknown_202DE58
_08063B28: .4byte 0x00000133
@@ -24191,7 +24191,7 @@ sub_8063B54:
pop {r0}
bx r0
.align 2, 0
-_08063BA4: .4byte gUnknown_203B418
+_08063BA4: .4byte gDungeonGlobalData
_08063BA8: .4byte 0x0001357c
_08063BAC: .4byte gUnknown_202DE58
_08063BB0: .4byte 0x00000133
@@ -24293,7 +24293,7 @@ _08063C5C:
pop {r0}
bx r0
.align 2, 0
-_08063C70: .4byte gUnknown_203B418
+_08063C70: .4byte gDungeonGlobalData
_08063C74: .4byte 0x0001357c
_08063C78: .4byte gUnknown_202DE58
_08063C7C: .4byte 0x00000119
@@ -24446,7 +24446,7 @@ _08063D70:
bl sub_80522A8
b _08063DBA
.align 2, 0
-_08063D98: .4byte gUnknown_203B418
+_08063D98: .4byte gDungeonGlobalData
_08063D9C: .4byte 0x0001357c
_08063DA0: .4byte gUnknown_202DE58
_08063DA4: .4byte 0x00000119
@@ -26340,7 +26340,7 @@ _08064C8C:
bl sub_8083D08
b _08064CC0
.align 2, 0
-_08064C94: .4byte gUnknown_203B418
+_08064C94: .4byte gDungeonGlobalData
_08064C98: .4byte gUnknown_202F2E0
_08064C9C: .4byte gUnknown_202EE10
_08064CA0: .4byte gRealInputs
@@ -26441,7 +26441,7 @@ _08064D4C:
.align 2, 0
_08064D68: .4byte gUnknown_202EE10
_08064D6C: .4byte gUnknown_202F2E0
-_08064D70: .4byte gUnknown_203B418
+_08064D70: .4byte gDungeonGlobalData
thumb_func_end sub_8064BE0
thumb_func_start sub_8064D74
@@ -26992,7 +26992,7 @@ _080651B6:
pop {r0}
bx r0
.align 2, 0
-_080651CC: .4byte gUnknown_203B418
+_080651CC: .4byte gDungeonGlobalData
thumb_func_end sub_806519C
thumb_func_start sub_80651D0
@@ -27049,7 +27049,7 @@ sub_80651FC:
.align 2, 0
_08065238: .4byte gUnknown_80FDEB8
_0806523C: .4byte 0x0000021b
-_08065240: .4byte gUnknown_203B418
+_08065240: .4byte gDungeonGlobalData
_08065244: .4byte 0x00000654
_08065248:
movs r0, 0x1
@@ -27238,7 +27238,7 @@ _080652D2:
.align 2, 0
_080653D0: .4byte gUnknown_202EE10
_080653D4: .4byte gUnknown_202F2E0
-_080653D8: .4byte gUnknown_203B418
+_080653D8: .4byte gDungeonGlobalData
_080653DC: .4byte gUnknown_80FE8F8
_080653E0: .4byte gUnknown_80FE9CC
_080653E4: .4byte gUnknown_80FE9E8
@@ -28716,7 +28716,7 @@ sub_8065FB4:
b _08065FFE
.align 2, 0
_08065FE0: .4byte 0xfffff608
-_08065FE4: .4byte gUnknown_203B418
+_08065FE4: .4byte gDungeonGlobalData
_08065FE8: .4byte 0x00000644
_08065FEC: .4byte gUnknown_80FA5F4
_08065FF0:
@@ -29473,7 +29473,7 @@ _08066600:
b _0806669E
.align 2, 0
_08066604: .4byte 0x000001a7
-_08066608: .4byte gUnknown_203B418
+_08066608: .4byte gDungeonGlobalData
_0806660C: .4byte 0x000037e4
_08066610: .4byte 0x0000343c
_08066614: .4byte 0x0000343e
@@ -30050,7 +30050,7 @@ _08066AA8: .4byte gUnknown_202DE58
_08066AAC: .4byte 0x0000014d
_08066AB0: .4byte gUnknown_80F8D44
_08066AB4: .4byte gUnknown_80F8BE0
-_08066AB8: .4byte gUnknown_203B418
+_08066AB8: .4byte gDungeonGlobalData
_08066ABC: .4byte 0x00003a08
thumb_func_end sub_80668D0
@@ -30176,7 +30176,7 @@ _08066BBC: .4byte gUnknown_202DE58
_08066BC0: .4byte gAvailablePokemonNames
_08066BC4: .4byte 0x0000014d
_08066BC8: .4byte gUnknown_80F8D7C
-_08066BCC: .4byte gUnknown_203B418
+_08066BCC: .4byte gDungeonGlobalData
_08066BD0: .4byte 0x00003a08
thumb_func_end sub_8066AC0
@@ -30306,7 +30306,7 @@ _08066CD8: .4byte gUnknown_202DE58
_08066CDC: .4byte gUnknown_202DFE8
_08066CE0: .4byte 0x0000014d
_08066CE4: .4byte gUnknown_80F8DB4
-_08066CE8: .4byte gUnknown_203B418
+_08066CE8: .4byte gDungeonGlobalData
_08066CEC: .4byte 0x00003a08
thumb_func_end sub_8066BD4
@@ -30446,7 +30446,7 @@ _08066DF8:
_08066E00: .4byte 0x0000014d
_08066E04: .4byte gAvailablePokemonNames
_08066E08: .4byte gUnknown_80F8E28
-_08066E0C: .4byte gUnknown_203B418
+_08066E0C: .4byte gDungeonGlobalData
_08066E10: .4byte 0x00003a08
thumb_func_end sub_8066D04
@@ -30633,7 +30633,7 @@ _08066F7E:
_08066F90: .4byte gUnknown_202DE58
_08066F94: .4byte 0x0000014d
_08066F98: .4byte gUnknown_80F8EAC
-_08066F9C: .4byte gUnknown_203B418
+_08066F9C: .4byte gDungeonGlobalData
_08066FA0: .4byte 0x00003a08
thumb_func_end sub_8066E14
@@ -30804,7 +30804,7 @@ _080670EE:
.align 2, 0
_08067100: .4byte 0x0000014d
_08067104: .4byte gUnknown_80F8EAC
-_08067108: .4byte gUnknown_203B418
+_08067108: .4byte gDungeonGlobalData
_0806710C: .4byte 0x00003a08
thumb_func_end sub_8066FA4
@@ -30868,7 +30868,7 @@ _08067188:
.align 2, 0
_08067190: .4byte gUnknown_202DE58
_08067194: .4byte gAvailablePokemonNames
-_08067198: .4byte gUnknown_203B418
+_08067198: .4byte gDungeonGlobalData
_0806719C: .4byte 0x00003a08
thumb_func_end sub_8067110
@@ -31292,7 +31292,7 @@ _080674F8:
pop {r0}
bx r0
.align 2, 0
-_08067508: .4byte gUnknown_203B418
+_08067508: .4byte gDungeonGlobalData
_0806750C: .4byte 0x00003a08
thumb_func_end sub_80671A0
@@ -31330,7 +31330,7 @@ sub_806752C:
pop {r0}
bx r0
.align 2, 0
-_08067550: .4byte gUnknown_203B418
+_08067550: .4byte gDungeonGlobalData
_08067554: .4byte 0x0001357c
thumb_func_end sub_806752C
@@ -31467,7 +31467,7 @@ _08067648:
movs r0, 0
b _08067716
.align 2, 0
-_08067668: .4byte gUnknown_203B418
+_08067668: .4byte gDungeonGlobalData
_0806766C: .4byte 0x0000066e
_08067670: .4byte gUnknown_80FF674
_08067674:
@@ -31531,7 +31531,7 @@ _080676D8:
movs r2, 0x2
b _08067708
.align 2, 0
-_080676E8: .4byte gUnknown_203B418
+_080676E8: .4byte gDungeonGlobalData
_080676EC: .4byte 0x0000065c
_080676F0:
movs r0, 0xE
@@ -31619,7 +31619,7 @@ sub_8067768:
pop {r0}
bx r0
.align 2, 0
-_0806778C: .4byte gUnknown_203B418
+_0806778C: .4byte gDungeonGlobalData
_08067790: .4byte 0x0001357c
thumb_func_end sub_8067768
@@ -32876,7 +32876,7 @@ _080681B0:
_080681B4: .4byte gUnknown_202F308
_080681B8: .4byte gUnknown_202EE10
_080681BC: .4byte gUnknown_8106E80
-_080681C0: .4byte gUnknown_203B418
+_080681C0: .4byte gDungeonGlobalData
_080681C4: .4byte 0x0000065a
_080681C8: .4byte gUnknown_2027370
_080681CC: .4byte gUnknown_8106DA4
@@ -33435,7 +33435,7 @@ sub_8068614:
.align 2, 0
_0806862C: .4byte gUnknown_8106E98
_08068630: .4byte gMonsterFileArchive
-_08068634: .4byte gUnknown_203B418
+_08068634: .4byte gDungeonGlobalData
_08068638: .4byte 0x000181e4
thumb_func_end sub_8068614
@@ -33451,7 +33451,7 @@ sub_806863C:
pop {r0}
bx r0
.align 2, 0
-_08068650: .4byte gUnknown_203B418
+_08068650: .4byte gDungeonGlobalData
_08068654: .4byte 0x000181e4
thumb_func_end sub_806863C
@@ -33577,7 +33577,7 @@ _08068738:
bx r0
.align 2, 0
_08068740: .4byte 0x000001a7
-_08068744: .4byte gUnknown_203B418
+_08068744: .4byte gDungeonGlobalData
_08068748: .4byte 0x00017b44
_0806874C: .4byte 0x000001a5
_08068750: .4byte 0x000037e4
@@ -33620,7 +33620,7 @@ _08068796:
pop {r0}
bx r0
.align 2, 0
-_080687A4: .4byte gUnknown_203B418
+_080687A4: .4byte gDungeonGlobalData
_080687A8: .4byte 0x000135cc
thumb_func_end sub_8068768
@@ -33639,7 +33639,7 @@ sub_80687AC:
str r0, [r1]
bx lr
.align 2, 0
-_080687C4: .4byte gUnknown_203B418
+_080687C4: .4byte gDungeonGlobalData
_080687C8: .4byte 0x000037f0
_080687CC: .4byte 0x000037f4
thumb_func_end sub_80687AC
@@ -33656,7 +33656,7 @@ sub_80687D0:
ldr r0, [r1]
bx lr
.align 2, 0
-_080687E4: .4byte gUnknown_203B418
+_080687E4: .4byte gDungeonGlobalData
_080687E8: .4byte 0x00017b44
thumb_func_end sub_80687D0
@@ -33692,7 +33692,7 @@ _08068820:
pop {r0}
bx r0
.align 2, 0
-_08068828: .4byte gUnknown_203B418
+_08068828: .4byte gDungeonGlobalData
_0806882C: .4byte 0x00017b44
_08068830: .4byte gUnknown_8106EA0
_08068834: .4byte gMonsterFileArchive
@@ -33774,7 +33774,7 @@ sub_80688B0:
pop {r0}
bx r0
.align 2, 0
-_080688C8: .4byte gUnknown_203B418
+_080688C8: .4byte gDungeonGlobalData
thumb_func_end sub_80688B0
thumb_func_start sub_80688CC
@@ -33807,7 +33807,7 @@ _080688F2:
pop {r0}
bx r0
.align 2, 0
-_08068900: .4byte gUnknown_203B418
+_08068900: .4byte gDungeonGlobalData
_08068904: .4byte 0x00017b44
_08068908: .4byte 0x000001a7
thumb_func_end sub_80688CC
@@ -33989,7 +33989,7 @@ _08068A50:
.align 2, 0
_08068A60: .4byte gRecruitedPokemonRef
_08068A64: .4byte 0x00008df8
-_08068A68: .4byte gUnknown_203B418
+_08068A68: .4byte gDungeonGlobalData
_08068A6C: .4byte 0x00000644
_08068A70: .4byte 0x00008dfb
_08068A74: .4byte 0x00008e0c
@@ -34287,7 +34287,7 @@ _08068CC4: .4byte 0xfffffdd8
_08068CC8: .4byte gRecruitedPokemonRef
_08068CCC: .4byte 0x00008df8
_08068CD0: .4byte 0xfffffe87
-_08068CD4: .4byte gUnknown_203B418
+_08068CD4: .4byte gDungeonGlobalData
_08068CD8: .4byte 0x00000644
_08068CDC:
movs r3, 0xA
@@ -34684,7 +34684,7 @@ _08068FCC:
pop {r0}
bx r0
.align 2, 0
-_08068FD4: .4byte gUnknown_203B418
+_08068FD4: .4byte gDungeonGlobalData
_08068FD8: .4byte 0x0000066c
_08068FDC: .4byte 0x0000066d
thumb_func_end sub_8068F80
@@ -34820,7 +34820,7 @@ _080690A2:
bl sub_8045B94
b _08069484
.align 2, 0
-_080690E4: .4byte gUnknown_203B418
+_080690E4: .4byte gDungeonGlobalData
_080690E8: .4byte 0x000135cc
_080690EC: .4byte 0x000037fc
_080690F0: .4byte gUnknown_203B450
@@ -34902,7 +34902,7 @@ _08069104:
strb r0, [r1]
b _08069484
.align 2, 0
-_08069198: .4byte gUnknown_203B418
+_08069198: .4byte gDungeonGlobalData
_0806919C: .4byte 0x0000066e
_080691A0: .4byte 0x00003a0d
_080691A4: .4byte 0x0000067b
@@ -35045,7 +35045,7 @@ _080692B2:
blt _080692B2
b _0806930A
.align 2, 0
-_080692C4: .4byte gUnknown_203B418
+_080692C4: .4byte gDungeonGlobalData
_080692C8: .4byte 0x0001357c
_080692CC: .4byte gRecruitedPokemonRef
_080692D0: .4byte 0x00008df8
@@ -35094,7 +35094,7 @@ _0806930A:
b _08069352
.align 2, 0
_0806932C: .4byte gUnknown_202EE70
-_08069330: .4byte gUnknown_203B418
+_08069330: .4byte gDungeonGlobalData
_08069334: .4byte 0x000005f4
_08069338:
cmp r0, 0x47
@@ -35268,7 +35268,7 @@ _08069484:
pop {r0}
bx r0
.align 2, 0
-_08069494: .4byte gUnknown_203B418
+_08069494: .4byte gDungeonGlobalData
_08069498: .4byte 0x000005f4
_0806949C: .4byte 0xfffffe5f
_080694A0: .4byte 0x000037fe
@@ -35398,7 +35398,7 @@ _08069588:
.align 2, 0
_0806959C: .4byte gUnknown_203B410
_080695A0: .4byte gUnknown_202EE0C
-_080695A4: .4byte gUnknown_203B418
+_080695A4: .4byte gDungeonGlobalData
_080695A8:
ldr r0, [r5, 0x70]
str r0, [r5, 0x74]
@@ -35938,7 +35938,7 @@ _080699A8: .4byte gUnknown_810AC68
_080699AC: .4byte gUnknown_810AC62
_080699B0: .4byte gUnknown_810AC64
_080699B4: .4byte gUnknown_810AC66
-_080699B8: .4byte gUnknown_203B418
+_080699B8: .4byte gDungeonGlobalData
_080699BC: .4byte 0x0000065a
_080699C0:
adds r1, r6, 0
@@ -35994,7 +35994,7 @@ _08069A02:
movs r1, 0x13
b _08069A34
.align 2, 0
-_08069A24: .4byte gUnknown_203B418
+_08069A24: .4byte gDungeonGlobalData
_08069A28: .4byte 0x00000676
_08069A2C:
adds r0, r6, 0
@@ -36599,7 +36599,7 @@ _08069E64:
pop {r0}
bx r0
.align 2, 0
-_08069E88: .4byte gUnknown_203B418
+_08069E88: .4byte gDungeonGlobalData
thumb_func_end sub_8069E0C
thumb_func_start sub_8069E8C
@@ -36641,7 +36641,7 @@ _08069EAA:
ldr r1, _08069EE4
b _08069F16
.align 2, 0
-_08069ED8: .4byte gUnknown_203B418
+_08069ED8: .4byte gDungeonGlobalData
_08069EDC: .4byte 0x0000e279
_08069EE0: .4byte 0x000135cc
_08069EE4: .4byte 0x0000e273
@@ -36921,7 +36921,7 @@ _0806A0FA:
pop {r0}
bx r0
.align 2, 0
-_0806A108: .4byte gUnknown_203B418
+_0806A108: .4byte gDungeonGlobalData
_0806A10C: .4byte gAvailablePokemonNames
_0806A110: .4byte gUnknown_80FCC7C
_0806A114: .4byte gUnknown_80F51E4
@@ -37162,7 +37162,7 @@ sub_806A2BC:
bl sub_804178C
b _0806A302
.align 2, 0
-_0806A2F4: .4byte gUnknown_203B418
+_0806A2F4: .4byte gDungeonGlobalData
_0806A2F8: .4byte 0x000181f8
_0806A2FC:
movs r0, 0x34
@@ -37190,7 +37190,7 @@ _0806A328:
pop {r0}
bx r0
.align 2, 0
-_0806A330: .4byte gUnknown_203B418
+_0806A330: .4byte gDungeonGlobalData
thumb_func_end sub_806A2BC
thumb_func_start nullsub_95
@@ -37232,7 +37232,7 @@ _0806A33E:
str r0, [r1]
b _0806A38A
.align 2, 0
-_0806A378: .4byte gUnknown_203B418
+_0806A378: .4byte gDungeonGlobalData
_0806A37C: .4byte 0x000135cc
_0806A380: .4byte 0x00017b30
_0806A384:
@@ -37613,7 +37613,7 @@ _0806A608:
b _0806A6D2
.align 2, 0
_0806A640: .4byte gUnknown_810ACC0
-_0806A644: .4byte gUnknown_203B418
+_0806A644: .4byte gDungeonGlobalData
_0806A648: .4byte 0x00003a0e
_0806A64C: .4byte 0x00000113
_0806A650:
@@ -37749,7 +37749,7 @@ _0806A744:
bl sub_80418D4
b _0806A776
.align 2, 0
-_0806A75C: .4byte gUnknown_203B418
+_0806A75C: .4byte gDungeonGlobalData
_0806A760: .4byte 0x00000676
_0806A764:
cmp r1, 0x11
@@ -37820,7 +37820,7 @@ _0806A7D2:
pop {r0}
bx r0
.align 2, 0
-_0806A7E0: .4byte gUnknown_203B418
+_0806A7E0: .4byte gDungeonGlobalData
_0806A7E4: .4byte 0x0001357c
thumb_func_end sub_806A7A0
@@ -38029,7 +38029,7 @@ _0806A95C:
pop {r0}
bx r0
.align 2, 0
-_0806A96C: .4byte gUnknown_203B418
+_0806A96C: .4byte gDungeonGlobalData
_0806A970: .4byte 0x000135cc
thumb_func_end sub_806A914
@@ -38063,7 +38063,7 @@ _0806A99E:
pop {r0}
bx r0
.align 2, 0
-_0806A9AC: .4byte gUnknown_203B418
+_0806A9AC: .4byte gDungeonGlobalData
_0806A9B0: .4byte 0x000135cc
thumb_func_end sub_806A974
@@ -38156,7 +38156,7 @@ _0806AA56:
movs r0, 0
b _0806AA6A
.align 2, 0
-_0806AA5C: .4byte gUnknown_203B418
+_0806AA5C: .4byte gDungeonGlobalData
_0806AA60: .4byte 0x000037fd
_0806AA64: .4byte 0x000037ff
_0806AA68:
@@ -38202,7 +38202,7 @@ _0806AA7C:
bl sub_8042B20
b _0806AB0A
.align 2, 0
-_0806AAB4: .4byte gUnknown_203B418
+_0806AAB4: .4byte gDungeonGlobalData
_0806AAB8: .4byte 0x0001357c
_0806AABC:
adds r0, r4, 0
@@ -38327,7 +38327,7 @@ _0806AB92:
pop {r0}
bx r0
.align 2, 0
-_0806ABA4: .4byte gUnknown_203B418
+_0806ABA4: .4byte gDungeonGlobalData
_0806ABA8: .4byte 0x000135cc
thumb_func_end sub_806AB2C
@@ -38649,7 +38649,7 @@ _0806AE06:
b _0806AE94
.align 2, 0
_0806AE1C: .4byte 0xfffffdfc
-_0806AE20: .4byte gUnknown_203B418
+_0806AE20: .4byte gDungeonGlobalData
_0806AE24: .4byte 0x00002f3c
_0806AE28: .4byte 0x000001a7
_0806AE2C: .4byte 0x0000363c
@@ -38737,7 +38737,7 @@ _0806AEB2:
pop {r0}
bx r0
.align 2, 0
-_0806AECC: .4byte gUnknown_203B418
+_0806AECC: .4byte gDungeonGlobalData
_0806AED0: .4byte 0x0000363c
_0806AED4: .4byte 0x000001a7
thumb_func_end sub_806AD3C
@@ -38766,7 +38766,7 @@ sub_806AED8:
movs r3, 0
b _0806AF7A
.align 2, 0
-_0806AF04: .4byte gUnknown_203B418
+_0806AF04: .4byte gDungeonGlobalData
_0806AF08: .4byte 0x00002f3c
_0806AF0C:
lsls r0, r2, 16
@@ -39318,7 +39318,7 @@ _0806B2D2:
mov r3, r10
b _0806B3A8
.align 2, 0
-_0806B324: .4byte gUnknown_203B418
+_0806B324: .4byte gDungeonGlobalData
_0806B328: .4byte 0x0000e218
_0806B32C: .4byte 0x0000e21a
_0806B330: .4byte gRecruitedPokemonRef
@@ -39395,7 +39395,7 @@ _0806B3A8:
bl sub_806B8CC
b _0806B3E8
.align 2, 0
-_0806B3CC: .4byte gUnknown_203B418
+_0806B3CC: .4byte gDungeonGlobalData
_0806B3D0: .4byte gUnknown_80F4598
_0806B3D4: .4byte 0x0000e218
_0806B3D8: .4byte 0x0000e21a
@@ -39605,7 +39605,7 @@ _0806B51C:
adds r2, r5
b _0806B642
.align 2, 0
-_0806B560: .4byte gUnknown_203B418
+_0806B560: .4byte gDungeonGlobalData
_0806B564: .4byte 0x0000e218
_0806B568: .4byte 0x0000e21a
_0806B56C: .4byte 0x000055aa
@@ -39770,7 +39770,7 @@ _0806B67C:
str r0, [r1]
b _0806B6BE
.align 2, 0
-_0806B6AC: .4byte gUnknown_203B418
+_0806B6AC: .4byte gDungeonGlobalData
_0806B6B0: .4byte 0x0001357c
_0806B6B4: .4byte gUnknown_202EE0C
_0806B6B8:
@@ -39818,7 +39818,7 @@ sub_806B6C4:
adds r0, r2
b _0806B71A
.align 2, 0
-_0806B708: .4byte gUnknown_203B418
+_0806B708: .4byte gDungeonGlobalData
_0806B70C: .4byte 0x000037ff
_0806B710:
ldr r0, _0806B77C
@@ -39878,7 +39878,7 @@ _0806B748:
movs r6, 0x1
b _0806B794
.align 2, 0
-_0806B77C: .4byte gUnknown_203B418
+_0806B77C: .4byte gDungeonGlobalData
_0806B780: .4byte 0x000037ff
_0806B784:
movs r0, 0
@@ -39938,7 +39938,7 @@ _0806B7E2:
pop {r0}
bx r0
.align 2, 0
-_0806B7F4: .4byte gUnknown_203B418
+_0806B7F4: .4byte gDungeonGlobalData
thumb_func_end sub_806B6C4
thumb_func_start sub_806B7F8
@@ -40096,7 +40096,7 @@ _0806B906:
ldrsh r4, [r0, r3]
b _0806B932
.align 2, 0
-_0806B92C: .4byte gUnknown_203B418
+_0806B92C: .4byte gDungeonGlobalData
_0806B930:
adds r4, r1, 0
_0806B932:
@@ -40378,7 +40378,7 @@ _0806BB54: .4byte 0xffff0000
_0806BB58: .4byte 0x0000ffff
_0806BB5C: .4byte gUnknown_202EE0C
_0806BB60: .4byte gUnknown_203B450
-_0806BB64: .4byte gUnknown_203B418
+_0806BB64: .4byte gDungeonGlobalData
_0806BB68: .4byte 0x00000644
thumb_func_end sub_806B8CC
@@ -40587,7 +40587,7 @@ sub_806BC68:
strb r3, [r6, 0x8]
b _0806BD24
.align 2, 0
-_0806BD0C: .4byte gUnknown_203B418
+_0806BD0C: .4byte gDungeonGlobalData
_0806BD10: .4byte 0x0000ffff
_0806BD14: .4byte 0x0000fffe
_0806BD18: .4byte 0x0000066e
@@ -40652,7 +40652,7 @@ _0806BD5E:
strb r0, [r6, 0x9]
b _0806BDA6
.align 2, 0
-_0806BD94: .4byte gUnknown_203B418
+_0806BD94: .4byte gDungeonGlobalData
_0806BD98: .4byte 0x000037fd
_0806BD9C: .4byte 0x000037ff
_0806BDA0: .4byte 0x000037f0
@@ -40918,7 +40918,7 @@ _0806BF70:
bx r0
.align 2, 0
_0806BFB4: .4byte 0x00000145
-_0806BFB8: .4byte gUnknown_203B418
+_0806BFB8: .4byte gDungeonGlobalData
_0806BFBC: .4byte 0x00018208
thumb_func_end sub_806BC68
@@ -41192,7 +41192,7 @@ _0806C188:
pop {r0}
bx r0
.align 2, 0
-_0806C1D0: .4byte gUnknown_203B418
+_0806C1D0: .4byte gDungeonGlobalData
_0806C1D4: .4byte 0x00000113
thumb_func_end sub_806BFC0
@@ -41264,7 +41264,7 @@ _0806C244:
pop {r0}
bx r0
.align 2, 0
-_0806C258: .4byte gUnknown_203B418
+_0806C258: .4byte gDungeonGlobalData
_0806C25C: .4byte 0x0001357c
_0806C260: .4byte 0x00000119
thumb_func_end sub_806C1D8
@@ -41410,7 +41410,7 @@ _0806C358:
strb r7, [r1, 0x2]
b _0806C3B8
.align 2, 0
-_0806C370: .4byte gUnknown_203B418
+_0806C370: .4byte gDungeonGlobalData
_0806C374: .4byte 0x0000057c
_0806C378:
adds r1, 0x8
@@ -41506,7 +41506,7 @@ _0806C416:
pop {r0}
bx r0
.align 2, 0
-_0806C424: .4byte gUnknown_203B418
+_0806C424: .4byte gDungeonGlobalData
_0806C428: .4byte 0x0000057c
thumb_func_end sub_806C3C0
@@ -41520,7 +41520,7 @@ sub_806C42C:
str r1, [r0, 0x40]
bx lr
.align 2, 0
-_0806C43C: .4byte gUnknown_203B418
+_0806C43C: .4byte gDungeonGlobalData
_0806C440: .4byte 0x0000057c
thumb_func_end sub_806C42C
@@ -41664,7 +41664,7 @@ sub_806C51C:
str r3, [sp, 0x38]
b _0806C554
.align 2, 0
-_0806C544: .4byte gUnknown_203B418
+_0806C544: .4byte gDungeonGlobalData
_0806C548: .4byte 0x000181f8
_0806C54C:
ldr r4, _0806C5AC
@@ -41951,7 +41951,7 @@ _0806C76A:
b _0806C7E2
.align 2, 0
_0806C774: .4byte 0x000001a5
-_0806C778: .4byte gUnknown_203B418
+_0806C778: .4byte gDungeonGlobalData
_0806C77C: .4byte 0x0001356c
_0806C780: .4byte 0x0000015f
_0806C784:
@@ -42091,7 +42091,7 @@ _0806C870:
str r0, [sp, 0x34]
b _0806C8D8
.align 2, 0
-_0806C88C: .4byte gUnknown_203B418
+_0806C88C: .4byte gDungeonGlobalData
_0806C890: .4byte 0x000181f0
_0806C894: .4byte 0x000181f2
_0806C898:
@@ -42226,7 +42226,7 @@ _0806C958:
.align 2, 0
_0806C998: .4byte 0xffff0000
_0806C99C: .4byte 0x0000ffff
-_0806C9A0: .4byte gUnknown_203B418
+_0806C9A0: .4byte gDungeonGlobalData
_0806C9A4: .4byte 0x00018208
_0806C9A8: .4byte 0x0000c7ff
_0806C9AC:
@@ -42330,7 +42330,7 @@ _0806CA58:
_0806CA5C: .4byte 0xfffff400
_0806CA60: .4byte 0x0000f3ff
_0806CA64: .4byte 0x0000ffff
-_0806CA68: .4byte gUnknown_203B418
+_0806CA68: .4byte gDungeonGlobalData
_0806CA6C: .4byte 0x00018208
_0806CA70: .4byte 0xfffffe5f
_0806CA74: .4byte 0x0001820f
@@ -42531,7 +42531,7 @@ _0806CBDE:
bx r0
.align 2, 0
_0806CBF0: .4byte gUnknown_202EDCC
-_0806CBF4: .4byte gUnknown_203B418
+_0806CBF4: .4byte gDungeonGlobalData
_0806CBF8: .4byte 0x000181f0
_0806CBFC: .4byte 0x000181f2
_0806CC00: .4byte 0x0000010f
@@ -42587,7 +42587,7 @@ _0806CC5C:
pop {r0}
bx r0
.align 2, 0
-_0806CC68: .4byte gUnknown_203B418
+_0806CC68: .4byte gDungeonGlobalData
_0806CC6C: .4byte 0x000135cc
thumb_func_end sub_806CC10
@@ -42623,7 +42623,7 @@ _0806CCA0:
pop {r0}
bx r0
.align 2, 0
-_0806CCAC: .4byte gUnknown_203B418
+_0806CCAC: .4byte gDungeonGlobalData
_0806CCB0: .4byte 0x000135cc
thumb_func_end sub_806CC70
@@ -42698,7 +42698,7 @@ _0806CCDC:
bl sub_80053AC
b _0806CD76
.align 2, 0
-_0806CD40: .4byte gUnknown_203B418
+_0806CD40: .4byte gDungeonGlobalData
_0806CD44: .4byte 0x00018210
_0806CD48: .4byte 0x000181f8
_0806CD4C:
@@ -42768,7 +42768,7 @@ _0806CDC0:
pop {r0}
bx r0
.align 2, 0
-_0806CDCC: .4byte gUnknown_203B418
+_0806CDCC: .4byte gDungeonGlobalData
_0806CDD0: .4byte 0x000135cc
thumb_func_end sub_806CD90
@@ -43032,7 +43032,7 @@ _0806CF84:
pop {r0}
bx r0
.align 2, 0
-_0806CF90: .4byte gUnknown_203B418
+_0806CF90: .4byte gDungeonGlobalData
_0806CF94: .4byte 0x000135cc
thumb_func_end sub_806CF60
@@ -43093,7 +43093,7 @@ _0806CFF8:
bx r1
.align 2, 0
_0806D000: .4byte gUnknown_810ACC0
-_0806D004: .4byte gUnknown_203B418
+_0806D004: .4byte gDungeonGlobalData
_0806D008: .4byte 0x00003a0e
_0806D00C: .4byte gUnknown_8106EEF
thumb_func_end sub_806CF98
@@ -43702,7 +43702,7 @@ _0806D48A:
_0806D4D4: .4byte gUnknown_80F4E1C
_0806D4D8: .4byte gUnknown_80F4E1E
_0806D4DC: .4byte gUnknown_80F4E20
-_0806D4E0: .4byte gUnknown_203B418
+_0806D4E0: .4byte gDungeonGlobalData
_0806D4E4: .4byte 0x000135cc
_0806D4E8:
ldr r0, [r4, 0x70]
@@ -44470,7 +44470,7 @@ _0806DB00:
.align 2, 0
_0806DB04: .4byte gRecruitedPokemonRef
_0806DB08: .4byte 0x00008df8
-_0806DB0C: .4byte gUnknown_203B418
+_0806DB0C: .4byte gDungeonGlobalData
_0806DB10: .4byte 0x0000065c
_0806DB14: .4byte gUnknown_80F9CEC
_0806DB18:
@@ -44522,7 +44522,7 @@ _0806DB4C:
lsls r1, r3, 2
b _0806DB82
.align 2, 0
-_0806DB70: .4byte gUnknown_203B418
+_0806DB70: .4byte gDungeonGlobalData
_0806DB74: .4byte 0x0000065d
_0806DB78: .4byte gUnknown_80F9D8C
_0806DB7C:
@@ -44634,7 +44634,7 @@ _0806DC48:
b _0806DEE4
.align 2, 0
_0806DC4C: .4byte gUnknown_80F9D28
-_0806DC50: .4byte gUnknown_203B418
+_0806DC50: .4byte gDungeonGlobalData
_0806DC54: .4byte 0x00000679
_0806DC58: .4byte 0x00000676
_0806DC5C:
@@ -44788,7 +44788,7 @@ _0806DD62:
bl sub_807A5D0
b _0806DDA2
.align 2, 0
-_0806DD80: .4byte gUnknown_203B418
+_0806DD80: .4byte gDungeonGlobalData
_0806DD84: .4byte 0x0001357c
_0806DD88: .4byte 0x00000221
_0806DD8C: .4byte 0x00000679
@@ -44951,7 +44951,7 @@ _0806DEC8:
b _0806DEF2
.align 2, 0
_0806DED4: .4byte gTeamInventory_203B460
-_0806DED8: .4byte gUnknown_203B418
+_0806DED8: .4byte gDungeonGlobalData
_0806DEDC: .4byte 0x00000679
_0806DEE0: .4byte 0x00000676
_0806DEE4:
@@ -45112,7 +45112,7 @@ _0806E020:
mov r10, r3
b _0806E066
.align 2, 0
-_0806E02C: .4byte gUnknown_203B418
+_0806E02C: .4byte gDungeonGlobalData
_0806E030: .4byte 0x0000066a
_0806E034: .4byte 0x000003e7
_0806E038: .4byte 0x0000014b
@@ -45177,7 +45177,7 @@ _0806E08A:
adds r0, r7, 0
b _0806E0DC
.align 2, 0
-_0806E0BC: .4byte gUnknown_203B418
+_0806E0BC: .4byte gDungeonGlobalData
_0806E0C0: .4byte 0x00000644
_0806E0C4: .4byte 0x00000149
_0806E0C8: .4byte 0x000001f5
@@ -45303,7 +45303,7 @@ _0806E17E:
strb r0, [r1]
b _0806E1CA
.align 2, 0
-_0806E1AC: .4byte gUnknown_203B418
+_0806E1AC: .4byte gDungeonGlobalData
_0806E1B0: .4byte 0x00000179
_0806E1B4:
ldr r2, _0806E4E4
@@ -45708,7 +45708,7 @@ _0806E4B8:
b _0806E53E
.align 2, 0
_0806E4E4: .4byte gUnknown_80F522C
-_0806E4E8: .4byte gUnknown_203B418
+_0806E4E8: .4byte gDungeonGlobalData
_0806E4EC: .4byte gUnknown_8106F54
_0806E4F0: .4byte gUnknown_80F54B4
_0806E4F4: .4byte gUnknown_8106EFC
@@ -45753,7 +45753,7 @@ _0806E53E:
bl sub_800A34C
b _0806E586
.align 2, 0
-_0806E560: .4byte gUnknown_203B418
+_0806E560: .4byte gDungeonGlobalData
_0806E564: .4byte gUnknown_8106F1C
_0806E568: .4byte 0x0000016b
_0806E56C:
@@ -45855,7 +45855,7 @@ _0806E61A:
pop {r1}
bx r1
.align 2, 0
-_0806E62C: .4byte gUnknown_203B418
+_0806E62C: .4byte gDungeonGlobalData
_0806E630: .4byte 0x0000016b
_0806E634: .4byte gUnknown_8106F14
_0806E638: .4byte gUnknown_8106F64
@@ -45978,7 +45978,7 @@ _0806E6F0:
b _0806E73E
.align 2, 0
_0806E724: .4byte gUnknown_8106F6C
-_0806E728: .4byte gUnknown_203B418
+_0806E728: .4byte gDungeonGlobalData
_0806E72C: .4byte 0x00000179
_0806E730:
ldrb r0, [r2]
@@ -46181,7 +46181,7 @@ _0806E894:
pop {r1}
bx r1
.align 2, 0
-_0806E8A4: .4byte gUnknown_203B418
+_0806E8A4: .4byte gDungeonGlobalData
_0806E8A8: .4byte 0x0000e277
_0806E8AC: .4byte 0x0000e278
thumb_func_end sub_806E654
@@ -46462,7 +46462,7 @@ _0806EACA:
.align 2, 0
_0806EADC: .4byte gUnknown_80FEE04
_0806EAE0: .4byte gUnknown_80FEE2C
-_0806EAE4: .4byte gUnknown_203B418
+_0806EAE4: .4byte gDungeonGlobalData
_0806EAE8: .4byte 0x000037fa
_0806EAEC: .4byte 0x000037f8
_0806EAF0: .4byte gUnknown_80FEE54
@@ -46821,7 +46821,7 @@ _0806ED74:
adds r0, r6
b _0806EE48
.align 2, 0
-_0806EDA4: .4byte gUnknown_203B418
+_0806EDA4: .4byte gDungeonGlobalData
_0806EDA8: .4byte 0x000001a1
_0806EDAC: .4byte 0x000001a3
_0806EDB0: .4byte gUnknown_80F504C
@@ -46984,7 +46984,7 @@ _0806EE7C:
_0806EEF8: .4byte gUnknown_810AC66
_0806EEFC: .4byte 0x00000163
_0806EF00: .4byte gUnknown_810AC62
-_0806EF04: .4byte gUnknown_203B418
+_0806EF04: .4byte gDungeonGlobalData
_0806EF08: .4byte 0x00000161
_0806EF0C: .4byte gUnknown_810AC68
_0806EF10: .4byte 0x000003e6
@@ -47161,7 +47161,7 @@ _0806F036:
bl sub_80522F4
b _0806F0BC
.align 2, 0
-_0806F098: .4byte gUnknown_203B418
+_0806F098: .4byte gDungeonGlobalData
_0806F09C: .4byte 0x00000ccc
_0806F0A0: .4byte gUnknown_8106F24
_0806F0A4: .4byte gUnknown_8106F04
@@ -47254,7 +47254,7 @@ _0806F140:
.align 2, 0
_0806F15C: .4byte gUnknown_80FADD8
_0806F160: .4byte gUnknown_8106F1C
-_0806F164: .4byte gUnknown_203B418
+_0806F164: .4byte gDungeonGlobalData
_0806F168: .4byte 0x00000167
_0806F16C: .4byte 0x000003e7
_0806F170:
@@ -47403,7 +47403,7 @@ _0806F294:
bx r0
.align 2, 0
_0806F2A4: .4byte gUnknown_80F4DAE
-_0806F2A8: .4byte gUnknown_203B418
+_0806F2A8: .4byte gDungeonGlobalData
_0806F2AC: .4byte 0x00000165
_0806F2B0: .4byte gUnknown_80F4DB0
_0806F2B4: .4byte 0x00000169
@@ -47851,7 +47851,7 @@ sub_806F500:
strb r2, [r0]
bx lr
.align 2, 0
-_0806F5F4: .4byte gUnknown_203B418
+_0806F5F4: .4byte gDungeonGlobalData
_0806F5F8: .4byte 0x00000161
_0806F5FC: .4byte 0x00000163
_0806F600: .4byte 0x00000165
@@ -47894,7 +47894,7 @@ _0806F652:
pop {r0}
bx r0
.align 2, 0
-_0806F658: .4byte gUnknown_203B418
+_0806F658: .4byte gDungeonGlobalData
_0806F65C: .4byte 0x000181e8
thumb_func_end sub_806F63C
@@ -47947,7 +47947,7 @@ sub_806F660:
bne _0806F702
b _0806F8FC
.align 2, 0
-_0806F6C0: .4byte gUnknown_203B418
+_0806F6C0: .4byte gDungeonGlobalData
_0806F6C4: .4byte 0x00003a14
_0806F6C8: .4byte 0x0000065c
_0806F6CC:
@@ -48140,7 +48140,7 @@ _0806F816:
b _0806F856
.align 2, 0
_0806F834: .4byte 0x00000644
-_0806F838: .4byte gUnknown_203B418
+_0806F838: .4byte gDungeonGlobalData
_0806F83C: .4byte 0x0000065d
_0806F840: .4byte 0x0000010d
_0806F844: .4byte 0xfffffc19
@@ -48232,7 +48232,7 @@ _0806F8E2:
movs r0, 0x1
b _0806F8FE
.align 2, 0
-_0806F8EC: .4byte gUnknown_203B418
+_0806F8EC: .4byte gDungeonGlobalData
_0806F8F0: .4byte 0x0001357c
_0806F8F4:
adds r0, r6, 0
@@ -48339,7 +48339,7 @@ _0806F9A2:
pop {r0}
bx r0
.align 2, 0
-_0806F9AC: .4byte gUnknown_203B418
+_0806F9AC: .4byte gDungeonGlobalData
_0806F9B0: .4byte 0x0001357c
_0806F9B4: .4byte 0x00000167
_0806F9B8: .4byte gUnknown_202EE70
@@ -48412,7 +48412,7 @@ _0806FA3C:
movs r0, 0
b _0806FA52
.align 2, 0
-_0806FA40: .4byte gUnknown_203B418
+_0806FA40: .4byte gDungeonGlobalData
_0806FA44: .4byte 0x00000199
_0806FA48: .4byte 0x000001a1
_0806FA4C: .4byte 0x000001a3
@@ -48658,7 +48658,7 @@ _0806FBC4:
_0806FC40: .4byte gRecruitedPokemonRef
_0806FC44: .4byte 0x00008df8
_0806FC48: .4byte 0x0000ffff
-_0806FC4C: .4byte gUnknown_203B418
+_0806FC4C: .4byte gDungeonGlobalData
_0806FC50: .4byte 0x00000644
_0806FC54: .4byte gUnknown_80FA058
_0806FC58:
@@ -48745,7 +48745,7 @@ _0806FD04: .4byte gAvailablePokemonNames
_0806FD08: .4byte gUnknown_80FA0F0
_0806FD0C: .4byte gUnknown_202E628
_0806FD10: .4byte gUnknown_80FA120
-_0806FD14: .4byte gUnknown_203B418
+_0806FD14: .4byte gDungeonGlobalData
thumb_func_end sub_806FA5C
thumb_func_start sub_806FD18
@@ -48858,7 +48858,7 @@ _0806FDDA:
movs r0, 0x1
b _0806FDEE
.align 2, 0
-_0806FDE4: .4byte gUnknown_203B418
+_0806FDE4: .4byte gDungeonGlobalData
_0806FDE8: .4byte 0x0001357c
_0806FDEC:
movs r0, 0
@@ -49058,7 +49058,7 @@ _0806FF34:
_0806FF74: .4byte gRecruitedPokemonRef
_0806FF78: .4byte 0x00008df8
_0806FF7C: .4byte 0x0000ffff
-_0806FF80: .4byte gUnknown_203B418
+_0806FF80: .4byte gDungeonGlobalData
_0806FF84: .4byte 0x00000644
_0806FF88:
ldr r0, _0806FF9C
diff --git a/asm/code_807001C.s b/asm/code_807001C.s
index 8dc5eb2..19a3a30 100644
--- a/asm/code_807001C.s
+++ b/asm/code_807001C.s
@@ -1104,7 +1104,7 @@ _0807080A:
bx r1
.align 2, 0
_0807081C: .4byte 0x000001a3
-_08070820: .4byte gUnknown_203B418
+_08070820: .4byte gDungeonGlobalData
_08070824: .4byte 0x0000066e
thumb_func_end sub_8070774
@@ -1209,7 +1209,7 @@ _080708DC:
ldr r0, _080708F0
b _08070900
.align 2, 0
-_080708E8: .4byte gUnknown_203B418
+_080708E8: .4byte gDungeonGlobalData
_080708EC: .4byte 0x0001820a
_080708F0: .4byte gUnknown_80F8988
_080708F4:
@@ -1351,7 +1351,7 @@ _080709EE:
ldr r0, _08070A00
b _08070A10
.align 2, 0
-_080709F8: .4byte gUnknown_203B418
+_080709F8: .4byte gDungeonGlobalData
_080709FC: .4byte 0x0001820a
_08070A00: .4byte gUnknown_80F8994
_08070A04:
@@ -2572,7 +2572,7 @@ _08071308:
b _08071348
.align 2, 0
_0807130C: .4byte gUnknown_80F4448
-_08071310: .4byte gUnknown_203B418
+_08071310: .4byte gDungeonGlobalData
_08071314: .4byte 0x00000671
_08071318: .4byte gUnknown_810ACC0
_0807131C: .4byte 0x00003a0e
@@ -2740,7 +2740,7 @@ _08071458:
b _0807146A
.align 2, 0
_0807145C: .4byte gUnknown_810ACC0
-_08071460: .4byte gUnknown_203B418
+_08071460: .4byte gDungeonGlobalData
_08071464: .4byte 0x00003a0e
_08071468:
movs r0, 0x1
@@ -3563,7 +3563,7 @@ _08071A0C:
pop {r1}
bx r1
.align 2, 0
-_08071A14: .4byte gUnknown_203B418
+_08071A14: .4byte gDungeonGlobalData
_08071A18: .4byte 0x0001357c
thumb_func_end sub_80719C4
@@ -3623,7 +3623,7 @@ sub_8071A70:
push {lr}
movs r1, 0x2
ldrsh r0, [r0, r1]
- bl GetUnk33
+ bl IsToolboxEnabled
lsls r0, 24
cmp r0, 0
beq _08071A84
@@ -3790,7 +3790,7 @@ _08071B7C:
ldr r0, _08071BA8
b _08071BAE
.align 2, 0
-_08071B94: .4byte gUnknown_203B418
+_08071B94: .4byte gDungeonGlobalData
_08071B98: .4byte 0x00000664
_08071B9C: .4byte 0x000037fd
_08071BA0: .4byte 0x00000662
@@ -3896,7 +3896,7 @@ _08071C6C: .4byte 0x00017b40
_08071C70: .4byte gAvailablePokemonNames
_08071C74: .4byte 0x0001358c
_08071C78: .4byte 0x0000066e
-_08071C7C: .4byte gUnknown_203B418
+_08071C7C: .4byte gDungeonGlobalData
_08071C80: .4byte 0x00003a0c
_08071C84: .4byte gUnknown_80F4DA6
_08071C88:
@@ -3974,7 +3974,7 @@ _08071CDC:
movs r0, 0x1
b _08071D2E
.align 2, 0
-_08071D24: .4byte gUnknown_203B418
+_08071D24: .4byte gDungeonGlobalData
_08071D28: .4byte 0x00000644
_08071D2C:
movs r0, 0
@@ -4043,7 +4043,7 @@ _08071D94:
.align 2, 0
_08071D98: .4byte 0x0098967e
_08071D9C: .4byte 0x0098967f
-_08071DA0: .4byte gUnknown_203B418
+_08071DA0: .4byte gDungeonGlobalData
thumb_func_end sub_8071D4C
thumb_func_start sub_8071DA4
@@ -4133,7 +4133,7 @@ _08071E32:
strb r2, [r1]
b _08071FCA
.align 2, 0
-_08071E44: .4byte gUnknown_203B418
+_08071E44: .4byte gDungeonGlobalData
_08071E48: .4byte 0x000135cc
_08071E4C:
movs r1, 0xFE
@@ -4598,7 +4598,7 @@ _080721EC:
bl sub_806A3D4
b _0807220A
.align 2, 0
-_080721F8: .4byte gUnknown_203B418
+_080721F8: .4byte gDungeonGlobalData
_080721FC: .4byte 0x0000065c
_08072200:
ldr r0, _08072308
@@ -6073,7 +6073,7 @@ sub_8072CF4:
b _08072D64
.align 2, 0
_08072D4C: .4byte gUnknown_203B434
-_08072D50: .4byte gUnknown_203B418
+_08072D50: .4byte gDungeonGlobalData
_08072D54: .4byte gUnknown_80F58F4
_08072D58:
adds r0, r2, 0x1
@@ -6403,7 +6403,7 @@ _08073046:
ldr r0, _08073070
b _080731A2
.align 2, 0
-_08073064: .4byte gUnknown_203B418
+_08073064: .4byte gDungeonGlobalData
_08073068: .4byte 0x00000644
_0807306C: .4byte 0x000037fe
_08073070: .4byte gUnknown_80FA5B4
@@ -6420,7 +6420,7 @@ _08073074:
strb r0, [r1]
b _080731B8
.align 2, 0
-_0807308C: .4byte gUnknown_203B418
+_0807308C: .4byte gDungeonGlobalData
_08073090: .4byte gUnknown_202F32C
_08073094:
adds r0, r4, 0
@@ -6476,7 +6476,7 @@ _080730E0:
str r0, [r2]
b _080731B8
.align 2, 0
-_080730FC: .4byte gUnknown_203B418
+_080730FC: .4byte gDungeonGlobalData
_08073100: .4byte 0x0001357c
_08073104:
adds r0, r4, 0
@@ -6769,7 +6769,7 @@ _08073332:
strb r0, [r4]
b _08073472
.align 2, 0
-_0807335C: .4byte gUnknown_203B418
+_0807335C: .4byte gDungeonGlobalData
_08073360: .4byte 0x000135cc
_08073364:
adds r0, r7, 0
@@ -6974,7 +6974,7 @@ _080734CC:
strb r0, [r4]
b _080735DA
.align 2, 0
-_080734E8: .4byte gUnknown_203B418
+_080734E8: .4byte gDungeonGlobalData
_080734EC: .4byte 0x000135cc
_080734F0: .4byte 0x00000165
_080734F4:
@@ -7158,7 +7158,7 @@ _08073644:
pop {r0}
bx r0
.align 2, 0
-_08073650: .4byte gUnknown_203B418
+_08073650: .4byte gDungeonGlobalData
_08073654: .4byte 0x000135cc
thumb_func_end sub_807360C
@@ -7440,7 +7440,7 @@ _08073866:
_08073870:
ldrb r0, [r7, 0x2]
movs r1, 0
- bl GetItemUnkFood
+ bl GetItemAIFlags
lsls r0, 24
cmp r0, 0
beq _080738EC
@@ -7508,7 +7508,7 @@ _080738EC:
_080738FC:
ldrb r0, [r7, 0x2]
mov r1, r9
- bl GetItemUnkFood
+ bl GetItemAIFlags
lsls r0, 24
cmp r0, 0
beq _080739AE
@@ -7675,7 +7675,7 @@ _08073A0A:
.align 2, 0
_08073A44: .4byte gUnknown_203B440
_08073A48: .4byte gUnknown_202F350
-_08073A4C: .4byte gUnknown_203B418
+_08073A4C: .4byte gDungeonGlobalData
_08073A50: .4byte 0x000135cc
_08073A54:
adds r0, r5, 0
@@ -7822,7 +7822,7 @@ _08073B56:
bx r0
.align 2, 0
_08073B6C: .4byte gUnknown_203B440
-_08073B70: .4byte gUnknown_203B418
+_08073B70: .4byte gDungeonGlobalData
_08073B74: .4byte 0x000135cc
thumb_func_end sub_8073AA0
@@ -8217,7 +8217,7 @@ _08073E48:
mov r8, r0
b _08073E80
.align 2, 0
-_08073E64: .4byte gUnknown_203B418
+_08073E64: .4byte gDungeonGlobalData
_08073E68: .4byte 0x0000065b
_08073E6C: .4byte gTeamInventory_203B460
_08073E70:
@@ -8832,7 +8832,7 @@ _08074320:
.align 2, 0
_0807434C: .4byte 0x00000169
_08074350: .4byte gUnknown_80F5594
-_08074354: .4byte gUnknown_203B418
+_08074354: .4byte gDungeonGlobalData
_08074358: .4byte 0x0000199a
_0807435C: .4byte gUnknown_80F54F4
_08074360: .4byte 0x00000153
@@ -8909,7 +8909,7 @@ _080743CA:
bl sub_806F324
b _08074466
.align 2, 0
-_08074408: .4byte gUnknown_203B418
+_08074408: .4byte gDungeonGlobalData
_0807440C: .4byte 0x00000679
_08074410: .4byte 0x00000153
_08074414: .4byte 0x0000e266
@@ -9502,7 +9502,7 @@ _080748D4: .4byte gUnknown_80F4F3C
_080748D8: .4byte gUnknown_80F4FB2
_080748DC: .4byte gUnknown_80F4F3E
_080748E0: .4byte gUnknown_80F4FB4
-_080748E4: .4byte gUnknown_203B418
+_080748E4: .4byte gDungeonGlobalData
_080748E8: .4byte 0x000135cc
_080748EC: .4byte gUnknown_80F4F40
_080748F0:
@@ -10729,7 +10729,7 @@ _080752B2:
b _0807534C
.align 2, 0
_080752D0: .4byte gUnknown_202F378
-_080752D4: .4byte gUnknown_203B418
+_080752D4: .4byte gDungeonGlobalData
_080752D8: .4byte 0x000135cc
_080752DC: .4byte 0x00000147
_080752E0:
@@ -10822,7 +10822,7 @@ _08075384:
movs r5, 0
b _0807549E
.align 2, 0
-_08075390: .4byte gUnknown_203B418
+_08075390: .4byte gDungeonGlobalData
_08075394: .4byte 0x0000066c
_08075398:
movs r0, 0x7
@@ -10892,7 +10892,7 @@ _080753A6:
strh r2, [r6]
b _08075492
.align 2, 0
-_08075420: .4byte gUnknown_203B418
+_08075420: .4byte gDungeonGlobalData
_08075424: .4byte 0x000135cc
_08075428:
movs r0, 0
@@ -11011,7 +11011,7 @@ _08075506:
b _08075600
.align 2, 0
_08075510: .4byte gUnknown_202F378
-_08075514: .4byte gUnknown_203B418
+_08075514: .4byte gDungeonGlobalData
_08075518: .4byte 0x000135cc
_0807551C:
ldr r2, [r4, 0x70]
@@ -11156,7 +11156,7 @@ _08075632:
str r3, [r0]
b _0807566A
.align 2, 0
-_08075650: .4byte gUnknown_203B418
+_08075650: .4byte gDungeonGlobalData
_08075654: .4byte 0x00003a08
_08075658: .4byte gUnknown_202F32D
_0807565C: .4byte 0x000135cc
@@ -11178,7 +11178,7 @@ _0807566C:
pop {r1}
bx r1
.align 2, 0
-_0807567C: .4byte gUnknown_203B418
+_0807567C: .4byte gDungeonGlobalData
thumb_func_end sub_807520C
thumb_func_start sub_8075680
@@ -11242,7 +11242,7 @@ _080756EE:
pop {r0}
bx r0
.align 2, 0
-_080756FC: .4byte gUnknown_203B418
+_080756FC: .4byte gDungeonGlobalData
_08075700: .4byte 0x000135cc
thumb_func_end sub_8075680
@@ -11562,7 +11562,7 @@ _0807597A:
pop {r0}
bx r0
.align 2, 0
-_08075980: .4byte gUnknown_203B418
+_08075980: .4byte gDungeonGlobalData
_08075984: .4byte 0x00000671
_08075988: .4byte gUnknown_80FE308
_0807598C: .4byte 0x00000672
@@ -11706,7 +11706,7 @@ _08075A9A:
strb r1, [r0]
b _08075AB6
.align 2, 0
-_08075AA4: .4byte gUnknown_203B418
+_08075AA4: .4byte gDungeonGlobalData
_08075AA8: .4byte 0x000037fc
_08075AAC: .4byte 0x000135cc
_08075AB0:
@@ -12756,7 +12756,7 @@ _080762CC:
b _080763DA
.align 2, 0
_080762D8: .4byte gUnknown_810ACC0
-_080762DC: .4byte gUnknown_203B418
+_080762DC: .4byte gDungeonGlobalData
_080762E0: .4byte 0x00003a0e
_080762E4: .4byte gUnknown_80FEBBC
_080762E8:
@@ -13435,7 +13435,7 @@ _0807685C:
b _080768C8
.align 2, 0
_08076868: .4byte gUnknown_810ACC0
-_0807686C: .4byte gUnknown_203B418
+_0807686C: .4byte gDungeonGlobalData
_08076870: .4byte 0x00003a0e
_08076874: .4byte gUnknown_80FCE34
_08076878:
@@ -13877,7 +13877,7 @@ _08076B74:
b _08076C98
.align 2, 0
_08076C0C: .4byte gUnknown_80F4E5C
-_08076C10: .4byte gUnknown_203B418
+_08076C10: .4byte gDungeonGlobalData
_08076C14: .4byte 0x000037f4
_08076C18: .4byte gAvailablePokemonNames
_08076C1C: .4byte gUnknown_80FB6D8
@@ -13998,7 +13998,7 @@ _08076CFA:
pop {r0}
bx r0
.align 2, 0
-_08076D08: .4byte gUnknown_203B418
+_08076D08: .4byte gDungeonGlobalData
_08076D0C: .4byte 0x000135cc
thumb_func_end sub_8076CB4
@@ -14132,7 +14132,7 @@ _08076E0E:
bx r0
.align 2, 0
_08076E14: .4byte gUnknown_80FB7DC
-_08076E18: .4byte gUnknown_203B418
+_08076E18: .4byte gDungeonGlobalData
_08076E1C: .4byte 0x0001357c
thumb_func_end sub_8076D10
@@ -16398,7 +16398,7 @@ _08078068:
pop {r0}
bx r0
.align 2, 0
-_08078078: .4byte gUnknown_203B418
+_08078078: .4byte gDungeonGlobalData
_0807807C: .4byte 0x000135cc
_08078080: .4byte gUnknown_80FAE58
thumb_func_end sub_8077F40
@@ -16450,7 +16450,7 @@ _080780D0:
pop {r0}
bx r0
.align 2, 0
-_080780DC: .4byte gUnknown_203B418
+_080780DC: .4byte gDungeonGlobalData
_080780E0: .4byte 0x000135cc
thumb_func_end sub_8078084
@@ -16565,7 +16565,7 @@ _080781C4:
pop {r0}
bx r0
.align 2, 0
-_080781D0: .4byte gUnknown_203B418
+_080781D0: .4byte gDungeonGlobalData
_080781D4: .4byte 0x000135cc
_080781D8: .4byte gUnknown_80FBB4C
thumb_func_end sub_80780E4
@@ -17017,7 +17017,7 @@ _0807856A:
pop {r0}
bx r0
.align 2, 0
-_0807857C: .4byte gUnknown_203B418
+_0807857C: .4byte gDungeonGlobalData
_08078580: .4byte 0x000135cc
_08078584: .4byte gAvailablePokemonNames
_08078588: .4byte gUnknown_80F4ED0
@@ -17229,7 +17229,7 @@ _08078732:
pop {r0}
bx r0
.align 2, 0
-_0807873C: .4byte gUnknown_203B418
+_0807873C: .4byte gDungeonGlobalData
_08078740: .4byte 0x000135cc
_08078744: .4byte gUnknown_80F4EA8
_08078748: .4byte 0x00017b30
@@ -18417,7 +18417,7 @@ sub_80790C8:
bl sub_80522F4
b _08079134
.align 2, 0
-_0807911C: .4byte gUnknown_203B418
+_0807911C: .4byte gDungeonGlobalData
_08079120: .4byte 0x00000676
_08079124: .4byte gUnknown_80FC028
_08079128:
@@ -21064,7 +21064,7 @@ _0807A642:
b _0807A6A4
.align 2, 0
_0807A658: .4byte gUnknown_80FA7DC
-_0807A65C: .4byte gUnknown_203B418
+_0807A65C: .4byte gDungeonGlobalData
_0807A660: .4byte 0x00017b30
_0807A664: .4byte 0x00017b3c
_0807A668:
@@ -21106,7 +21106,7 @@ _0807A6B2:
pop {r0}
bx r0
.align 2, 0
-_0807A6B8: .4byte gUnknown_203B418
+_0807A6B8: .4byte gDungeonGlobalData
_0807A6BC: .4byte 0x000037fc
_0807A6C0: .4byte gAvailablePokemonNames
_0807A6C4: .4byte gUnknown_80FA9A0
@@ -21633,7 +21633,7 @@ _0807AACE:
mov r9, r0
b _0807AB06
.align 2, 0
-_0807AAD8: .4byte gUnknown_203B418
+_0807AAD8: .4byte gDungeonGlobalData
_0807AADC: .4byte 0x0001358c
_0807AAE0: .4byte 0x0001357c
_0807AAE4:
@@ -21798,7 +21798,7 @@ _0807AC00:
ble _0807ABAE
b _0807ACB4
.align 2, 0
-_0807AC10: .4byte gUnknown_203B418
+_0807AC10: .4byte gDungeonGlobalData
_0807AC14: .4byte 0x00000671
_0807AC18: .4byte 0x00003a0c
_0807AC1C: .4byte 0x000104c4
@@ -22255,7 +22255,7 @@ _0807AF74:
mov r10, r4
b _0807AFB4
.align 2, 0
-_0807AF8C: .4byte gUnknown_203B418
+_0807AF8C: .4byte gDungeonGlobalData
_0807AF90: .4byte 0x000037fc
_0807AF94: .4byte 0x000135cc
_0807AF98:
@@ -22328,7 +22328,7 @@ _0807AFD6:
.align 2, 0
_0807B01C: .4byte 0x0001358c
_0807B020: .4byte 0x000003e7
-_0807B024: .4byte gUnknown_203B418
+_0807B024: .4byte gDungeonGlobalData
_0807B028: .4byte 0x000037fc
_0807B02C:
ldrb r0, [r7, 0x6]
@@ -22539,7 +22539,7 @@ _0807B17C:
adds r0, 0x2
b _0807B1EC
.align 2, 0
-_0807B1BC: .4byte gUnknown_203B418
+_0807B1BC: .4byte gDungeonGlobalData
_0807B1C0: .4byte 0x00018209
_0807B1C4:
lsls r0, r1, 3
@@ -23121,7 +23121,7 @@ sub_807B5E0:
b _0807B64C
.align 2, 0
_0807B61C: .4byte 0x000f423f
-_0807B620: .4byte gUnknown_203B418
+_0807B620: .4byte gDungeonGlobalData
_0807B624: .4byte 0x000037fc
_0807B628: .4byte 0x000135cc
_0807B62C:
@@ -23307,7 +23307,7 @@ _0807B75E:
b _0807B910
.align 2, 0
_0807B790: .4byte 0x0001358c
-_0807B794: .4byte gUnknown_203B418
+_0807B794: .4byte gDungeonGlobalData
_0807B798: .4byte 0x000037fc
_0807B79C: .4byte 0x000f423f
_0807B7A0: .4byte gUnknown_80F4448
@@ -23479,7 +23479,7 @@ _0807B8AA:
movs r0, 0x1
b _0807B910
.align 2, 0
-_0807B8D0: .4byte gUnknown_203B418
+_0807B8D0: .4byte gDungeonGlobalData
_0807B8D4: .4byte 0x00010884
_0807B8D8: .4byte 0x00010844
_0807B8DC: .4byte 0xfff0bdc1
@@ -23655,7 +23655,7 @@ _0807B9DC:
strh r0, [r1]
b _0807BB60
.align 2, 0
-_0807BA30: .4byte gUnknown_203B418
+_0807BA30: .4byte gDungeonGlobalData
_0807BA34: .4byte 0x00010844
_0807BA38: .4byte 0x00010884
_0807BA3C: .4byte gUnknown_80F4448
@@ -24682,7 +24682,7 @@ _0807C1E0:
ble _0807C1A2
b _0807C3F6
.align 2, 0
-_0807C1E8: .4byte gUnknown_203B418
+_0807C1E8: .4byte gDungeonGlobalData
_0807C1EC: .4byte 0x000135cc
_0807C1F0:
cmp r0, 0x40
@@ -24876,7 +24876,7 @@ _0807C370:
ble _0807C2C0
b _0807C3F6
.align 2, 0
-_0807C37C: .4byte gUnknown_203B418
+_0807C37C: .4byte gDungeonGlobalData
_0807C380: .4byte 0x000135cc
_0807C384: .4byte gUnknown_202F380
_0807C388: .4byte gUnknown_202F388
@@ -24915,7 +24915,7 @@ _0807C3CA:
ble _0807C39A
b _0807C3F6
.align 2, 0
-_0807C3D4: .4byte gUnknown_203B418
+_0807C3D4: .4byte gDungeonGlobalData
_0807C3D8: .4byte 0x000135cc
_0807C3DC:
cmp r0, 0x70
@@ -25493,7 +25493,7 @@ _0807C7DA:
ldrb r6, [r0]
b _0807C846
.align 2, 0
-_0807C7FC: .4byte gUnknown_203B418
+_0807C7FC: .4byte gDungeonGlobalData
_0807C800: .4byte 0x0000363c
_0807C804:
adds r0, r5, 0
@@ -26169,7 +26169,7 @@ _0807CD18:
bl sub_8075900
b _0807CD44
.align 2, 0
-_0807CD30: .4byte gUnknown_203B418
+_0807CD30: .4byte gDungeonGlobalData
_0807CD34: .4byte 0x00003a08
_0807CD38:
cmp r4, 0
@@ -26554,7 +26554,7 @@ _0807D050: .4byte gUnknown_80F4F90
_0807D054: .4byte 0x00000219
_0807D058: .4byte 0x00000163
_0807D05C: .4byte 0x0000021a
-_0807D060: .4byte gUnknown_203B418
+_0807D060: .4byte gDungeonGlobalData
_0807D064: .4byte 0x00003a08
thumb_func_end sub_807CD9C
@@ -26739,7 +26739,7 @@ _0807D1A4:
bl sub_8076D10
b _0807D3A8
.align 2, 0
-_0807D1D0: .4byte gUnknown_203B418
+_0807D1D0: .4byte gDungeonGlobalData
_0807D1D4: .4byte 0x0000e21c
_0807D1D8: .4byte gUnknown_80FC9A0
_0807D1DC:
@@ -26839,7 +26839,7 @@ _0807D288:
str r3, [sp, 0x8]
b _0807D2CE
.align 2, 0
-_0807D2A8: .4byte gUnknown_203B418
+_0807D2A8: .4byte gDungeonGlobalData
_0807D2AC: .4byte 0x0000e21c
_0807D2B0:
mov r0, sp
@@ -26972,7 +26972,7 @@ _0807D3A8:
_0807D3B8: .4byte gUnknown_202EDCC
_0807D3BC: .4byte 0xfffffc00
_0807D3C0: .4byte gUnknown_80FCB14
-_0807D3C4: .4byte gUnknown_203B418
+_0807D3C4: .4byte gDungeonGlobalData
_0807D3C8: .4byte 0x00003a08
thumb_func_end sub_807D148
@@ -27043,7 +27043,7 @@ _0807D438:
ble _0807D408
b _0807D4A8
.align 2, 0
-_0807D448: .4byte gUnknown_203B418
+_0807D448: .4byte gDungeonGlobalData
_0807D44C: .4byte 0x00018209
_0807D450:
lsls r0, r1, 3
@@ -27313,7 +27313,7 @@ _0807D634:
_0807D650: .4byte 0x00000d08
_0807D654: .4byte 0x00000b58
_0807D658: .4byte 0x00000d0c
-_0807D65C: .4byte gUnknown_203B418
+_0807D65C: .4byte gDungeonGlobalData
_0807D660: .4byte 0x00003804
_0807D664: .4byte 0x00003904
_0807D668: .4byte 0x0001361c
@@ -27735,7 +27735,7 @@ _0807D9B8: .4byte 0x00000bbc
_0807D9BC: .4byte 0x00000d0c
_0807D9C0: .4byte 0x00000c24
_0807D9C4: .4byte 0x00000d08
-_0807D9C8: .4byte gUnknown_203B418
+_0807D9C8: .4byte gDungeonGlobalData
_0807D9CC: .4byte 0x00018210
_0807D9D0: .4byte 0x00000d14
_0807D9D4: .4byte 0x00000d1c
@@ -27930,7 +27930,7 @@ _0807DB5E:
pop {r0}
bx r0
.align 2, 0
-_0807DB6C: .4byte gUnknown_203B418
+_0807DB6C: .4byte gDungeonGlobalData
_0807DB70: .4byte 0x00003a08
thumb_func_end sub_807DA14
@@ -28051,7 +28051,7 @@ _0807DC54:
bx r0
.align 2, 0
_0807DC60: .4byte gUnknown_80FD060
-_0807DC64: .4byte gUnknown_203B418
+_0807DC64: .4byte gDungeonGlobalData
thumb_func_end sub_807DB74
thumb_func_start sub_807DC68
@@ -28072,7 +28072,7 @@ sub_807DC68:
ldr r0, _0807DC90
b _0807DCB8
.align 2, 0
-_0807DC88: .4byte gUnknown_203B418
+_0807DC88: .4byte gDungeonGlobalData
_0807DC8C: .4byte 0x00003a08
_0807DC90: .4byte gUnknown_80FD3C8
_0807DC94:
@@ -28188,7 +28188,7 @@ _0807DD5C:
_0807DD68: .4byte 0x0000fffc
_0807DD6C: .4byte 0x0000fbff
_0807DD70: .4byte 0x0000fff7
-_0807DD74: .4byte gUnknown_203B418
+_0807DD74: .4byte gDungeonGlobalData
_0807DD78:
ldrh r1, [r2]
movs r0, 0x3
@@ -28395,7 +28395,7 @@ _0807DF0E:
pop {r0}
bx r0
.align 2, 0
-_0807DF1C: .4byte gUnknown_203B418
+_0807DF1C: .4byte gDungeonGlobalData
_0807DF20: .4byte 0x0000e21c
_0807DF24: .4byte 0x0000fffc
_0807DF28: .4byte 0x00003a0c
@@ -28461,7 +28461,7 @@ _0807DF8E:
bl sub_8045B94
b _0807DFC2
.align 2, 0
-_0807DFA8: .4byte gUnknown_203B418
+_0807DFA8: .4byte gDungeonGlobalData
_0807DFAC: .4byte 0x000135cc
_0807DFB0: .4byte gAvailablePokemonNames
_0807DFB4:
@@ -28921,7 +28921,7 @@ _0807E366:
pop {r0}
bx r0
.align 2, 0
-_0807E370: .4byte gUnknown_203B418
+_0807E370: .4byte gDungeonGlobalData
_0807E374: .4byte 0x00003a08
thumb_func_end sub_807E254
@@ -29006,7 +29006,7 @@ _0807E3EE:
strb r1, [r0]
b _0807E564
.align 2, 0
-_0807E41C: .4byte gUnknown_203B418
+_0807E41C: .4byte gDungeonGlobalData
_0807E420: .4byte 0x00000666
_0807E424: .4byte 0x0000067a
_0807E428: .4byte gUnknown_80F9C4C
@@ -29178,7 +29178,7 @@ _0807E5A0:
pop {r1}
bx r1
.align 2, 0
-_0807E5A4: .4byte gUnknown_203B418
+_0807E5A4: .4byte gDungeonGlobalData
_0807E5A8: .4byte 0x0000e264
thumb_func_end sub_807E580
@@ -29205,7 +29205,7 @@ _0807E5C6:
pop {r0}
bx r0
.align 2, 0
-_0807E5DC: .4byte gUnknown_203B418
+_0807E5DC: .4byte gDungeonGlobalData
_0807E5E0: .4byte 0x0001c578
thumb_func_end sub_807E5AC
@@ -29285,7 +29285,7 @@ _0807E64C:
pop {r0}
bx r0
.align 2, 0
-_0807E674: .4byte gUnknown_203B418
+_0807E674: .4byte gDungeonGlobalData
_0807E678: .4byte 0x0000e265
_0807E67C: .4byte 0x0000e264
_0807E680: .4byte 0x0000e279
@@ -29367,7 +29367,7 @@ _0807E71A:
.align 2, 0
_0807E724: .4byte gUnknown_202ECA0
_0807E728: .4byte gUnknown_203B40D
-_0807E72C: .4byte gUnknown_203B418
+_0807E72C: .4byte gDungeonGlobalData
_0807E730:
movs r7, 0x1
adds r2, r0, 0
@@ -29545,7 +29545,7 @@ _0807E866:
pop {r0}
bx r0
.align 2, 0
-_0807E874: .4byte gUnknown_203B418
+_0807E874: .4byte gDungeonGlobalData
_0807E878: .4byte 0x000181f8
_0807E87C: .4byte 0x0001356c
_0807E880: .4byte gAvailablePokemonNames
@@ -29600,7 +29600,7 @@ _0807E8A8:
bx r0
.align 2, 0
_0807E8E4: .4byte gUnknown_202ECA0
-_0807E8E8: .4byte gUnknown_203B418
+_0807E8E8: .4byte gDungeonGlobalData
_0807E8EC: .4byte 0x0000017d
thumb_func_end sub_807E88C
@@ -29789,7 +29789,7 @@ sub_807EA30:
b _0807EA8C
.align 2, 0
_0807EA5C: .4byte gUnknown_80F4EAC
-_0807EA60: .4byte gUnknown_203B418
+_0807EA60: .4byte gDungeonGlobalData
_0807EA64: .4byte 0x0000e277
_0807EA68: .4byte gUnknown_80FAD8C
_0807EA6C:
@@ -29811,7 +29811,7 @@ _0807EA8C:
bx r0
.align 2, 0
_0807EA90: .4byte gUnknown_80F4EAC
-_0807EA94: .4byte gUnknown_203B418
+_0807EA94: .4byte gDungeonGlobalData
_0807EA98: .4byte 0x0000e278
_0807EA9C: .4byte gUnknown_80FADB0
thumb_func_end sub_807EA30
@@ -29859,7 +29859,7 @@ _0807EAD6:
strb r0, [r4]
b _0807EB08
.align 2, 0
-_0807EAF0: .4byte gUnknown_203B418
+_0807EAF0: .4byte gDungeonGlobalData
_0807EAF4: .4byte 0x0000e267
_0807EAF8: .4byte 0x0000e26f
_0807EAFC:
@@ -29896,7 +29896,7 @@ _0807EB1C:
b _0807EB4E
.align 2, 0
_0807EB38: .4byte 0x0000e267
-_0807EB3C: .4byte gUnknown_203B418
+_0807EB3C: .4byte gDungeonGlobalData
_0807EB40: .4byte 0x0000e265
_0807EB44:
ldr r0, [r0]
@@ -29943,7 +29943,7 @@ _0807EB82:
b _0807EBA6
.align 2, 0
_0807EB94: .4byte 0x0000e264
-_0807EB98: .4byte gUnknown_203B418
+_0807EB98: .4byte gDungeonGlobalData
_0807EB9C: .4byte 0x0000e279
_0807EBA0: .4byte 0x0000e266
_0807EBA4:
@@ -30000,7 +30000,7 @@ _0807EC00:
pop {r1}
bx r1
.align 2, 0
-_0807EC14: .4byte gUnknown_203B418
+_0807EC14: .4byte gDungeonGlobalData
_0807EC18: .4byte 0x0000e277
_0807EC1C: .4byte gUnknown_80FA778
_0807EC20: .4byte 0x0000e278
@@ -30079,7 +30079,7 @@ _0807EC9C:
strb r1, [r0]
b _0807EF32
.align 2, 0
-_0807ECB4: .4byte gUnknown_203B418
+_0807ECB4: .4byte gDungeonGlobalData
_0807ECB8: .4byte 0x00000699
_0807ECBC: .4byte 0x0000066e
_0807ECC0:
@@ -30150,7 +30150,7 @@ _0807ED3A:
bl PrintFieldMessage
b _0807EF32
.align 2, 0
-_0807ED48: .4byte gUnknown_203B418
+_0807ED48: .4byte gDungeonGlobalData
_0807ED4C: .4byte 0x0001358c
_0807ED50: .4byte 0xffff0000
_0807ED54: .4byte 0xff00ffff
@@ -30316,7 +30316,7 @@ _0807EE72:
bl sub_806CE34
b _0807EEB2
.align 2, 0
-_0807EE90: .4byte gUnknown_203B418
+_0807EE90: .4byte gDungeonGlobalData
_0807EE94: .4byte 0x0001358c
_0807EE98: .4byte 0xffff0000
_0807EE9C: .4byte 0x0000ffff
@@ -30368,7 +30368,7 @@ _0807EEF2:
bl sub_807F33C
b _0807EF32
.align 2, 0
-_0807EEF8: .4byte gUnknown_203B418
+_0807EEF8: .4byte gDungeonGlobalData
_0807EEFC: .4byte 0x00000694
_0807EF00: .4byte 0x0000068c
_0807EF04:
@@ -30428,7 +30428,7 @@ sub_807EF48:
movs r0, 0
b _0807EF7E
.align 2, 0
-_0807EF70: .4byte gUnknown_203B418
+_0807EF70: .4byte gDungeonGlobalData
_0807EF74: .4byte 0x00000694
_0807EF78: .4byte 0x0000068c
_0807EF7C:
@@ -30680,7 +30680,7 @@ _0807F158:
pop {r0}
bx r0
.align 2, 0
-_0807F168: .4byte gUnknown_203B418
+_0807F168: .4byte gDungeonGlobalData
_0807F16C: .4byte 0xffff0000
_0807F170: .4byte 0xff00ffff
_0807F174: .4byte gUnknown_202DE30
@@ -30740,7 +30740,7 @@ _0807F1E6:
.align 2, 0
_0807F1EC: .4byte 0xffff0000
_0807F1F0: .4byte 0xff00ffff
-_0807F1F4: .4byte gUnknown_203B418
+_0807F1F4: .4byte gDungeonGlobalData
_0807F1F8: .4byte 0x00000694
_0807F1FC: .4byte gUnknown_202DE30
_0807F200: .4byte gUnknown_80FE568
@@ -30889,7 +30889,7 @@ _0807F31C:
bx r1
.align 2, 0
_0807F324: .4byte gTeamInventory_203B460
-_0807F328: .4byte gUnknown_203B418
+_0807F328: .4byte gDungeonGlobalData
_0807F32C: .4byte 0x000135cc
_0807F330: .4byte 0x00000694
_0807F334: .4byte 0x0000068c
@@ -31010,7 +31010,7 @@ _0807F3F4:
pop {r0}
bx r0
.align 2, 0
-_0807F41C: .4byte gUnknown_203B418
+_0807F41C: .4byte gDungeonGlobalData
_0807F420: .4byte 0x0000066e
_0807F424: .4byte 0x0000066f
_0807F428: .4byte gUnknown_80FE4B8
@@ -31123,7 +31123,7 @@ _0807F4E4:
_0807F500:
b _0807F51E
.align 2, 0
-_0807F504: .4byte gUnknown_203B418
+_0807F504: .4byte gDungeonGlobalData
_0807F508: .4byte 0x000135cc
_0807F50C:
ldr r0, [sp, 0xEC]
@@ -31744,7 +31744,7 @@ _0807FA0A:
pop {r0}
bx r0
.align 2, 0
-_0807FA10: .4byte gUnknown_203B418
+_0807FA10: .4byte gDungeonGlobalData
_0807FA14: .4byte 0x00003a08
thumb_func_end sub_807F9BC
@@ -31843,7 +31843,7 @@ sub_807FA9C:
mov r8, r1
b _0807FBFE
.align 2, 0
-_0807FAC4: .4byte gUnknown_203B418
+_0807FAC4: .4byte gDungeonGlobalData
_0807FAC8: .4byte 0x0001820f
_0807FACC: .4byte 0x000181ea
_0807FAD0:
@@ -32020,7 +32020,7 @@ _0807FC06:
_0807FC18: .4byte 0x000181e8
_0807FC1C: .4byte gUnknown_202EDC0
_0807FC20: .4byte 0x0000f3ff
-_0807FC24: .4byte gUnknown_203B418
+_0807FC24: .4byte gDungeonGlobalData
_0807FC28: .4byte 0x000181f0
_0807FC2C: .4byte 0x000181f2
_0807FC30: .4byte 0x00000fff
@@ -32057,7 +32057,7 @@ sub_807FC3C:
pop {r0}
bx r0
.align 2, 0
-_0807FC70: .4byte gUnknown_203B418
+_0807FC70: .4byte gDungeonGlobalData
_0807FC74: .4byte 0x00013574
_0807FC78: .4byte 0x00013576
_0807FC7C: .4byte 0x00013579
@@ -32220,7 +32220,7 @@ sub_807FD84:
movs r0, 0
b _0807FDF6
.align 2, 0
-_0807FD9C: .4byte gUnknown_203B418
+_0807FD9C: .4byte gDungeonGlobalData
_0807FDA0: .4byte 0x00013570
_0807FDA4:
strb r5, [r1]
@@ -32451,7 +32451,7 @@ _0807FF50:
.align 2, 0
_0807FF58: .4byte gAvailablePokemonNames
_0807FF5C: .4byte gUnknown_80FDB5C
-_0807FF60: .4byte gUnknown_203B418
+_0807FF60: .4byte gDungeonGlobalData
_0807FF64: .4byte 0x0001820f
_0807FF68:
cmp r7, 0xE
@@ -32507,7 +32507,7 @@ _0807FF96:
b _0807FFFA
.align 2, 0
_0807FFD8: .4byte gUnknown_80FDB7C
-_0807FFDC: .4byte gUnknown_203B418
+_0807FFDC: .4byte gDungeonGlobalData
_0807FFE0: .4byte 0x0001820a
_0807FFE4: .4byte gUnknown_80FD7F4
_0807FFE8:
@@ -33250,7 +33250,7 @@ _0808055E:
_080805A4: .4byte 0x00000193
_080805A8: .4byte gUnknown_80F4F8A
_080805AC: .4byte 0x00000215
-_080805B0: .4byte gUnknown_203B418
+_080805B0: .4byte gDungeonGlobalData
_080805B4:
ldr r0, _080805C0
ldr r1, [r0]
@@ -33658,7 +33658,7 @@ sub_80808A4:
ldr r0, _080808D8
b _08080A2E
.align 2, 0
-_080808D0: .4byte gUnknown_203B418
+_080808D0: .4byte gDungeonGlobalData
_080808D4: .4byte 0x00018209
_080808D8: .4byte gUnknown_80FED08
_080808DC:
@@ -33758,7 +33758,7 @@ _08080980:
b _080809AE
.align 2, 0
_08080994: .4byte 0x000104c4
-_08080998: .4byte gUnknown_203B418
+_08080998: .4byte gDungeonGlobalData
_0808099C: .4byte 0x0000066e
_080809A0:
movs r0, 0
@@ -34021,7 +34021,7 @@ sub_8080B90:
bx r0
.align 2, 0
_08080BB0: .4byte gUnknown_81071E0
-_08080BB4: .4byte gUnknown_203B418
+_08080BB4: .4byte gDungeonGlobalData
_08080BB8: .4byte 0x00000644
thumb_func_end sub_8080B90
@@ -34087,7 +34087,7 @@ _08080C28:
bx r0
.align 2, 0
_08080C38: .4byte gUnknown_81071E0
-_08080C3C: .4byte gUnknown_203B418
+_08080C3C: .4byte gDungeonGlobalData
_08080C40: .4byte 0x0001361c
thumb_func_end sub_8080BBC
@@ -34170,7 +34170,7 @@ _08080CD6:
bx r0
.align 2, 0
_08080CE4: .4byte gUnknown_81071E0
-_08080CE8: .4byte gUnknown_203B418
+_08080CE8: .4byte gDungeonGlobalData
_08080CEC: .4byte 0x0001371c
thumb_func_end sub_8080C44
@@ -34280,7 +34280,7 @@ _08080DB6:
bx r0
.align 2, 0
_08080DD4: .4byte gUnknown_81071E0
-_08080DD8: .4byte gUnknown_203B418
+_08080DD8: .4byte gDungeonGlobalData
_08080DDC: .4byte 0x000037f0
_08080DE0: .4byte 0x000037f4
_08080DE4: .4byte 0x000037f8
@@ -35170,7 +35170,7 @@ _080815B2:
bx r0
.align 2, 0
_08081600: .4byte gUnknown_81071E0
-_08081604: .4byte gUnknown_203B418
+_08081604: .4byte gDungeonGlobalData
_08081608: .4byte 0x00003a08
_0808160C: .4byte 0x00003a09
_08081610: .4byte 0x00003a0a
@@ -35272,7 +35272,7 @@ sub_808165C:
bx r0
.align 2, 0
_08081708: .4byte gUnknown_81071E0
-_0808170C: .4byte gUnknown_203B418
+_0808170C: .4byte gDungeonGlobalData
_08081710: .4byte 0x00018208
_08081714: .4byte 0x00018209
_08081718: .4byte 0x0001820a
@@ -35316,7 +35316,7 @@ sub_808173C:
pop {r0}
bx r0
.align 2, 0
-_08081778: .4byte gUnknown_203B418
+_08081778: .4byte gDungeonGlobalData
_0808177C: .4byte 0x0001ced6
_08081780: .4byte 0x0001ced8
_08081784: .4byte 0x0001ceda
@@ -35972,7 +35972,7 @@ sub_8081C50:
bx r0
.align 2, 0
_08081C70: .4byte gUnknown_81071E0
-_08081C74: .4byte gUnknown_203B418
+_08081C74: .4byte gDungeonGlobalData
_08081C78: .4byte 0x00000644
thumb_func_end sub_8081C50
@@ -36172,7 +36172,7 @@ _08081DD0:
bx r0
.align 2, 0
_08081E20: .4byte gUnknown_81071E0
-_08081E24: .4byte gUnknown_203B418
+_08081E24: .4byte gDungeonGlobalData
_08081E28: .4byte 0x00003a08
_08081E2C: .4byte 0x00003a09
_08081E30: .4byte 0x00003a0a
@@ -36362,7 +36362,7 @@ sub_8081F2C:
bx r0
.align 2, 0
_08081FE4: .4byte gUnknown_81071E0
-_08081FE8: .4byte gUnknown_203B418
+_08081FE8: .4byte gDungeonGlobalData
_08081FEC: .4byte 0x000181f8
_08081FF0: .4byte 0x00018208
_08081FF4: .4byte 0x00018209
@@ -36403,7 +36403,7 @@ sub_808201C:
pop {r0}
bx r0
.align 2, 0
-_08082050: .4byte gUnknown_203B418
+_08082050: .4byte gDungeonGlobalData
_08082054: .4byte 0x0001ced6
_08082058: .4byte 0x0001ced8
_0808205C: .4byte 0x0001ceda
@@ -36649,7 +36649,7 @@ _08082238:
bx r0
.align 2, 0
_08082250: .4byte gUnknown_81071E0
-_08082254: .4byte gUnknown_203B418
+_08082254: .4byte gDungeonGlobalData
_08082258: .4byte 0x000037f0
_0808225C: .4byte 0x000037f4
_08082260: .4byte 0x000037f8
@@ -37494,7 +37494,7 @@ _080829E6:
pop {r1}
bx r1
.align 2, 0
-_080829F4: .4byte gUnknown_203B418
+_080829F4: .4byte gDungeonGlobalData
_080829F8: .4byte 0x0001357c
_080829FC: .4byte 0x0000069c
_08082A00: .4byte 0x00000167
@@ -37657,7 +37657,7 @@ _08082B1C:
pop {r1}
bx r1
.align 2, 0
-_08082B2C: .4byte gUnknown_203B418
+_08082B2C: .4byte gDungeonGlobalData
_08082B30: .4byte 0x0001358c
_08082B34: .4byte 0x00000ebc
_08082B38: .4byte 0x00000167
@@ -37722,7 +37722,7 @@ _08082BA8:
pop {r0}
bx r0
.align 2, 0
-_08082BB8: .4byte gUnknown_203B418
+_08082BB8: .4byte gDungeonGlobalData
_08082BBC: .4byte 0x000135cc
thumb_func_end sub_8082B40
@@ -38759,7 +38759,7 @@ _080832E4:
movs r0, 0x1
b _08083330
.align 2, 0
-_080832E8: .4byte gUnknown_203B418
+_080832E8: .4byte gDungeonGlobalData
_080832EC: .4byte 0x00018209
_080832F0:
lsls r0, r1, 3
@@ -38877,7 +38877,7 @@ _080833BE:
movs r0, 0
b _080833E0
.align 2, 0
-_080833C4: .4byte gUnknown_203B418
+_080833C4: .4byte gDungeonGlobalData
_080833C8: .4byte 0x000104c4
_080833CC:
cmp r1, 0x2
@@ -38938,7 +38938,7 @@ _0808340C:
adds r0, 0x1
b _0808346A
.align 2, 0
-_08083438: .4byte gUnknown_203B418
+_08083438: .4byte gDungeonGlobalData
_0808343C: .4byte 0x00018209
_08083440:
lsls r1, r0, 3
@@ -39173,7 +39173,7 @@ sub_8083568:
movs r0, 0x1
b _080835FA
.align 2, 0
-_080835E0: .4byte gUnknown_203B418
+_080835E0: .4byte gDungeonGlobalData
_080835E4: .4byte 0x000181f0
_080835E8: .4byte 0x000181f2
_080835EC: .4byte gUnknown_202ED28
@@ -39220,7 +39220,7 @@ _0808362E:
b _0808364A
.align 2, 0
_08083638: .4byte gUnknown_203B450
-_0808363C: .4byte gUnknown_203B418
+_0808363C: .4byte gDungeonGlobalData
_08083640: .4byte 0x0001357c
_08083644:
ldr r0, _08083650
@@ -39679,7 +39679,7 @@ _08083960:
b _080839D0
.align 2, 0
_080839A0: .4byte gUnknown_80F4CC4
-_080839A4: .4byte gUnknown_203B418
+_080839A4: .4byte gDungeonGlobalData
_080839A8: .4byte 0x000037fc
_080839AC: .4byte 0x000135cc
_080839B0:
@@ -39858,7 +39858,7 @@ _08083AE4:
bl CopyStringtoBuffer
b _08083B0E
.align 2, 0
-_08083AFC: .4byte gUnknown_203B418
+_08083AFC: .4byte gDungeonGlobalData
_08083B00: .4byte 0x0001ce98
_08083B04:
ldr r0, _08083C04
@@ -39995,7 +39995,7 @@ _08083BF8:
bx r0
.align 2, 0
_08083C04: .4byte gUnknown_80FE6F4
-_08083C08: .4byte gUnknown_203B418
+_08083C08: .4byte gDungeonGlobalData
_08083C0C: .4byte 0x00000644
_08083C10: .4byte gUnknown_810AC60
_08083C14: .4byte gUnknown_810AC68
@@ -40019,7 +40019,7 @@ sub_8083C24:
movs r0, 0
b _08083C4A
.align 2, 0
-_08083C3C: .4byte gUnknown_203B418
+_08083C3C: .4byte gDungeonGlobalData
_08083C40: .4byte 0x0001ce98
_08083C44: .4byte 0x00000225
_08083C48:
@@ -40051,7 +40051,7 @@ _08083C70:
movs r0, 0x1
b _08083C82
.align 2, 0
-_08083C74: .4byte gUnknown_203B418
+_08083C74: .4byte gDungeonGlobalData
_08083C78: .4byte 0x0001ce98
_08083C7C: .4byte 0x00000227
_08083C80:
@@ -40095,7 +40095,7 @@ _08083CC0:
movs r0, 0x1
b _08083CDA
.align 2, 0
-_08083CC4: .4byte gUnknown_203B418
+_08083CC4: .4byte gDungeonGlobalData
_08083CC8: .4byte 0x0001ce98
_08083CCC: .4byte 0x00000644
_08083CD0: .4byte 0x0000065c
@@ -40253,7 +40253,7 @@ sub_8083D98:
pop {r0}
bx r0
.align 2, 0
-_08083DCC: .4byte gUnknown_203B418
+_08083DCC: .4byte gDungeonGlobalData
_08083DD0: .4byte 0x0000066f
_08083DD4: .4byte 0x00000672
_08083DD8: .4byte 0x0000066a
@@ -40287,7 +40287,7 @@ sub_8083DE0:
pop {r0}
bx r0
.align 2, 0
-_08083E14: .4byte gUnknown_203B418
+_08083E14: .4byte gDungeonGlobalData
_08083E18: .4byte 0x0000066f
_08083E1C: .4byte 0x00000672
_08083E20: .4byte 0x0000066a
@@ -40366,7 +40366,7 @@ sub_8083E88:
strh r3, [r1]
bx lr
.align 2, 0
-_08083E9C: .4byte gUnknown_203B418
+_08083E9C: .4byte gDungeonGlobalData
_08083EA0: .4byte 0x0001ceda
_08083EA4: .4byte 0x0001ced4
thumb_func_end sub_8083E88
@@ -40392,7 +40392,7 @@ sub_8083EA8:
pop {r0}
bx r0
.align 2, 0
-_08083ECC: .4byte gUnknown_203B418
+_08083ECC: .4byte gDungeonGlobalData
_08083ED0: .4byte 0x0001ceda
_08083ED4: .4byte 0x0001ced4
thumb_func_end sub_8083EA8
@@ -40418,7 +40418,7 @@ sub_8083ED8:
pop {r0}
bx r0
.align 2, 0
-_08083F00: .4byte gUnknown_203B418
+_08083F00: .4byte gDungeonGlobalData
_08083F04: .4byte 0x0001ced6
_08083F08: .4byte 0x000003e7
_08083F0C: .4byte 0x0001ced8
@@ -40459,7 +40459,7 @@ sub_8083F34:
strh r1, [r0, 0xE]
bx lr
.align 2, 0
-_08083F4C: .4byte gUnknown_203B418
+_08083F4C: .4byte gDungeonGlobalData
_08083F50: .4byte 0x0001cecc
_08083F54: .4byte 0x000003e7
thumb_func_end sub_8083F34
@@ -40485,7 +40485,7 @@ sub_8083F58:
movs r1, 0x12
b _08083FB2
.align 2, 0
-_08083F7C: .4byte gUnknown_203B418
+_08083F7C: .4byte gDungeonGlobalData
_08083F80: .4byte 0x0001cecc
_08083F84: .4byte 0x0000066a
_08083F88: .4byte 0x000003e7
@@ -40885,7 +40885,7 @@ sub_80841EC:
bl sub_8083DE0
b _0808427C
.align 2, 0
-_0808426C: .4byte gUnknown_203B418
+_0808426C: .4byte gDungeonGlobalData
_08084270: .4byte 0x0001ceac
_08084274: .4byte 0x00000225
_08084278:
@@ -40919,7 +40919,7 @@ _08084290:
b _08084290
.align 2, 0
_080842B8: .4byte gUnknown_80FE6E8
-_080842BC: .4byte gUnknown_203B418
+_080842BC: .4byte gDungeonGlobalData
_080842C0: .4byte 0x0001ce98
_080842C4:
bl sub_8094D14
@@ -41008,7 +41008,7 @@ _08084320:
strb r7, [r2, 0x9]
b _080843A8
.align 2, 0
-_0808436C: .4byte gUnknown_203B418
+_0808436C: .4byte gDungeonGlobalData
_08084370: .4byte 0x00000677
_08084374: .4byte 0x0000068a
_08084378: .4byte 0x0000ffff
@@ -41102,7 +41102,7 @@ _0808440C:
bx r0
.align 2, 0
_08084418: .4byte 0x0000ffff
-_0808441C: .4byte gUnknown_203B418
+_0808441C: .4byte gDungeonGlobalData
_08084420: .4byte 0x00000644
thumb_func_end sub_80843BC
@@ -41219,7 +41219,7 @@ _080844F0:
bl PrintFieldMessage
b _080845D4
.align 2, 0
-_080844FC: .4byte gUnknown_203B418
+_080844FC: .4byte gDungeonGlobalData
_08084500: .4byte 0x0000068a
_08084504: .4byte gUnknown_80FA32C
_08084508: .4byte gUnknown_202DE58
@@ -41298,7 +41298,7 @@ _08084582:
_080845B0: .4byte gUnknown_80FA2F0
_080845B4: .4byte gUnknown_80FA260
_080845B8: .4byte gUnknown_80FA36C
-_080845BC: .4byte gUnknown_203B418
+_080845BC: .4byte gDungeonGlobalData
_080845C0: .4byte gUnknown_80FA394
_080845C4:
ldr r0, _080845DC
@@ -41380,7 +41380,7 @@ _0808465A:
movs r0, 0x1
b _0808466A
.align 2, 0
-_08084660: .4byte gUnknown_203B418
+_08084660: .4byte gDungeonGlobalData
_08084664: .4byte 0x0001357c
_08084668:
movs r0, 0
@@ -41487,7 +41487,7 @@ _08084716:
b _08084768
.align 2, 0
_08084744: .4byte gUnknown_80FA4D4
-_08084748: .4byte gUnknown_203B418
+_08084748: .4byte gDungeonGlobalData
_0808474C: .4byte 0x00000644
_08084750: .4byte gUnknown_80FA4D8
_08084754: .4byte gUnknown_80FA394
@@ -41544,7 +41544,7 @@ _08084784:
.align 2, 0
_080847B8: .4byte gUnknown_202E088
_080847BC: .4byte gUnknown_8107224
-_080847C0: .4byte gUnknown_203B418
+_080847C0: .4byte gDungeonGlobalData
_080847C4: .4byte 0x00000644
_080847C8:
adds r4, 0x1
@@ -41597,7 +41597,7 @@ _08084810:
bl sub_8084854
b _08084846
.align 2, 0
-_08084820: .4byte gUnknown_203B418
+_08084820: .4byte gDungeonGlobalData
_08084824: .4byte 0x00003a0d
_08084828: .4byte 0x0001356c
_0808482C: .4byte gUnknown_8107234
@@ -41639,7 +41639,7 @@ sub_8084854:
strb r1, [r0]
b _080848C8
.align 2, 0
-_08084874: .4byte gUnknown_203B418
+_08084874: .4byte gDungeonGlobalData
_08084878: .4byte 0x00003a0d
_0808487C:
ldrb r0, [r4, 0x4]
@@ -41693,7 +41693,7 @@ _080848C8:
bx r0
.align 2, 0
_080848E0: .4byte 0x00003a0d
-_080848E4: .4byte gUnknown_203B418
+_080848E4: .4byte gDungeonGlobalData
_080848E8: .4byte 0x00000675
thumb_func_end sub_8084854
@@ -41726,7 +41726,7 @@ _0808490C:
ldr r0, [r0]
mov pc, r0
.align 2, 0
-_08084918: .4byte gUnknown_203B418
+_08084918: .4byte gDungeonGlobalData
_0808491C: .4byte 0x0001356c
_08084920: .4byte 0x00003a0d
_08084924: .4byte _08084928
@@ -41978,7 +41978,7 @@ _08084B76:
ldr r0, [r0]
mov pc, r0
.align 2, 0
-_08084B80: .4byte gUnknown_203B418
+_08084B80: .4byte gDungeonGlobalData
_08084B84: .4byte 0x00003a0d
_08084B88: .4byte _08084B8C
.align 2, 0
@@ -42230,7 +42230,7 @@ _08084DDA:
pop {r0}
bx r0
.align 2, 0
-_08084DF8: .4byte gUnknown_203B418
+_08084DF8: .4byte gDungeonGlobalData
_08084DFC: .4byte 0x0001356c
thumb_func_end DisplayPreFightDialogue
@@ -42262,7 +42262,7 @@ _08084E24:
ldr r0, [r0]
mov pc, r0
.align 2, 0
-_08084E30: .4byte gUnknown_203B418
+_08084E30: .4byte gDungeonGlobalData
_08084E34: .4byte 0x00003a0d
_08084E38: .4byte _08084E3C
.align 2, 0
@@ -42580,7 +42580,7 @@ _0808512E:
bx r0
.align 2, 0
_08085134: .4byte 0x00003a0d
-_08085138: .4byte gUnknown_203B418
+_08085138: .4byte gDungeonGlobalData
_0808513C: .4byte 0x000003e7
thumb_func_end sub_8084E00
@@ -42603,7 +42603,7 @@ _08085154:
ldr r0, [r0]
mov pc, r0
.align 2, 0
-_08085160: .4byte gUnknown_203B418
+_08085160: .4byte gDungeonGlobalData
_08085164: .4byte 0x00003a0d
_08085168: .4byte _0808516C
.align 2, 0
@@ -42936,7 +42936,7 @@ _080853EE:
bl sub_806B7F8
b _0808546E
.align 2, 0
-_08085444: .4byte gUnknown_203B418
+_08085444: .4byte gDungeonGlobalData
_08085448: .4byte 0x0001357c
_0808544C: .4byte 0x0000065c
_08085450: .4byte gUnknown_80F4598
@@ -42997,7 +42997,7 @@ _08085490:
adds r0, r4, 0
b _080854CC
.align 2, 0
-_080854B8: .4byte gUnknown_203B418
+_080854B8: .4byte gDungeonGlobalData
_080854BC: .4byte 0x0001357c
_080854C0:
adds r5, 0x1
@@ -43156,7 +43156,7 @@ _080855C4:
pop {r0}
bx r0
.align 2, 0
-_080855D8: .4byte gUnknown_203B418
+_080855D8: .4byte gDungeonGlobalData
_080855DC: .4byte 0x0001357c
_080855E0: .4byte 0x0000e220
thumb_func_end sub_80854D4
@@ -43204,7 +43204,7 @@ _0808562E:
pop {r0}
bx r0
.align 2, 0
-_08085634: .4byte gUnknown_203B418
+_08085634: .4byte gDungeonGlobalData
_08085638: .4byte 0x0001357c
thumb_func_end sub_80855E4
@@ -43241,7 +43241,7 @@ _0808566C:
pop {r0}
bx r0
.align 2, 0
-_08085678: .4byte gUnknown_203B418
+_08085678: .4byte gDungeonGlobalData
_0808567C: .4byte 0x0001358c
thumb_func_end sub_808563C
@@ -43272,7 +43272,7 @@ _08085688:
adds r0, r4, 0
b _080856C0
.align 2, 0
-_080856B0: .4byte gUnknown_203B418
+_080856B0: .4byte gDungeonGlobalData
_080856B4: .4byte 0x000135cc
_080856B8:
adds r5, 0x1
@@ -43404,7 +43404,7 @@ _0808579E:
pop {r0}
bx r0
.align 2, 0
-_080857AC: .4byte gUnknown_203B418
+_080857AC: .4byte gDungeonGlobalData
_080857B0: .4byte 0x0001358c
_080857B4: .4byte 0x00000207
thumb_func_end sub_8085764
@@ -43488,7 +43488,7 @@ _08085840:
pop {r0}
bx r0
.align 2, 0
-_08085854: .4byte gUnknown_203B418
+_08085854: .4byte gDungeonGlobalData
_08085858: .4byte gUnknown_80F4448
_0808585C: .4byte 0x000135cc
thumb_func_end sub_80857B8
@@ -43629,7 +43629,7 @@ _0808593C:
bl sub_806CE68
b _08085982
.align 2, 0
-_0808596C: .4byte gUnknown_203B418
+_0808596C: .4byte gDungeonGlobalData
_08085970: .4byte 0x0001357c
_08085974:
ldr r0, [r4, 0x70]
@@ -43674,7 +43674,7 @@ _08085990:
bl sub_806CE68
b _080859E2
.align 2, 0
-_080859CC: .4byte gUnknown_203B418
+_080859CC: .4byte gDungeonGlobalData
_080859D0: .4byte 0x0001358c
_080859D4:
adds r0, r1, 0
@@ -43722,7 +43722,7 @@ _080859FC:
bl sub_806CE68
b _08085A42
.align 2, 0
-_08085A2C: .4byte gUnknown_203B418
+_08085A2C: .4byte gDungeonGlobalData
_08085A30: .4byte 0x0001358c
_08085A34:
ldr r0, [r4, 0x70]
@@ -44276,7 +44276,7 @@ _08085E74: .4byte 0xffffff00
_08085E78: .4byte 0xffff00ff
_08085E7C: .4byte 0xff00ffff
_08085E80: .4byte gUnknown_202EDC8
-_08085E84: .4byte gUnknown_203B418
+_08085E84: .4byte gDungeonGlobalData
_08085E88: .4byte 0xffff0000
_08085E8C: .4byte gUnknown_202EE8C
_08085E90: .4byte gUnknown_202ECA4
@@ -44293,7 +44293,7 @@ sub_8085E98:
strb r1, [r0]
bx lr
.align 2, 0
-_08085EA8: .4byte gUnknown_203B418
+_08085EA8: .4byte gDungeonGlobalData
_08085EAC: .4byte 0x00018215
thumb_func_end sub_8085E98
@@ -44307,7 +44307,7 @@ sub_8085EB0:
strb r1, [r0]
bx lr
.align 2, 0
-_08085EC0: .4byte gUnknown_203B418
+_08085EC0: .4byte gDungeonGlobalData
_08085EC4: .4byte 0x00018215
thumb_func_end sub_8085EB0
@@ -44395,7 +44395,7 @@ _08085F5C:
pop {r0}
bx r0
.align 2, 0
-_08085F70: .4byte gUnknown_203B418
+_08085F70: .4byte gDungeonGlobalData
_08085F74: .4byte 0x000181f0
thumb_func_end sub_8085F44
@@ -44417,7 +44417,7 @@ _08085F8A:
ldr r0, [r0]
mov pc, r0
.align 2, 0
-_08085F94: .4byte gUnknown_203B418
+_08085F94: .4byte gDungeonGlobalData
_08085F98: .4byte 0x00003a0d
_08085F9C: .4byte _08085FA0
.align 2, 0
@@ -44551,7 +44551,7 @@ _08086104:
b _0808611C
.align 2, 0
_08086108: .4byte gTeamInventory_203B460
-_0808610C: .4byte gUnknown_203B418
+_0808610C: .4byte gDungeonGlobalData
_08086110: .4byte 0x0001357c
_08086114:
adds r5, 0x1
diff --git a/asm/code_80869E4.s b/asm/code_80869E4.s
index 6528560..0d39418 100644
--- a/asm/code_80869E4.s
+++ b/asm/code_80869E4.s
@@ -53,4 +53,4 @@ _08086A30:
bx r0
thumb_func_end sub_80869E4
- .align 2,0
+ .align 2,0
diff --git a/asm/code_8086A3C.s b/asm/code_8086A3C.s
index b0fe243..8d2e8b2 100644
--- a/asm/code_8086A3C.s
+++ b/asm/code_8086A3C.s
@@ -248,7 +248,7 @@ sub_8086E40:
bx r0
.align 2, 0
_08086E6C: .4byte gUnknown_8100D3C
-_08086E70: .4byte gUnknown_203B418
+_08086E70: .4byte gDungeonGlobalData
thumb_func_end sub_8086E40
thumb_func_start sub_8086E74
@@ -398,7 +398,7 @@ _08086FA8:
pop {r0}
bx r0
.align 2, 0
-_08086FB0: .4byte gUnknown_203B418
+_08086FB0: .4byte gDungeonGlobalData
_08086FB4: .4byte 0x0001358c
thumb_func_end sub_8086F54
@@ -799,7 +799,7 @@ _0808735A:
pop {r0}
bx r0
.align 2, 0
-_08087360: .4byte gUnknown_203B418
+_08087360: .4byte gDungeonGlobalData
thumb_func_end sub_8087334
thumb_func_start ZapdosPreFightDialogue
diff --git a/asm/jirachi_wish.s b/asm/jirachi_wish.s
index 6ac1fc7..aacd5e0 100644
--- a/asm/jirachi_wish.s
+++ b/asm/jirachi_wish.s
@@ -4,7 +4,7 @@
.syntax unified
.text
-
+
thumb_func_start JirachiWish
JirachiWish:
push {r4-r7,lr}
@@ -286,7 +286,7 @@ _0808B82C: .4byte gUnknown_202E038
_0808B830: .4byte 0x0000019d
_0808B834: .4byte sub_808BBA8
_0808B838: .4byte sub_80861A8
-_0808B83C: .4byte gUnknown_203B418
+_0808B83C: .4byte gDungeonGlobalData
_0808B840: .4byte 0x0001356c
_0808B844: .4byte gUnknown_8105668
_0808B848: .4byte 0x000001a7
@@ -501,7 +501,7 @@ _0808BA58: .4byte gUnknown_8105BF4
_0808BA5C: .4byte gUnknown_8105D2C
_0808BA60: .4byte gUnknown_8105D80
_0808BA64: .4byte gUnknown_8105D9C
-_0808BA68: .4byte gUnknown_203B418
+_0808BA68: .4byte gDungeonGlobalData
_0808BA6C: .4byte 0x00000674
_0808BA70: .4byte gUnknown_81058E0
_0808BA74: .4byte gUnknown_810593C
diff --git a/data/dungeon/Autopilot/floor_id.json b/data/dungeon/Autopilot/floor_id.json
index a61ad82..7c7662a 100644
--- a/data/dungeon/Autopilot/floor_id.json
+++ b/data/dungeon/Autopilot/floor_id.json
@@ -1,95 +1,95 @@
-{
- "name": "AutopilotFloorID",
- "tables": [
- {
- "MainData": 1129,
- "Pokemon": 526,
- "Traps": 10,
- "Items": 126,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 1130,
- "Pokemon": 526,
- "Traps": 10,
- "Items": 126,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 1131,
- "Pokemon": 527,
- "Traps": 10,
- "Items": 126,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 1132,
- "Pokemon": 528,
- "Traps": 10,
- "Items": 127,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 1133,
- "Pokemon": 529,
- "Traps": 10,
- "Items": 127,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 1134,
- "Pokemon": 529,
- "Traps": 10,
- "Items": 127,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 1135,
- "Pokemon": 530,
- "Traps": 10,
- "Items": 127,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 1136,
- "Pokemon": 530,
- "Traps": 10,
- "Items": 127,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 1137,
- "Pokemon": 530,
- "Traps": 10,
- "Items": 127,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 1138,
- "Pokemon": 531,
- "Traps": 10,
- "Items": 127,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- }
- ]
-}
+{
+ "name": "AutopilotFloorID",
+ "tables": [
+ {
+ "MainData": 1129,
+ "Pokemon": 526,
+ "Traps": 10,
+ "Items": 126,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1130,
+ "Pokemon": 526,
+ "Traps": 10,
+ "Items": 126,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1131,
+ "Pokemon": 527,
+ "Traps": 10,
+ "Items": 126,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1132,
+ "Pokemon": 528,
+ "Traps": 10,
+ "Items": 127,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1133,
+ "Pokemon": 529,
+ "Traps": 10,
+ "Items": 127,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1134,
+ "Pokemon": 529,
+ "Traps": 10,
+ "Items": 127,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1135,
+ "Pokemon": 530,
+ "Traps": 10,
+ "Items": 127,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1136,
+ "Pokemon": 530,
+ "Traps": 10,
+ "Items": 127,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1137,
+ "Pokemon": 530,
+ "Traps": 10,
+ "Items": 127,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1138,
+ "Pokemon": 531,
+ "Traps": 10,
+ "Items": 127,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ }
+ ]
+}
diff --git a/data/dungeon/Boss3/floor_id.json b/data/dungeon/Boss3/floor_id.json
index d7ab2ae..8e9c4a5 100644
--- a/data/dungeon/Boss3/floor_id.json
+++ b/data/dungeon/Boss3/floor_id.json
@@ -1,185 +1,185 @@
-{
- "name": "Boss3FloorID",
- "tables": [
- {
- "MainData": 449,
- "Pokemon": 206,
- "Traps": 12,
- "Items": 65,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 450,
- "Pokemon": 206,
- "Traps": 13,
- "Items": 65,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 451,
- "Pokemon": 206,
- "Traps": 14,
- "Items": 65,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 452,
- "Pokemon": 206,
- "Traps": 15,
- "Items": 67,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 453,
- "Pokemon": 206,
- "Traps": 16,
- "Items": 67,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 454,
- "Pokemon": 206,
- "Traps": 17,
- "Items": 67,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 455,
- "Pokemon": 206,
- "Traps": 18,
- "Items": 68,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 456,
- "Pokemon": 206,
- "Traps": 18,
- "Items": 68,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 457,
- "Pokemon": 206,
- "Traps": 18,
- "Items": 68,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 458,
- "Pokemon": 206,
- "Traps": 18,
- "Items": 69,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 459,
- "Pokemon": 206,
- "Traps": 19,
- "Items": 69,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 460,
- "Pokemon": 206,
- "Traps": 19,
- "Items": 69,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 461,
- "Pokemon": 206,
- "Traps": 19,
- "Items": 69,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 462,
- "Pokemon": 206,
- "Traps": 19,
- "Items": 69,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 463,
- "Pokemon": 206,
- "Traps": 19,
- "Items": 69,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 464,
- "Pokemon": 206,
- "Traps": 20,
- "Items": 69,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 465,
- "Pokemon": 206,
- "Traps": 20,
- "Items": 69,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 466,
- "Pokemon": 206,
- "Traps": 20,
- "Items": 69,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 467,
- "Pokemon": 206,
- "Traps": 20,
- "Items": 69,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 468,
- "Pokemon": 206,
- "Traps": 21,
- "Items": 69,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- }
- ]
-}
+{
+ "name": "Boss3FloorID",
+ "tables": [
+ {
+ "MainData": 449,
+ "Pokemon": 206,
+ "Traps": 12,
+ "Items": 65,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 450,
+ "Pokemon": 206,
+ "Traps": 13,
+ "Items": 65,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 451,
+ "Pokemon": 206,
+ "Traps": 14,
+ "Items": 65,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 452,
+ "Pokemon": 206,
+ "Traps": 15,
+ "Items": 67,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 453,
+ "Pokemon": 206,
+ "Traps": 16,
+ "Items": 67,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 454,
+ "Pokemon": 206,
+ "Traps": 17,
+ "Items": 67,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 455,
+ "Pokemon": 206,
+ "Traps": 18,
+ "Items": 68,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 456,
+ "Pokemon": 206,
+ "Traps": 18,
+ "Items": 68,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 457,
+ "Pokemon": 206,
+ "Traps": 18,
+ "Items": 68,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 458,
+ "Pokemon": 206,
+ "Traps": 18,
+ "Items": 69,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 459,
+ "Pokemon": 206,
+ "Traps": 19,
+ "Items": 69,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 460,
+ "Pokemon": 206,
+ "Traps": 19,
+ "Items": 69,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 461,
+ "Pokemon": 206,
+ "Traps": 19,
+ "Items": 69,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 462,
+ "Pokemon": 206,
+ "Traps": 19,
+ "Items": 69,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 463,
+ "Pokemon": 206,
+ "Traps": 19,
+ "Items": 69,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 464,
+ "Pokemon": 206,
+ "Traps": 20,
+ "Items": 69,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 465,
+ "Pokemon": 206,
+ "Traps": 20,
+ "Items": 69,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 466,
+ "Pokemon": 206,
+ "Traps": 20,
+ "Items": 69,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 467,
+ "Pokemon": 206,
+ "Traps": 20,
+ "Items": 69,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 468,
+ "Pokemon": 206,
+ "Traps": 21,
+ "Items": 69,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ }
+ ]
+}
diff --git a/data/dungeon/Boss4/floor_id.json b/data/dungeon/Boss4/floor_id.json
index 86bf269..8653db9 100644
--- a/data/dungeon/Boss4/floor_id.json
+++ b/data/dungeon/Boss4/floor_id.json
@@ -1,104 +1,104 @@
-{
- "name": "Boss4FloorID",
- "tables": [
- {
- "MainData": 469,
- "Pokemon": 207,
- "Traps": 22,
- "Items": 70,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 470,
- "Pokemon": 207,
- "Traps": 23,
- "Items": 70,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 471,
- "Pokemon": 207,
- "Traps": 24,
- "Items": 70,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 472,
- "Pokemon": 208,
- "Traps": 25,
- "Items": 71,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 473,
- "Pokemon": 209,
- "Traps": 26,
- "Items": 71,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 474,
- "Pokemon": 210,
- "Traps": 27,
- "Items": 71,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 475,
- "Pokemon": 210,
- "Traps": 28,
- "Items": 72,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 476,
- "Pokemon": 211,
- "Traps": 28,
- "Items": 72,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 477,
- "Pokemon": 212,
- "Traps": 28,
- "Items": 72,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 478,
- "Pokemon": 213,
- "Traps": 28,
- "Items": 73,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 479,
- "Pokemon": 214,
- "Traps": 29,
- "Items": 73,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- }
- ]
-}
+{
+ "name": "Boss4FloorID",
+ "tables": [
+ {
+ "MainData": 469,
+ "Pokemon": 207,
+ "Traps": 22,
+ "Items": 70,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 470,
+ "Pokemon": 207,
+ "Traps": 23,
+ "Items": 70,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 471,
+ "Pokemon": 207,
+ "Traps": 24,
+ "Items": 70,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 472,
+ "Pokemon": 208,
+ "Traps": 25,
+ "Items": 71,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 473,
+ "Pokemon": 209,
+ "Traps": 26,
+ "Items": 71,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 474,
+ "Pokemon": 210,
+ "Traps": 27,
+ "Items": 71,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 475,
+ "Pokemon": 210,
+ "Traps": 28,
+ "Items": 72,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 476,
+ "Pokemon": 211,
+ "Traps": 28,
+ "Items": 72,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 477,
+ "Pokemon": 212,
+ "Traps": 28,
+ "Items": 72,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 478,
+ "Pokemon": 213,
+ "Traps": 28,
+ "Items": 73,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 479,
+ "Pokemon": 214,
+ "Traps": 29,
+ "Items": 73,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ }
+ ]
+}
diff --git a/data/dungeon/Boss9/floor_id.json b/data/dungeon/Boss9/floor_id.json
index 4f6f3a4..1d7ed32 100644
--- a/data/dungeon/Boss9/floor_id.json
+++ b/data/dungeon/Boss9/floor_id.json
@@ -1,113 +1,113 @@
-{
- "name": "Boss9FloorID",
- "tables": [
- {
- "MainData": 728,
- "Pokemon": 339,
- "Traps": 63,
- "Items": 87,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 729,
- "Pokemon": 339,
- "Traps": 63,
- "Items": 87,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 730,
- "Pokemon": 339,
- "Traps": 63,
- "Items": 87,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 731,
- "Pokemon": 339,
- "Traps": 63,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 732,
- "Pokemon": 339,
- "Traps": 63,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 733,
- "Pokemon": 339,
- "Traps": 63,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 734,
- "Pokemon": 339,
- "Traps": 63,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 735,
- "Pokemon": 339,
- "Traps": 63,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 736,
- "Pokemon": 339,
- "Traps": 63,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 737,
- "Pokemon": 339,
- "Traps": 63,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 738,
- "Pokemon": 339,
- "Traps": 63,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 739,
- "Pokemon": 339,
- "Traps": 63,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- }
- ]
-}
+{
+ "name": "Boss9FloorID",
+ "tables": [
+ {
+ "MainData": 728,
+ "Pokemon": 339,
+ "Traps": 63,
+ "Items": 87,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 729,
+ "Pokemon": 339,
+ "Traps": 63,
+ "Items": 87,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 730,
+ "Pokemon": 339,
+ "Traps": 63,
+ "Items": 87,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 731,
+ "Pokemon": 339,
+ "Traps": 63,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 732,
+ "Pokemon": 339,
+ "Traps": 63,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 733,
+ "Pokemon": 339,
+ "Traps": 63,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 734,
+ "Pokemon": 339,
+ "Traps": 63,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 735,
+ "Pokemon": 339,
+ "Traps": 63,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 736,
+ "Pokemon": 339,
+ "Traps": 63,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 737,
+ "Pokemon": 339,
+ "Traps": 63,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 738,
+ "Pokemon": 339,
+ "Traps": 63,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 739,
+ "Pokemon": 339,
+ "Traps": 63,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ }
+ ]
+}
diff --git a/data/dungeon/BuriedRelic/floor_id.json b/data/dungeon/BuriedRelic/floor_id.json
index b4f232b..5eeffe3 100644
--- a/data/dungeon/BuriedRelic/floor_id.json
+++ b/data/dungeon/BuriedRelic/floor_id.json
@@ -1,896 +1,896 @@
-{
- "name": "BuriedRelicFloorID",
- "tables": [
- {
- "MainData": 579,
- "Pokemon": 278,
- "Traps": 7,
- "Items": 80,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 580,
- "Pokemon": 278,
- "Traps": 7,
- "Items": 80,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 581,
- "Pokemon": 278,
- "Traps": 7,
- "Items": 80,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 582,
- "Pokemon": 279,
- "Traps": 7,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 583,
- "Pokemon": 280,
- "Traps": 7,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 584,
- "Pokemon": 280,
- "Traps": 7,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 585,
- "Pokemon": 280,
- "Traps": 7,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 586,
- "Pokemon": 280,
- "Traps": 7,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 587,
- "Pokemon": 281,
- "Traps": 7,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 588,
- "Pokemon": 282,
- "Traps": 8,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 589,
- "Pokemon": 283,
- "Traps": 8,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 590,
- "Pokemon": 284,
- "Traps": 8,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 591,
- "Pokemon": 284,
- "Traps": 8,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 592,
- "Pokemon": 285,
- "Traps": 8,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 593,
- "Pokemon": 286,
- "Traps": 8,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 594,
- "Pokemon": 287,
- "Traps": 8,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 595,
- "Pokemon": 288,
- "Traps": 8,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 596,
- "Pokemon": 288,
- "Traps": 8,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 597,
- "Pokemon": 289,
- "Traps": 8,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 598,
- "Pokemon": 290,
- "Traps": 8,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 599,
- "Pokemon": 291,
- "Traps": 8,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 600,
- "Pokemon": 291,
- "Traps": 8,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 601,
- "Pokemon": 292,
- "Traps": 8,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 602,
- "Pokemon": 293,
- "Traps": 8,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 603,
- "Pokemon": 294,
- "Traps": 8,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 604,
- "Pokemon": 295,
- "Traps": 8,
- "Items": 82,
- "KecleonShop": 83,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 605,
- "Pokemon": 295,
- "Traps": 8,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 606,
- "Pokemon": 295,
- "Traps": 8,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 607,
- "Pokemon": 295,
- "Traps": 8,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 608,
- "Pokemon": 296,
- "Traps": 48,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 609,
- "Pokemon": 297,
- "Traps": 49,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 610,
- "Pokemon": 297,
- "Traps": 49,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 611,
- "Pokemon": 297,
- "Traps": 49,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 612,
- "Pokemon": 297,
- "Traps": 49,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 613,
- "Pokemon": 298,
- "Traps": 49,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 614,
- "Pokemon": 299,
- "Traps": 49,
- "Items": 82,
- "KecleonShop": 83,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 615,
- "Pokemon": 299,
- "Traps": 49,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 616,
- "Pokemon": 299,
- "Traps": 49,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 617,
- "Pokemon": 299,
- "Traps": 49,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 618,
- "Pokemon": 300,
- "Traps": 50,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 619,
- "Pokemon": 301,
- "Traps": 50,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 620,
- "Pokemon": 301,
- "Traps": 50,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 621,
- "Pokemon": 301,
- "Traps": 50,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 622,
- "Pokemon": 301,
- "Traps": 50,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 623,
- "Pokemon": 301,
- "Traps": 50,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 624,
- "Pokemon": 301,
- "Traps": 50,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 625,
- "Pokemon": 301,
- "Traps": 50,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 626,
- "Pokemon": 301,
- "Traps": 50,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 627,
- "Pokemon": 301,
- "Traps": 50,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 628,
- "Pokemon": 302,
- "Traps": 51,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 629,
- "Pokemon": 302,
- "Traps": 51,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 630,
- "Pokemon": 302,
- "Traps": 51,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 631,
- "Pokemon": 302,
- "Traps": 51,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 632,
- "Pokemon": 302,
- "Traps": 51,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 633,
- "Pokemon": 302,
- "Traps": 51,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 634,
- "Pokemon": 302,
- "Traps": 51,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 635,
- "Pokemon": 302,
- "Traps": 51,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 636,
- "Pokemon": 302,
- "Traps": 51,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 637,
- "Pokemon": 302,
- "Traps": 51,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 638,
- "Pokemon": 303,
- "Traps": 52,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 639,
- "Pokemon": 304,
- "Traps": 52,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 640,
- "Pokemon": 304,
- "Traps": 52,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 641,
- "Pokemon": 304,
- "Traps": 52,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 642,
- "Pokemon": 304,
- "Traps": 52,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 643,
- "Pokemon": 305,
- "Traps": 52,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 644,
- "Pokemon": 305,
- "Traps": 52,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 645,
- "Pokemon": 305,
- "Traps": 52,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 646,
- "Pokemon": 306,
- "Traps": 52,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 647,
- "Pokemon": 306,
- "Traps": 52,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 648,
- "Pokemon": 307,
- "Traps": 53,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 649,
- "Pokemon": 308,
- "Traps": 54,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 650,
- "Pokemon": 308,
- "Traps": 54,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 651,
- "Pokemon": 308,
- "Traps": 55,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 652,
- "Pokemon": 309,
- "Traps": 56,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 653,
- "Pokemon": 310,
- "Traps": 54,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 654,
- "Pokemon": 310,
- "Traps": 54,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 655,
- "Pokemon": 310,
- "Traps": 54,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 656,
- "Pokemon": 310,
- "Traps": 54,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 657,
- "Pokemon": 310,
- "Traps": 57,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 658,
- "Pokemon": 311,
- "Traps": 57,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 659,
- "Pokemon": 311,
- "Traps": 57,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 660,
- "Pokemon": 312,
- "Traps": 57,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 661,
- "Pokemon": 312,
- "Traps": 57,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 662,
- "Pokemon": 312,
- "Traps": 57,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 663,
- "Pokemon": 312,
- "Traps": 57,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 664,
- "Pokemon": 312,
- "Traps": 57,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 665,
- "Pokemon": 312,
- "Traps": 57,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 666,
- "Pokemon": 313,
- "Traps": 57,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 667,
- "Pokemon": 313,
- "Traps": 57,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 668,
- "Pokemon": 313,
- "Traps": 57,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 669,
- "Pokemon": 314,
- "Traps": 57,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 670,
- "Pokemon": 314,
- "Traps": 57,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 671,
- "Pokemon": 314,
- "Traps": 57,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 672,
- "Pokemon": 315,
- "Traps": 57,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 673,
- "Pokemon": 315,
- "Traps": 57,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 674,
- "Pokemon": 315,
- "Traps": 57,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 675,
- "Pokemon": 315,
- "Traps": 57,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 676,
- "Pokemon": 315,
- "Traps": 57,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- },
- {
- "MainData": 677,
- "Pokemon": 316,
- "Traps": 58,
- "Items": 82,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 81
- }
- ]
-}
+{
+ "name": "BuriedRelicFloorID",
+ "tables": [
+ {
+ "MainData": 579,
+ "Pokemon": 278,
+ "Traps": 7,
+ "Items": 80,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 580,
+ "Pokemon": 278,
+ "Traps": 7,
+ "Items": 80,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 581,
+ "Pokemon": 278,
+ "Traps": 7,
+ "Items": 80,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 582,
+ "Pokemon": 279,
+ "Traps": 7,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 583,
+ "Pokemon": 280,
+ "Traps": 7,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 584,
+ "Pokemon": 280,
+ "Traps": 7,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 585,
+ "Pokemon": 280,
+ "Traps": 7,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 586,
+ "Pokemon": 280,
+ "Traps": 7,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 587,
+ "Pokemon": 281,
+ "Traps": 7,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 588,
+ "Pokemon": 282,
+ "Traps": 8,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 589,
+ "Pokemon": 283,
+ "Traps": 8,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 590,
+ "Pokemon": 284,
+ "Traps": 8,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 591,
+ "Pokemon": 284,
+ "Traps": 8,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 592,
+ "Pokemon": 285,
+ "Traps": 8,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 593,
+ "Pokemon": 286,
+ "Traps": 8,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 594,
+ "Pokemon": 287,
+ "Traps": 8,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 595,
+ "Pokemon": 288,
+ "Traps": 8,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 596,
+ "Pokemon": 288,
+ "Traps": 8,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 597,
+ "Pokemon": 289,
+ "Traps": 8,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 598,
+ "Pokemon": 290,
+ "Traps": 8,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 599,
+ "Pokemon": 291,
+ "Traps": 8,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 600,
+ "Pokemon": 291,
+ "Traps": 8,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 601,
+ "Pokemon": 292,
+ "Traps": 8,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 602,
+ "Pokemon": 293,
+ "Traps": 8,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 603,
+ "Pokemon": 294,
+ "Traps": 8,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 604,
+ "Pokemon": 295,
+ "Traps": 8,
+ "Items": 82,
+ "KecleonShop": 83,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 605,
+ "Pokemon": 295,
+ "Traps": 8,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 606,
+ "Pokemon": 295,
+ "Traps": 8,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 607,
+ "Pokemon": 295,
+ "Traps": 8,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 608,
+ "Pokemon": 296,
+ "Traps": 48,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 609,
+ "Pokemon": 297,
+ "Traps": 49,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 610,
+ "Pokemon": 297,
+ "Traps": 49,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 611,
+ "Pokemon": 297,
+ "Traps": 49,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 612,
+ "Pokemon": 297,
+ "Traps": 49,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 613,
+ "Pokemon": 298,
+ "Traps": 49,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 614,
+ "Pokemon": 299,
+ "Traps": 49,
+ "Items": 82,
+ "KecleonShop": 83,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 615,
+ "Pokemon": 299,
+ "Traps": 49,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 616,
+ "Pokemon": 299,
+ "Traps": 49,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 617,
+ "Pokemon": 299,
+ "Traps": 49,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 618,
+ "Pokemon": 300,
+ "Traps": 50,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 619,
+ "Pokemon": 301,
+ "Traps": 50,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 620,
+ "Pokemon": 301,
+ "Traps": 50,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 621,
+ "Pokemon": 301,
+ "Traps": 50,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 622,
+ "Pokemon": 301,
+ "Traps": 50,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 623,
+ "Pokemon": 301,
+ "Traps": 50,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 624,
+ "Pokemon": 301,
+ "Traps": 50,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 625,
+ "Pokemon": 301,
+ "Traps": 50,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 626,
+ "Pokemon": 301,
+ "Traps": 50,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 627,
+ "Pokemon": 301,
+ "Traps": 50,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 628,
+ "Pokemon": 302,
+ "Traps": 51,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 629,
+ "Pokemon": 302,
+ "Traps": 51,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 630,
+ "Pokemon": 302,
+ "Traps": 51,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 631,
+ "Pokemon": 302,
+ "Traps": 51,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 632,
+ "Pokemon": 302,
+ "Traps": 51,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 633,
+ "Pokemon": 302,
+ "Traps": 51,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 634,
+ "Pokemon": 302,
+ "Traps": 51,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 635,
+ "Pokemon": 302,
+ "Traps": 51,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 636,
+ "Pokemon": 302,
+ "Traps": 51,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 637,
+ "Pokemon": 302,
+ "Traps": 51,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 638,
+ "Pokemon": 303,
+ "Traps": 52,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 639,
+ "Pokemon": 304,
+ "Traps": 52,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 640,
+ "Pokemon": 304,
+ "Traps": 52,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 641,
+ "Pokemon": 304,
+ "Traps": 52,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 642,
+ "Pokemon": 304,
+ "Traps": 52,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 643,
+ "Pokemon": 305,
+ "Traps": 52,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 644,
+ "Pokemon": 305,
+ "Traps": 52,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 645,
+ "Pokemon": 305,
+ "Traps": 52,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 646,
+ "Pokemon": 306,
+ "Traps": 52,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 647,
+ "Pokemon": 306,
+ "Traps": 52,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 648,
+ "Pokemon": 307,
+ "Traps": 53,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 649,
+ "Pokemon": 308,
+ "Traps": 54,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 650,
+ "Pokemon": 308,
+ "Traps": 54,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 651,
+ "Pokemon": 308,
+ "Traps": 55,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 652,
+ "Pokemon": 309,
+ "Traps": 56,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 653,
+ "Pokemon": 310,
+ "Traps": 54,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 654,
+ "Pokemon": 310,
+ "Traps": 54,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 655,
+ "Pokemon": 310,
+ "Traps": 54,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 656,
+ "Pokemon": 310,
+ "Traps": 54,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 657,
+ "Pokemon": 310,
+ "Traps": 57,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 658,
+ "Pokemon": 311,
+ "Traps": 57,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 659,
+ "Pokemon": 311,
+ "Traps": 57,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 660,
+ "Pokemon": 312,
+ "Traps": 57,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 661,
+ "Pokemon": 312,
+ "Traps": 57,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 662,
+ "Pokemon": 312,
+ "Traps": 57,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 663,
+ "Pokemon": 312,
+ "Traps": 57,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 664,
+ "Pokemon": 312,
+ "Traps": 57,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 665,
+ "Pokemon": 312,
+ "Traps": 57,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 666,
+ "Pokemon": 313,
+ "Traps": 57,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 667,
+ "Pokemon": 313,
+ "Traps": 57,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 668,
+ "Pokemon": 313,
+ "Traps": 57,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 669,
+ "Pokemon": 314,
+ "Traps": 57,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 670,
+ "Pokemon": 314,
+ "Traps": 57,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 671,
+ "Pokemon": 314,
+ "Traps": 57,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 672,
+ "Pokemon": 315,
+ "Traps": 57,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 673,
+ "Pokemon": 315,
+ "Traps": 57,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 674,
+ "Pokemon": 315,
+ "Traps": 57,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 675,
+ "Pokemon": 315,
+ "Traps": 57,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 676,
+ "Pokemon": 315,
+ "Traps": 57,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ },
+ {
+ "MainData": 677,
+ "Pokemon": 316,
+ "Traps": 58,
+ "Items": 82,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 81
+ }
+ ]
+}
diff --git a/data/dungeon/D50/floor_id.json b/data/dungeon/D50/floor_id.json
index 4dc2f2e..6f23a99 100644
--- a/data/dungeon/D50/floor_id.json
+++ b/data/dungeon/D50/floor_id.json
@@ -1,23 +1,23 @@
-{
- "name": "D50FloorID",
- "tables": [
- {
- "MainData": 1139,
- "Pokemon": 526,
- "Traps": 87,
- "Items": 87,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 1140,
- "Pokemon": 526,
- "Traps": 87,
- "Items": 87,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- }
- ]
-}
+{
+ "name": "D50FloorID",
+ "tables": [
+ {
+ "MainData": 1139,
+ "Pokemon": 526,
+ "Traps": 87,
+ "Items": 87,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1140,
+ "Pokemon": 526,
+ "Traps": 87,
+ "Items": 87,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ }
+ ]
+}
diff --git a/data/dungeon/D51/floor_id.json b/data/dungeon/D51/floor_id.json
index 42acf2d..6c67400 100644
--- a/data/dungeon/D51/floor_id.json
+++ b/data/dungeon/D51/floor_id.json
@@ -1,455 +1,455 @@
-{
- "name": "D51FloorID",
- "tables": [
- {
- "MainData": 1141,
- "Pokemon": 526,
- "Traps": 87,
- "Items": 128,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1142,
- "Pokemon": 526,
- "Traps": 87,
- "Items": 128,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1143,
- "Pokemon": 532,
- "Traps": 87,
- "Items": 128,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1144,
- "Pokemon": 533,
- "Traps": 87,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1145,
- "Pokemon": 529,
- "Traps": 87,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1146,
- "Pokemon": 529,
- "Traps": 87,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1147,
- "Pokemon": 530,
- "Traps": 87,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1148,
- "Pokemon": 530,
- "Traps": 87,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1149,
- "Pokemon": 530,
- "Traps": 87,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1150,
- "Pokemon": 531,
- "Traps": 87,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1151,
- "Pokemon": 531,
- "Traps": 87,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1152,
- "Pokemon": 531,
- "Traps": 87,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1153,
- "Pokemon": 531,
- "Traps": 87,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1154,
- "Pokemon": 534,
- "Traps": 87,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1155,
- "Pokemon": 534,
- "Traps": 87,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1156,
- "Pokemon": 535,
- "Traps": 87,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1157,
- "Pokemon": 535,
- "Traps": 87,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1158,
- "Pokemon": 535,
- "Traps": 87,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1159,
- "Pokemon": 535,
- "Traps": 87,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1160,
- "Pokemon": 536,
- "Traps": 87,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1161,
- "Pokemon": 536,
- "Traps": 88,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1162,
- "Pokemon": 537,
- "Traps": 88,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1163,
- "Pokemon": 537,
- "Traps": 88,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1164,
- "Pokemon": 537,
- "Traps": 88,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1165,
- "Pokemon": 537,
- "Traps": 88,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1166,
- "Pokemon": 538,
- "Traps": 88,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1167,
- "Pokemon": 538,
- "Traps": 88,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1168,
- "Pokemon": 538,
- "Traps": 88,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1169,
- "Pokemon": 538,
- "Traps": 88,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1170,
- "Pokemon": 538,
- "Traps": 88,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1171,
- "Pokemon": 539,
- "Traps": 88,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1172,
- "Pokemon": 539,
- "Traps": 88,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1173,
- "Pokemon": 539,
- "Traps": 88,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1174,
- "Pokemon": 539,
- "Traps": 88,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1175,
- "Pokemon": 539,
- "Traps": 88,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1176,
- "Pokemon": 540,
- "Traps": 88,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1177,
- "Pokemon": 540,
- "Traps": 88,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1178,
- "Pokemon": 540,
- "Traps": 88,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1179,
- "Pokemon": 540,
- "Traps": 88,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1180,
- "Pokemon": 540,
- "Traps": 88,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1181,
- "Pokemon": 541,
- "Traps": 89,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1182,
- "Pokemon": 541,
- "Traps": 89,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1183,
- "Pokemon": 541,
- "Traps": 89,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1184,
- "Pokemon": 541,
- "Traps": 89,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1185,
- "Pokemon": 541,
- "Traps": 89,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1186,
- "Pokemon": 541,
- "Traps": 89,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1187,
- "Pokemon": 542,
- "Traps": 89,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1188,
- "Pokemon": 542,
- "Traps": 89,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1189,
- "Pokemon": 542,
- "Traps": 89,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1190,
- "Pokemon": 542,
- "Traps": 90,
- "Items": 129,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- }
- ]
-}
+{
+ "name": "D51FloorID",
+ "tables": [
+ {
+ "MainData": 1141,
+ "Pokemon": 526,
+ "Traps": 87,
+ "Items": 128,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1142,
+ "Pokemon": 526,
+ "Traps": 87,
+ "Items": 128,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1143,
+ "Pokemon": 532,
+ "Traps": 87,
+ "Items": 128,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1144,
+ "Pokemon": 533,
+ "Traps": 87,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1145,
+ "Pokemon": 529,
+ "Traps": 87,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1146,
+ "Pokemon": 529,
+ "Traps": 87,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1147,
+ "Pokemon": 530,
+ "Traps": 87,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1148,
+ "Pokemon": 530,
+ "Traps": 87,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1149,
+ "Pokemon": 530,
+ "Traps": 87,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1150,
+ "Pokemon": 531,
+ "Traps": 87,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1151,
+ "Pokemon": 531,
+ "Traps": 87,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1152,
+ "Pokemon": 531,
+ "Traps": 87,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1153,
+ "Pokemon": 531,
+ "Traps": 87,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1154,
+ "Pokemon": 534,
+ "Traps": 87,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1155,
+ "Pokemon": 534,
+ "Traps": 87,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1156,
+ "Pokemon": 535,
+ "Traps": 87,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1157,
+ "Pokemon": 535,
+ "Traps": 87,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1158,
+ "Pokemon": 535,
+ "Traps": 87,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1159,
+ "Pokemon": 535,
+ "Traps": 87,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1160,
+ "Pokemon": 536,
+ "Traps": 87,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1161,
+ "Pokemon": 536,
+ "Traps": 88,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1162,
+ "Pokemon": 537,
+ "Traps": 88,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1163,
+ "Pokemon": 537,
+ "Traps": 88,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1164,
+ "Pokemon": 537,
+ "Traps": 88,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1165,
+ "Pokemon": 537,
+ "Traps": 88,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1166,
+ "Pokemon": 538,
+ "Traps": 88,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1167,
+ "Pokemon": 538,
+ "Traps": 88,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1168,
+ "Pokemon": 538,
+ "Traps": 88,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1169,
+ "Pokemon": 538,
+ "Traps": 88,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1170,
+ "Pokemon": 538,
+ "Traps": 88,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1171,
+ "Pokemon": 539,
+ "Traps": 88,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1172,
+ "Pokemon": 539,
+ "Traps": 88,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1173,
+ "Pokemon": 539,
+ "Traps": 88,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1174,
+ "Pokemon": 539,
+ "Traps": 88,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1175,
+ "Pokemon": 539,
+ "Traps": 88,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1176,
+ "Pokemon": 540,
+ "Traps": 88,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1177,
+ "Pokemon": 540,
+ "Traps": 88,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1178,
+ "Pokemon": 540,
+ "Traps": 88,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1179,
+ "Pokemon": 540,
+ "Traps": 88,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1180,
+ "Pokemon": 540,
+ "Traps": 88,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1181,
+ "Pokemon": 541,
+ "Traps": 89,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1182,
+ "Pokemon": 541,
+ "Traps": 89,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1183,
+ "Pokemon": 541,
+ "Traps": 89,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1184,
+ "Pokemon": 541,
+ "Traps": 89,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1185,
+ "Pokemon": 541,
+ "Traps": 89,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1186,
+ "Pokemon": 541,
+ "Traps": 89,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1187,
+ "Pokemon": 542,
+ "Traps": 89,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1188,
+ "Pokemon": 542,
+ "Traps": 89,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1189,
+ "Pokemon": 542,
+ "Traps": 89,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1190,
+ "Pokemon": 542,
+ "Traps": 90,
+ "Items": 129,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ }
+ ]
+}
diff --git a/data/dungeon/D54/floor_id.json b/data/dungeon/D54/floor_id.json
index 8c217eb..df03c60 100644
--- a/data/dungeon/D54/floor_id.json
+++ b/data/dungeon/D54/floor_id.json
@@ -1,275 +1,275 @@
-{
- "name": "D54FloorID",
- "tables": [
- {
- "MainData": 1272,
- "Pokemon": 526,
- "Traps": 10,
- "Items": 87,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1273,
- "Pokemon": 526,
- "Traps": 10,
- "Items": 87,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1274,
- "Pokemon": 527,
- "Traps": 10,
- "Items": 87,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1275,
- "Pokemon": 528,
- "Traps": 10,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1276,
- "Pokemon": 529,
- "Traps": 10,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1277,
- "Pokemon": 529,
- "Traps": 10,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1278,
- "Pokemon": 530,
- "Traps": 10,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1279,
- "Pokemon": 530,
- "Traps": 10,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1280,
- "Pokemon": 530,
- "Traps": 10,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1281,
- "Pokemon": 531,
- "Traps": 10,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1282,
- "Pokemon": 531,
- "Traps": 10,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1283,
- "Pokemon": 531,
- "Traps": 10,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1284,
- "Pokemon": 531,
- "Traps": 10,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1285,
- "Pokemon": 534,
- "Traps": 10,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1286,
- "Pokemon": 534,
- "Traps": 10,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1287,
- "Pokemon": 535,
- "Traps": 10,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1288,
- "Pokemon": 535,
- "Traps": 10,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1289,
- "Pokemon": 535,
- "Traps": 10,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1290,
- "Pokemon": 535,
- "Traps": 10,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1291,
- "Pokemon": 536,
- "Traps": 10,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1292,
- "Pokemon": 536,
- "Traps": 10,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1293,
- "Pokemon": 537,
- "Traps": 10,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1294,
- "Pokemon": 537,
- "Traps": 10,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1295,
- "Pokemon": 537,
- "Traps": 10,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1296,
- "Pokemon": 537,
- "Traps": 10,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1297,
- "Pokemon": 538,
- "Traps": 10,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1298,
- "Pokemon": 538,
- "Traps": 10,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1299,
- "Pokemon": 538,
- "Traps": 10,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1300,
- "Pokemon": 538,
- "Traps": 10,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1301,
- "Pokemon": 538,
- "Traps": 10,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- }
- ]
-}
+{
+ "name": "D54FloorID",
+ "tables": [
+ {
+ "MainData": 1272,
+ "Pokemon": 526,
+ "Traps": 10,
+ "Items": 87,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1273,
+ "Pokemon": 526,
+ "Traps": 10,
+ "Items": 87,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1274,
+ "Pokemon": 527,
+ "Traps": 10,
+ "Items": 87,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1275,
+ "Pokemon": 528,
+ "Traps": 10,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1276,
+ "Pokemon": 529,
+ "Traps": 10,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1277,
+ "Pokemon": 529,
+ "Traps": 10,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1278,
+ "Pokemon": 530,
+ "Traps": 10,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1279,
+ "Pokemon": 530,
+ "Traps": 10,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1280,
+ "Pokemon": 530,
+ "Traps": 10,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1281,
+ "Pokemon": 531,
+ "Traps": 10,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1282,
+ "Pokemon": 531,
+ "Traps": 10,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1283,
+ "Pokemon": 531,
+ "Traps": 10,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1284,
+ "Pokemon": 531,
+ "Traps": 10,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1285,
+ "Pokemon": 534,
+ "Traps": 10,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1286,
+ "Pokemon": 534,
+ "Traps": 10,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1287,
+ "Pokemon": 535,
+ "Traps": 10,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1288,
+ "Pokemon": 535,
+ "Traps": 10,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1289,
+ "Pokemon": 535,
+ "Traps": 10,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1290,
+ "Pokemon": 535,
+ "Traps": 10,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1291,
+ "Pokemon": 536,
+ "Traps": 10,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1292,
+ "Pokemon": 536,
+ "Traps": 10,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1293,
+ "Pokemon": 537,
+ "Traps": 10,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1294,
+ "Pokemon": 537,
+ "Traps": 10,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1295,
+ "Pokemon": 537,
+ "Traps": 10,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1296,
+ "Pokemon": 537,
+ "Traps": 10,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1297,
+ "Pokemon": 538,
+ "Traps": 10,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1298,
+ "Pokemon": 538,
+ "Traps": 10,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1299,
+ "Pokemon": 538,
+ "Traps": 10,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1300,
+ "Pokemon": 538,
+ "Traps": 10,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1301,
+ "Pokemon": 538,
+ "Traps": 10,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ }
+ ]
+}
diff --git a/data/dungeon/D61/floor_id.json b/data/dungeon/D61/floor_id.json
index 285755d..885165e 100644
--- a/data/dungeon/D61/floor_id.json
+++ b/data/dungeon/D61/floor_id.json
@@ -1,896 +1,896 @@
-{
- "name": "D61FloorID",
- "tables": [
- {
- "MainData": 1565,
- "Pokemon": 727,
- "Traps": 115,
- "Items": 87,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1566,
- "Pokemon": 727,
- "Traps": 115,
- "Items": 87,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1567,
- "Pokemon": 727,
- "Traps": 115,
- "Items": 87,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1568,
- "Pokemon": 727,
- "Traps": 115,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1569,
- "Pokemon": 728,
- "Traps": 115,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1570,
- "Pokemon": 728,
- "Traps": 115,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1571,
- "Pokemon": 728,
- "Traps": 115,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1572,
- "Pokemon": 728,
- "Traps": 115,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1573,
- "Pokemon": 728,
- "Traps": 115,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1574,
- "Pokemon": 729,
- "Traps": 115,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1575,
- "Pokemon": 729,
- "Traps": 115,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1576,
- "Pokemon": 729,
- "Traps": 115,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1577,
- "Pokemon": 730,
- "Traps": 115,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1578,
- "Pokemon": 730,
- "Traps": 115,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1579,
- "Pokemon": 730,
- "Traps": 115,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1580,
- "Pokemon": 730,
- "Traps": 115,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1581,
- "Pokemon": 730,
- "Traps": 115,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1582,
- "Pokemon": 730,
- "Traps": 115,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1583,
- "Pokemon": 730,
- "Traps": 115,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1584,
- "Pokemon": 731,
- "Traps": 115,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1585,
- "Pokemon": 732,
- "Traps": 116,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1586,
- "Pokemon": 732,
- "Traps": 116,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1587,
- "Pokemon": 732,
- "Traps": 116,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1588,
- "Pokemon": 732,
- "Traps": 116,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1589,
- "Pokemon": 732,
- "Traps": 116,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1590,
- "Pokemon": 732,
- "Traps": 116,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1591,
- "Pokemon": 732,
- "Traps": 116,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1592,
- "Pokemon": 732,
- "Traps": 116,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1593,
- "Pokemon": 732,
- "Traps": 116,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1594,
- "Pokemon": 733,
- "Traps": 116,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1595,
- "Pokemon": 734,
- "Traps": 116,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1596,
- "Pokemon": 734,
- "Traps": 116,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1597,
- "Pokemon": 734,
- "Traps": 116,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1598,
- "Pokemon": 735,
- "Traps": 116,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1599,
- "Pokemon": 735,
- "Traps": 116,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1600,
- "Pokemon": 736,
- "Traps": 116,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1601,
- "Pokemon": 736,
- "Traps": 116,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1602,
- "Pokemon": 736,
- "Traps": 116,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1603,
- "Pokemon": 736,
- "Traps": 116,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1604,
- "Pokemon": 737,
- "Traps": 116,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1605,
- "Pokemon": 737,
- "Traps": 117,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1606,
- "Pokemon": 737,
- "Traps": 117,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1607,
- "Pokemon": 738,
- "Traps": 117,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1608,
- "Pokemon": 738,
- "Traps": 117,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1609,
- "Pokemon": 738,
- "Traps": 117,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1610,
- "Pokemon": 738,
- "Traps": 117,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1611,
- "Pokemon": 738,
- "Traps": 117,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1612,
- "Pokemon": 738,
- "Traps": 117,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1613,
- "Pokemon": 739,
- "Traps": 117,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1614,
- "Pokemon": 740,
- "Traps": 118,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1615,
- "Pokemon": 740,
- "Traps": 119,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1616,
- "Pokemon": 740,
- "Traps": 120,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1617,
- "Pokemon": 741,
- "Traps": 120,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1618,
- "Pokemon": 742,
- "Traps": 120,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1619,
- "Pokemon": 742,
- "Traps": 120,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1620,
- "Pokemon": 743,
- "Traps": 120,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1621,
- "Pokemon": 743,
- "Traps": 119,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1622,
- "Pokemon": 743,
- "Traps": 121,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1623,
- "Pokemon": 743,
- "Traps": 121,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1624,
- "Pokemon": 744,
- "Traps": 122,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1625,
- "Pokemon": 744,
- "Traps": 122,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1626,
- "Pokemon": 744,
- "Traps": 122,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1627,
- "Pokemon": 744,
- "Traps": 122,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1628,
- "Pokemon": 744,
- "Traps": 122,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1629,
- "Pokemon": 745,
- "Traps": 122,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1630,
- "Pokemon": 745,
- "Traps": 122,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1631,
- "Pokemon": 746,
- "Traps": 122,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1632,
- "Pokemon": 746,
- "Traps": 122,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1633,
- "Pokemon": 746,
- "Traps": 122,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1634,
- "Pokemon": 747,
- "Traps": 123,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1635,
- "Pokemon": 748,
- "Traps": 124,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1636,
- "Pokemon": 748,
- "Traps": 124,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1637,
- "Pokemon": 748,
- "Traps": 125,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1638,
- "Pokemon": 748,
- "Traps": 126,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1639,
- "Pokemon": 748,
- "Traps": 124,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1640,
- "Pokemon": 748,
- "Traps": 124,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1641,
- "Pokemon": 748,
- "Traps": 124,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1642,
- "Pokemon": 748,
- "Traps": 127,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1643,
- "Pokemon": 748,
- "Traps": 128,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1644,
- "Pokemon": 748,
- "Traps": 129,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1645,
- "Pokemon": 748,
- "Traps": 129,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1646,
- "Pokemon": 748,
- "Traps": 129,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1647,
- "Pokemon": 748,
- "Traps": 129,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1648,
- "Pokemon": 748,
- "Traps": 129,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1649,
- "Pokemon": 748,
- "Traps": 130,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1650,
- "Pokemon": 748,
- "Traps": 130,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1651,
- "Pokemon": 748,
- "Traps": 131,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1652,
- "Pokemon": 748,
- "Traps": 132,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1653,
- "Pokemon": 748,
- "Traps": 132,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1654,
- "Pokemon": 748,
- "Traps": 132,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1655,
- "Pokemon": 749,
- "Traps": 133,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1656,
- "Pokemon": 749,
- "Traps": 133,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1657,
- "Pokemon": 749,
- "Traps": 133,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1658,
- "Pokemon": 749,
- "Traps": 134,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1659,
- "Pokemon": 749,
- "Traps": 134,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1660,
- "Pokemon": 749,
- "Traps": 135,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1661,
- "Pokemon": 749,
- "Traps": 136,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1662,
- "Pokemon": 749,
- "Traps": 136,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1663,
- "Pokemon": 749,
- "Traps": 136,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- }
- ]
-}
+{
+ "name": "D61FloorID",
+ "tables": [
+ {
+ "MainData": 1565,
+ "Pokemon": 727,
+ "Traps": 115,
+ "Items": 87,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1566,
+ "Pokemon": 727,
+ "Traps": 115,
+ "Items": 87,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1567,
+ "Pokemon": 727,
+ "Traps": 115,
+ "Items": 87,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1568,
+ "Pokemon": 727,
+ "Traps": 115,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1569,
+ "Pokemon": 728,
+ "Traps": 115,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1570,
+ "Pokemon": 728,
+ "Traps": 115,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1571,
+ "Pokemon": 728,
+ "Traps": 115,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1572,
+ "Pokemon": 728,
+ "Traps": 115,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1573,
+ "Pokemon": 728,
+ "Traps": 115,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1574,
+ "Pokemon": 729,
+ "Traps": 115,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1575,
+ "Pokemon": 729,
+ "Traps": 115,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1576,
+ "Pokemon": 729,
+ "Traps": 115,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1577,
+ "Pokemon": 730,
+ "Traps": 115,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1578,
+ "Pokemon": 730,
+ "Traps": 115,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1579,
+ "Pokemon": 730,
+ "Traps": 115,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1580,
+ "Pokemon": 730,
+ "Traps": 115,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1581,
+ "Pokemon": 730,
+ "Traps": 115,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1582,
+ "Pokemon": 730,
+ "Traps": 115,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1583,
+ "Pokemon": 730,
+ "Traps": 115,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1584,
+ "Pokemon": 731,
+ "Traps": 115,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1585,
+ "Pokemon": 732,
+ "Traps": 116,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1586,
+ "Pokemon": 732,
+ "Traps": 116,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1587,
+ "Pokemon": 732,
+ "Traps": 116,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1588,
+ "Pokemon": 732,
+ "Traps": 116,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1589,
+ "Pokemon": 732,
+ "Traps": 116,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1590,
+ "Pokemon": 732,
+ "Traps": 116,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1591,
+ "Pokemon": 732,
+ "Traps": 116,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1592,
+ "Pokemon": 732,
+ "Traps": 116,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1593,
+ "Pokemon": 732,
+ "Traps": 116,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1594,
+ "Pokemon": 733,
+ "Traps": 116,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1595,
+ "Pokemon": 734,
+ "Traps": 116,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1596,
+ "Pokemon": 734,
+ "Traps": 116,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1597,
+ "Pokemon": 734,
+ "Traps": 116,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1598,
+ "Pokemon": 735,
+ "Traps": 116,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1599,
+ "Pokemon": 735,
+ "Traps": 116,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1600,
+ "Pokemon": 736,
+ "Traps": 116,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1601,
+ "Pokemon": 736,
+ "Traps": 116,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1602,
+ "Pokemon": 736,
+ "Traps": 116,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1603,
+ "Pokemon": 736,
+ "Traps": 116,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1604,
+ "Pokemon": 737,
+ "Traps": 116,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1605,
+ "Pokemon": 737,
+ "Traps": 117,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1606,
+ "Pokemon": 737,
+ "Traps": 117,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1607,
+ "Pokemon": 738,
+ "Traps": 117,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1608,
+ "Pokemon": 738,
+ "Traps": 117,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1609,
+ "Pokemon": 738,
+ "Traps": 117,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1610,
+ "Pokemon": 738,
+ "Traps": 117,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1611,
+ "Pokemon": 738,
+ "Traps": 117,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1612,
+ "Pokemon": 738,
+ "Traps": 117,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1613,
+ "Pokemon": 739,
+ "Traps": 117,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1614,
+ "Pokemon": 740,
+ "Traps": 118,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1615,
+ "Pokemon": 740,
+ "Traps": 119,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1616,
+ "Pokemon": 740,
+ "Traps": 120,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1617,
+ "Pokemon": 741,
+ "Traps": 120,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1618,
+ "Pokemon": 742,
+ "Traps": 120,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1619,
+ "Pokemon": 742,
+ "Traps": 120,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1620,
+ "Pokemon": 743,
+ "Traps": 120,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1621,
+ "Pokemon": 743,
+ "Traps": 119,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1622,
+ "Pokemon": 743,
+ "Traps": 121,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1623,
+ "Pokemon": 743,
+ "Traps": 121,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1624,
+ "Pokemon": 744,
+ "Traps": 122,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1625,
+ "Pokemon": 744,
+ "Traps": 122,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1626,
+ "Pokemon": 744,
+ "Traps": 122,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1627,
+ "Pokemon": 744,
+ "Traps": 122,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1628,
+ "Pokemon": 744,
+ "Traps": 122,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1629,
+ "Pokemon": 745,
+ "Traps": 122,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1630,
+ "Pokemon": 745,
+ "Traps": 122,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1631,
+ "Pokemon": 746,
+ "Traps": 122,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1632,
+ "Pokemon": 746,
+ "Traps": 122,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1633,
+ "Pokemon": 746,
+ "Traps": 122,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1634,
+ "Pokemon": 747,
+ "Traps": 123,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1635,
+ "Pokemon": 748,
+ "Traps": 124,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1636,
+ "Pokemon": 748,
+ "Traps": 124,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1637,
+ "Pokemon": 748,
+ "Traps": 125,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1638,
+ "Pokemon": 748,
+ "Traps": 126,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1639,
+ "Pokemon": 748,
+ "Traps": 124,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1640,
+ "Pokemon": 748,
+ "Traps": 124,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1641,
+ "Pokemon": 748,
+ "Traps": 124,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1642,
+ "Pokemon": 748,
+ "Traps": 127,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1643,
+ "Pokemon": 748,
+ "Traps": 128,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1644,
+ "Pokemon": 748,
+ "Traps": 129,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1645,
+ "Pokemon": 748,
+ "Traps": 129,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1646,
+ "Pokemon": 748,
+ "Traps": 129,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1647,
+ "Pokemon": 748,
+ "Traps": 129,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1648,
+ "Pokemon": 748,
+ "Traps": 129,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1649,
+ "Pokemon": 748,
+ "Traps": 130,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1650,
+ "Pokemon": 748,
+ "Traps": 130,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1651,
+ "Pokemon": 748,
+ "Traps": 131,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1652,
+ "Pokemon": 748,
+ "Traps": 132,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1653,
+ "Pokemon": 748,
+ "Traps": 132,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1654,
+ "Pokemon": 748,
+ "Traps": 132,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1655,
+ "Pokemon": 749,
+ "Traps": 133,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1656,
+ "Pokemon": 749,
+ "Traps": 133,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1657,
+ "Pokemon": 749,
+ "Traps": 133,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1658,
+ "Pokemon": 749,
+ "Traps": 134,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1659,
+ "Pokemon": 749,
+ "Traps": 134,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1660,
+ "Pokemon": 749,
+ "Traps": 135,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1661,
+ "Pokemon": 749,
+ "Traps": 136,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1662,
+ "Pokemon": 749,
+ "Traps": 136,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1663,
+ "Pokemon": 749,
+ "Traps": 136,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ }
+ ]
+}
diff --git a/data/dungeon/DarknightRelic/floor_id.json b/data/dungeon/DarknightRelic/floor_id.json
index 9ff8fc6..5d9bbc2 100644
--- a/data/dungeon/DarknightRelic/floor_id.json
+++ b/data/dungeon/DarknightRelic/floor_id.json
@@ -1,140 +1,140 @@
-{
- "name": "DarknightRelicFloorID",
- "tables": [
- {
- "MainData": 950,
- "Pokemon": 443,
- "Traps": 7,
- "Items": 107,
- "KecleonShop": 108,
- "MonsterRoomItems": 46,
- "BuriedItems": 109
- },
- {
- "MainData": 951,
- "Pokemon": 443,
- "Traps": 7,
- "Items": 107,
- "KecleonShop": 108,
- "MonsterRoomItems": 46,
- "BuriedItems": 109
- },
- {
- "MainData": 952,
- "Pokemon": 443,
- "Traps": 7,
- "Items": 107,
- "KecleonShop": 108,
- "MonsterRoomItems": 46,
- "BuriedItems": 109
- },
- {
- "MainData": 953,
- "Pokemon": 443,
- "Traps": 7,
- "Items": 110,
- "KecleonShop": 108,
- "MonsterRoomItems": 46,
- "BuriedItems": 109
- },
- {
- "MainData": 954,
- "Pokemon": 443,
- "Traps": 7,
- "Items": 110,
- "KecleonShop": 108,
- "MonsterRoomItems": 46,
- "BuriedItems": 109
- },
- {
- "MainData": 955,
- "Pokemon": 444,
- "Traps": 7,
- "Items": 110,
- "KecleonShop": 108,
- "MonsterRoomItems": 46,
- "BuriedItems": 109
- },
- {
- "MainData": 956,
- "Pokemon": 445,
- "Traps": 7,
- "Items": 110,
- "KecleonShop": 108,
- "MonsterRoomItems": 46,
- "BuriedItems": 109
- },
- {
- "MainData": 957,
- "Pokemon": 445,
- "Traps": 7,
- "Items": 110,
- "KecleonShop": 108,
- "MonsterRoomItems": 46,
- "BuriedItems": 109
- },
- {
- "MainData": 958,
- "Pokemon": 445,
- "Traps": 7,
- "Items": 110,
- "KecleonShop": 108,
- "MonsterRoomItems": 46,
- "BuriedItems": 109
- },
- {
- "MainData": 959,
- "Pokemon": 445,
- "Traps": 8,
- "Items": 110,
- "KecleonShop": 108,
- "MonsterRoomItems": 46,
- "BuriedItems": 109
- },
- {
- "MainData": 960,
- "Pokemon": 446,
- "Traps": 8,
- "Items": 110,
- "KecleonShop": 108,
- "MonsterRoomItems": 46,
- "BuriedItems": 109
- },
- {
- "MainData": 961,
- "Pokemon": 447,
- "Traps": 8,
- "Items": 110,
- "KecleonShop": 108,
- "MonsterRoomItems": 46,
- "BuriedItems": 109
- },
- {
- "MainData": 962,
- "Pokemon": 447,
- "Traps": 8,
- "Items": 110,
- "KecleonShop": 108,
- "MonsterRoomItems": 46,
- "BuriedItems": 109
- },
- {
- "MainData": 963,
- "Pokemon": 447,
- "Traps": 8,
- "Items": 110,
- "KecleonShop": 108,
- "MonsterRoomItems": 46,
- "BuriedItems": 109
- },
- {
- "MainData": 964,
- "Pokemon": 447,
- "Traps": 8,
- "Items": 110,
- "KecleonShop": 108,
- "MonsterRoomItems": 46,
- "BuriedItems": 109
- }
- ]
-}
+{
+ "name": "DarknightRelicFloorID",
+ "tables": [
+ {
+ "MainData": 950,
+ "Pokemon": 443,
+ "Traps": 7,
+ "Items": 107,
+ "KecleonShop": 108,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 109
+ },
+ {
+ "MainData": 951,
+ "Pokemon": 443,
+ "Traps": 7,
+ "Items": 107,
+ "KecleonShop": 108,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 109
+ },
+ {
+ "MainData": 952,
+ "Pokemon": 443,
+ "Traps": 7,
+ "Items": 107,
+ "KecleonShop": 108,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 109
+ },
+ {
+ "MainData": 953,
+ "Pokemon": 443,
+ "Traps": 7,
+ "Items": 110,
+ "KecleonShop": 108,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 109
+ },
+ {
+ "MainData": 954,
+ "Pokemon": 443,
+ "Traps": 7,
+ "Items": 110,
+ "KecleonShop": 108,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 109
+ },
+ {
+ "MainData": 955,
+ "Pokemon": 444,
+ "Traps": 7,
+ "Items": 110,
+ "KecleonShop": 108,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 109
+ },
+ {
+ "MainData": 956,
+ "Pokemon": 445,
+ "Traps": 7,
+ "Items": 110,
+ "KecleonShop": 108,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 109
+ },
+ {
+ "MainData": 957,
+ "Pokemon": 445,
+ "Traps": 7,
+ "Items": 110,
+ "KecleonShop": 108,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 109
+ },
+ {
+ "MainData": 958,
+ "Pokemon": 445,
+ "Traps": 7,
+ "Items": 110,
+ "KecleonShop": 108,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 109
+ },
+ {
+ "MainData": 959,
+ "Pokemon": 445,
+ "Traps": 8,
+ "Items": 110,
+ "KecleonShop": 108,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 109
+ },
+ {
+ "MainData": 960,
+ "Pokemon": 446,
+ "Traps": 8,
+ "Items": 110,
+ "KecleonShop": 108,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 109
+ },
+ {
+ "MainData": 961,
+ "Pokemon": 447,
+ "Traps": 8,
+ "Items": 110,
+ "KecleonShop": 108,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 109
+ },
+ {
+ "MainData": 962,
+ "Pokemon": 447,
+ "Traps": 8,
+ "Items": 110,
+ "KecleonShop": 108,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 109
+ },
+ {
+ "MainData": 963,
+ "Pokemon": 447,
+ "Traps": 8,
+ "Items": 110,
+ "KecleonShop": 108,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 109
+ },
+ {
+ "MainData": 964,
+ "Pokemon": 447,
+ "Traps": 8,
+ "Items": 110,
+ "KecleonShop": 108,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 109
+ }
+ ]
+}
diff --git a/data/dungeon/DesertRegion/floor_id.json b/data/dungeon/DesertRegion/floor_id.json
index bb03749..862ab4b 100644
--- a/data/dungeon/DesertRegion/floor_id.json
+++ b/data/dungeon/DesertRegion/floor_id.json
@@ -1,185 +1,185 @@
-{
- "name": "DesertRegionFloorID",
- "tables": [
- {
- "MainData": 740,
- "Pokemon": 340,
- "Traps": 64,
- "Items": 89,
- "KecleonShop": 90,
- "MonsterRoomItems": 46,
- "BuriedItems": 91
- },
- {
- "MainData": 741,
- "Pokemon": 340,
- "Traps": 64,
- "Items": 89,
- "KecleonShop": 90,
- "MonsterRoomItems": 46,
- "BuriedItems": 91
- },
- {
- "MainData": 742,
- "Pokemon": 340,
- "Traps": 64,
- "Items": 89,
- "KecleonShop": 90,
- "MonsterRoomItems": 46,
- "BuriedItems": 91
- },
- {
- "MainData": 743,
- "Pokemon": 340,
- "Traps": 64,
- "Items": 89,
- "KecleonShop": 90,
- "MonsterRoomItems": 46,
- "BuriedItems": 91
- },
- {
- "MainData": 744,
- "Pokemon": 340,
- "Traps": 64,
- "Items": 89,
- "KecleonShop": 90,
- "MonsterRoomItems": 46,
- "BuriedItems": 91
- },
- {
- "MainData": 745,
- "Pokemon": 340,
- "Traps": 64,
- "Items": 89,
- "KecleonShop": 90,
- "MonsterRoomItems": 46,
- "BuriedItems": 91
- },
- {
- "MainData": 746,
- "Pokemon": 341,
- "Traps": 64,
- "Items": 89,
- "KecleonShop": 90,
- "MonsterRoomItems": 46,
- "BuriedItems": 91
- },
- {
- "MainData": 747,
- "Pokemon": 341,
- "Traps": 64,
- "Items": 89,
- "KecleonShop": 90,
- "MonsterRoomItems": 46,
- "BuriedItems": 91
- },
- {
- "MainData": 748,
- "Pokemon": 341,
- "Traps": 64,
- "Items": 89,
- "KecleonShop": 90,
- "MonsterRoomItems": 46,
- "BuriedItems": 91
- },
- {
- "MainData": 749,
- "Pokemon": 341,
- "Traps": 64,
- "Items": 89,
- "KecleonShop": 90,
- "MonsterRoomItems": 46,
- "BuriedItems": 91
- },
- {
- "MainData": 750,
- "Pokemon": 341,
- "Traps": 64,
- "Items": 89,
- "KecleonShop": 90,
- "MonsterRoomItems": 46,
- "BuriedItems": 91
- },
- {
- "MainData": 751,
- "Pokemon": 342,
- "Traps": 64,
- "Items": 89,
- "KecleonShop": 90,
- "MonsterRoomItems": 46,
- "BuriedItems": 91
- },
- {
- "MainData": 752,
- "Pokemon": 342,
- "Traps": 64,
- "Items": 89,
- "KecleonShop": 90,
- "MonsterRoomItems": 46,
- "BuriedItems": 91
- },
- {
- "MainData": 753,
- "Pokemon": 343,
- "Traps": 64,
- "Items": 89,
- "KecleonShop": 90,
- "MonsterRoomItems": 46,
- "BuriedItems": 91
- },
- {
- "MainData": 754,
- "Pokemon": 344,
- "Traps": 64,
- "Items": 89,
- "KecleonShop": 90,
- "MonsterRoomItems": 46,
- "BuriedItems": 91
- },
- {
- "MainData": 755,
- "Pokemon": 344,
- "Traps": 64,
- "Items": 89,
- "KecleonShop": 90,
- "MonsterRoomItems": 46,
- "BuriedItems": 91
- },
- {
- "MainData": 756,
- "Pokemon": 344,
- "Traps": 64,
- "Items": 89,
- "KecleonShop": 90,
- "MonsterRoomItems": 46,
- "BuriedItems": 91
- },
- {
- "MainData": 757,
- "Pokemon": 344,
- "Traps": 64,
- "Items": 89,
- "KecleonShop": 90,
- "MonsterRoomItems": 46,
- "BuriedItems": 91
- },
- {
- "MainData": 758,
- "Pokemon": 344,
- "Traps": 64,
- "Items": 92,
- "KecleonShop": 90,
- "MonsterRoomItems": 46,
- "BuriedItems": 91
- },
- {
- "MainData": 759,
- "Pokemon": 344,
- "Traps": 64,
- "Items": 92,
- "KecleonShop": 90,
- "MonsterRoomItems": 46,
- "BuriedItems": 91
- }
- ]
-}
+{
+ "name": "DesertRegionFloorID",
+ "tables": [
+ {
+ "MainData": 740,
+ "Pokemon": 340,
+ "Traps": 64,
+ "Items": 89,
+ "KecleonShop": 90,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 91
+ },
+ {
+ "MainData": 741,
+ "Pokemon": 340,
+ "Traps": 64,
+ "Items": 89,
+ "KecleonShop": 90,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 91
+ },
+ {
+ "MainData": 742,
+ "Pokemon": 340,
+ "Traps": 64,
+ "Items": 89,
+ "KecleonShop": 90,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 91
+ },
+ {
+ "MainData": 743,
+ "Pokemon": 340,
+ "Traps": 64,
+ "Items": 89,
+ "KecleonShop": 90,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 91
+ },
+ {
+ "MainData": 744,
+ "Pokemon": 340,
+ "Traps": 64,
+ "Items": 89,
+ "KecleonShop": 90,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 91
+ },
+ {
+ "MainData": 745,
+ "Pokemon": 340,
+ "Traps": 64,
+ "Items": 89,
+ "KecleonShop": 90,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 91
+ },
+ {
+ "MainData": 746,
+ "Pokemon": 341,
+ "Traps": 64,
+ "Items": 89,
+ "KecleonShop": 90,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 91
+ },
+ {
+ "MainData": 747,
+ "Pokemon": 341,
+ "Traps": 64,
+ "Items": 89,
+ "KecleonShop": 90,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 91
+ },
+ {
+ "MainData": 748,
+ "Pokemon": 341,
+ "Traps": 64,
+ "Items": 89,
+ "KecleonShop": 90,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 91
+ },
+ {
+ "MainData": 749,
+ "Pokemon": 341,
+ "Traps": 64,
+ "Items": 89,
+ "KecleonShop": 90,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 91
+ },
+ {
+ "MainData": 750,
+ "Pokemon": 341,
+ "Traps": 64,
+ "Items": 89,
+ "KecleonShop": 90,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 91
+ },
+ {
+ "MainData": 751,
+ "Pokemon": 342,
+ "Traps": 64,
+ "Items": 89,
+ "KecleonShop": 90,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 91
+ },
+ {
+ "MainData": 752,
+ "Pokemon": 342,
+ "Traps": 64,
+ "Items": 89,
+ "KecleonShop": 90,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 91
+ },
+ {
+ "MainData": 753,
+ "Pokemon": 343,
+ "Traps": 64,
+ "Items": 89,
+ "KecleonShop": 90,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 91
+ },
+ {
+ "MainData": 754,
+ "Pokemon": 344,
+ "Traps": 64,
+ "Items": 89,
+ "KecleonShop": 90,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 91
+ },
+ {
+ "MainData": 755,
+ "Pokemon": 344,
+ "Traps": 64,
+ "Items": 89,
+ "KecleonShop": 90,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 91
+ },
+ {
+ "MainData": 756,
+ "Pokemon": 344,
+ "Traps": 64,
+ "Items": 89,
+ "KecleonShop": 90,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 91
+ },
+ {
+ "MainData": 757,
+ "Pokemon": 344,
+ "Traps": 64,
+ "Items": 89,
+ "KecleonShop": 90,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 91
+ },
+ {
+ "MainData": 758,
+ "Pokemon": 344,
+ "Traps": 64,
+ "Items": 92,
+ "KecleonShop": 90,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 91
+ },
+ {
+ "MainData": 759,
+ "Pokemon": 344,
+ "Traps": 64,
+ "Items": 92,
+ "KecleonShop": 90,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 91
+ }
+ ]
+}
diff --git a/data/dungeon/DojoRegistration/floor_id.json b/data/dungeon/DojoRegistration/floor_id.json
index a62a8ff..3fc17d1 100644
--- a/data/dungeon/DojoRegistration/floor_id.json
+++ b/data/dungeon/DojoRegistration/floor_id.json
@@ -1,626 +1,626 @@
-{
- "name": "DojoRegistrationFloorID",
- "tables": [
- {
- "MainData": 1191,
- "Pokemon": 543,
- "Traps": 91,
- "Items": 130,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1192,
- "Pokemon": 543,
- "Traps": 91,
- "Items": 130,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1193,
- "Pokemon": 544,
- "Traps": 91,
- "Items": 130,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1194,
- "Pokemon": 545,
- "Traps": 91,
- "Items": 131,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1195,
- "Pokemon": 545,
- "Traps": 91,
- "Items": 131,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1196,
- "Pokemon": 545,
- "Traps": 91,
- "Items": 131,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1197,
- "Pokemon": 546,
- "Traps": 91,
- "Items": 132,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1198,
- "Pokemon": 546,
- "Traps": 91,
- "Items": 132,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1199,
- "Pokemon": 546,
- "Traps": 91,
- "Items": 132,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1200,
- "Pokemon": 547,
- "Traps": 91,
- "Items": 133,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1201,
- "Pokemon": 547,
- "Traps": 91,
- "Items": 133,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1202,
- "Pokemon": 548,
- "Traps": 91,
- "Items": 133,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1203,
- "Pokemon": 549,
- "Traps": 91,
- "Items": 134,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1204,
- "Pokemon": 549,
- "Traps": 91,
- "Items": 134,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1205,
- "Pokemon": 550,
- "Traps": 91,
- "Items": 134,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1206,
- "Pokemon": 551,
- "Traps": 91,
- "Items": 135,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1207,
- "Pokemon": 551,
- "Traps": 91,
- "Items": 135,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1208,
- "Pokemon": 551,
- "Traps": 91,
- "Items": 135,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1209,
- "Pokemon": 552,
- "Traps": 91,
- "Items": 136,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1210,
- "Pokemon": 552,
- "Traps": 91,
- "Items": 136,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1211,
- "Pokemon": 553,
- "Traps": 91,
- "Items": 136,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1212,
- "Pokemon": 554,
- "Traps": 91,
- "Items": 137,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1213,
- "Pokemon": 554,
- "Traps": 91,
- "Items": 137,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1214,
- "Pokemon": 554,
- "Traps": 91,
- "Items": 137,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1215,
- "Pokemon": 555,
- "Traps": 91,
- "Items": 138,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1216,
- "Pokemon": 555,
- "Traps": 91,
- "Items": 138,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1217,
- "Pokemon": 556,
- "Traps": 91,
- "Items": 138,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1218,
- "Pokemon": 557,
- "Traps": 91,
- "Items": 139,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1219,
- "Pokemon": 557,
- "Traps": 91,
- "Items": 139,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1220,
- "Pokemon": 557,
- "Traps": 91,
- "Items": 139,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1221,
- "Pokemon": 558,
- "Traps": 91,
- "Items": 140,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1222,
- "Pokemon": 558,
- "Traps": 91,
- "Items": 140,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1223,
- "Pokemon": 559,
- "Traps": 91,
- "Items": 140,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1224,
- "Pokemon": 560,
- "Traps": 91,
- "Items": 141,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1225,
- "Pokemon": 560,
- "Traps": 91,
- "Items": 141,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1226,
- "Pokemon": 560,
- "Traps": 91,
- "Items": 141,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1227,
- "Pokemon": 561,
- "Traps": 91,
- "Items": 142,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1228,
- "Pokemon": 561,
- "Traps": 91,
- "Items": 142,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1229,
- "Pokemon": 562,
- "Traps": 91,
- "Items": 142,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1230,
- "Pokemon": 563,
- "Traps": 91,
- "Items": 143,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1231,
- "Pokemon": 563,
- "Traps": 91,
- "Items": 143,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1232,
- "Pokemon": 563,
- "Traps": 91,
- "Items": 143,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1233,
- "Pokemon": 564,
- "Traps": 91,
- "Items": 144,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1234,
- "Pokemon": 564,
- "Traps": 91,
- "Items": 144,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1235,
- "Pokemon": 564,
- "Traps": 91,
- "Items": 144,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1236,
- "Pokemon": 565,
- "Traps": 91,
- "Items": 145,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1237,
- "Pokemon": 565,
- "Traps": 91,
- "Items": 145,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1238,
- "Pokemon": 566,
- "Traps": 91,
- "Items": 145,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1233,
- "Pokemon": 567,
- "Traps": 91,
- "Items": 146,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1239,
- "Pokemon": 567,
- "Traps": 91,
- "Items": 146,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1240,
- "Pokemon": 567,
- "Traps": 91,
- "Items": 146,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1241,
- "Pokemon": 568,
- "Traps": 91,
- "Items": 147,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1242,
- "Pokemon": 568,
- "Traps": 91,
- "Items": 147,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1243,
- "Pokemon": 569,
- "Traps": 91,
- "Items": 147,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1244,
- "Pokemon": 570,
- "Traps": 91,
- "Items": 147,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1245,
- "Pokemon": 570,
- "Traps": 91,
- "Items": 147,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1246,
- "Pokemon": 571,
- "Traps": 91,
- "Items": 147,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1247,
- "Pokemon": 546,
- "Traps": 91,
- "Items": 147,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1248,
- "Pokemon": 546,
- "Traps": 91,
- "Items": 147,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1249,
- "Pokemon": 572,
- "Traps": 91,
- "Items": 147,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1250,
- "Pokemon": 573,
- "Traps": 91,
- "Items": 147,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1251,
- "Pokemon": 573,
- "Traps": 91,
- "Items": 147,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1252,
- "Pokemon": 574,
- "Traps": 91,
- "Items": 147,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1250,
- "Pokemon": 546,
- "Traps": 91,
- "Items": 147,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1251,
- "Pokemon": 546,
- "Traps": 91,
- "Items": 147,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1253,
- "Pokemon": 546,
- "Traps": 91,
- "Items": 147,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1254,
- "Pokemon": 575,
- "Traps": 91,
- "Items": 147,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1255,
- "Pokemon": 575,
- "Traps": 91,
- "Items": 147,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1256,
- "Pokemon": 575,
- "Traps": 91,
- "Items": 147,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- }
- ]
-}
+{
+ "name": "DojoRegistrationFloorID",
+ "tables": [
+ {
+ "MainData": 1191,
+ "Pokemon": 543,
+ "Traps": 91,
+ "Items": 130,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1192,
+ "Pokemon": 543,
+ "Traps": 91,
+ "Items": 130,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1193,
+ "Pokemon": 544,
+ "Traps": 91,
+ "Items": 130,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1194,
+ "Pokemon": 545,
+ "Traps": 91,
+ "Items": 131,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1195,
+ "Pokemon": 545,
+ "Traps": 91,
+ "Items": 131,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1196,
+ "Pokemon": 545,
+ "Traps": 91,
+ "Items": 131,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1197,
+ "Pokemon": 546,
+ "Traps": 91,
+ "Items": 132,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1198,
+ "Pokemon": 546,
+ "Traps": 91,
+ "Items": 132,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1199,
+ "Pokemon": 546,
+ "Traps": 91,
+ "Items": 132,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1200,
+ "Pokemon": 547,
+ "Traps": 91,
+ "Items": 133,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1201,
+ "Pokemon": 547,
+ "Traps": 91,
+ "Items": 133,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1202,
+ "Pokemon": 548,
+ "Traps": 91,
+ "Items": 133,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1203,
+ "Pokemon": 549,
+ "Traps": 91,
+ "Items": 134,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1204,
+ "Pokemon": 549,
+ "Traps": 91,
+ "Items": 134,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1205,
+ "Pokemon": 550,
+ "Traps": 91,
+ "Items": 134,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1206,
+ "Pokemon": 551,
+ "Traps": 91,
+ "Items": 135,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1207,
+ "Pokemon": 551,
+ "Traps": 91,
+ "Items": 135,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1208,
+ "Pokemon": 551,
+ "Traps": 91,
+ "Items": 135,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1209,
+ "Pokemon": 552,
+ "Traps": 91,
+ "Items": 136,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1210,
+ "Pokemon": 552,
+ "Traps": 91,
+ "Items": 136,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1211,
+ "Pokemon": 553,
+ "Traps": 91,
+ "Items": 136,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1212,
+ "Pokemon": 554,
+ "Traps": 91,
+ "Items": 137,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1213,
+ "Pokemon": 554,
+ "Traps": 91,
+ "Items": 137,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1214,
+ "Pokemon": 554,
+ "Traps": 91,
+ "Items": 137,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1215,
+ "Pokemon": 555,
+ "Traps": 91,
+ "Items": 138,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1216,
+ "Pokemon": 555,
+ "Traps": 91,
+ "Items": 138,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1217,
+ "Pokemon": 556,
+ "Traps": 91,
+ "Items": 138,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1218,
+ "Pokemon": 557,
+ "Traps": 91,
+ "Items": 139,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1219,
+ "Pokemon": 557,
+ "Traps": 91,
+ "Items": 139,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1220,
+ "Pokemon": 557,
+ "Traps": 91,
+ "Items": 139,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1221,
+ "Pokemon": 558,
+ "Traps": 91,
+ "Items": 140,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1222,
+ "Pokemon": 558,
+ "Traps": 91,
+ "Items": 140,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1223,
+ "Pokemon": 559,
+ "Traps": 91,
+ "Items": 140,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1224,
+ "Pokemon": 560,
+ "Traps": 91,
+ "Items": 141,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1225,
+ "Pokemon": 560,
+ "Traps": 91,
+ "Items": 141,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1226,
+ "Pokemon": 560,
+ "Traps": 91,
+ "Items": 141,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1227,
+ "Pokemon": 561,
+ "Traps": 91,
+ "Items": 142,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1228,
+ "Pokemon": 561,
+ "Traps": 91,
+ "Items": 142,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1229,
+ "Pokemon": 562,
+ "Traps": 91,
+ "Items": 142,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1230,
+ "Pokemon": 563,
+ "Traps": 91,
+ "Items": 143,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1231,
+ "Pokemon": 563,
+ "Traps": 91,
+ "Items": 143,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1232,
+ "Pokemon": 563,
+ "Traps": 91,
+ "Items": 143,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1233,
+ "Pokemon": 564,
+ "Traps": 91,
+ "Items": 144,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1234,
+ "Pokemon": 564,
+ "Traps": 91,
+ "Items": 144,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1235,
+ "Pokemon": 564,
+ "Traps": 91,
+ "Items": 144,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1236,
+ "Pokemon": 565,
+ "Traps": 91,
+ "Items": 145,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1237,
+ "Pokemon": 565,
+ "Traps": 91,
+ "Items": 145,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1238,
+ "Pokemon": 566,
+ "Traps": 91,
+ "Items": 145,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1233,
+ "Pokemon": 567,
+ "Traps": 91,
+ "Items": 146,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1239,
+ "Pokemon": 567,
+ "Traps": 91,
+ "Items": 146,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1240,
+ "Pokemon": 567,
+ "Traps": 91,
+ "Items": 146,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1241,
+ "Pokemon": 568,
+ "Traps": 91,
+ "Items": 147,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1242,
+ "Pokemon": 568,
+ "Traps": 91,
+ "Items": 147,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1243,
+ "Pokemon": 569,
+ "Traps": 91,
+ "Items": 147,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1244,
+ "Pokemon": 570,
+ "Traps": 91,
+ "Items": 147,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1245,
+ "Pokemon": 570,
+ "Traps": 91,
+ "Items": 147,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1246,
+ "Pokemon": 571,
+ "Traps": 91,
+ "Items": 147,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1247,
+ "Pokemon": 546,
+ "Traps": 91,
+ "Items": 147,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1248,
+ "Pokemon": 546,
+ "Traps": 91,
+ "Items": 147,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1249,
+ "Pokemon": 572,
+ "Traps": 91,
+ "Items": 147,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1250,
+ "Pokemon": 573,
+ "Traps": 91,
+ "Items": 147,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1251,
+ "Pokemon": 573,
+ "Traps": 91,
+ "Items": 147,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1252,
+ "Pokemon": 574,
+ "Traps": 91,
+ "Items": 147,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1250,
+ "Pokemon": 546,
+ "Traps": 91,
+ "Items": 147,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1251,
+ "Pokemon": 546,
+ "Traps": 91,
+ "Items": 147,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1253,
+ "Pokemon": 546,
+ "Traps": 91,
+ "Items": 147,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1254,
+ "Pokemon": 575,
+ "Traps": 91,
+ "Items": 147,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1255,
+ "Pokemon": 575,
+ "Traps": 91,
+ "Items": 147,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1256,
+ "Pokemon": 575,
+ "Traps": 91,
+ "Items": 147,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ }
+ ]
+}
diff --git a/data/dungeon/FantasyStrait/floor_id.json b/data/dungeon/FantasyStrait/floor_id.json
index b948978..38b8b3e 100644
--- a/data/dungeon/FantasyStrait/floor_id.json
+++ b/data/dungeon/FantasyStrait/floor_id.json
@@ -1,275 +1,275 @@
-{
- "name": "FantasyStraitFloorID",
- "tables": [
- {
- "MainData": 1091,
- "Pokemon": 509,
- "Traps": 86,
- "Items": 121,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1092,
- "Pokemon": 509,
- "Traps": 86,
- "Items": 121,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1093,
- "Pokemon": 509,
- "Traps": 86,
- "Items": 121,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1094,
- "Pokemon": 509,
- "Traps": 86,
- "Items": 122,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1095,
- "Pokemon": 510,
- "Traps": 86,
- "Items": 122,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1096,
- "Pokemon": 511,
- "Traps": 86,
- "Items": 122,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1097,
- "Pokemon": 511,
- "Traps": 86,
- "Items": 122,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1098,
- "Pokemon": 511,
- "Traps": 86,
- "Items": 122,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1099,
- "Pokemon": 512,
- "Traps": 86,
- "Items": 122,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1100,
- "Pokemon": 513,
- "Traps": 86,
- "Items": 122,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1101,
- "Pokemon": 513,
- "Traps": 86,
- "Items": 122,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1102,
- "Pokemon": 513,
- "Traps": 86,
- "Items": 122,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1103,
- "Pokemon": 513,
- "Traps": 86,
- "Items": 122,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1104,
- "Pokemon": 514,
- "Traps": 86,
- "Items": 122,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1105,
- "Pokemon": 515,
- "Traps": 86,
- "Items": 122,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1106,
- "Pokemon": 515,
- "Traps": 86,
- "Items": 122,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1107,
- "Pokemon": 515,
- "Traps": 86,
- "Items": 122,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1108,
- "Pokemon": 515,
- "Traps": 86,
- "Items": 122,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1109,
- "Pokemon": 515,
- "Traps": 86,
- "Items": 122,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1110,
- "Pokemon": 516,
- "Traps": 86,
- "Items": 122,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1111,
- "Pokemon": 517,
- "Traps": 86,
- "Items": 122,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1112,
- "Pokemon": 517,
- "Traps": 86,
- "Items": 122,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1113,
- "Pokemon": 517,
- "Traps": 86,
- "Items": 122,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1114,
- "Pokemon": 137,
- "Traps": 86,
- "Items": 122,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1115,
- "Pokemon": 518,
- "Traps": 86,
- "Items": 122,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1116,
- "Pokemon": 519,
- "Traps": 86,
- "Items": 122,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1117,
- "Pokemon": 519,
- "Traps": 86,
- "Items": 122,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1118,
- "Pokemon": 519,
- "Traps": 86,
- "Items": 122,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1119,
- "Pokemon": 519,
- "Traps": 86,
- "Items": 122,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1120,
- "Pokemon": 520,
- "Traps": 86,
- "Items": 122,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- }
- ]
-}
+{
+ "name": "FantasyStraitFloorID",
+ "tables": [
+ {
+ "MainData": 1091,
+ "Pokemon": 509,
+ "Traps": 86,
+ "Items": 121,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1092,
+ "Pokemon": 509,
+ "Traps": 86,
+ "Items": 121,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1093,
+ "Pokemon": 509,
+ "Traps": 86,
+ "Items": 121,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1094,
+ "Pokemon": 509,
+ "Traps": 86,
+ "Items": 122,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1095,
+ "Pokemon": 510,
+ "Traps": 86,
+ "Items": 122,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1096,
+ "Pokemon": 511,
+ "Traps": 86,
+ "Items": 122,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1097,
+ "Pokemon": 511,
+ "Traps": 86,
+ "Items": 122,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1098,
+ "Pokemon": 511,
+ "Traps": 86,
+ "Items": 122,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1099,
+ "Pokemon": 512,
+ "Traps": 86,
+ "Items": 122,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1100,
+ "Pokemon": 513,
+ "Traps": 86,
+ "Items": 122,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1101,
+ "Pokemon": 513,
+ "Traps": 86,
+ "Items": 122,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1102,
+ "Pokemon": 513,
+ "Traps": 86,
+ "Items": 122,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1103,
+ "Pokemon": 513,
+ "Traps": 86,
+ "Items": 122,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1104,
+ "Pokemon": 514,
+ "Traps": 86,
+ "Items": 122,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1105,
+ "Pokemon": 515,
+ "Traps": 86,
+ "Items": 122,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1106,
+ "Pokemon": 515,
+ "Traps": 86,
+ "Items": 122,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1107,
+ "Pokemon": 515,
+ "Traps": 86,
+ "Items": 122,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1108,
+ "Pokemon": 515,
+ "Traps": 86,
+ "Items": 122,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1109,
+ "Pokemon": 515,
+ "Traps": 86,
+ "Items": 122,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1110,
+ "Pokemon": 516,
+ "Traps": 86,
+ "Items": 122,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1111,
+ "Pokemon": 517,
+ "Traps": 86,
+ "Items": 122,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1112,
+ "Pokemon": 517,
+ "Traps": 86,
+ "Items": 122,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1113,
+ "Pokemon": 517,
+ "Traps": 86,
+ "Items": 122,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1114,
+ "Pokemon": 137,
+ "Traps": 86,
+ "Items": 122,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1115,
+ "Pokemon": 518,
+ "Traps": 86,
+ "Items": 122,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1116,
+ "Pokemon": 519,
+ "Traps": 86,
+ "Items": 122,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1117,
+ "Pokemon": 519,
+ "Traps": 86,
+ "Items": 122,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1118,
+ "Pokemon": 519,
+ "Traps": 86,
+ "Items": 122,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1119,
+ "Pokemon": 519,
+ "Traps": 86,
+ "Items": 122,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1120,
+ "Pokemon": 520,
+ "Traps": 86,
+ "Items": 122,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ }
+ ]
+}
diff --git a/data/dungeon/FantasyStraitAlt/floor_id.json b/data/dungeon/FantasyStraitAlt/floor_id.json
index c7945af..b3a4e2d 100644
--- a/data/dungeon/FantasyStraitAlt/floor_id.json
+++ b/data/dungeon/FantasyStraitAlt/floor_id.json
@@ -1,176 +1,176 @@
-{
- "name": "FantasyStraitAltFloorID",
- "tables": [
- {
- "MainData": 1302,
- "Pokemon": 526,
- "Traps": 87,
- "Items": 87,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1303,
- "Pokemon": 526,
- "Traps": 87,
- "Items": 87,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1304,
- "Pokemon": 527,
- "Traps": 87,
- "Items": 87,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1305,
- "Pokemon": 528,
- "Traps": 87,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1306,
- "Pokemon": 529,
- "Traps": 87,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1307,
- "Pokemon": 529,
- "Traps": 87,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1308,
- "Pokemon": 530,
- "Traps": 87,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1309,
- "Pokemon": 530,
- "Traps": 87,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1310,
- "Pokemon": 530,
- "Traps": 87,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1311,
- "Pokemon": 531,
- "Traps": 87,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1312,
- "Pokemon": 531,
- "Traps": 87,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1313,
- "Pokemon": 531,
- "Traps": 87,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1314,
- "Pokemon": 531,
- "Traps": 87,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1315,
- "Pokemon": 534,
- "Traps": 87,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1316,
- "Pokemon": 534,
- "Traps": 87,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1317,
- "Pokemon": 535,
- "Traps": 87,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1318,
- "Pokemon": 535,
- "Traps": 87,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1319,
- "Pokemon": 535,
- "Traps": 87,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1320,
- "Pokemon": 535,
- "Traps": 92,
- "Items": 88,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- }
- ]
-}
+{
+ "name": "FantasyStraitAltFloorID",
+ "tables": [
+ {
+ "MainData": 1302,
+ "Pokemon": 526,
+ "Traps": 87,
+ "Items": 87,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1303,
+ "Pokemon": 526,
+ "Traps": 87,
+ "Items": 87,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1304,
+ "Pokemon": 527,
+ "Traps": 87,
+ "Items": 87,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1305,
+ "Pokemon": 528,
+ "Traps": 87,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1306,
+ "Pokemon": 529,
+ "Traps": 87,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1307,
+ "Pokemon": 529,
+ "Traps": 87,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1308,
+ "Pokemon": 530,
+ "Traps": 87,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1309,
+ "Pokemon": 530,
+ "Traps": 87,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1310,
+ "Pokemon": 530,
+ "Traps": 87,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1311,
+ "Pokemon": 531,
+ "Traps": 87,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1312,
+ "Pokemon": 531,
+ "Traps": 87,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1313,
+ "Pokemon": 531,
+ "Traps": 87,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1314,
+ "Pokemon": 531,
+ "Traps": 87,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1315,
+ "Pokemon": 534,
+ "Traps": 87,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1316,
+ "Pokemon": 534,
+ "Traps": 87,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1317,
+ "Pokemon": 535,
+ "Traps": 87,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1318,
+ "Pokemon": 535,
+ "Traps": 87,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1319,
+ "Pokemon": 535,
+ "Traps": 87,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1320,
+ "Pokemon": 535,
+ "Traps": 92,
+ "Items": 88,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ }
+ ]
+}
diff --git a/data/dungeon/FaroffSea/floor_id.json b/data/dungeon/FaroffSea/floor_id.json
index 473c344..8853274 100644
--- a/data/dungeon/FaroffSea/floor_id.json
+++ b/data/dungeon/FaroffSea/floor_id.json
@@ -1,680 +1,680 @@
-{
- "name": "FarOffSeaFloorID",
- "tables": [
- {
- "MainData": 1450,
- "Pokemon": 689,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1451,
- "Pokemon": 689,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1452,
- "Pokemon": 689,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1453,
- "Pokemon": 689,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1454,
- "Pokemon": 689,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1455,
- "Pokemon": 690,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1456,
- "Pokemon": 690,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1457,
- "Pokemon": 690,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1458,
- "Pokemon": 691,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1459,
- "Pokemon": 692,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1460,
- "Pokemon": 693,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1461,
- "Pokemon": 693,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1462,
- "Pokemon": 693,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1463,
- "Pokemon": 694,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1464,
- "Pokemon": 695,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1465,
- "Pokemon": 695,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1466,
- "Pokemon": 695,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1467,
- "Pokemon": 695,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1468,
- "Pokemon": 695,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1469,
- "Pokemon": 696,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1470,
- "Pokemon": 697,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1471,
- "Pokemon": 697,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1472,
- "Pokemon": 697,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1473,
- "Pokemon": 698,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1474,
- "Pokemon": 698,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1475,
- "Pokemon": 699,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1476,
- "Pokemon": 699,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1477,
- "Pokemon": 699,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1478,
- "Pokemon": 699,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1479,
- "Pokemon": 700,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1480,
- "Pokemon": 701,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1481,
- "Pokemon": 701,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1482,
- "Pokemon": 701,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1483,
- "Pokemon": 701,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1484,
- "Pokemon": 702,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1485,
- "Pokemon": 703,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1486,
- "Pokemon": 704,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1487,
- "Pokemon": 704,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1488,
- "Pokemon": 704,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1489,
- "Pokemon": 705,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1490,
- "Pokemon": 706,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1491,
- "Pokemon": 706,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1492,
- "Pokemon": 706,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1493,
- "Pokemon": 706,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1494,
- "Pokemon": 707,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1495,
- "Pokemon": 707,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1496,
- "Pokemon": 707,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1497,
- "Pokemon": 707,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1498,
- "Pokemon": 707,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1499,
- "Pokemon": 708,
- "Traps": 6,
- "Items": 164,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1500,
- "Pokemon": 709,
- "Traps": 6,
- "Items": 165,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1501,
- "Pokemon": 709,
- "Traps": 6,
- "Items": 165,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1502,
- "Pokemon": 709,
- "Traps": 6,
- "Items": 165,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1503,
- "Pokemon": 709,
- "Traps": 6,
- "Items": 165,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1504,
- "Pokemon": 710,
- "Traps": 6,
- "Items": 165,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1505,
- "Pokemon": 710,
- "Traps": 6,
- "Items": 165,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1506,
- "Pokemon": 710,
- "Traps": 6,
- "Items": 165,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1507,
- "Pokemon": 710,
- "Traps": 6,
- "Items": 165,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1508,
- "Pokemon": 710,
- "Traps": 6,
- "Items": 165,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1509,
- "Pokemon": 711,
- "Traps": 6,
- "Items": 165,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1510,
- "Pokemon": 153,
- "Traps": 6,
- "Items": 165,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1511,
- "Pokemon": 153,
- "Traps": 6,
- "Items": 165,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1512,
- "Pokemon": 153,
- "Traps": 6,
- "Items": 165,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1513,
- "Pokemon": 153,
- "Traps": 6,
- "Items": 165,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1514,
- "Pokemon": 712,
- "Traps": 6,
- "Items": 165,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1515,
- "Pokemon": 712,
- "Traps": 6,
- "Items": 165,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1516,
- "Pokemon": 712,
- "Traps": 6,
- "Items": 165,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1517,
- "Pokemon": 712,
- "Traps": 6,
- "Items": 165,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1518,
- "Pokemon": 712,
- "Traps": 6,
- "Items": 165,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1519,
- "Pokemon": 713,
- "Traps": 6,
- "Items": 165,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1520,
- "Pokemon": 714,
- "Traps": 6,
- "Items": 165,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1521,
- "Pokemon": 714,
- "Traps": 6,
- "Items": 165,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1522,
- "Pokemon": 714,
- "Traps": 6,
- "Items": 165,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1523,
- "Pokemon": 714,
- "Traps": 6,
- "Items": 165,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- },
- {
- "MainData": 1524,
- "Pokemon": 714,
- "Traps": 6,
- "Items": 165,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 62
- }
- ]
-}
+{
+ "name": "FarOffSeaFloorID",
+ "tables": [
+ {
+ "MainData": 1450,
+ "Pokemon": 689,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1451,
+ "Pokemon": 689,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1452,
+ "Pokemon": 689,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1453,
+ "Pokemon": 689,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1454,
+ "Pokemon": 689,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1455,
+ "Pokemon": 690,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1456,
+ "Pokemon": 690,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1457,
+ "Pokemon": 690,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1458,
+ "Pokemon": 691,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1459,
+ "Pokemon": 692,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1460,
+ "Pokemon": 693,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1461,
+ "Pokemon": 693,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1462,
+ "Pokemon": 693,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1463,
+ "Pokemon": 694,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1464,
+ "Pokemon": 695,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1465,
+ "Pokemon": 695,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1466,
+ "Pokemon": 695,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1467,
+ "Pokemon": 695,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1468,
+ "Pokemon": 695,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1469,
+ "Pokemon": 696,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1470,
+ "Pokemon": 697,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1471,
+ "Pokemon": 697,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1472,
+ "Pokemon": 697,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1473,
+ "Pokemon": 698,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1474,
+ "Pokemon": 698,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1475,
+ "Pokemon": 699,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1476,
+ "Pokemon": 699,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1477,
+ "Pokemon": 699,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1478,
+ "Pokemon": 699,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1479,
+ "Pokemon": 700,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1480,
+ "Pokemon": 701,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1481,
+ "Pokemon": 701,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1482,
+ "Pokemon": 701,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1483,
+ "Pokemon": 701,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1484,
+ "Pokemon": 702,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1485,
+ "Pokemon": 703,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1486,
+ "Pokemon": 704,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1487,
+ "Pokemon": 704,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1488,
+ "Pokemon": 704,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1489,
+ "Pokemon": 705,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1490,
+ "Pokemon": 706,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1491,
+ "Pokemon": 706,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1492,
+ "Pokemon": 706,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1493,
+ "Pokemon": 706,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1494,
+ "Pokemon": 707,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1495,
+ "Pokemon": 707,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1496,
+ "Pokemon": 707,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1497,
+ "Pokemon": 707,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1498,
+ "Pokemon": 707,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1499,
+ "Pokemon": 708,
+ "Traps": 6,
+ "Items": 164,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1500,
+ "Pokemon": 709,
+ "Traps": 6,
+ "Items": 165,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1501,
+ "Pokemon": 709,
+ "Traps": 6,
+ "Items": 165,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1502,
+ "Pokemon": 709,
+ "Traps": 6,
+ "Items": 165,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1503,
+ "Pokemon": 709,
+ "Traps": 6,
+ "Items": 165,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1504,
+ "Pokemon": 710,
+ "Traps": 6,
+ "Items": 165,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1505,
+ "Pokemon": 710,
+ "Traps": 6,
+ "Items": 165,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1506,
+ "Pokemon": 710,
+ "Traps": 6,
+ "Items": 165,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1507,
+ "Pokemon": 710,
+ "Traps": 6,
+ "Items": 165,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1508,
+ "Pokemon": 710,
+ "Traps": 6,
+ "Items": 165,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1509,
+ "Pokemon": 711,
+ "Traps": 6,
+ "Items": 165,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1510,
+ "Pokemon": 153,
+ "Traps": 6,
+ "Items": 165,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1511,
+ "Pokemon": 153,
+ "Traps": 6,
+ "Items": 165,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1512,
+ "Pokemon": 153,
+ "Traps": 6,
+ "Items": 165,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1513,
+ "Pokemon": 153,
+ "Traps": 6,
+ "Items": 165,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1514,
+ "Pokemon": 712,
+ "Traps": 6,
+ "Items": 165,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1515,
+ "Pokemon": 712,
+ "Traps": 6,
+ "Items": 165,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1516,
+ "Pokemon": 712,
+ "Traps": 6,
+ "Items": 165,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1517,
+ "Pokemon": 712,
+ "Traps": 6,
+ "Items": 165,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1518,
+ "Pokemon": 712,
+ "Traps": 6,
+ "Items": 165,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1519,
+ "Pokemon": 713,
+ "Traps": 6,
+ "Items": 165,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1520,
+ "Pokemon": 714,
+ "Traps": 6,
+ "Items": 165,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1521,
+ "Pokemon": 714,
+ "Traps": 6,
+ "Items": 165,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1522,
+ "Pokemon": 714,
+ "Traps": 6,
+ "Items": 165,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1523,
+ "Pokemon": 714,
+ "Traps": 6,
+ "Items": 165,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1524,
+ "Pokemon": 714,
+ "Traps": 6,
+ "Items": 165,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 62
+ }
+ ]
+}
diff --git a/data/dungeon/FieryField/floor_id.json b/data/dungeon/FieryField/floor_id.json
index 1f4bdd5..b3b2c00 100644
--- a/data/dungeon/FieryField/floor_id.json
+++ b/data/dungeon/FieryField/floor_id.json
@@ -1,275 +1,275 @@
-{
- "name": "FieryFieldFloorID",
- "tables": [
- {
- "MainData": 840,
- "Pokemon": 381,
- "Traps": 72,
- "Items": 98,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 841,
- "Pokemon": 381,
- "Traps": 72,
- "Items": 98,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 842,
- "Pokemon": 381,
- "Traps": 72,
- "Items": 98,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 843,
- "Pokemon": 382,
- "Traps": 72,
- "Items": 98,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 844,
- "Pokemon": 383,
- "Traps": 72,
- "Items": 98,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 845,
- "Pokemon": 384,
- "Traps": 72,
- "Items": 98,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 846,
- "Pokemon": 384,
- "Traps": 72,
- "Items": 98,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 847,
- "Pokemon": 385,
- "Traps": 72,
- "Items": 98,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 848,
- "Pokemon": 386,
- "Traps": 72,
- "Items": 98,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 849,
- "Pokemon": 387,
- "Traps": 73,
- "Items": 98,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 850,
- "Pokemon": 387,
- "Traps": 74,
- "Items": 98,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 851,
- "Pokemon": 387,
- "Traps": 74,
- "Items": 98,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 852,
- "Pokemon": 387,
- "Traps": 74,
- "Items": 98,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 853,
- "Pokemon": 387,
- "Traps": 74,
- "Items": 98,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 854,
- "Pokemon": 388,
- "Traps": 74,
- "Items": 98,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 855,
- "Pokemon": 388,
- "Traps": 74,
- "Items": 98,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 856,
- "Pokemon": 389,
- "Traps": 74,
- "Items": 98,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 857,
- "Pokemon": 389,
- "Traps": 74,
- "Items": 98,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 858,
- "Pokemon": 389,
- "Traps": 74,
- "Items": 98,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 859,
- "Pokemon": 389,
- "Traps": 74,
- "Items": 98,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 860,
- "Pokemon": 390,
- "Traps": 74,
- "Items": 98,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 861,
- "Pokemon": 391,
- "Traps": 74,
- "Items": 98,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 862,
- "Pokemon": 391,
- "Traps": 74,
- "Items": 98,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 863,
- "Pokemon": 391,
- "Traps": 74,
- "Items": 98,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 864,
- "Pokemon": 392,
- "Traps": 74,
- "Items": 98,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 865,
- "Pokemon": 393,
- "Traps": 74,
- "Items": 98,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 866,
- "Pokemon": 393,
- "Traps": 74,
- "Items": 98,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 867,
- "Pokemon": 393,
- "Traps": 74,
- "Items": 98,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 868,
- "Pokemon": 393,
- "Traps": 74,
- "Items": 99,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 869,
- "Pokemon": 394,
- "Traps": 74,
- "Items": 99,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- }
- ]
-}
+{
+ "name": "FieryFieldFloorID",
+ "tables": [
+ {
+ "MainData": 840,
+ "Pokemon": 381,
+ "Traps": 72,
+ "Items": 98,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 841,
+ "Pokemon": 381,
+ "Traps": 72,
+ "Items": 98,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 842,
+ "Pokemon": 381,
+ "Traps": 72,
+ "Items": 98,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 843,
+ "Pokemon": 382,
+ "Traps": 72,
+ "Items": 98,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 844,
+ "Pokemon": 383,
+ "Traps": 72,
+ "Items": 98,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 845,
+ "Pokemon": 384,
+ "Traps": 72,
+ "Items": 98,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 846,
+ "Pokemon": 384,
+ "Traps": 72,
+ "Items": 98,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 847,
+ "Pokemon": 385,
+ "Traps": 72,
+ "Items": 98,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 848,
+ "Pokemon": 386,
+ "Traps": 72,
+ "Items": 98,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 849,
+ "Pokemon": 387,
+ "Traps": 73,
+ "Items": 98,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 850,
+ "Pokemon": 387,
+ "Traps": 74,
+ "Items": 98,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 851,
+ "Pokemon": 387,
+ "Traps": 74,
+ "Items": 98,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 852,
+ "Pokemon": 387,
+ "Traps": 74,
+ "Items": 98,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 853,
+ "Pokemon": 387,
+ "Traps": 74,
+ "Items": 98,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 854,
+ "Pokemon": 388,
+ "Traps": 74,
+ "Items": 98,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 855,
+ "Pokemon": 388,
+ "Traps": 74,
+ "Items": 98,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 856,
+ "Pokemon": 389,
+ "Traps": 74,
+ "Items": 98,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 857,
+ "Pokemon": 389,
+ "Traps": 74,
+ "Items": 98,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 858,
+ "Pokemon": 389,
+ "Traps": 74,
+ "Items": 98,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 859,
+ "Pokemon": 389,
+ "Traps": 74,
+ "Items": 98,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 860,
+ "Pokemon": 390,
+ "Traps": 74,
+ "Items": 98,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 861,
+ "Pokemon": 391,
+ "Traps": 74,
+ "Items": 98,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 862,
+ "Pokemon": 391,
+ "Traps": 74,
+ "Items": 98,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 863,
+ "Pokemon": 391,
+ "Traps": 74,
+ "Items": 98,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 864,
+ "Pokemon": 392,
+ "Traps": 74,
+ "Items": 98,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 865,
+ "Pokemon": 393,
+ "Traps": 74,
+ "Items": 98,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 866,
+ "Pokemon": 393,
+ "Traps": 74,
+ "Items": 98,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 867,
+ "Pokemon": 393,
+ "Traps": 74,
+ "Items": 98,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 868,
+ "Pokemon": 393,
+ "Traps": 74,
+ "Items": 99,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 869,
+ "Pokemon": 394,
+ "Traps": 74,
+ "Items": 99,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ }
+ ]
+}
diff --git a/data/dungeon/FrostyForest/floor_id.json b/data/dungeon/FrostyForest/floor_id.json
index 538dae7..9e907aa 100644
--- a/data/dungeon/FrostyForest/floor_id.json
+++ b/data/dungeon/FrostyForest/floor_id.json
@@ -1,86 +1,86 @@
-{
- "name": "FrostyForestFloorID",
- "tables": [
- {
- "MainData": 93,
- "Pokemon": 64,
- "Traps": 3,
- "Items": 27,
- "KecleonShop": 28,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 94,
- "Pokemon": 64,
- "Traps": 3,
- "Items": 27,
- "KecleonShop": 28,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 95,
- "Pokemon": 65,
- "Traps": 3,
- "Items": 27,
- "KecleonShop": 28,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 96,
- "Pokemon": 66,
- "Traps": 3,
- "Items": 29,
- "KecleonShop": 28,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 97,
- "Pokemon": 67,
- "Traps": 3,
- "Items": 29,
- "KecleonShop": 28,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 98,
- "Pokemon": 67,
- "Traps": 3,
- "Items": 29,
- "KecleonShop": 28,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 99,
- "Pokemon": 68,
- "Traps": 3,
- "Items": 29,
- "KecleonShop": 28,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 100,
- "Pokemon": 69,
- "Traps": 3,
- "Items": 29,
- "KecleonShop": 28,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 101,
- "Pokemon": 69,
- "Traps": 3,
- "Items": 29,
- "KecleonShop": 28,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- }
- ]
-}
+{
+ "name": "FrostyForestFloorID",
+ "tables": [
+ {
+ "MainData": 93,
+ "Pokemon": 64,
+ "Traps": 3,
+ "Items": 27,
+ "KecleonShop": 28,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 94,
+ "Pokemon": 64,
+ "Traps": 3,
+ "Items": 27,
+ "KecleonShop": 28,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 95,
+ "Pokemon": 65,
+ "Traps": 3,
+ "Items": 27,
+ "KecleonShop": 28,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 96,
+ "Pokemon": 66,
+ "Traps": 3,
+ "Items": 29,
+ "KecleonShop": 28,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 97,
+ "Pokemon": 67,
+ "Traps": 3,
+ "Items": 29,
+ "KecleonShop": 28,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 98,
+ "Pokemon": 67,
+ "Traps": 3,
+ "Items": 29,
+ "KecleonShop": 28,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 99,
+ "Pokemon": 68,
+ "Traps": 3,
+ "Items": 29,
+ "KecleonShop": 28,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 100,
+ "Pokemon": 69,
+ "Traps": 3,
+ "Items": 29,
+ "KecleonShop": 28,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 101,
+ "Pokemon": 69,
+ "Traps": 3,
+ "Items": 29,
+ "KecleonShop": 28,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ }
+ ]
+}
diff --git a/data/dungeon/FrostyForest/pokemon_found.json b/data/dungeon/FrostyForest/pokemon_found.json
index 66e0441..c35cf48 100644
--- a/data/dungeon/FrostyForest/pokemon_found.json
+++ b/data/dungeon/FrostyForest/pokemon_found.json
@@ -1,184 +1,184 @@
-{
- "tables": [{
- "name": "FrostyForest_1F_2F_Pokemon",
- "pokemon": [{
- "species": "SPECIES_FURRET",
- "level": 14,
- "probability": 6250
- },
- {
- "species": "SPECIES_AZURILL",
- "level": 11,
- "probability": 3750
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
-
- "name": "FrostyForest_3F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_FURRET",
- "level": 14,
- "probability": 4167
- },
- {
- "species": "SPECIES_AZURILL",
- "level": 11,
- "probability": 2500
- },
- {
- "species": "SPECIES_NOSEPASS",
- "level": 13,
- "probability": 3333
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
-
- ]
- }, {
- "name": "FrostyForest_4F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_DITTO",
- "level": 25,
- "probability": 1429
- },
- {
- "species": "SPECIES_FURRET",
- "level": 14,
- "probability": 3571
- },
- {
- "species": "SPECIES_PILOSWINE",
- "level": 14,
- "probability": 2143
- },
- {
- "species": "SPECIES_NOSEPASS",
- "level": 13,
- "probability": 2857
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "FrostyForest_5F_6F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_DITTO",
- "level": 25,
- "probability": 2222
- },
- {
- "species": "SPECIES_PILOSWINE",
- "level": 14,
- "probability": 3334
- },
- {
- "species": "SPECIES_NOSEPASS",
- "level": 13,
- "probability": 4444
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "FrostyForest_7F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_DITTO",
- "level": 25,
- "probability": 2000
- },
- {
- "species": "SPECIES_MIGHTYENA",
- "level": 17,
- "probability": 4000
- },
- {
- "species": "SPECIES_LAIRON",
- "level": 17,
- "probability": 4000
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "FrostyForest_8F_9F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_DITTO",
- "level": 25,
- "probability": 1600
- },
- {
- "species": "SPECIES_MIGHTYENA",
- "level": 17,
- "probability": 3200
- },
- {
- "species": "SPECIES_LAIRON",
- "level": 17,
- "probability": 3200
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_SNORUNT",
- "level": 20,
- "probability": 2000
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }
- ]
-}
+{
+ "tables": [{
+ "name": "FrostyForest_1F_2F_Pokemon",
+ "pokemon": [{
+ "species": "SPECIES_FURRET",
+ "level": 14,
+ "probability": 6250
+ },
+ {
+ "species": "SPECIES_AZURILL",
+ "level": 11,
+ "probability": 3750
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+
+ "name": "FrostyForest_3F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_FURRET",
+ "level": 14,
+ "probability": 4167
+ },
+ {
+ "species": "SPECIES_AZURILL",
+ "level": 11,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_NOSEPASS",
+ "level": 13,
+ "probability": 3333
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+
+ ]
+ }, {
+ "name": "FrostyForest_4F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_DITTO",
+ "level": 25,
+ "probability": 1429
+ },
+ {
+ "species": "SPECIES_FURRET",
+ "level": 14,
+ "probability": 3571
+ },
+ {
+ "species": "SPECIES_PILOSWINE",
+ "level": 14,
+ "probability": 2143
+ },
+ {
+ "species": "SPECIES_NOSEPASS",
+ "level": 13,
+ "probability": 2857
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "FrostyForest_5F_6F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_DITTO",
+ "level": 25,
+ "probability": 2222
+ },
+ {
+ "species": "SPECIES_PILOSWINE",
+ "level": 14,
+ "probability": 3334
+ },
+ {
+ "species": "SPECIES_NOSEPASS",
+ "level": 13,
+ "probability": 4444
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "FrostyForest_7F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_DITTO",
+ "level": 25,
+ "probability": 2000
+ },
+ {
+ "species": "SPECIES_MIGHTYENA",
+ "level": 17,
+ "probability": 4000
+ },
+ {
+ "species": "SPECIES_LAIRON",
+ "level": 17,
+ "probability": 4000
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "FrostyForest_8F_9F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_DITTO",
+ "level": 25,
+ "probability": 1600
+ },
+ {
+ "species": "SPECIES_MIGHTYENA",
+ "level": 17,
+ "probability": 3200
+ },
+ {
+ "species": "SPECIES_LAIRON",
+ "level": 17,
+ "probability": 3200
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_SNORUNT",
+ "level": 20,
+ "probability": 2000
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }
+ ]
+}
diff --git a/data/dungeon/FrostyGrotto/floor_id.json b/data/dungeon/FrostyGrotto/floor_id.json
index 886b207..2b8c806 100644
--- a/data/dungeon/FrostyGrotto/floor_id.json
+++ b/data/dungeon/FrostyGrotto/floor_id.json
@@ -1,50 +1,50 @@
-{
- "name": "FrostyGrottoFloorID",
- "tables": [
- {
- "MainData": 102,
- "Pokemon": 70,
- "Traps": 3,
- "Items": 30,
- "KecleonShop": 28,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 103,
- "Pokemon": 70,
- "Traps": 3,
- "Items": 30,
- "KecleonShop": 28,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 104,
- "Pokemon": 70,
- "Traps": 3,
- "Items": 30,
- "KecleonShop": 28,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 105,
- "Pokemon": 70,
- "Traps": 3,
- "Items": 31,
- "KecleonShop": 28,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 106,
- "Pokemon": 71,
- "Traps": 3,
- "Items": 31,
- "KecleonShop": 28,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- }
- ]
-}
+{
+ "name": "FrostyGrottoFloorID",
+ "tables": [
+ {
+ "MainData": 102,
+ "Pokemon": 70,
+ "Traps": 3,
+ "Items": 30,
+ "KecleonShop": 28,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 103,
+ "Pokemon": 70,
+ "Traps": 3,
+ "Items": 30,
+ "KecleonShop": 28,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 104,
+ "Pokemon": 70,
+ "Traps": 3,
+ "Items": 30,
+ "KecleonShop": 28,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 105,
+ "Pokemon": 70,
+ "Traps": 3,
+ "Items": 31,
+ "KecleonShop": 28,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 106,
+ "Pokemon": 71,
+ "Traps": 3,
+ "Items": 31,
+ "KecleonShop": 28,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ }
+ ]
+}
diff --git a/data/dungeon/FrostyGrotto/pokemon_found.json b/data/dungeon/FrostyGrotto/pokemon_found.json
index 65ad404..241f094 100644
--- a/data/dungeon/FrostyGrotto/pokemon_found.json
+++ b/data/dungeon/FrostyGrotto/pokemon_found.json
@@ -1,47 +1,47 @@
-{
- "tables": [{
- "name": "FrostyGrotto_1F_4F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_RHYHORN",
- "level": 16,
- "probability": 5000
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_METANG",
- "level": 17,
- "probability": 5000
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "FrostyGrotto_5F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_ARTICUNO",
- "level": 33,
- "probability": 10000
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }
- ]
-}
+{
+ "tables": [{
+ "name": "FrostyGrotto_1F_4F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_RHYHORN",
+ "level": 16,
+ "probability": 5000
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_METANG",
+ "level": 17,
+ "probability": 5000
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "FrostyGrotto_5F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_ARTICUNO",
+ "level": 33,
+ "probability": 10000
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }
+ ]
+}
diff --git a/data/dungeon/GrandSea/floor_id.json b/data/dungeon/GrandSea/floor_id.json
index 4f3333d..a69fa5c 100644
--- a/data/dungeon/GrandSea/floor_id.json
+++ b/data/dungeon/GrandSea/floor_id.json
@@ -1,275 +1,275 @@
-{
- "name": "GrandSeaFloorID",
- "tables": [
- {
- "MainData": 996,
- "Pokemon": 460,
- "Traps": 6,
- "Items": 113,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 997,
- "Pokemon": 460,
- "Traps": 6,
- "Items": 113,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 998,
- "Pokemon": 460,
- "Traps": 6,
- "Items": 113,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 999,
- "Pokemon": 460,
- "Traps": 6,
- "Items": 114,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 1000,
- "Pokemon": 461,
- "Traps": 6,
- "Items": 114,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 1001,
- "Pokemon": 462,
- "Traps": 6,
- "Items": 114,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 1002,
- "Pokemon": 462,
- "Traps": 6,
- "Items": 114,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 1003,
- "Pokemon": 462,
- "Traps": 6,
- "Items": 114,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 1004,
- "Pokemon": 462,
- "Traps": 6,
- "Items": 114,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 1005,
- "Pokemon": 463,
- "Traps": 6,
- "Items": 114,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 1006,
- "Pokemon": 464,
- "Traps": 6,
- "Items": 114,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 1007,
- "Pokemon": 464,
- "Traps": 6,
- "Items": 114,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 1008,
- "Pokemon": 464,
- "Traps": 6,
- "Items": 114,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 1009,
- "Pokemon": 465,
- "Traps": 6,
- "Items": 114,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 1010,
- "Pokemon": 466,
- "Traps": 6,
- "Items": 114,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 1011,
- "Pokemon": 467,
- "Traps": 6,
- "Items": 114,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 1012,
- "Pokemon": 467,
- "Traps": 6,
- "Items": 114,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 1013,
- "Pokemon": 467,
- "Traps": 6,
- "Items": 114,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 1014,
- "Pokemon": 467,
- "Traps": 6,
- "Items": 114,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 1015,
- "Pokemon": 468,
- "Traps": 6,
- "Items": 114,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 1016,
- "Pokemon": 469,
- "Traps": 6,
- "Items": 114,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 1017,
- "Pokemon": 469,
- "Traps": 6,
- "Items": 114,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 1018,
- "Pokemon": 469,
- "Traps": 6,
- "Items": 114,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 1019,
- "Pokemon": 470,
- "Traps": 6,
- "Items": 114,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 1020,
- "Pokemon": 471,
- "Traps": 6,
- "Items": 114,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 1021,
- "Pokemon": 472,
- "Traps": 6,
- "Items": 114,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 1022,
- "Pokemon": 473,
- "Traps": 6,
- "Items": 114,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 1023,
- "Pokemon": 473,
- "Traps": 6,
- "Items": 114,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 1024,
- "Pokemon": 473,
- "Traps": 6,
- "Items": 114,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 1025,
- "Pokemon": 474,
- "Traps": 6,
- "Items": 114,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- }
- ]
-}
+{
+ "name": "GrandSeaFloorID",
+ "tables": [
+ {
+ "MainData": 996,
+ "Pokemon": 460,
+ "Traps": 6,
+ "Items": 113,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 997,
+ "Pokemon": 460,
+ "Traps": 6,
+ "Items": 113,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 998,
+ "Pokemon": 460,
+ "Traps": 6,
+ "Items": 113,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 999,
+ "Pokemon": 460,
+ "Traps": 6,
+ "Items": 114,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1000,
+ "Pokemon": 461,
+ "Traps": 6,
+ "Items": 114,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1001,
+ "Pokemon": 462,
+ "Traps": 6,
+ "Items": 114,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1002,
+ "Pokemon": 462,
+ "Traps": 6,
+ "Items": 114,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1003,
+ "Pokemon": 462,
+ "Traps": 6,
+ "Items": 114,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1004,
+ "Pokemon": 462,
+ "Traps": 6,
+ "Items": 114,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1005,
+ "Pokemon": 463,
+ "Traps": 6,
+ "Items": 114,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1006,
+ "Pokemon": 464,
+ "Traps": 6,
+ "Items": 114,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1007,
+ "Pokemon": 464,
+ "Traps": 6,
+ "Items": 114,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1008,
+ "Pokemon": 464,
+ "Traps": 6,
+ "Items": 114,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1009,
+ "Pokemon": 465,
+ "Traps": 6,
+ "Items": 114,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1010,
+ "Pokemon": 466,
+ "Traps": 6,
+ "Items": 114,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1011,
+ "Pokemon": 467,
+ "Traps": 6,
+ "Items": 114,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1012,
+ "Pokemon": 467,
+ "Traps": 6,
+ "Items": 114,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1013,
+ "Pokemon": 467,
+ "Traps": 6,
+ "Items": 114,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1014,
+ "Pokemon": 467,
+ "Traps": 6,
+ "Items": 114,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1015,
+ "Pokemon": 468,
+ "Traps": 6,
+ "Items": 114,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1016,
+ "Pokemon": 469,
+ "Traps": 6,
+ "Items": 114,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1017,
+ "Pokemon": 469,
+ "Traps": 6,
+ "Items": 114,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1018,
+ "Pokemon": 469,
+ "Traps": 6,
+ "Items": 114,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1019,
+ "Pokemon": 470,
+ "Traps": 6,
+ "Items": 114,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1020,
+ "Pokemon": 471,
+ "Traps": 6,
+ "Items": 114,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1021,
+ "Pokemon": 472,
+ "Traps": 6,
+ "Items": 114,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1022,
+ "Pokemon": 473,
+ "Traps": 6,
+ "Items": 114,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1023,
+ "Pokemon": 473,
+ "Traps": 6,
+ "Items": 114,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1024,
+ "Pokemon": 473,
+ "Traps": 6,
+ "Items": 114,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1025,
+ "Pokemon": 474,
+ "Traps": 6,
+ "Items": 114,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ }
+ ]
+}
diff --git a/data/dungeon/GreatCanyon/floor_id.json b/data/dungeon/GreatCanyon/floor_id.json
index 064c14e..2e30d01 100644
--- a/data/dungeon/GreatCanyon/floor_id.json
+++ b/data/dungeon/GreatCanyon/floor_id.json
@@ -1,113 +1,113 @@
-{
- "name": "GreatCanyonFloorID",
- "tables": [
- {
- "MainData": 52,
- "Pokemon": 39,
- "Traps": 3,
- "Items": 18,
- "KecleonShop": 19,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 53,
- "Pokemon": 39,
- "Traps": 3,
- "Items": 18,
- "KecleonShop": 19,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 54,
- "Pokemon": 39,
- "Traps": 3,
- "Items": 18,
- "KecleonShop": 19,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 55,
- "Pokemon": 40,
- "Traps": 3,
- "Items": 20,
- "KecleonShop": 19,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 56,
- "Pokemon": 41,
- "Traps": 3,
- "Items": 20,
- "KecleonShop": 19,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 57,
- "Pokemon": 42,
- "Traps": 3,
- "Items": 20,
- "KecleonShop": 19,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 58,
- "Pokemon": 43,
- "Traps": 3,
- "Items": 20,
- "KecleonShop": 19,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 59,
- "Pokemon": 44,
- "Traps": 3,
- "Items": 20,
- "KecleonShop": 19,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 60,
- "Pokemon": 45,
- "Traps": 3,
- "Items": 20,
- "KecleonShop": 19,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 61,
- "Pokemon": 46,
- "Traps": 3,
- "Items": 20,
- "KecleonShop": 19,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 62,
- "Pokemon": 46,
- "Traps": 3,
- "Items": 20,
- "KecleonShop": 19,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 63,
- "Pokemon": 47,
- "Traps": 3,
- "Items": 20,
- "KecleonShop": 19,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- }
- ]
-}
+{
+ "name": "GreatCanyonFloorID",
+ "tables": [
+ {
+ "MainData": 52,
+ "Pokemon": 39,
+ "Traps": 3,
+ "Items": 18,
+ "KecleonShop": 19,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 53,
+ "Pokemon": 39,
+ "Traps": 3,
+ "Items": 18,
+ "KecleonShop": 19,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 54,
+ "Pokemon": 39,
+ "Traps": 3,
+ "Items": 18,
+ "KecleonShop": 19,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 55,
+ "Pokemon": 40,
+ "Traps": 3,
+ "Items": 20,
+ "KecleonShop": 19,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 56,
+ "Pokemon": 41,
+ "Traps": 3,
+ "Items": 20,
+ "KecleonShop": 19,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 57,
+ "Pokemon": 42,
+ "Traps": 3,
+ "Items": 20,
+ "KecleonShop": 19,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 58,
+ "Pokemon": 43,
+ "Traps": 3,
+ "Items": 20,
+ "KecleonShop": 19,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 59,
+ "Pokemon": 44,
+ "Traps": 3,
+ "Items": 20,
+ "KecleonShop": 19,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 60,
+ "Pokemon": 45,
+ "Traps": 3,
+ "Items": 20,
+ "KecleonShop": 19,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 61,
+ "Pokemon": 46,
+ "Traps": 3,
+ "Items": 20,
+ "KecleonShop": 19,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 62,
+ "Pokemon": 46,
+ "Traps": 3,
+ "Items": 20,
+ "KecleonShop": 19,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 63,
+ "Pokemon": 47,
+ "Traps": 3,
+ "Items": 20,
+ "KecleonShop": 19,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ }
+ ]
+}
diff --git a/data/dungeon/GreatCanyon/pokemon_found.json b/data/dungeon/GreatCanyon/pokemon_found.json
index c7af421..bf2dde4 100644
--- a/data/dungeon/GreatCanyon/pokemon_found.json
+++ b/data/dungeon/GreatCanyon/pokemon_found.json
@@ -1,284 +1,284 @@
-{
- "tables": [{
- "name": "GreatCanyon_1F_3F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_DODUO",
- "level": 14,
- "probability": 1429
- },
- {
- "species": "SPECIES_SKIPLOOM",
- "level": 13,
- "probability": 2857
- },
- {
- "species": "SPECIES_DUNSPARCE",
- "level": 13,
- "probability": 2857
- },
- {
- "species": "SPECIES_PHANPY",
- "level": 14,
- "probability": 2857
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "GreatCanyon_4F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_VILEPLUME",
- "level": 14,
- "probability": 4000
- },
- {
- "species": "SPECIES_DODUO",
- "level": 14,
- "probability": 2000
- },
- {
- "species": "SPECIES_BRELOOM",
- "level": 14,
- "probability": 4000
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "GreatCanyon_5F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_VILEPLUME",
- "level": 14,
- "probability": 2500
- },
- {
- "species": "SPECIES_MURKROW",
- "level": 14,
- "probability": 2500
- },
- {
- "species": "SPECIES_BRELOOM",
- "level": 14,
- "probability": 2500
- },
- {
- "species": "SPECIES_CACTURNE",
- "level": 14,
- "probability": 2500
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "GreatCanyon_6F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_VILEPLUME",
- "level": 14,
- "probability": 2000
- },
- {
- "species": "SPECIES_NOCTOWL",
- "level": 14,
- "probability": 2000
- },
- {
- "species": "SPECIES_MURKROW",
- "level": 14,
- "probability": 2000
- },
- {
- "species": "SPECIES_BRELOOM",
- "level": 14,
- "probability": 2000
- },
- {
- "species": "SPECIES_CACTURNE",
- "level": 14,
- "probability": 2000
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "GreatCanyon_7F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_NOCTOWL",
- "level": 14,
- "probability": 2500
- },
- {
- "species": "SPECIES_MURKROW",
- "level": 14,
- "probability": 2500
- },
- {
- "species": "SPECIES_HERACROSS",
- "level": 14,
- "probability": 2500
- },
- {
- "species": "SPECIES_CACTURNE",
- "level": 14,
- "probability": 2500
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "GreatCanyon_8F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_NOCTOWL",
- "level": 14,
- "probability": 2500
- },
- {
- "species": "SPECIES_ARIADOS",
- "level": 14,
- "probability": 2500
- },
- {
- "species": "SPECIES_HERACROSS",
- "level": 14,
- "probability": 2500
- },
- {
- "species": "SPECIES_CACTURNE",
- "level": 14,
- "probability": 2500
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "GreatCanyon_9F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_ARIADOS",
- "level": 14,
- "probability": 5000
- },
- {
- "species": "SPECIES_HERACROSS",
- "level": 14,
- "probability": 5000
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "GreatCanyon_10F_11F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_TAUROS",
- "level": 15,
- "probability": 3077
- },
- {
- "species": "SPECIES_ARIADOS",
- "level": 14,
- "probability": 3077
- },
- {
- "species": "SPECIES_HOUNDOOM",
- "level": 15,
- "probability": 3846
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "GreatCanyon_12F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_TAUROS",
- "level": 15,
- "probability": 4444
- },
- {
- "species": "SPECIES_HOUNDOOM",
- "level": 15,
- "probability": 5556
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }]
-}
+{
+ "tables": [{
+ "name": "GreatCanyon_1F_3F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_DODUO",
+ "level": 14,
+ "probability": 1429
+ },
+ {
+ "species": "SPECIES_SKIPLOOM",
+ "level": 13,
+ "probability": 2857
+ },
+ {
+ "species": "SPECIES_DUNSPARCE",
+ "level": 13,
+ "probability": 2857
+ },
+ {
+ "species": "SPECIES_PHANPY",
+ "level": 14,
+ "probability": 2857
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "GreatCanyon_4F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_VILEPLUME",
+ "level": 14,
+ "probability": 4000
+ },
+ {
+ "species": "SPECIES_DODUO",
+ "level": 14,
+ "probability": 2000
+ },
+ {
+ "species": "SPECIES_BRELOOM",
+ "level": 14,
+ "probability": 4000
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "GreatCanyon_5F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_VILEPLUME",
+ "level": 14,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_MURKROW",
+ "level": 14,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_BRELOOM",
+ "level": 14,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_CACTURNE",
+ "level": 14,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "GreatCanyon_6F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_VILEPLUME",
+ "level": 14,
+ "probability": 2000
+ },
+ {
+ "species": "SPECIES_NOCTOWL",
+ "level": 14,
+ "probability": 2000
+ },
+ {
+ "species": "SPECIES_MURKROW",
+ "level": 14,
+ "probability": 2000
+ },
+ {
+ "species": "SPECIES_BRELOOM",
+ "level": 14,
+ "probability": 2000
+ },
+ {
+ "species": "SPECIES_CACTURNE",
+ "level": 14,
+ "probability": 2000
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "GreatCanyon_7F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_NOCTOWL",
+ "level": 14,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_MURKROW",
+ "level": 14,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_HERACROSS",
+ "level": 14,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_CACTURNE",
+ "level": 14,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "GreatCanyon_8F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_NOCTOWL",
+ "level": 14,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_ARIADOS",
+ "level": 14,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_HERACROSS",
+ "level": 14,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_CACTURNE",
+ "level": 14,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "GreatCanyon_9F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_ARIADOS",
+ "level": 14,
+ "probability": 5000
+ },
+ {
+ "species": "SPECIES_HERACROSS",
+ "level": 14,
+ "probability": 5000
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "GreatCanyon_10F_11F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_TAUROS",
+ "level": 15,
+ "probability": 3077
+ },
+ {
+ "species": "SPECIES_ARIADOS",
+ "level": 14,
+ "probability": 3077
+ },
+ {
+ "species": "SPECIES_HOUNDOOM",
+ "level": 15,
+ "probability": 3846
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "GreatCanyon_12F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_TAUROS",
+ "level": 15,
+ "probability": 4444
+ },
+ {
+ "species": "SPECIES_HOUNDOOM",
+ "level": 15,
+ "probability": 5556
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }]
+}
diff --git a/data/dungeon/HowlingForest/floor_id.json b/data/dungeon/HowlingForest/floor_id.json
index 71262ba..e24db95 100644
--- a/data/dungeon/HowlingForest/floor_id.json
+++ b/data/dungeon/HowlingForest/floor_id.json
@@ -1,140 +1,140 @@
-{
- "name": "HowlingForestFloorID",
- "tables": [
- {
- "MainData": 1257,
- "Pokemon": 576,
- "Traps": 10,
- "Items": 148,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1258,
- "Pokemon": 576,
- "Traps": 10,
- "Items": 148,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1259,
- "Pokemon": 576,
- "Traps": 10,
- "Items": 148,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1260,
- "Pokemon": 577,
- "Traps": 10,
- "Items": 149,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1261,
- "Pokemon": 578,
- "Traps": 10,
- "Items": 149,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1262,
- "Pokemon": 578,
- "Traps": 10,
- "Items": 149,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1263,
- "Pokemon": 579,
- "Traps": 10,
- "Items": 150,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1264,
- "Pokemon": 579,
- "Traps": 10,
- "Items": 150,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1265,
- "Pokemon": 580,
- "Traps": 10,
- "Items": 150,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1266,
- "Pokemon": 580,
- "Traps": 10,
- "Items": 150,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1267,
- "Pokemon": 581,
- "Traps": 10,
- "Items": 150,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1268,
- "Pokemon": 582,
- "Traps": 10,
- "Items": 150,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1269,
- "Pokemon": 582,
- "Traps": 10,
- "Items": 150,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1270,
- "Pokemon": 583,
- "Traps": 10,
- "Items": 150,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1271,
- "Pokemon": 584,
- "Traps": 10,
- "Items": 150,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- }
- ]
-}
+{
+ "name": "HowlingForestFloorID",
+ "tables": [
+ {
+ "MainData": 1257,
+ "Pokemon": 576,
+ "Traps": 10,
+ "Items": 148,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1258,
+ "Pokemon": 576,
+ "Traps": 10,
+ "Items": 148,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1259,
+ "Pokemon": 576,
+ "Traps": 10,
+ "Items": 148,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1260,
+ "Pokemon": 577,
+ "Traps": 10,
+ "Items": 149,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1261,
+ "Pokemon": 578,
+ "Traps": 10,
+ "Items": 149,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1262,
+ "Pokemon": 578,
+ "Traps": 10,
+ "Items": 149,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1263,
+ "Pokemon": 579,
+ "Traps": 10,
+ "Items": 150,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1264,
+ "Pokemon": 579,
+ "Traps": 10,
+ "Items": 150,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1265,
+ "Pokemon": 580,
+ "Traps": 10,
+ "Items": 150,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1266,
+ "Pokemon": 580,
+ "Traps": 10,
+ "Items": 150,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1267,
+ "Pokemon": 581,
+ "Traps": 10,
+ "Items": 150,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1268,
+ "Pokemon": 582,
+ "Traps": 10,
+ "Items": 150,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1269,
+ "Pokemon": 582,
+ "Traps": 10,
+ "Items": 150,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1270,
+ "Pokemon": 583,
+ "Traps": 10,
+ "Items": 150,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1271,
+ "Pokemon": 584,
+ "Traps": 10,
+ "Items": 150,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ }
+ ]
+}
diff --git a/data/dungeon/JoyousTower/floor_id.json b/data/dungeon/JoyousTower/floor_id.json
index c78c93c..7dfa4e1 100644
--- a/data/dungeon/JoyousTower/floor_id.json
+++ b/data/dungeon/JoyousTower/floor_id.json
@@ -1,896 +1,896 @@
-{
- "name": "JoyousTowerFloorID",
- "tables": [
- {
- "MainData": 1351,
- "Pokemon": 611,
- "Traps": 94,
- "Items": 157,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1352,
- "Pokemon": 612,
- "Traps": 30,
- "Items": 157,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1353,
- "Pokemon": 613,
- "Traps": 30,
- "Items": 157,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1354,
- "Pokemon": 614,
- "Traps": 30,
- "Items": 159,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1355,
- "Pokemon": 615,
- "Traps": 30,
- "Items": 159,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1356,
- "Pokemon": 616,
- "Traps": 30,
- "Items": 159,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1357,
- "Pokemon": 617,
- "Traps": 30,
- "Items": 159,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1358,
- "Pokemon": 618,
- "Traps": 30,
- "Items": 159,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1359,
- "Pokemon": 619,
- "Traps": 30,
- "Items": 159,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1360,
- "Pokemon": 619,
- "Traps": 95,
- "Items": 159,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1361,
- "Pokemon": 620,
- "Traps": 96,
- "Items": 159,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1362,
- "Pokemon": 621,
- "Traps": 96,
- "Items": 159,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1363,
- "Pokemon": 622,
- "Traps": 95,
- "Items": 159,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1364,
- "Pokemon": 623,
- "Traps": 95,
- "Items": 159,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1365,
- "Pokemon": 624,
- "Traps": 95,
- "Items": 159,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1366,
- "Pokemon": 625,
- "Traps": 95,
- "Items": 159,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1367,
- "Pokemon": 626,
- "Traps": 95,
- "Items": 159,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1368,
- "Pokemon": 627,
- "Traps": 95,
- "Items": 159,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1369,
- "Pokemon": 628,
- "Traps": 95,
- "Items": 159,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1370,
- "Pokemon": 629,
- "Traps": 97,
- "Items": 159,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1371,
- "Pokemon": 630,
- "Traps": 98,
- "Items": 159,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1372,
- "Pokemon": 631,
- "Traps": 98,
- "Items": 159,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1373,
- "Pokemon": 632,
- "Traps": 98,
- "Items": 159,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1374,
- "Pokemon": 633,
- "Traps": 98,
- "Items": 159,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1375,
- "Pokemon": 634,
- "Traps": 98,
- "Items": 159,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1376,
- "Pokemon": 635,
- "Traps": 98,
- "Items": 160,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1377,
- "Pokemon": 636,
- "Traps": 98,
- "Items": 160,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1378,
- "Pokemon": 637,
- "Traps": 98,
- "Items": 160,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1379,
- "Pokemon": 638,
- "Traps": 98,
- "Items": 160,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1380,
- "Pokemon": 639,
- "Traps": 99,
- "Items": 160,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1381,
- "Pokemon": 640,
- "Traps": 100,
- "Items": 160,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1382,
- "Pokemon": 640,
- "Traps": 100,
- "Items": 160,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1383,
- "Pokemon": 641,
- "Traps": 100,
- "Items": 160,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1384,
- "Pokemon": 641,
- "Traps": 100,
- "Items": 160,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1385,
- "Pokemon": 642,
- "Traps": 100,
- "Items": 160,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1386,
- "Pokemon": 643,
- "Traps": 100,
- "Items": 160,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1387,
- "Pokemon": 644,
- "Traps": 100,
- "Items": 160,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1388,
- "Pokemon": 644,
- "Traps": 100,
- "Items": 160,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1389,
- "Pokemon": 645,
- "Traps": 100,
- "Items": 160,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1390,
- "Pokemon": 646,
- "Traps": 101,
- "Items": 160,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1391,
- "Pokemon": 647,
- "Traps": 101,
- "Items": 160,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1392,
- "Pokemon": 648,
- "Traps": 101,
- "Items": 160,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1393,
- "Pokemon": 649,
- "Traps": 101,
- "Items": 160,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1394,
- "Pokemon": 650,
- "Traps": 101,
- "Items": 160,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1395,
- "Pokemon": 651,
- "Traps": 101,
- "Items": 160,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1396,
- "Pokemon": 652,
- "Traps": 101,
- "Items": 160,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1397,
- "Pokemon": 653,
- "Traps": 101,
- "Items": 160,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1398,
- "Pokemon": 653,
- "Traps": 101,
- "Items": 160,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1399,
- "Pokemon": 653,
- "Traps": 101,
- "Items": 160,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1400,
- "Pokemon": 654,
- "Traps": 102,
- "Items": 160,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1401,
- "Pokemon": 655,
- "Traps": 103,
- "Items": 160,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1402,
- "Pokemon": 656,
- "Traps": 103,
- "Items": 160,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1403,
- "Pokemon": 657,
- "Traps": 103,
- "Items": 160,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1404,
- "Pokemon": 657,
- "Traps": 103,
- "Items": 160,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1405,
- "Pokemon": 658,
- "Traps": 103,
- "Items": 160,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1406,
- "Pokemon": 659,
- "Traps": 103,
- "Items": 160,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1407,
- "Pokemon": 660,
- "Traps": 103,
- "Items": 160,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1408,
- "Pokemon": 661,
- "Traps": 103,
- "Items": 160,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1409,
- "Pokemon": 662,
- "Traps": 103,
- "Items": 160,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1410,
- "Pokemon": 663,
- "Traps": 104,
- "Items": 161,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1411,
- "Pokemon": 664,
- "Traps": 104,
- "Items": 161,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1412,
- "Pokemon": 665,
- "Traps": 104,
- "Items": 161,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1413,
- "Pokemon": 666,
- "Traps": 104,
- "Items": 161,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1414,
- "Pokemon": 666,
- "Traps": 104,
- "Items": 161,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1415,
- "Pokemon": 667,
- "Traps": 104,
- "Items": 161,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1416,
- "Pokemon": 668,
- "Traps": 104,
- "Items": 161,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1417,
- "Pokemon": 669,
- "Traps": 104,
- "Items": 161,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1418,
- "Pokemon": 670,
- "Traps": 104,
- "Items": 161,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1419,
- "Pokemon": 670,
- "Traps": 104,
- "Items": 161,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1420,
- "Pokemon": 671,
- "Traps": 105,
- "Items": 161,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1421,
- "Pokemon": 672,
- "Traps": 106,
- "Items": 161,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1422,
- "Pokemon": 673,
- "Traps": 106,
- "Items": 161,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1423,
- "Pokemon": 673,
- "Traps": 107,
- "Items": 161,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1424,
- "Pokemon": 674,
- "Traps": 108,
- "Items": 161,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1425,
- "Pokemon": 674,
- "Traps": 106,
- "Items": 161,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1426,
- "Pokemon": 675,
- "Traps": 106,
- "Items": 161,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1427,
- "Pokemon": 676,
- "Traps": 106,
- "Items": 161,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1428,
- "Pokemon": 677,
- "Traps": 106,
- "Items": 162,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1429,
- "Pokemon": 678,
- "Traps": 109,
- "Items": 162,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1430,
- "Pokemon": 679,
- "Traps": 110,
- "Items": 162,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1431,
- "Pokemon": 679,
- "Traps": 111,
- "Items": 162,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1432,
- "Pokemon": 679,
- "Traps": 111,
- "Items": 162,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1433,
- "Pokemon": 680,
- "Traps": 111,
- "Items": 162,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1434,
- "Pokemon": 680,
- "Traps": 111,
- "Items": 162,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1435,
- "Pokemon": 681,
- "Traps": 111,
- "Items": 162,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1436,
- "Pokemon": 682,
- "Traps": 111,
- "Items": 162,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1437,
- "Pokemon": 682,
- "Traps": 111,
- "Items": 162,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1438,
- "Pokemon": 683,
- "Traps": 111,
- "Items": 162,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1439,
- "Pokemon": 684,
- "Traps": 111,
- "Items": 162,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1440,
- "Pokemon": 685,
- "Traps": 111,
- "Items": 162,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1441,
- "Pokemon": 685,
- "Traps": 111,
- "Items": 163,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1442,
- "Pokemon": 686,
- "Traps": 111,
- "Items": 163,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1443,
- "Pokemon": 687,
- "Traps": 111,
- "Items": 163,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1444,
- "Pokemon": 688,
- "Traps": 111,
- "Items": 163,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1445,
- "Pokemon": 688,
- "Traps": 111,
- "Items": 163,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1446,
- "Pokemon": 688,
- "Traps": 111,
- "Items": 163,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1447,
- "Pokemon": 688,
- "Traps": 111,
- "Items": 163,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1448,
- "Pokemon": 688,
- "Traps": 111,
- "Items": 163,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 1449,
- "Pokemon": 688,
- "Traps": 111,
- "Items": 163,
- "KecleonShop": 158,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- }
- ]
-}
+{
+ "name": "JoyousTowerFloorID",
+ "tables": [
+ {
+ "MainData": 1351,
+ "Pokemon": 611,
+ "Traps": 94,
+ "Items": 157,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1352,
+ "Pokemon": 612,
+ "Traps": 30,
+ "Items": 157,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1353,
+ "Pokemon": 613,
+ "Traps": 30,
+ "Items": 157,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1354,
+ "Pokemon": 614,
+ "Traps": 30,
+ "Items": 159,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1355,
+ "Pokemon": 615,
+ "Traps": 30,
+ "Items": 159,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1356,
+ "Pokemon": 616,
+ "Traps": 30,
+ "Items": 159,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1357,
+ "Pokemon": 617,
+ "Traps": 30,
+ "Items": 159,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1358,
+ "Pokemon": 618,
+ "Traps": 30,
+ "Items": 159,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1359,
+ "Pokemon": 619,
+ "Traps": 30,
+ "Items": 159,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1360,
+ "Pokemon": 619,
+ "Traps": 95,
+ "Items": 159,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1361,
+ "Pokemon": 620,
+ "Traps": 96,
+ "Items": 159,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1362,
+ "Pokemon": 621,
+ "Traps": 96,
+ "Items": 159,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1363,
+ "Pokemon": 622,
+ "Traps": 95,
+ "Items": 159,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1364,
+ "Pokemon": 623,
+ "Traps": 95,
+ "Items": 159,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1365,
+ "Pokemon": 624,
+ "Traps": 95,
+ "Items": 159,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1366,
+ "Pokemon": 625,
+ "Traps": 95,
+ "Items": 159,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1367,
+ "Pokemon": 626,
+ "Traps": 95,
+ "Items": 159,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1368,
+ "Pokemon": 627,
+ "Traps": 95,
+ "Items": 159,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1369,
+ "Pokemon": 628,
+ "Traps": 95,
+ "Items": 159,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1370,
+ "Pokemon": 629,
+ "Traps": 97,
+ "Items": 159,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1371,
+ "Pokemon": 630,
+ "Traps": 98,
+ "Items": 159,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1372,
+ "Pokemon": 631,
+ "Traps": 98,
+ "Items": 159,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1373,
+ "Pokemon": 632,
+ "Traps": 98,
+ "Items": 159,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1374,
+ "Pokemon": 633,
+ "Traps": 98,
+ "Items": 159,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1375,
+ "Pokemon": 634,
+ "Traps": 98,
+ "Items": 159,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1376,
+ "Pokemon": 635,
+ "Traps": 98,
+ "Items": 160,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1377,
+ "Pokemon": 636,
+ "Traps": 98,
+ "Items": 160,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1378,
+ "Pokemon": 637,
+ "Traps": 98,
+ "Items": 160,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1379,
+ "Pokemon": 638,
+ "Traps": 98,
+ "Items": 160,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1380,
+ "Pokemon": 639,
+ "Traps": 99,
+ "Items": 160,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1381,
+ "Pokemon": 640,
+ "Traps": 100,
+ "Items": 160,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1382,
+ "Pokemon": 640,
+ "Traps": 100,
+ "Items": 160,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1383,
+ "Pokemon": 641,
+ "Traps": 100,
+ "Items": 160,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1384,
+ "Pokemon": 641,
+ "Traps": 100,
+ "Items": 160,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1385,
+ "Pokemon": 642,
+ "Traps": 100,
+ "Items": 160,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1386,
+ "Pokemon": 643,
+ "Traps": 100,
+ "Items": 160,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1387,
+ "Pokemon": 644,
+ "Traps": 100,
+ "Items": 160,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1388,
+ "Pokemon": 644,
+ "Traps": 100,
+ "Items": 160,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1389,
+ "Pokemon": 645,
+ "Traps": 100,
+ "Items": 160,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1390,
+ "Pokemon": 646,
+ "Traps": 101,
+ "Items": 160,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1391,
+ "Pokemon": 647,
+ "Traps": 101,
+ "Items": 160,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1392,
+ "Pokemon": 648,
+ "Traps": 101,
+ "Items": 160,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1393,
+ "Pokemon": 649,
+ "Traps": 101,
+ "Items": 160,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1394,
+ "Pokemon": 650,
+ "Traps": 101,
+ "Items": 160,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1395,
+ "Pokemon": 651,
+ "Traps": 101,
+ "Items": 160,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1396,
+ "Pokemon": 652,
+ "Traps": 101,
+ "Items": 160,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1397,
+ "Pokemon": 653,
+ "Traps": 101,
+ "Items": 160,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1398,
+ "Pokemon": 653,
+ "Traps": 101,
+ "Items": 160,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1399,
+ "Pokemon": 653,
+ "Traps": 101,
+ "Items": 160,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1400,
+ "Pokemon": 654,
+ "Traps": 102,
+ "Items": 160,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1401,
+ "Pokemon": 655,
+ "Traps": 103,
+ "Items": 160,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1402,
+ "Pokemon": 656,
+ "Traps": 103,
+ "Items": 160,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1403,
+ "Pokemon": 657,
+ "Traps": 103,
+ "Items": 160,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1404,
+ "Pokemon": 657,
+ "Traps": 103,
+ "Items": 160,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1405,
+ "Pokemon": 658,
+ "Traps": 103,
+ "Items": 160,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1406,
+ "Pokemon": 659,
+ "Traps": 103,
+ "Items": 160,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1407,
+ "Pokemon": 660,
+ "Traps": 103,
+ "Items": 160,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1408,
+ "Pokemon": 661,
+ "Traps": 103,
+ "Items": 160,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1409,
+ "Pokemon": 662,
+ "Traps": 103,
+ "Items": 160,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1410,
+ "Pokemon": 663,
+ "Traps": 104,
+ "Items": 161,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1411,
+ "Pokemon": 664,
+ "Traps": 104,
+ "Items": 161,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1412,
+ "Pokemon": 665,
+ "Traps": 104,
+ "Items": 161,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1413,
+ "Pokemon": 666,
+ "Traps": 104,
+ "Items": 161,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1414,
+ "Pokemon": 666,
+ "Traps": 104,
+ "Items": 161,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1415,
+ "Pokemon": 667,
+ "Traps": 104,
+ "Items": 161,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1416,
+ "Pokemon": 668,
+ "Traps": 104,
+ "Items": 161,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1417,
+ "Pokemon": 669,
+ "Traps": 104,
+ "Items": 161,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1418,
+ "Pokemon": 670,
+ "Traps": 104,
+ "Items": 161,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1419,
+ "Pokemon": 670,
+ "Traps": 104,
+ "Items": 161,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1420,
+ "Pokemon": 671,
+ "Traps": 105,
+ "Items": 161,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1421,
+ "Pokemon": 672,
+ "Traps": 106,
+ "Items": 161,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1422,
+ "Pokemon": 673,
+ "Traps": 106,
+ "Items": 161,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1423,
+ "Pokemon": 673,
+ "Traps": 107,
+ "Items": 161,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1424,
+ "Pokemon": 674,
+ "Traps": 108,
+ "Items": 161,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1425,
+ "Pokemon": 674,
+ "Traps": 106,
+ "Items": 161,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1426,
+ "Pokemon": 675,
+ "Traps": 106,
+ "Items": 161,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1427,
+ "Pokemon": 676,
+ "Traps": 106,
+ "Items": 161,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1428,
+ "Pokemon": 677,
+ "Traps": 106,
+ "Items": 162,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1429,
+ "Pokemon": 678,
+ "Traps": 109,
+ "Items": 162,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1430,
+ "Pokemon": 679,
+ "Traps": 110,
+ "Items": 162,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1431,
+ "Pokemon": 679,
+ "Traps": 111,
+ "Items": 162,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1432,
+ "Pokemon": 679,
+ "Traps": 111,
+ "Items": 162,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1433,
+ "Pokemon": 680,
+ "Traps": 111,
+ "Items": 162,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1434,
+ "Pokemon": 680,
+ "Traps": 111,
+ "Items": 162,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1435,
+ "Pokemon": 681,
+ "Traps": 111,
+ "Items": 162,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1436,
+ "Pokemon": 682,
+ "Traps": 111,
+ "Items": 162,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1437,
+ "Pokemon": 682,
+ "Traps": 111,
+ "Items": 162,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1438,
+ "Pokemon": 683,
+ "Traps": 111,
+ "Items": 162,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1439,
+ "Pokemon": 684,
+ "Traps": 111,
+ "Items": 162,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1440,
+ "Pokemon": 685,
+ "Traps": 111,
+ "Items": 162,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1441,
+ "Pokemon": 685,
+ "Traps": 111,
+ "Items": 163,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1442,
+ "Pokemon": 686,
+ "Traps": 111,
+ "Items": 163,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1443,
+ "Pokemon": 687,
+ "Traps": 111,
+ "Items": 163,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1444,
+ "Pokemon": 688,
+ "Traps": 111,
+ "Items": 163,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1445,
+ "Pokemon": 688,
+ "Traps": 111,
+ "Items": 163,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1446,
+ "Pokemon": 688,
+ "Traps": 111,
+ "Items": 163,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1447,
+ "Pokemon": 688,
+ "Traps": 111,
+ "Items": 163,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1448,
+ "Pokemon": 688,
+ "Traps": 111,
+ "Items": 163,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1449,
+ "Pokemon": 688,
+ "Traps": 111,
+ "Items": 163,
+ "KecleonShop": 158,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ }
+ ]
+}
diff --git a/data/dungeon/LapisCave/floor_id.json b/data/dungeon/LapisCave/floor_id.json
index ef52aa7..9ea5aca 100644
--- a/data/dungeon/LapisCave/floor_id.json
+++ b/data/dungeon/LapisCave/floor_id.json
@@ -1,131 +1,131 @@
-{
- "name": "LapisCaveFloorID",
- "tables": [
- {
- "MainData": 64,
- "Pokemon": 48,
- "Traps": 4,
- "Items": 21,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 65,
- "Pokemon": 48,
- "Traps": 4,
- "Items": 21,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 66,
- "Pokemon": 48,
- "Traps": 4,
- "Items": 21,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 67,
- "Pokemon": 49,
- "Traps": 4,
- "Items": 21,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 68,
- "Pokemon": 50,
- "Traps": 4,
- "Items": 22,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 69,
- "Pokemon": 50,
- "Traps": 4,
- "Items": 22,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 70,
- "Pokemon": 50,
- "Traps": 4,
- "Items": 23,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 71,
- "Pokemon": 50,
- "Traps": 4,
- "Items": 23,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 72,
- "Pokemon": 51,
- "Traps": 4,
- "Items": 23,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 73,
- "Pokemon": 51,
- "Traps": 4,
- "Items": 23,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 74,
- "Pokemon": 52,
- "Traps": 4,
- "Items": 23,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 75,
- "Pokemon": 52,
- "Traps": 4,
- "Items": 23,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 76,
- "Pokemon": 53,
- "Traps": 4,
- "Items": 23,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 77,
- "Pokemon": 54,
- "Traps": 4,
- "Items": 23,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- }
- ]
-}
+{
+ "name": "LapisCaveFloorID",
+ "tables": [
+ {
+ "MainData": 64,
+ "Pokemon": 48,
+ "Traps": 4,
+ "Items": 21,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 65,
+ "Pokemon": 48,
+ "Traps": 4,
+ "Items": 21,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 66,
+ "Pokemon": 48,
+ "Traps": 4,
+ "Items": 21,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 67,
+ "Pokemon": 49,
+ "Traps": 4,
+ "Items": 21,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 68,
+ "Pokemon": 50,
+ "Traps": 4,
+ "Items": 22,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 69,
+ "Pokemon": 50,
+ "Traps": 4,
+ "Items": 22,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 70,
+ "Pokemon": 50,
+ "Traps": 4,
+ "Items": 23,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 71,
+ "Pokemon": 50,
+ "Traps": 4,
+ "Items": 23,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 72,
+ "Pokemon": 51,
+ "Traps": 4,
+ "Items": 23,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 73,
+ "Pokemon": 51,
+ "Traps": 4,
+ "Items": 23,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 74,
+ "Pokemon": 52,
+ "Traps": 4,
+ "Items": 23,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 75,
+ "Pokemon": 52,
+ "Traps": 4,
+ "Items": 23,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 76,
+ "Pokemon": 53,
+ "Traps": 4,
+ "Items": 23,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 77,
+ "Pokemon": 54,
+ "Traps": 4,
+ "Items": 23,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ }
+ ]
+}
diff --git a/data/dungeon/LapisCave/pokemon_found.json b/data/dungeon/LapisCave/pokemon_found.json
index 4e46b1c..7964480 100644
--- a/data/dungeon/LapisCave/pokemon_found.json
+++ b/data/dungeon/LapisCave/pokemon_found.json
@@ -1,174 +1,174 @@
-{
- "tables": [{
- "name": "LapisCave_1F_3F_Pokemon",
- "pokemon": [{
- "species": "SPECIES_ZUBAT",
- "level": 17,
- "probability": 5000
- },
- {
- "species": "SPECIES_NINCADA",
- "level": 14,
- "probability": 5000
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "LapisCave_4F_Pokemon",
- "pokemon": [{
- "species": "SPECIES_NIDORINA",
- "level": 15,
- "probability": 3333
- },
- {
- "species": "SPECIES_NIDORINO",
- "level": 15,
- "probability": 3334
- },
- {
- "species": "SPECIES_NINCADA",
- "level": 14,
- "probability": 3333
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "LapisCave_5F_8F_Pokemon",
- "pokemon": [{
- "species": "SPECIES_NIDORINA",
- "level": 15,
- "probability": 3333
- },
- {
- "species": "SPECIES_NIDORINO",
- "level": 15,
- "probability": 3334
- },
- {
- "species": "SPECIES_ILLIMISE",
- "level": 15,
- "probability": 3333
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "LapisCave_9F_10F_Pokemon",
- "pokemon": [{
- "species": "SPECIES_TANGELA",
- "level": 14,
- "probability": 5000
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_BAGON",
- "level": 16,
- "probability": 5000
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "LapisCave_11F_12F_Pokemon",
- "pokemon": [{
- "species": "SPECIES_GOLBAT",
- "level": 10,
- "probability": 3333
- },
- {
- "species": "SPECIES_TANGELA",
- "level": 14,
- "probability": 3334
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_BAGON",
- "level": 16,
- "probability": 3333
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "LapisCave_13F_Pokemon",
- "pokemon": [{
- "species": "SPECIES_GOLBAT",
- "level": 10,
- "probability": 5000
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_BAGON",
- "level": 16,
- "probability": 5000
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "LapisCave_14F_Pokemon",
- "pokemon": [{
- "species": "SPECIES_GOLBAT",
- "level": 10,
- "probability": 10000
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }]
-}
+{
+ "tables": [{
+ "name": "LapisCave_1F_3F_Pokemon",
+ "pokemon": [{
+ "species": "SPECIES_ZUBAT",
+ "level": 17,
+ "probability": 5000
+ },
+ {
+ "species": "SPECIES_NINCADA",
+ "level": 14,
+ "probability": 5000
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "LapisCave_4F_Pokemon",
+ "pokemon": [{
+ "species": "SPECIES_NIDORINA",
+ "level": 15,
+ "probability": 3333
+ },
+ {
+ "species": "SPECIES_NIDORINO",
+ "level": 15,
+ "probability": 3334
+ },
+ {
+ "species": "SPECIES_NINCADA",
+ "level": 14,
+ "probability": 3333
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "LapisCave_5F_8F_Pokemon",
+ "pokemon": [{
+ "species": "SPECIES_NIDORINA",
+ "level": 15,
+ "probability": 3333
+ },
+ {
+ "species": "SPECIES_NIDORINO",
+ "level": 15,
+ "probability": 3334
+ },
+ {
+ "species": "SPECIES_ILLIMISE",
+ "level": 15,
+ "probability": 3333
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "LapisCave_9F_10F_Pokemon",
+ "pokemon": [{
+ "species": "SPECIES_TANGELA",
+ "level": 14,
+ "probability": 5000
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_BAGON",
+ "level": 16,
+ "probability": 5000
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "LapisCave_11F_12F_Pokemon",
+ "pokemon": [{
+ "species": "SPECIES_GOLBAT",
+ "level": 10,
+ "probability": 3333
+ },
+ {
+ "species": "SPECIES_TANGELA",
+ "level": 14,
+ "probability": 3334
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_BAGON",
+ "level": 16,
+ "probability": 3333
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "LapisCave_13F_Pokemon",
+ "pokemon": [{
+ "species": "SPECIES_GOLBAT",
+ "level": 10,
+ "probability": 5000
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_BAGON",
+ "level": 16,
+ "probability": 5000
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "LapisCave_14F_Pokemon",
+ "pokemon": [{
+ "species": "SPECIES_GOLBAT",
+ "level": 10,
+ "probability": 10000
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }]
+}
diff --git a/data/dungeon/LightningField/floor_id.json b/data/dungeon/LightningField/floor_id.json
index 222b181..3cb8074 100644
--- a/data/dungeon/LightningField/floor_id.json
+++ b/data/dungeon/LightningField/floor_id.json
@@ -1,275 +1,275 @@
-{
- "name": "LightningFieldFloorID",
- "tables": [
- {
- "MainData": 920,
- "Pokemon": 427,
- "Traps": 72,
- "Items": 105,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 921,
- "Pokemon": 427,
- "Traps": 72,
- "Items": 105,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 922,
- "Pokemon": 427,
- "Traps": 72,
- "Items": 105,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 923,
- "Pokemon": 427,
- "Traps": 72,
- "Items": 105,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 924,
- "Pokemon": 427,
- "Traps": 72,
- "Items": 105,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 925,
- "Pokemon": 428,
- "Traps": 72,
- "Items": 105,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 926,
- "Pokemon": 429,
- "Traps": 72,
- "Items": 105,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 927,
- "Pokemon": 430,
- "Traps": 72,
- "Items": 105,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 928,
- "Pokemon": 430,
- "Traps": 72,
- "Items": 105,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 929,
- "Pokemon": 430,
- "Traps": 73,
- "Items": 105,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 930,
- "Pokemon": 431,
- "Traps": 74,
- "Items": 105,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 931,
- "Pokemon": 431,
- "Traps": 74,
- "Items": 105,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 932,
- "Pokemon": 431,
- "Traps": 74,
- "Items": 105,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 933,
- "Pokemon": 432,
- "Traps": 74,
- "Items": 105,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 934,
- "Pokemon": 433,
- "Traps": 74,
- "Items": 105,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 935,
- "Pokemon": 434,
- "Traps": 74,
- "Items": 105,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 936,
- "Pokemon": 434,
- "Traps": 74,
- "Items": 105,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 937,
- "Pokemon": 435,
- "Traps": 74,
- "Items": 105,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 938,
- "Pokemon": 435,
- "Traps": 74,
- "Items": 105,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 939,
- "Pokemon": 436,
- "Traps": 74,
- "Items": 105,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 940,
- "Pokemon": 436,
- "Traps": 74,
- "Items": 105,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 941,
- "Pokemon": 437,
- "Traps": 74,
- "Items": 105,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 942,
- "Pokemon": 438,
- "Traps": 74,
- "Items": 105,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 943,
- "Pokemon": 438,
- "Traps": 74,
- "Items": 105,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 944,
- "Pokemon": 439,
- "Traps": 74,
- "Items": 105,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 945,
- "Pokemon": 440,
- "Traps": 74,
- "Items": 105,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 946,
- "Pokemon": 440,
- "Traps": 74,
- "Items": 105,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 947,
- "Pokemon": 440,
- "Traps": 74,
- "Items": 105,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 948,
- "Pokemon": 441,
- "Traps": 74,
- "Items": 106,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 949,
- "Pokemon": 442,
- "Traps": 74,
- "Items": 106,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- }
- ]
-}
+{
+ "name": "LightningFieldFloorID",
+ "tables": [
+ {
+ "MainData": 920,
+ "Pokemon": 427,
+ "Traps": 72,
+ "Items": 105,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 921,
+ "Pokemon": 427,
+ "Traps": 72,
+ "Items": 105,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 922,
+ "Pokemon": 427,
+ "Traps": 72,
+ "Items": 105,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 923,
+ "Pokemon": 427,
+ "Traps": 72,
+ "Items": 105,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 924,
+ "Pokemon": 427,
+ "Traps": 72,
+ "Items": 105,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 925,
+ "Pokemon": 428,
+ "Traps": 72,
+ "Items": 105,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 926,
+ "Pokemon": 429,
+ "Traps": 72,
+ "Items": 105,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 927,
+ "Pokemon": 430,
+ "Traps": 72,
+ "Items": 105,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 928,
+ "Pokemon": 430,
+ "Traps": 72,
+ "Items": 105,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 929,
+ "Pokemon": 430,
+ "Traps": 73,
+ "Items": 105,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 930,
+ "Pokemon": 431,
+ "Traps": 74,
+ "Items": 105,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 931,
+ "Pokemon": 431,
+ "Traps": 74,
+ "Items": 105,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 932,
+ "Pokemon": 431,
+ "Traps": 74,
+ "Items": 105,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 933,
+ "Pokemon": 432,
+ "Traps": 74,
+ "Items": 105,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 934,
+ "Pokemon": 433,
+ "Traps": 74,
+ "Items": 105,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 935,
+ "Pokemon": 434,
+ "Traps": 74,
+ "Items": 105,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 936,
+ "Pokemon": 434,
+ "Traps": 74,
+ "Items": 105,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 937,
+ "Pokemon": 435,
+ "Traps": 74,
+ "Items": 105,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 938,
+ "Pokemon": 435,
+ "Traps": 74,
+ "Items": 105,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 939,
+ "Pokemon": 436,
+ "Traps": 74,
+ "Items": 105,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 940,
+ "Pokemon": 436,
+ "Traps": 74,
+ "Items": 105,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 941,
+ "Pokemon": 437,
+ "Traps": 74,
+ "Items": 105,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 942,
+ "Pokemon": 438,
+ "Traps": 74,
+ "Items": 105,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 943,
+ "Pokemon": 438,
+ "Traps": 74,
+ "Items": 105,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 944,
+ "Pokemon": 439,
+ "Traps": 74,
+ "Items": 105,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 945,
+ "Pokemon": 440,
+ "Traps": 74,
+ "Items": 105,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 946,
+ "Pokemon": 440,
+ "Traps": 74,
+ "Items": 105,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 947,
+ "Pokemon": 440,
+ "Traps": 74,
+ "Items": 105,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 948,
+ "Pokemon": 441,
+ "Traps": 74,
+ "Items": 106,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 949,
+ "Pokemon": 442,
+ "Traps": 74,
+ "Items": 106,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ }
+ ]
+}
diff --git a/data/dungeon/MagmaCavern/floor_id.json b/data/dungeon/MagmaCavern/floor_id.json
index d9d59d5..23dcfdd 100644
--- a/data/dungeon/MagmaCavern/floor_id.json
+++ b/data/dungeon/MagmaCavern/floor_id.json
@@ -1,212 +1,212 @@
-{
- "name": "MagmaCavernFloorID",
- "tables": [
- {
- "MainData": 127,
- "Pokemon": 81,
- "Traps": 4,
- "Items": 36,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 128,
- "Pokemon": 81,
- "Traps": 4,
- "Items": 36,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 129,
- "Pokemon": 81,
- "Traps": 4,
- "Items": 36,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 130,
- "Pokemon": 82,
- "Traps": 4,
- "Items": 38,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 131,
- "Pokemon": 83,
- "Traps": 4,
- "Items": 38,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 132,
- "Pokemon": 83,
- "Traps": 4,
- "Items": 38,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 133,
- "Pokemon": 84,
- "Traps": 4,
- "Items": 38,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 134,
- "Pokemon": 85,
- "Traps": 4,
- "Items": 38,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 135,
- "Pokemon": 86,
- "Traps": 4,
- "Items": 38,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 136,
- "Pokemon": 86,
- "Traps": 4,
- "Items": 39,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 137,
- "Pokemon": 87,
- "Traps": 4,
- "Items": 39,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 138,
- "Pokemon": 88,
- "Traps": 4,
- "Items": 39,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 139,
- "Pokemon": 89,
- "Traps": 4,
- "Items": 39,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 140,
- "Pokemon": 90,
- "Traps": 4,
- "Items": 39,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 141,
- "Pokemon": 91,
- "Traps": 4,
- "Items": 39,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 142,
- "Pokemon": 91,
- "Traps": 4,
- "Items": 39,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 143,
- "Pokemon": 91,
- "Traps": 4,
- "Items": 39,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 144,
- "Pokemon": 91,
- "Traps": 4,
- "Items": 39,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 145,
- "Pokemon": 91,
- "Traps": 4,
- "Items": 39,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 146,
- "Pokemon": 91,
- "Traps": 4,
- "Items": 39,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 147,
- "Pokemon": 92,
- "Traps": 4,
- "Items": 39,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 148,
- "Pokemon": 93,
- "Traps": 4,
- "Items": 39,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 149,
- "Pokemon": 93,
- "Traps": 4,
- "Items": 39,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- }
- ]
-}
+{
+ "name": "MagmaCavernFloorID",
+ "tables": [
+ {
+ "MainData": 127,
+ "Pokemon": 81,
+ "Traps": 4,
+ "Items": 36,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 128,
+ "Pokemon": 81,
+ "Traps": 4,
+ "Items": 36,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 129,
+ "Pokemon": 81,
+ "Traps": 4,
+ "Items": 36,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 130,
+ "Pokemon": 82,
+ "Traps": 4,
+ "Items": 38,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 131,
+ "Pokemon": 83,
+ "Traps": 4,
+ "Items": 38,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 132,
+ "Pokemon": 83,
+ "Traps": 4,
+ "Items": 38,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 133,
+ "Pokemon": 84,
+ "Traps": 4,
+ "Items": 38,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 134,
+ "Pokemon": 85,
+ "Traps": 4,
+ "Items": 38,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 135,
+ "Pokemon": 86,
+ "Traps": 4,
+ "Items": 38,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 136,
+ "Pokemon": 86,
+ "Traps": 4,
+ "Items": 39,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 137,
+ "Pokemon": 87,
+ "Traps": 4,
+ "Items": 39,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 138,
+ "Pokemon": 88,
+ "Traps": 4,
+ "Items": 39,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 139,
+ "Pokemon": 89,
+ "Traps": 4,
+ "Items": 39,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 140,
+ "Pokemon": 90,
+ "Traps": 4,
+ "Items": 39,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 141,
+ "Pokemon": 91,
+ "Traps": 4,
+ "Items": 39,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 142,
+ "Pokemon": 91,
+ "Traps": 4,
+ "Items": 39,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 143,
+ "Pokemon": 91,
+ "Traps": 4,
+ "Items": 39,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 144,
+ "Pokemon": 91,
+ "Traps": 4,
+ "Items": 39,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 145,
+ "Pokemon": 91,
+ "Traps": 4,
+ "Items": 39,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 146,
+ "Pokemon": 91,
+ "Traps": 4,
+ "Items": 39,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 147,
+ "Pokemon": 92,
+ "Traps": 4,
+ "Items": 39,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 148,
+ "Pokemon": 93,
+ "Traps": 4,
+ "Items": 39,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 149,
+ "Pokemon": 93,
+ "Traps": 4,
+ "Items": 39,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ }
+ ]
+}
diff --git a/data/dungeon/MagmaCavern/pokemon_found.json b/data/dungeon/MagmaCavern/pokemon_found.json
index 59411a2..d40c6af 100644
--- a/data/dungeon/MagmaCavern/pokemon_found.json
+++ b/data/dungeon/MagmaCavern/pokemon_found.json
@@ -1,391 +1,391 @@
-{
- "tables": [{
- "name": "MagmaCavern_1F_3F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_RATICATE",
- "level": 19,
- "probability": 2500
- },
- {
- "species": "SPECIES_SANDSHREW",
- "level": 20,
- "probability": 2500
- },
- {
- "species": "SPECIES_NIDOQUEEN",
- "level": 20,
- "probability": 2500
- },
- {
- "species": "SPECIES_NIDOKING",
- "level": 21,
- "probability": 2500
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "MagmaCavern_4F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_SANDSHREW",
- "level": 20,
- "probability": 3333
- },
- {
- "species": "SPECIES_NIDOQUEEN",
- "level": 20,
- "probability": 3334
- },
- {
- "species": "SPECIES_NIDOKING",
- "level": 21,
- "probability": 3333
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "MagmaCavern_5F_6F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_SANDSHREW",
- "level": 20,
- "probability": 2500
- },
- {
- "species": "SPECIES_NIDOQUEEN",
- "level": 20,
- "probability": 2500
- },
- {
- "species": "SPECIES_NIDOKING",
- "level": 21,
- "probability": 2500
- },
- {
- "species": "SPECIES_GRAVELER",
- "level": 22,
- "probability": 2500
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "MagmaCavern_7F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_GRAVELER",
- "level": 22,
- "probability": 5000
- },
- {
- "species": "SPECIES_MAGMAR",
- "level": 21,
- "probability": 5000
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "MagmaCavern_8F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_ARBOK",
- "level": 21,
- "probability": 2500
- },
- {
- "species": "SPECIES_GRAVELER",
- "level": 22,
- "probability": 2500
- },
- {
- "species": "SPECIES_MAGMAR",
- "level": 21,
- "probability": 2500
- },
- {
- "species": "SPECIES_MAWILE",
- "level": 20,
- "probability": 2500
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "MagmaCavern_9F_10F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_ARBOK",
- "level": 21,
- "probability": 2000
- },
- {
- "species": "SPECIES_GRAVELER",
- "level": 22,
- "probability": 2000
- },
- {
- "species": "SPECIES_MAGMAR",
- "level": 21,
- "probability": 2000
- },
- {
- "species": "SPECIES_MAGCARGO",
- "level": 21,
- "probability": 2000
- },
- {
- "species": "SPECIES_MAWILE",
- "level": 20,
- "probability": 2000
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "MagmaCavern_11F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_ARBOK",
- "level": 21,
- "probability": 2500
- },
- {
- "species": "SPECIES_MAGMAR",
- "level": 21,
- "probability": 2500
- },
- {
- "species": "SPECIES_MAGCARGO",
- "level": 21,
- "probability": 2500
- },
- {
- "species": "SPECIES_MAWILE",
- "level": 20,
- "probability": 2500
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "MagmaCavern_12F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_ARBOK",
- "level": 21,
- "probability": 3333
- },
- {
- "species": "SPECIES_MAGCARGO",
- "level": 21,
- "probability": 3334
- },
- {
- "species": "SPECIES_MAWILE",
- "level": 20,
- "probability": 3333
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "MagmaCavern_13F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_ARBOK",
- "level": 21,
- "probability": 5000
- },
- {
- "species": "SPECIES_MAGCARGO",
- "level": 21,
- "probability": 5000
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "MagmaCavern_14F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_ARBOK",
- "level": 21,
- "probability": 3333
- },
- {
- "species": "SPECIES_RHYDON",
- "level": 23,
- "probability": 3334
- },
- {
- "species": "SPECIES_MAGCARGO",
- "level": 21,
- "probability": 3333
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "MagmaCavern_15F_20F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_SANDSLASH",
- "level": 24,
- "probability": 2500
- },
- {
- "species": "SPECIES_GOLEM",
- "level": 15,
- "probability": 2500
- },
- {
- "species": "SPECIES_GRIMER",
- "level": 20,
- "probability": 2500
- },
- {
- "species": "SPECIES_RHYDON",
- "level": 23,
- "probability": 2500
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "MagmaCavern_21F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_GRIMER",
- "level": 20,
- "probability": 8000
- },
- {
- "species": "SPECIES_ONIX",
- "level": 30,
- "probability": 2000
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "MagmaCavern_22F_23F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_ONIX",
- "level": 30,
- "probability": 10000
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }
- ]
-}
+{
+ "tables": [{
+ "name": "MagmaCavern_1F_3F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_RATICATE",
+ "level": 19,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_SANDSHREW",
+ "level": 20,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_NIDOQUEEN",
+ "level": 20,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_NIDOKING",
+ "level": 21,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "MagmaCavern_4F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_SANDSHREW",
+ "level": 20,
+ "probability": 3333
+ },
+ {
+ "species": "SPECIES_NIDOQUEEN",
+ "level": 20,
+ "probability": 3334
+ },
+ {
+ "species": "SPECIES_NIDOKING",
+ "level": 21,
+ "probability": 3333
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "MagmaCavern_5F_6F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_SANDSHREW",
+ "level": 20,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_NIDOQUEEN",
+ "level": 20,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_NIDOKING",
+ "level": 21,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_GRAVELER",
+ "level": 22,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "MagmaCavern_7F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_GRAVELER",
+ "level": 22,
+ "probability": 5000
+ },
+ {
+ "species": "SPECIES_MAGMAR",
+ "level": 21,
+ "probability": 5000
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "MagmaCavern_8F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_ARBOK",
+ "level": 21,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_GRAVELER",
+ "level": 22,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_MAGMAR",
+ "level": 21,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_MAWILE",
+ "level": 20,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "MagmaCavern_9F_10F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_ARBOK",
+ "level": 21,
+ "probability": 2000
+ },
+ {
+ "species": "SPECIES_GRAVELER",
+ "level": 22,
+ "probability": 2000
+ },
+ {
+ "species": "SPECIES_MAGMAR",
+ "level": 21,
+ "probability": 2000
+ },
+ {
+ "species": "SPECIES_MAGCARGO",
+ "level": 21,
+ "probability": 2000
+ },
+ {
+ "species": "SPECIES_MAWILE",
+ "level": 20,
+ "probability": 2000
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "MagmaCavern_11F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_ARBOK",
+ "level": 21,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_MAGMAR",
+ "level": 21,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_MAGCARGO",
+ "level": 21,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_MAWILE",
+ "level": 20,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "MagmaCavern_12F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_ARBOK",
+ "level": 21,
+ "probability": 3333
+ },
+ {
+ "species": "SPECIES_MAGCARGO",
+ "level": 21,
+ "probability": 3334
+ },
+ {
+ "species": "SPECIES_MAWILE",
+ "level": 20,
+ "probability": 3333
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "MagmaCavern_13F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_ARBOK",
+ "level": 21,
+ "probability": 5000
+ },
+ {
+ "species": "SPECIES_MAGCARGO",
+ "level": 21,
+ "probability": 5000
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "MagmaCavern_14F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_ARBOK",
+ "level": 21,
+ "probability": 3333
+ },
+ {
+ "species": "SPECIES_RHYDON",
+ "level": 23,
+ "probability": 3334
+ },
+ {
+ "species": "SPECIES_MAGCARGO",
+ "level": 21,
+ "probability": 3333
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "MagmaCavern_15F_20F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_SANDSLASH",
+ "level": 24,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_GOLEM",
+ "level": 15,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_GRIMER",
+ "level": 20,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_RHYDON",
+ "level": 23,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "MagmaCavern_21F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_GRIMER",
+ "level": 20,
+ "probability": 8000
+ },
+ {
+ "species": "SPECIES_ONIX",
+ "level": 30,
+ "probability": 2000
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "MagmaCavern_22F_23F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_ONIX",
+ "level": 30,
+ "probability": 10000
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }
+ ]
+}
diff --git a/data/dungeon/MagmaCavernPit/floor_id.json b/data/dungeon/MagmaCavernPit/floor_id.json
index 42995f5..837d1d1 100644
--- a/data/dungeon/MagmaCavernPit/floor_id.json
+++ b/data/dungeon/MagmaCavernPit/floor_id.json
@@ -1,32 +1,32 @@
-{
- "name": "MagmaCavernPitFloorID",
- "tables": [
- {
- "MainData": 150,
- "Pokemon": 94,
- "Traps": 3,
- "Items": 40,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 151,
- "Pokemon": 95,
- "Traps": 3,
- "Items": 40,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 152,
- "Pokemon": 96,
- "Traps": 3,
- "Items": 40,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- }
- ]
-}
+{
+ "name": "MagmaCavernPitFloorID",
+ "tables": [
+ {
+ "MainData": 150,
+ "Pokemon": 94,
+ "Traps": 3,
+ "Items": 40,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 151,
+ "Pokemon": 95,
+ "Traps": 3,
+ "Items": 40,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 152,
+ "Pokemon": 96,
+ "Traps": 3,
+ "Items": 40,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ }
+ ]
+}
diff --git a/data/dungeon/MagmaCavernPit/pokemon_found.json b/data/dungeon/MagmaCavernPit/pokemon_found.json
index c0e312f..c2cd5f2 100644
--- a/data/dungeon/MagmaCavernPit/pokemon_found.json
+++ b/data/dungeon/MagmaCavernPit/pokemon_found.json
@@ -1,75 +1,75 @@
-{
- "tables": [{
- "name": "MagmaCavernPit_1F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_ONIX",
- "level": 30,
- "probability": 5000
- },
- {
- "species": "SPECIES_STEELIX",
- "level": 25,
- "probability": 5000
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "MagmaCavernPit_2F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_CHARIZARD",
- "level": 55,
- "probability": 0
- },
- {
- "species": "SPECIES_TYRANITAR",
- "level": 50,
- "probability": 10000
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "MagmaCavernPit_3F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_ALAKAZAM",
- "level": 50,
- "probability": 5000
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_GROUDON",
- "level": 27,
- "probability": 5000
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }]
-}
+{
+ "tables": [{
+ "name": "MagmaCavernPit_1F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_ONIX",
+ "level": 30,
+ "probability": 5000
+ },
+ {
+ "species": "SPECIES_STEELIX",
+ "level": 25,
+ "probability": 5000
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "MagmaCavernPit_2F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_CHARIZARD",
+ "level": 55,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_TYRANITAR",
+ "level": 50,
+ "probability": 10000
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "MagmaCavernPit_3F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_ALAKAZAM",
+ "level": 50,
+ "probability": 5000
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_GROUDON",
+ "level": 27,
+ "probability": 5000
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }]
+}
diff --git a/data/dungeon/MarvelousSea/floor_id.json b/data/dungeon/MarvelousSea/floor_id.json
index a0660cf..ffd84e4 100644
--- a/data/dungeon/MarvelousSea/floor_id.json
+++ b/data/dungeon/MarvelousSea/floor_id.json
@@ -1,185 +1,185 @@
-{
- "name": "MarvelousSeaFloorID",
- "tables": [
- {
- "MainData": 1071,
- "Pokemon": 502,
- "Traps": 86,
- "Items": 121,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1072,
- "Pokemon": 502,
- "Traps": 86,
- "Items": 121,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1073,
- "Pokemon": 502,
- "Traps": 86,
- "Items": 121,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1074,
- "Pokemon": 502,
- "Traps": 86,
- "Items": 122,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1075,
- "Pokemon": 502,
- "Traps": 86,
- "Items": 122,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1076,
- "Pokemon": 503,
- "Traps": 86,
- "Items": 122,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1077,
- "Pokemon": 503,
- "Traps": 86,
- "Items": 122,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1078,
- "Pokemon": 503,
- "Traps": 86,
- "Items": 122,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1079,
- "Pokemon": 504,
- "Traps": 86,
- "Items": 122,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1080,
- "Pokemon": 505,
- "Traps": 86,
- "Items": 122,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1081,
- "Pokemon": 505,
- "Traps": 86,
- "Items": 122,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1082,
- "Pokemon": 505,
- "Traps": 86,
- "Items": 122,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1083,
- "Pokemon": 505,
- "Traps": 86,
- "Items": 122,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1084,
- "Pokemon": 506,
- "Traps": 86,
- "Items": 122,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1085,
- "Pokemon": 507,
- "Traps": 86,
- "Items": 122,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1086,
- "Pokemon": 507,
- "Traps": 86,
- "Items": 122,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1087,
- "Pokemon": 507,
- "Traps": 86,
- "Items": 122,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1088,
- "Pokemon": 507,
- "Traps": 86,
- "Items": 122,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1089,
- "Pokemon": 507,
- "Traps": 86,
- "Items": 122,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 1090,
- "Pokemon": 508,
- "Traps": 86,
- "Items": 122,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- }
- ]
-}
+{
+ "name": "MarvelousSeaFloorID",
+ "tables": [
+ {
+ "MainData": 1071,
+ "Pokemon": 502,
+ "Traps": 86,
+ "Items": 121,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1072,
+ "Pokemon": 502,
+ "Traps": 86,
+ "Items": 121,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1073,
+ "Pokemon": 502,
+ "Traps": 86,
+ "Items": 121,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1074,
+ "Pokemon": 502,
+ "Traps": 86,
+ "Items": 122,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1075,
+ "Pokemon": 502,
+ "Traps": 86,
+ "Items": 122,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1076,
+ "Pokemon": 503,
+ "Traps": 86,
+ "Items": 122,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1077,
+ "Pokemon": 503,
+ "Traps": 86,
+ "Items": 122,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1078,
+ "Pokemon": 503,
+ "Traps": 86,
+ "Items": 122,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1079,
+ "Pokemon": 504,
+ "Traps": 86,
+ "Items": 122,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1080,
+ "Pokemon": 505,
+ "Traps": 86,
+ "Items": 122,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1081,
+ "Pokemon": 505,
+ "Traps": 86,
+ "Items": 122,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1082,
+ "Pokemon": 505,
+ "Traps": 86,
+ "Items": 122,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1083,
+ "Pokemon": 505,
+ "Traps": 86,
+ "Items": 122,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1084,
+ "Pokemon": 506,
+ "Traps": 86,
+ "Items": 122,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1085,
+ "Pokemon": 507,
+ "Traps": 86,
+ "Items": 122,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1086,
+ "Pokemon": 507,
+ "Traps": 86,
+ "Items": 122,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1087,
+ "Pokemon": 507,
+ "Traps": 86,
+ "Items": 122,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1088,
+ "Pokemon": 507,
+ "Traps": 86,
+ "Items": 122,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1089,
+ "Pokemon": 507,
+ "Traps": 86,
+ "Items": 122,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1090,
+ "Pokemon": 508,
+ "Traps": 86,
+ "Items": 122,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ }
+ ]
+}
diff --git a/data/dungeon/MeteorCave/floor_id.json b/data/dungeon/MeteorCave/floor_id.json
index 6d25001..7a5dc81 100644
--- a/data/dungeon/MeteorCave/floor_id.json
+++ b/data/dungeon/MeteorCave/floor_id.json
@@ -1,185 +1,185 @@
-{
- "name": "MeteorCaveFloorID",
- "tables": [
- {
- "MainData": 326,
- "Pokemon": 161,
- "Traps": 7,
- "Items": 56,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 327,
- "Pokemon": 161,
- "Traps": 7,
- "Items": 56,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 328,
- "Pokemon": 161,
- "Traps": 7,
- "Items": 56,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 329,
- "Pokemon": 161,
- "Traps": 7,
- "Items": 58,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 330,
- "Pokemon": 161,
- "Traps": 7,
- "Items": 58,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 331,
- "Pokemon": 161,
- "Traps": 7,
- "Items": 58,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 332,
- "Pokemon": 161,
- "Traps": 7,
- "Items": 59,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 333,
- "Pokemon": 161,
- "Traps": 7,
- "Items": 59,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 334,
- "Pokemon": 161,
- "Traps": 7,
- "Items": 59,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 335,
- "Pokemon": 161,
- "Traps": 8,
- "Items": 59,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 336,
- "Pokemon": 161,
- "Traps": 8,
- "Items": 59,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 337,
- "Pokemon": 161,
- "Traps": 8,
- "Items": 59,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 338,
- "Pokemon": 161,
- "Traps": 8,
- "Items": 59,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 339,
- "Pokemon": 161,
- "Traps": 8,
- "Items": 59,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 340,
- "Pokemon": 161,
- "Traps": 8,
- "Items": 59,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 341,
- "Pokemon": 161,
- "Traps": 8,
- "Items": 59,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 342,
- "Pokemon": 161,
- "Traps": 8,
- "Items": 59,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 343,
- "Pokemon": 161,
- "Traps": 8,
- "Items": 59,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 344,
- "Pokemon": 161,
- "Traps": 8,
- "Items": 59,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 345,
- "Pokemon": 162,
- "Traps": 9,
- "Items": 59,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- }
- ]
-}
+{
+ "name": "MeteorCaveFloorID",
+ "tables": [
+ {
+ "MainData": 326,
+ "Pokemon": 161,
+ "Traps": 7,
+ "Items": 56,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 327,
+ "Pokemon": 161,
+ "Traps": 7,
+ "Items": 56,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 328,
+ "Pokemon": 161,
+ "Traps": 7,
+ "Items": 56,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 329,
+ "Pokemon": 161,
+ "Traps": 7,
+ "Items": 58,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 330,
+ "Pokemon": 161,
+ "Traps": 7,
+ "Items": 58,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 331,
+ "Pokemon": 161,
+ "Traps": 7,
+ "Items": 58,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 332,
+ "Pokemon": 161,
+ "Traps": 7,
+ "Items": 59,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 333,
+ "Pokemon": 161,
+ "Traps": 7,
+ "Items": 59,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 334,
+ "Pokemon": 161,
+ "Traps": 7,
+ "Items": 59,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 335,
+ "Pokemon": 161,
+ "Traps": 8,
+ "Items": 59,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 336,
+ "Pokemon": 161,
+ "Traps": 8,
+ "Items": 59,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 337,
+ "Pokemon": 161,
+ "Traps": 8,
+ "Items": 59,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 338,
+ "Pokemon": 161,
+ "Traps": 8,
+ "Items": 59,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 339,
+ "Pokemon": 161,
+ "Traps": 8,
+ "Items": 59,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 340,
+ "Pokemon": 161,
+ "Traps": 8,
+ "Items": 59,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 341,
+ "Pokemon": 161,
+ "Traps": 8,
+ "Items": 59,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 342,
+ "Pokemon": 161,
+ "Traps": 8,
+ "Items": 59,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 343,
+ "Pokemon": 161,
+ "Traps": 8,
+ "Items": 59,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 344,
+ "Pokemon": 161,
+ "Traps": 8,
+ "Items": 59,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 345,
+ "Pokemon": 162,
+ "Traps": 9,
+ "Items": 59,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ }
+ ]
+}
diff --git a/data/dungeon/MtBlaze/floor_id.json b/data/dungeon/MtBlaze/floor_id.json
index 6dcb1a4..6c6cc42 100644
--- a/data/dungeon/MtBlaze/floor_id.json
+++ b/data/dungeon/MtBlaze/floor_id.json
@@ -1,113 +1,113 @@
-{
- "name": "MtBlazeFloorID",
- "tables": [
- {
- "MainData": 78,
- "Pokemon": 55,
- "Traps": 3,
- "Items": 24,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 79,
- "Pokemon": 55,
- "Traps": 3,
- "Items": 24,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 80,
- "Pokemon": 55,
- "Traps": 3,
- "Items": 24,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 81,
- "Pokemon": 56,
- "Traps": 3,
- "Items": 25,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 82,
- "Pokemon": 57,
- "Traps": 3,
- "Items": 25,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 83,
- "Pokemon": 58,
- "Traps": 3,
- "Items": 25,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 84,
- "Pokemon": 59,
- "Traps": 3,
- "Items": 25,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 85,
- "Pokemon": 60,
- "Traps": 3,
- "Items": 25,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 86,
- "Pokemon": 60,
- "Traps": 3,
- "Items": 25,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 87,
- "Pokemon": 61,
- "Traps": 3,
- "Items": 25,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 88,
- "Pokemon": 61,
- "Traps": 3,
- "Items": 25,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 89,
- "Pokemon": 61,
- "Traps": 3,
- "Items": 25,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- }
- ]
-}
+{
+ "name": "MtBlazeFloorID",
+ "tables": [
+ {
+ "MainData": 78,
+ "Pokemon": 55,
+ "Traps": 3,
+ "Items": 24,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 79,
+ "Pokemon": 55,
+ "Traps": 3,
+ "Items": 24,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 80,
+ "Pokemon": 55,
+ "Traps": 3,
+ "Items": 24,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 81,
+ "Pokemon": 56,
+ "Traps": 3,
+ "Items": 25,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 82,
+ "Pokemon": 57,
+ "Traps": 3,
+ "Items": 25,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 83,
+ "Pokemon": 58,
+ "Traps": 3,
+ "Items": 25,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 84,
+ "Pokemon": 59,
+ "Traps": 3,
+ "Items": 25,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 85,
+ "Pokemon": 60,
+ "Traps": 3,
+ "Items": 25,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 86,
+ "Pokemon": 60,
+ "Traps": 3,
+ "Items": 25,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 87,
+ "Pokemon": 61,
+ "Traps": 3,
+ "Items": 25,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 88,
+ "Pokemon": 61,
+ "Traps": 3,
+ "Items": 25,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 89,
+ "Pokemon": 61,
+ "Traps": 3,
+ "Items": 25,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ }
+ ]
+}
diff --git a/data/dungeon/MtBlaze/pokemon_found.json b/data/dungeon/MtBlaze/pokemon_found.json
index 2961618..b269470 100644
--- a/data/dungeon/MtBlaze/pokemon_found.json
+++ b/data/dungeon/MtBlaze/pokemon_found.json
@@ -1,220 +1,220 @@
-{
- "tables": [{
- "name": "MtBlaze_1F_3F_Pokemon",
- "pokemon": [{
- "species": "SPECIES_PIDGEOT",
- "level": 16,
- "probability": 2857
- },
- {
- "species": "SPECIES_SLUGMA",
- "level": 16,
- "probability": 1429
- },
- {
- "species": "SPECIES_MAGBY",
- "level": 17,
- "probability": 2857
- },
- {
- "species": "SPECIES_NUMEL",
- "level": 14,
- "probability": 2857
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
-
- "name": "MtBlaze_4F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_SLUGMA",
- "level": 16,
- "probability": 2000
- },
- {
- "species": "SPECIES_MAGBY",
- "level": 17,
- "probability": 4000
- },
- {
- "species": "SPECIES_NUMEL",
- "level": 14,
- "probability": 4000
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
-
- ]
- }, {
- "name": "MtBlaze_5F_Pokemon",
- "pokemon": [{
- "species": "SPECIES_SHUCKLE",
- "level": 15,
- "probability": 1304
- },
- {
- "species": "SPECIES_SLUGMA",
- "level": 16,
- "probability": 1739
- },
- {
- "species": "SPECIES_MAGBY",
- "level": 17,
- "probability": 3479
- },
- {
- "species": "SPECIES_NUMEL",
- "level": 14,
- "probability": 3478
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "MtBlaze_6F_Pokemon",
- "pokemon": [{
- "species": "SPECIES_SHUCKLE",
- "level": 15,
- "probability": 2000
- },
- {
- "species": "SPECIES_SLUGMA",
- "level": 16,
- "probability": 2667
- },
- {
- "species": "SPECIES_NUMEL",
- "level": 14,
- "probability": 5333
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "MtBlaze_7F_Pokemon",
- "pokemon": [{
- "species": "SPECIES_SHUCKLE",
- "level": 15,
- "probability": 2000
- },
- {
- "species": "SPECIES_SLUGMA",
- "level": 16,
- "probability": 2667
- },
- {
- "species": "SPECIES_TORKOAL",
- "level": 15,
- "probability": 5333
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "MtBlaze_8F_9F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_RAPIDASH",
- "level": 10,
- "probability": 3478
- },
- {
- "species": "SPECIES_SHUCKLE",
- "level": 15,
- "probability": 1305
- },
- {
- "species": "SPECIES_SLUGMA",
- "level": 16,
- "probability": 1739
- },
- {
- "species": "SPECIES_TORKOAL",
- "level": 15,
- "probability": 3478
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "MtBlaze_10F_12F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_RAPIDASH",
- "level": 10,
- "probability": 4000
- },
- {
- "species": "SPECIES_SLUGMA",
- "level": 16,
- "probability": 2000
- },
- {
- "species": "SPECIES_TORKOAL",
- "level": 15,
- "probability": 4000
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }
- ]
-}
+{
+ "tables": [{
+ "name": "MtBlaze_1F_3F_Pokemon",
+ "pokemon": [{
+ "species": "SPECIES_PIDGEOT",
+ "level": 16,
+ "probability": 2857
+ },
+ {
+ "species": "SPECIES_SLUGMA",
+ "level": 16,
+ "probability": 1429
+ },
+ {
+ "species": "SPECIES_MAGBY",
+ "level": 17,
+ "probability": 2857
+ },
+ {
+ "species": "SPECIES_NUMEL",
+ "level": 14,
+ "probability": 2857
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+
+ "name": "MtBlaze_4F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_SLUGMA",
+ "level": 16,
+ "probability": 2000
+ },
+ {
+ "species": "SPECIES_MAGBY",
+ "level": 17,
+ "probability": 4000
+ },
+ {
+ "species": "SPECIES_NUMEL",
+ "level": 14,
+ "probability": 4000
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+
+ ]
+ }, {
+ "name": "MtBlaze_5F_Pokemon",
+ "pokemon": [{
+ "species": "SPECIES_SHUCKLE",
+ "level": 15,
+ "probability": 1304
+ },
+ {
+ "species": "SPECIES_SLUGMA",
+ "level": 16,
+ "probability": 1739
+ },
+ {
+ "species": "SPECIES_MAGBY",
+ "level": 17,
+ "probability": 3479
+ },
+ {
+ "species": "SPECIES_NUMEL",
+ "level": 14,
+ "probability": 3478
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "MtBlaze_6F_Pokemon",
+ "pokemon": [{
+ "species": "SPECIES_SHUCKLE",
+ "level": 15,
+ "probability": 2000
+ },
+ {
+ "species": "SPECIES_SLUGMA",
+ "level": 16,
+ "probability": 2667
+ },
+ {
+ "species": "SPECIES_NUMEL",
+ "level": 14,
+ "probability": 5333
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "MtBlaze_7F_Pokemon",
+ "pokemon": [{
+ "species": "SPECIES_SHUCKLE",
+ "level": 15,
+ "probability": 2000
+ },
+ {
+ "species": "SPECIES_SLUGMA",
+ "level": 16,
+ "probability": 2667
+ },
+ {
+ "species": "SPECIES_TORKOAL",
+ "level": 15,
+ "probability": 5333
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "MtBlaze_8F_9F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_RAPIDASH",
+ "level": 10,
+ "probability": 3478
+ },
+ {
+ "species": "SPECIES_SHUCKLE",
+ "level": 15,
+ "probability": 1305
+ },
+ {
+ "species": "SPECIES_SLUGMA",
+ "level": 16,
+ "probability": 1739
+ },
+ {
+ "species": "SPECIES_TORKOAL",
+ "level": 15,
+ "probability": 3478
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "MtBlaze_10F_12F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_RAPIDASH",
+ "level": 10,
+ "probability": 4000
+ },
+ {
+ "species": "SPECIES_SLUGMA",
+ "level": 16,
+ "probability": 2000
+ },
+ {
+ "species": "SPECIES_TORKOAL",
+ "level": 15,
+ "probability": 4000
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }
+ ]
+}
diff --git a/data/dungeon/MtBlazePeak/floor_id.json b/data/dungeon/MtBlazePeak/floor_id.json
index 72d5a3d..e21fe80 100644
--- a/data/dungeon/MtBlazePeak/floor_id.json
+++ b/data/dungeon/MtBlazePeak/floor_id.json
@@ -1,32 +1,32 @@
-{
- "name": "MtBlazePeakFloorID",
- "tables": [
- {
- "MainData": 90,
- "Pokemon": 62,
- "Traps": 1,
- "Items": 26,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 91,
- "Pokemon": 62,
- "Traps": 1,
- "Items": 26,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 92,
- "Pokemon": 63,
- "Traps": 1,
- "Items": 26,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- }
- ]
-}
+{
+ "name": "MtBlazePeakFloorID",
+ "tables": [
+ {
+ "MainData": 90,
+ "Pokemon": 62,
+ "Traps": 1,
+ "Items": 26,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 91,
+ "Pokemon": 62,
+ "Traps": 1,
+ "Items": 26,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 92,
+ "Pokemon": 63,
+ "Traps": 1,
+ "Items": 26,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ }
+ ]
+}
diff --git a/data/dungeon/MtBlazePeak/pokemon_found.json b/data/dungeon/MtBlazePeak/pokemon_found.json
index f13a655..76c7400 100644
--- a/data/dungeon/MtBlazePeak/pokemon_found.json
+++ b/data/dungeon/MtBlazePeak/pokemon_found.json
@@ -1,45 +1,45 @@
-{
- "tables": [{
- "name": "MtBlazePeak_1F_2F_Pokemon",
- "pokemon": [{
- "species": "SPECIES_FEAROW",
- "level": 17,
- "probability": 5000
- },
- {
- "species": "SPECIES_ARCANINE",
- "level": 18,
- "probability": 5000
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "MtBlazePeak_3F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_MOLTRES",
- "level": 32,
- "probability": 10000
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }]
-}
+{
+ "tables": [{
+ "name": "MtBlazePeak_1F_2F_Pokemon",
+ "pokemon": [{
+ "species": "SPECIES_FEAROW",
+ "level": 17,
+ "probability": 5000
+ },
+ {
+ "species": "SPECIES_ARCANINE",
+ "level": 18,
+ "probability": 5000
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "MtBlazePeak_3F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_MOLTRES",
+ "level": 32,
+ "probability": 10000
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }]
+}
diff --git a/data/dungeon/MtFaraway/floor_id.json b/data/dungeon/MtFaraway/floor_id.json
index f90c5de..5ab9103 100644
--- a/data/dungeon/MtFaraway/floor_id.json
+++ b/data/dungeon/MtFaraway/floor_id.json
@@ -1,365 +1,365 @@
-{
- "name": "MtFarawayFloorID",
- "tables": [
- {
- "MainData": 1525,
- "Pokemon": 715,
- "Traps": 72,
- "Items": 166,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 1526,
- "Pokemon": 715,
- "Traps": 72,
- "Items": 166,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 1527,
- "Pokemon": 715,
- "Traps": 72,
- "Items": 166,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 1528,
- "Pokemon": 715,
- "Traps": 72,
- "Items": 167,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 1529,
- "Pokemon": 715,
- "Traps": 72,
- "Items": 167,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 1530,
- "Pokemon": 716,
- "Traps": 72,
- "Items": 167,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 1531,
- "Pokemon": 716,
- "Traps": 72,
- "Items": 167,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 1532,
- "Pokemon": 716,
- "Traps": 72,
- "Items": 167,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 1533,
- "Pokemon": 716,
- "Traps": 72,
- "Items": 167,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 1534,
- "Pokemon": 717,
- "Traps": 73,
- "Items": 167,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 1535,
- "Pokemon": 718,
- "Traps": 74,
- "Items": 167,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 1536,
- "Pokemon": 719,
- "Traps": 74,
- "Items": 167,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 1537,
- "Pokemon": 719,
- "Traps": 74,
- "Items": 167,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 1538,
- "Pokemon": 719,
- "Traps": 74,
- "Items": 167,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 1539,
- "Pokemon": 719,
- "Traps": 74,
- "Items": 167,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 1540,
- "Pokemon": 719,
- "Traps": 74,
- "Items": 167,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 1541,
- "Pokemon": 719,
- "Traps": 74,
- "Items": 167,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 1542,
- "Pokemon": 719,
- "Traps": 74,
- "Items": 167,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 1543,
- "Pokemon": 719,
- "Traps": 74,
- "Items": 167,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 1544,
- "Pokemon": 720,
- "Traps": 112,
- "Items": 167,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 1545,
- "Pokemon": 721,
- "Traps": 112,
- "Items": 167,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 1546,
- "Pokemon": 721,
- "Traps": 112,
- "Items": 167,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 1547,
- "Pokemon": 721,
- "Traps": 112,
- "Items": 167,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 1548,
- "Pokemon": 721,
- "Traps": 112,
- "Items": 167,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 1549,
- "Pokemon": 721,
- "Traps": 112,
- "Items": 167,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 1550,
- "Pokemon": 721,
- "Traps": 112,
- "Items": 167,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 1551,
- "Pokemon": 721,
- "Traps": 112,
- "Items": 167,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 1552,
- "Pokemon": 721,
- "Traps": 112,
- "Items": 167,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 1553,
- "Pokemon": 721,
- "Traps": 112,
- "Items": 167,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 1554,
- "Pokemon": 722,
- "Traps": 112,
- "Items": 167,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 1555,
- "Pokemon": 723,
- "Traps": 113,
- "Items": 167,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 1556,
- "Pokemon": 723,
- "Traps": 113,
- "Items": 167,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 1557,
- "Pokemon": 723,
- "Traps": 113,
- "Items": 167,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 1558,
- "Pokemon": 723,
- "Traps": 113,
- "Items": 167,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 1559,
- "Pokemon": 724,
- "Traps": 113,
- "Items": 167,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 1560,
- "Pokemon": 723,
- "Traps": 113,
- "Items": 167,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 1561,
- "Pokemon": 723,
- "Traps": 113,
- "Items": 167,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 1562,
- "Pokemon": 723,
- "Traps": 113,
- "Items": 167,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 1563,
- "Pokemon": 725,
- "Traps": 113,
- "Items": 167,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 1564,
- "Pokemon": 726,
- "Traps": 114,
- "Items": 167,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- }
- ]
-}
+{
+ "name": "MtFarawayFloorID",
+ "tables": [
+ {
+ "MainData": 1525,
+ "Pokemon": 715,
+ "Traps": 72,
+ "Items": 166,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1526,
+ "Pokemon": 715,
+ "Traps": 72,
+ "Items": 166,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1527,
+ "Pokemon": 715,
+ "Traps": 72,
+ "Items": 166,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1528,
+ "Pokemon": 715,
+ "Traps": 72,
+ "Items": 167,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1529,
+ "Pokemon": 715,
+ "Traps": 72,
+ "Items": 167,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1530,
+ "Pokemon": 716,
+ "Traps": 72,
+ "Items": 167,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1531,
+ "Pokemon": 716,
+ "Traps": 72,
+ "Items": 167,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1532,
+ "Pokemon": 716,
+ "Traps": 72,
+ "Items": 167,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1533,
+ "Pokemon": 716,
+ "Traps": 72,
+ "Items": 167,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1534,
+ "Pokemon": 717,
+ "Traps": 73,
+ "Items": 167,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1535,
+ "Pokemon": 718,
+ "Traps": 74,
+ "Items": 167,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1536,
+ "Pokemon": 719,
+ "Traps": 74,
+ "Items": 167,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1537,
+ "Pokemon": 719,
+ "Traps": 74,
+ "Items": 167,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1538,
+ "Pokemon": 719,
+ "Traps": 74,
+ "Items": 167,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1539,
+ "Pokemon": 719,
+ "Traps": 74,
+ "Items": 167,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1540,
+ "Pokemon": 719,
+ "Traps": 74,
+ "Items": 167,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1541,
+ "Pokemon": 719,
+ "Traps": 74,
+ "Items": 167,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1542,
+ "Pokemon": 719,
+ "Traps": 74,
+ "Items": 167,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1543,
+ "Pokemon": 719,
+ "Traps": 74,
+ "Items": 167,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1544,
+ "Pokemon": 720,
+ "Traps": 112,
+ "Items": 167,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1545,
+ "Pokemon": 721,
+ "Traps": 112,
+ "Items": 167,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1546,
+ "Pokemon": 721,
+ "Traps": 112,
+ "Items": 167,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1547,
+ "Pokemon": 721,
+ "Traps": 112,
+ "Items": 167,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1548,
+ "Pokemon": 721,
+ "Traps": 112,
+ "Items": 167,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1549,
+ "Pokemon": 721,
+ "Traps": 112,
+ "Items": 167,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1550,
+ "Pokemon": 721,
+ "Traps": 112,
+ "Items": 167,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1551,
+ "Pokemon": 721,
+ "Traps": 112,
+ "Items": 167,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1552,
+ "Pokemon": 721,
+ "Traps": 112,
+ "Items": 167,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1553,
+ "Pokemon": 721,
+ "Traps": 112,
+ "Items": 167,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1554,
+ "Pokemon": 722,
+ "Traps": 112,
+ "Items": 167,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1555,
+ "Pokemon": 723,
+ "Traps": 113,
+ "Items": 167,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1556,
+ "Pokemon": 723,
+ "Traps": 113,
+ "Items": 167,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1557,
+ "Pokemon": 723,
+ "Traps": 113,
+ "Items": 167,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1558,
+ "Pokemon": 723,
+ "Traps": 113,
+ "Items": 167,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1559,
+ "Pokemon": 724,
+ "Traps": 113,
+ "Items": 167,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1560,
+ "Pokemon": 723,
+ "Traps": 113,
+ "Items": 167,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1561,
+ "Pokemon": 723,
+ "Traps": 113,
+ "Items": 167,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1562,
+ "Pokemon": 723,
+ "Traps": 113,
+ "Items": 167,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1563,
+ "Pokemon": 725,
+ "Traps": 113,
+ "Items": 167,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 1564,
+ "Pokemon": 726,
+ "Traps": 114,
+ "Items": 167,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ }
+ ]
+}
diff --git a/data/dungeon/MtFreeze/floor_id.json b/data/dungeon/MtFreeze/floor_id.json
index 3cd5011..9fc3948 100644
--- a/data/dungeon/MtFreeze/floor_id.json
+++ b/data/dungeon/MtFreeze/floor_id.json
@@ -1,140 +1,140 @@
-{
- "name": "MtFreezeFloorID",
- "tables": [
- {
- "MainData": 107,
- "Pokemon": 72,
- "Traps": 3,
- "Items": 32,
- "KecleonShop": 28,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 108,
- "Pokemon": 72,
- "Traps": 3,
- "Items": 32,
- "KecleonShop": 28,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 109,
- "Pokemon": 73,
- "Traps": 3,
- "Items": 32,
- "KecleonShop": 28,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 110,
- "Pokemon": 73,
- "Traps": 3,
- "Items": 33,
- "KecleonShop": 28,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 111,
- "Pokemon": 73,
- "Traps": 3,
- "Items": 33,
- "KecleonShop": 28,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 112,
- "Pokemon": 74,
- "Traps": 3,
- "Items": 33,
- "KecleonShop": 28,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 113,
- "Pokemon": 75,
- "Traps": 3,
- "Items": 33,
- "KecleonShop": 28,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 114,
- "Pokemon": 76,
- "Traps": 3,
- "Items": 33,
- "KecleonShop": 28,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 115,
- "Pokemon": 76,
- "Traps": 3,
- "Items": 33,
- "KecleonShop": 28,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 116,
- "Pokemon": 76,
- "Traps": 3,
- "Items": 33,
- "KecleonShop": 28,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 117,
- "Pokemon": 76,
- "Traps": 3,
- "Items": 33,
- "KecleonShop": 28,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 118,
- "Pokemon": 77,
- "Traps": 3,
- "Items": 33,
- "KecleonShop": 28,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 119,
- "Pokemon": 78,
- "Traps": 3,
- "Items": 33,
- "KecleonShop": 28,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 120,
- "Pokemon": 78,
- "Traps": 3,
- "Items": 33,
- "KecleonShop": 28,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 121,
- "Pokemon": 78,
- "Traps": 3,
- "Items": 33,
- "KecleonShop": 28,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- }
- ]
-}
+{
+ "name": "MtFreezeFloorID",
+ "tables": [
+ {
+ "MainData": 107,
+ "Pokemon": 72,
+ "Traps": 3,
+ "Items": 32,
+ "KecleonShop": 28,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 108,
+ "Pokemon": 72,
+ "Traps": 3,
+ "Items": 32,
+ "KecleonShop": 28,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 109,
+ "Pokemon": 73,
+ "Traps": 3,
+ "Items": 32,
+ "KecleonShop": 28,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 110,
+ "Pokemon": 73,
+ "Traps": 3,
+ "Items": 33,
+ "KecleonShop": 28,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 111,
+ "Pokemon": 73,
+ "Traps": 3,
+ "Items": 33,
+ "KecleonShop": 28,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 112,
+ "Pokemon": 74,
+ "Traps": 3,
+ "Items": 33,
+ "KecleonShop": 28,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 113,
+ "Pokemon": 75,
+ "Traps": 3,
+ "Items": 33,
+ "KecleonShop": 28,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 114,
+ "Pokemon": 76,
+ "Traps": 3,
+ "Items": 33,
+ "KecleonShop": 28,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 115,
+ "Pokemon": 76,
+ "Traps": 3,
+ "Items": 33,
+ "KecleonShop": 28,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 116,
+ "Pokemon": 76,
+ "Traps": 3,
+ "Items": 33,
+ "KecleonShop": 28,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 117,
+ "Pokemon": 76,
+ "Traps": 3,
+ "Items": 33,
+ "KecleonShop": 28,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 118,
+ "Pokemon": 77,
+ "Traps": 3,
+ "Items": 33,
+ "KecleonShop": 28,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 119,
+ "Pokemon": 78,
+ "Traps": 3,
+ "Items": 33,
+ "KecleonShop": 28,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 120,
+ "Pokemon": 78,
+ "Traps": 3,
+ "Items": 33,
+ "KecleonShop": 28,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 121,
+ "Pokemon": 78,
+ "Traps": 3,
+ "Items": 33,
+ "KecleonShop": 28,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ }
+ ]
+}
diff --git a/data/dungeon/MtFreeze/pokemon_found.json b/data/dungeon/MtFreeze/pokemon_found.json
index 413e22c..bdd07d0 100644
--- a/data/dungeon/MtFreeze/pokemon_found.json
+++ b/data/dungeon/MtFreeze/pokemon_found.json
@@ -1,216 +1,216 @@
-{
- "tables": [{
- "name": "MtFreeze_1F_2F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_PINECO",
- "level": 18,
- "probability": 1111
- },
- {
- "species": "SPECIES_SWABLU",
- "level": 18,
- "probability": 4445
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_SHELGON",
- "level": 19,
- "probability": 4444
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "MtFreeze_3F_5F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_SEEL",
- "level": 18,
- "probability": 2759
- },
- {
- "species": "SPECIES_PINECO",
- "level": 18,
- "probability": 689
- },
- {
- "species": "SPECIES_PUPITAR",
- "level": 17,
- "probability": 1035
- },
- {
- "species": "SPECIES_SWABLU",
- "level": 18,
- "probability": 2758
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_SHELGON",
- "level": 19,
- "probability": 2759
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "MtFreeze_6F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_SEEL",
- "level": 18,
- "probability": 3333
- },
- {
- "species": "SPECIES_SWABLU",
- "level": 18,
- "probability": 3334
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_SHELGON",
- "level": 19,
- "probability": 3333
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "MtFreeze_7F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_SEEL",
- "level": 18,
- "probability": 2857
- },
- {
- "species": "SPECIES_VIGOROTH",
- "level": 20,
- "probability": 2857
- },
- {
- "species": "SPECIES_ZANGOOSE",
- "level": 18,
- "probability": 2857
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_CHIMECHO",
- "level": 22,
- "probability": 1429
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "MtFreeze_8F_11F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_VIGOROTH",
- "level": 20,
- "probability": 4000
- },
- {
- "species": "SPECIES_ZANGOOSE",
- "level": 18,
- "probability": 4000
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_CHIMECHO",
- "level": 22,
- "probability": 2000
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "MtFreeze_12F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_SLAKING",
- "level": 15,
- "probability": 4000
- },
- {
- "species": "SPECIES_ZANGOOSE",
- "level": 18,
- "probability": 4000
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_CHIMECHO",
- "level": 22,
- "probability": 2000
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "MtFreeze_13F_15F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_SLAKING",
- "level": 15,
- "probability": 5000
- },
- {
- "species": "SPECIES_SEVIPER",
- "level": 19,
- "probability": 5000
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }]
-}
+{
+ "tables": [{
+ "name": "MtFreeze_1F_2F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_PINECO",
+ "level": 18,
+ "probability": 1111
+ },
+ {
+ "species": "SPECIES_SWABLU",
+ "level": 18,
+ "probability": 4445
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_SHELGON",
+ "level": 19,
+ "probability": 4444
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "MtFreeze_3F_5F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_SEEL",
+ "level": 18,
+ "probability": 2759
+ },
+ {
+ "species": "SPECIES_PINECO",
+ "level": 18,
+ "probability": 689
+ },
+ {
+ "species": "SPECIES_PUPITAR",
+ "level": 17,
+ "probability": 1035
+ },
+ {
+ "species": "SPECIES_SWABLU",
+ "level": 18,
+ "probability": 2758
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_SHELGON",
+ "level": 19,
+ "probability": 2759
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "MtFreeze_6F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_SEEL",
+ "level": 18,
+ "probability": 3333
+ },
+ {
+ "species": "SPECIES_SWABLU",
+ "level": 18,
+ "probability": 3334
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_SHELGON",
+ "level": 19,
+ "probability": 3333
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "MtFreeze_7F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_SEEL",
+ "level": 18,
+ "probability": 2857
+ },
+ {
+ "species": "SPECIES_VIGOROTH",
+ "level": 20,
+ "probability": 2857
+ },
+ {
+ "species": "SPECIES_ZANGOOSE",
+ "level": 18,
+ "probability": 2857
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_CHIMECHO",
+ "level": 22,
+ "probability": 1429
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "MtFreeze_8F_11F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_VIGOROTH",
+ "level": 20,
+ "probability": 4000
+ },
+ {
+ "species": "SPECIES_ZANGOOSE",
+ "level": 18,
+ "probability": 4000
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_CHIMECHO",
+ "level": 22,
+ "probability": 2000
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "MtFreeze_12F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_SLAKING",
+ "level": 15,
+ "probability": 4000
+ },
+ {
+ "species": "SPECIES_ZANGOOSE",
+ "level": 18,
+ "probability": 4000
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_CHIMECHO",
+ "level": 22,
+ "probability": 2000
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "MtFreeze_13F_15F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_SLAKING",
+ "level": 15,
+ "probability": 5000
+ },
+ {
+ "species": "SPECIES_SEVIPER",
+ "level": 19,
+ "probability": 5000
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }]
+}
diff --git a/data/dungeon/MtFreezePeak/floor_id.json b/data/dungeon/MtFreezePeak/floor_id.json
index 23d45db..31275ad 100644
--- a/data/dungeon/MtFreezePeak/floor_id.json
+++ b/data/dungeon/MtFreezePeak/floor_id.json
@@ -1,50 +1,50 @@
-{
- "name": "MtFreezePeakFloorID",
- "tables": [
- {
- "MainData": 122,
- "Pokemon": 79,
- "Traps": 3,
- "Items": 34,
- "KecleonShop": 28,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 123,
- "Pokemon": 79,
- "Traps": 3,
- "Items": 34,
- "KecleonShop": 28,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 124,
- "Pokemon": 79,
- "Traps": 3,
- "Items": 34,
- "KecleonShop": 28,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 125,
- "Pokemon": 79,
- "Traps": 3,
- "Items": 35,
- "KecleonShop": 28,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 126,
- "Pokemon": 80,
- "Traps": 3,
- "Items": 35,
- "KecleonShop": 28,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- }
- ]
-}
+{
+ "name": "MtFreezePeakFloorID",
+ "tables": [
+ {
+ "MainData": 122,
+ "Pokemon": 79,
+ "Traps": 3,
+ "Items": 34,
+ "KecleonShop": 28,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 123,
+ "Pokemon": 79,
+ "Traps": 3,
+ "Items": 34,
+ "KecleonShop": 28,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 124,
+ "Pokemon": 79,
+ "Traps": 3,
+ "Items": 34,
+ "KecleonShop": 28,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 125,
+ "Pokemon": 79,
+ "Traps": 3,
+ "Items": 35,
+ "KecleonShop": 28,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 126,
+ "Pokemon": 80,
+ "Traps": 3,
+ "Items": 35,
+ "KecleonShop": 28,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ }
+ ]
+}
diff --git a/data/dungeon/MtFreezePeak/pokemon_found.json b/data/dungeon/MtFreezePeak/pokemon_found.json
index 7d1a50c..683135d 100644
--- a/data/dungeon/MtFreezePeak/pokemon_found.json
+++ b/data/dungeon/MtFreezePeak/pokemon_found.json
@@ -1,56 +1,56 @@
-{
- "tables": [{
- "name": "MtFreezePeak_1F_4F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_GLALIE",
- "level": 20,
- "probability": 10000
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "MtFreezePeak_5F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_CHARIZARD",
- "level": 55,
- "probability": 0
- },
- {
- "species": "SPECIES_ALAKAZAM",
- "level": 50,
- "probability": 0
- },
- {
- "species": "SPECIES_TYRANITAR",
- "level": 50,
- "probability": 0
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_GLALIE",
- "level": 20,
- "probability": 10000
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }]
-}
+{
+ "tables": [{
+ "name": "MtFreezePeak_1F_4F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_GLALIE",
+ "level": 20,
+ "probability": 10000
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "MtFreezePeak_5F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_CHARIZARD",
+ "level": 55,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_ALAKAZAM",
+ "level": 50,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_TYRANITAR",
+ "level": 50,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_GLALIE",
+ "level": 20,
+ "probability": 10000
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }]
+}
diff --git a/data/dungeon/MtFreezePeakAlt/floor_id.json b/data/dungeon/MtFreezePeakAlt/floor_id.json
index a3823ba..03836e0 100644
--- a/data/dungeon/MtFreezePeakAlt/floor_id.json
+++ b/data/dungeon/MtFreezePeakAlt/floor_id.json
@@ -1,41 +1,41 @@
-{
- "name": "MtFreezePeakAltFloorID",
- "tables": [
- {
- "MainData": 346,
- "Pokemon": 79,
- "Traps": 10,
- "Items": 34,
- "KecleonShop": 28,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 347,
- "Pokemon": 79,
- "Traps": 10,
- "Items": 34,
- "KecleonShop": 28,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 348,
- "Pokemon": 79,
- "Traps": 10,
- "Items": 34,
- "KecleonShop": 28,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 349,
- "Pokemon": 79,
- "Traps": 10,
- "Items": 35,
- "KecleonShop": 28,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- }
- ]
-}
+{
+ "name": "MtFreezePeakAltFloorID",
+ "tables": [
+ {
+ "MainData": 346,
+ "Pokemon": 79,
+ "Traps": 10,
+ "Items": 34,
+ "KecleonShop": 28,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 347,
+ "Pokemon": 79,
+ "Traps": 10,
+ "Items": 34,
+ "KecleonShop": 28,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 348,
+ "Pokemon": 79,
+ "Traps": 10,
+ "Items": 34,
+ "KecleonShop": 28,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 349,
+ "Pokemon": 79,
+ "Traps": 10,
+ "Items": 35,
+ "KecleonShop": 28,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ }
+ ]
+}
diff --git a/data/dungeon/MtSteel/floor_id.json b/data/dungeon/MtSteel/floor_id.json
index fc28d1a..986c5f3 100644
--- a/data/dungeon/MtSteel/floor_id.json
+++ b/data/dungeon/MtSteel/floor_id.json
@@ -1,86 +1,86 @@
-{
- "name": "MtSteelFloorID",
- "tables": [
- {
- "MainData": 8,
- "Pokemon": 5,
- "Traps": 1,
- "Items": 8,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 9,
- "Pokemon": 5,
- "Traps": 1,
- "Items": 8,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 10,
- "Pokemon": 5,
- "Traps": 1,
- "Items": 8,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 11,
- "Pokemon": 5,
- "Traps": 1,
- "Items": 9,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 12,
- "Pokemon": 6,
- "Traps": 1,
- "Items": 9,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 13,
- "Pokemon": 7,
- "Traps": 1,
- "Items": 9,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 14,
- "Pokemon": 8,
- "Traps": 1,
- "Items": 10,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 15,
- "Pokemon": 8,
- "Traps": 1,
- "Items": 10,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 16,
- "Pokemon": 9,
- "Traps": 1,
- "Items": 10,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- }
- ]
-}
+{
+ "name": "MtSteelFloorID",
+ "tables": [
+ {
+ "MainData": 8,
+ "Pokemon": 5,
+ "Traps": 1,
+ "Items": 8,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 9,
+ "Pokemon": 5,
+ "Traps": 1,
+ "Items": 8,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 10,
+ "Pokemon": 5,
+ "Traps": 1,
+ "Items": 8,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 11,
+ "Pokemon": 5,
+ "Traps": 1,
+ "Items": 9,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 12,
+ "Pokemon": 6,
+ "Traps": 1,
+ "Items": 9,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 13,
+ "Pokemon": 7,
+ "Traps": 1,
+ "Items": 9,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 14,
+ "Pokemon": 8,
+ "Traps": 1,
+ "Items": 10,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 15,
+ "Pokemon": 8,
+ "Traps": 1,
+ "Items": 10,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 16,
+ "Pokemon": 9,
+ "Traps": 1,
+ "Items": 10,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ }
+ ]
+}
diff --git a/data/dungeon/MtSteel/pokemon_found.json b/data/dungeon/MtSteel/pokemon_found.json
index dbaeff9..8b8b110 100644
--- a/data/dungeon/MtSteel/pokemon_found.json
+++ b/data/dungeon/MtSteel/pokemon_found.json
@@ -1,188 +1,188 @@
-{
- "tables": [{
- "name": "MtSteel_1F_4F_Pokemon",
- "pokemon": [{
- "species": "SPECIES_SPEAROW",
- "level": 4,
- "probability": 2353
- },
- {
- "species": "SPECIES_ZIGZAGOON",
- "level": 5,
- "probability": 2353
- },
- {
- "species": "SPECIES_ARON",
- "level": 6,
- "probability": 2941
- },
- {
- "species": "SPECIES_BALTOY",
- "level": 5,
- "probability": 2353
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "MtSteel_5F_Pokemon",
- "pokemon": [{
- "species": "SPECIES_GEODUDE",
- "level": 5,
- "probability": 1905
- },
- {
- "species": "SPECIES_TYROGUE",
- "level": 6,
- "probability": 1905
- },
- {
- "species": "SPECIES_ZIGZAGOON",
- "level": 5,
- "probability": 1904
- },
- {
- "species": "SPECIES_ARON",
- "level": 6,
- "probability": 2381
- },
- {
- "species": "SPECIES_MEDITITE",
- "level": 6,
- "probability": 1905
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "MtSteel_6F_Pokemon",
- "pokemon": [{
- "species": "SPECIES_GEODUDE",
- "level": 5,
- "probability": 2051
- },
- {
- "species": "SPECIES_TYROGUE",
- "level": 6,
- "probability": 2052
- },
- {
- "species": "SPECIES_ARON",
- "level": 6,
- "probability": 2564
- },
- {
- "species": "SPECIES_MEDITITE",
- "level": 6,
- "probability": 2051
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_BELDUM",
- "level": 5,
- "probability": 1282
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "MtSteel_7F_8F_Pokemon",
- "pokemon": [{
- "species": "SPECIES_GEODUDE",
- "level": 5,
- "probability": 1633
- },
- {
- "species": "SPECIES_PINSIR",
- "level": 6,
- "probability": 2040
- },
- {
- "species": "SPECIES_TYROGUE",
- "level": 6,
- "probability": 1633
- },
- {
- "species": "SPECIES_ARON",
- "level": 6,
- "probability": 2041
- },
- {
- "species": "SPECIES_MEDITITE",
- "level": 6,
- "probability": 1633
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_BELDUM",
- "level": 5,
- "probability": 1020
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "MtSteel_9F_Pokemon",
- "pokemon": [{
- "species": "SPECIES_DIGLETT",
- "level": 5,
- "probability": 0
- },
- {
- "species": "SPECIES_SKARMORY",
- "level": 10,
- "probability": 0
- },
- {
- "species": "SPECIES_ARON",
- "level": 6,
- "probability": 6667
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_BELDUM",
- "level": 5,
- "probability": 3333
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }]
-}
+{
+ "tables": [{
+ "name": "MtSteel_1F_4F_Pokemon",
+ "pokemon": [{
+ "species": "SPECIES_SPEAROW",
+ "level": 4,
+ "probability": 2353
+ },
+ {
+ "species": "SPECIES_ZIGZAGOON",
+ "level": 5,
+ "probability": 2353
+ },
+ {
+ "species": "SPECIES_ARON",
+ "level": 6,
+ "probability": 2941
+ },
+ {
+ "species": "SPECIES_BALTOY",
+ "level": 5,
+ "probability": 2353
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "MtSteel_5F_Pokemon",
+ "pokemon": [{
+ "species": "SPECIES_GEODUDE",
+ "level": 5,
+ "probability": 1905
+ },
+ {
+ "species": "SPECIES_TYROGUE",
+ "level": 6,
+ "probability": 1905
+ },
+ {
+ "species": "SPECIES_ZIGZAGOON",
+ "level": 5,
+ "probability": 1904
+ },
+ {
+ "species": "SPECIES_ARON",
+ "level": 6,
+ "probability": 2381
+ },
+ {
+ "species": "SPECIES_MEDITITE",
+ "level": 6,
+ "probability": 1905
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "MtSteel_6F_Pokemon",
+ "pokemon": [{
+ "species": "SPECIES_GEODUDE",
+ "level": 5,
+ "probability": 2051
+ },
+ {
+ "species": "SPECIES_TYROGUE",
+ "level": 6,
+ "probability": 2052
+ },
+ {
+ "species": "SPECIES_ARON",
+ "level": 6,
+ "probability": 2564
+ },
+ {
+ "species": "SPECIES_MEDITITE",
+ "level": 6,
+ "probability": 2051
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_BELDUM",
+ "level": 5,
+ "probability": 1282
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "MtSteel_7F_8F_Pokemon",
+ "pokemon": [{
+ "species": "SPECIES_GEODUDE",
+ "level": 5,
+ "probability": 1633
+ },
+ {
+ "species": "SPECIES_PINSIR",
+ "level": 6,
+ "probability": 2040
+ },
+ {
+ "species": "SPECIES_TYROGUE",
+ "level": 6,
+ "probability": 1633
+ },
+ {
+ "species": "SPECIES_ARON",
+ "level": 6,
+ "probability": 2041
+ },
+ {
+ "species": "SPECIES_MEDITITE",
+ "level": 6,
+ "probability": 1633
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_BELDUM",
+ "level": 5,
+ "probability": 1020
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "MtSteel_9F_Pokemon",
+ "pokemon": [{
+ "species": "SPECIES_DIGLETT",
+ "level": 5,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_SKARMORY",
+ "level": 10,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_ARON",
+ "level": 6,
+ "probability": 6667
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_BELDUM",
+ "level": 5,
+ "probability": 3333
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }]
+}
diff --git a/data/dungeon/MtThunder/floor_id.json b/data/dungeon/MtThunder/floor_id.json
index 0af734b..db52745 100644
--- a/data/dungeon/MtThunder/floor_id.json
+++ b/data/dungeon/MtThunder/floor_id.json
@@ -1,95 +1,95 @@
-{
- "name": "MtThunderFloorID",
- "tables": [
- {
- "MainData": 39,
- "Pokemon": 29,
- "Traps": 1,
- "Items": 15,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 40,
- "Pokemon": 30,
- "Traps": 1,
- "Items": 15,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 41,
- "Pokemon": 30,
- "Traps": 1,
- "Items": 15,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 42,
- "Pokemon": 30,
- "Traps": 1,
- "Items": 16,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 43,
- "Pokemon": 31,
- "Traps": 1,
- "Items": 16,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 44,
- "Pokemon": 32,
- "Traps": 1,
- "Items": 16,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 45,
- "Pokemon": 33,
- "Traps": 1,
- "Items": 16,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 46,
- "Pokemon": 34,
- "Traps": 1,
- "Items": 16,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 47,
- "Pokemon": 35,
- "Traps": 1,
- "Items": 16,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 48,
- "Pokemon": 36,
- "Traps": 1,
- "Items": 16,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- }
- ]
-}
+{
+ "name": "MtThunderFloorID",
+ "tables": [
+ {
+ "MainData": 39,
+ "Pokemon": 29,
+ "Traps": 1,
+ "Items": 15,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 40,
+ "Pokemon": 30,
+ "Traps": 1,
+ "Items": 15,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 41,
+ "Pokemon": 30,
+ "Traps": 1,
+ "Items": 15,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 42,
+ "Pokemon": 30,
+ "Traps": 1,
+ "Items": 16,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 43,
+ "Pokemon": 31,
+ "Traps": 1,
+ "Items": 16,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 44,
+ "Pokemon": 32,
+ "Traps": 1,
+ "Items": 16,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 45,
+ "Pokemon": 33,
+ "Traps": 1,
+ "Items": 16,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 46,
+ "Pokemon": 34,
+ "Traps": 1,
+ "Items": 16,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 47,
+ "Pokemon": 35,
+ "Traps": 1,
+ "Items": 16,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 48,
+ "Pokemon": 36,
+ "Traps": 1,
+ "Items": 16,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ }
+ ]
+}
diff --git a/data/dungeon/MtThunder/pokemon_found.json b/data/dungeon/MtThunder/pokemon_found.json
index f6c5c76..731f4ac 100644
--- a/data/dungeon/MtThunder/pokemon_found.json
+++ b/data/dungeon/MtThunder/pokemon_found.json
@@ -1,300 +1,300 @@
-{
- "tables": [{
- "name": "MtThunder_1F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_WEEDLE",
- "level": 8,
- "probability": 1875
- },
- {
- "species": "SPECIES_NIDORAN_M",
- "level": 12,
- "probability": 3125
- },
- {
- "species": "SPECIES_ELECTRIKE",
- "level": 12,
- "probability": 3125
- },
- {
- "species": "SPECIES_CACNEA",
- "level": 11,
- "probability": 1875
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "MtThunder_2F_4F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_WEEDLE",
- "level": 8,
- "probability": 1429
- },
- {
- "species": "SPECIES_PIDGEOTTO",
- "level": 11,
- "probability": 2381
- },
- {
- "species": "SPECIES_NIDORAN_M",
- "level": 12,
- "probability": 2380
- },
- {
- "species": "SPECIES_ELECTRIKE",
- "level": 12,
- "probability": 2381
- },
- {
- "species": "SPECIES_CACNEA",
- "level": 11,
- "probability": 1429
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "MtThunder_5F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_BEEDRILL",
- "level": 10,
- "probability": 1333
- },
- {
- "species": "SPECIES_PIDGEOTTO",
- "level": 11,
- "probability": 3334
- },
- {
- "species": "SPECIES_ELECTABUZZ",
- "level": 12,
- "probability": 2666
- },
- {
- "species": "SPECIES_STANTLER",
- "level": 9,
- "probability": 2667
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "MtThunder_6F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_BEEDRILL",
- "level": 10,
- "probability": 1538
- },
- {
- "species": "SPECIES_ELECTABUZZ",
- "level": 12,
- "probability": 3077
- },
- {
- "species": "SPECIES_AMPHAROS",
- "level": 12,
- "probability": 2308
- },
- {
- "species": "SPECIES_STANTLER",
- "level": 9,
- "probability": 3077
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "MtThunder_7F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_BEEDRILL",
- "level": 10,
- "probability": 1111
- },
- {
- "species": "SPECIES_ELECTABUZZ",
- "level": 12,
- "probability": 2222
- },
- {
- "species": "SPECIES_AMPHAROS",
- "level": 12,
- "probability": 1667
- },
- {
- "species": "SPECIES_GLIGAR",
- "level": 12,
- "probability": 2778
- },
- {
- "species": "SPECIES_STANTLER",
- "level": 9,
- "probability": 2222
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "MtThunder_8F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_BEEDRILL",
- "level": 10,
- "probability": 870
- },
- {
- "species": "SPECIES_ELECTABUZZ",
- "level": 12,
- "probability": 1739
- },
- {
- "species": "SPECIES_AMPHAROS",
- "level": 12,
- "probability": 1304
- },
- {
- "species": "SPECIES_GLIGAR",
- "level": 12,
- "probability": 2174
- },
- {
- "species": "SPECIES_STANTLER",
- "level": 9,
- "probability": 1739
- },
- {
- "species": "SPECIES_MANECTRIC",
- "level": 9,
- "probability": 2174
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "MtThunder_9F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_GROWLITHE",
- "level": 10,
- "probability": 1905
- },
- {
- "species": "SPECIES_AMPHAROS",
- "level": 12,
- "probability": 1428
- },
- {
- "species": "SPECIES_GLIGAR",
- "level": 12,
- "probability": 2381
- },
- {
- "species": "SPECIES_STANTLER",
- "level": 9,
- "probability": 1905
- },
- {
- "species": "SPECIES_MANECTRIC",
- "level": 9,
- "probability": 2381
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "MtThunder_10F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_GROWLITHE",
- "level": 10,
- "probability": 2353
- },
- {
- "species": "SPECIES_AMPHAROS",
- "level": 12,
- "probability": 1765
- },
- {
- "species": "SPECIES_GLIGAR",
- "level": 12,
- "probability": 2941
- },
- {
- "species": "SPECIES_MANECTRIC",
- "level": 9,
- "probability": 2941
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }]
-}
+{
+ "tables": [{
+ "name": "MtThunder_1F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_WEEDLE",
+ "level": 8,
+ "probability": 1875
+ },
+ {
+ "species": "SPECIES_NIDORAN_M",
+ "level": 12,
+ "probability": 3125
+ },
+ {
+ "species": "SPECIES_ELECTRIKE",
+ "level": 12,
+ "probability": 3125
+ },
+ {
+ "species": "SPECIES_CACNEA",
+ "level": 11,
+ "probability": 1875
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "MtThunder_2F_4F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_WEEDLE",
+ "level": 8,
+ "probability": 1429
+ },
+ {
+ "species": "SPECIES_PIDGEOTTO",
+ "level": 11,
+ "probability": 2381
+ },
+ {
+ "species": "SPECIES_NIDORAN_M",
+ "level": 12,
+ "probability": 2380
+ },
+ {
+ "species": "SPECIES_ELECTRIKE",
+ "level": 12,
+ "probability": 2381
+ },
+ {
+ "species": "SPECIES_CACNEA",
+ "level": 11,
+ "probability": 1429
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "MtThunder_5F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_BEEDRILL",
+ "level": 10,
+ "probability": 1333
+ },
+ {
+ "species": "SPECIES_PIDGEOTTO",
+ "level": 11,
+ "probability": 3334
+ },
+ {
+ "species": "SPECIES_ELECTABUZZ",
+ "level": 12,
+ "probability": 2666
+ },
+ {
+ "species": "SPECIES_STANTLER",
+ "level": 9,
+ "probability": 2667
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "MtThunder_6F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_BEEDRILL",
+ "level": 10,
+ "probability": 1538
+ },
+ {
+ "species": "SPECIES_ELECTABUZZ",
+ "level": 12,
+ "probability": 3077
+ },
+ {
+ "species": "SPECIES_AMPHAROS",
+ "level": 12,
+ "probability": 2308
+ },
+ {
+ "species": "SPECIES_STANTLER",
+ "level": 9,
+ "probability": 3077
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "MtThunder_7F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_BEEDRILL",
+ "level": 10,
+ "probability": 1111
+ },
+ {
+ "species": "SPECIES_ELECTABUZZ",
+ "level": 12,
+ "probability": 2222
+ },
+ {
+ "species": "SPECIES_AMPHAROS",
+ "level": 12,
+ "probability": 1667
+ },
+ {
+ "species": "SPECIES_GLIGAR",
+ "level": 12,
+ "probability": 2778
+ },
+ {
+ "species": "SPECIES_STANTLER",
+ "level": 9,
+ "probability": 2222
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "MtThunder_8F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_BEEDRILL",
+ "level": 10,
+ "probability": 870
+ },
+ {
+ "species": "SPECIES_ELECTABUZZ",
+ "level": 12,
+ "probability": 1739
+ },
+ {
+ "species": "SPECIES_AMPHAROS",
+ "level": 12,
+ "probability": 1304
+ },
+ {
+ "species": "SPECIES_GLIGAR",
+ "level": 12,
+ "probability": 2174
+ },
+ {
+ "species": "SPECIES_STANTLER",
+ "level": 9,
+ "probability": 1739
+ },
+ {
+ "species": "SPECIES_MANECTRIC",
+ "level": 9,
+ "probability": 2174
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "MtThunder_9F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_GROWLITHE",
+ "level": 10,
+ "probability": 1905
+ },
+ {
+ "species": "SPECIES_AMPHAROS",
+ "level": 12,
+ "probability": 1428
+ },
+ {
+ "species": "SPECIES_GLIGAR",
+ "level": 12,
+ "probability": 2381
+ },
+ {
+ "species": "SPECIES_STANTLER",
+ "level": 9,
+ "probability": 1905
+ },
+ {
+ "species": "SPECIES_MANECTRIC",
+ "level": 9,
+ "probability": 2381
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "MtThunder_10F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_GROWLITHE",
+ "level": 10,
+ "probability": 2353
+ },
+ {
+ "species": "SPECIES_AMPHAROS",
+ "level": 12,
+ "probability": 1765
+ },
+ {
+ "species": "SPECIES_GLIGAR",
+ "level": 12,
+ "probability": 2941
+ },
+ {
+ "species": "SPECIES_MANECTRIC",
+ "level": 9,
+ "probability": 2941
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }]
+}
diff --git a/data/dungeon/MtThunderPeak/floor_id.json b/data/dungeon/MtThunderPeak/floor_id.json
index f59f15a..6e39e10 100644
--- a/data/dungeon/MtThunderPeak/floor_id.json
+++ b/data/dungeon/MtThunderPeak/floor_id.json
@@ -1,33 +1,33 @@
-{
- "name": "MtThunderPeakFloorID",
- "tables": [
- {
- "MainData": 49,
- "Pokemon": 37,
- "Traps": 3,
- "Items": 17,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 50,
- "Pokemon": 37,
- "Traps": 3,
- "Items": 17,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 51,
- "Pokemon": 38,
- "Traps": 3,
- "Items": 17,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- }
-
- ]
-}
+{
+ "name": "MtThunderPeakFloorID",
+ "tables": [
+ {
+ "MainData": 49,
+ "Pokemon": 37,
+ "Traps": 3,
+ "Items": 17,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 50,
+ "Pokemon": 37,
+ "Traps": 3,
+ "Items": 17,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 51,
+ "Pokemon": 38,
+ "Traps": 3,
+ "Items": 17,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ }
+
+ ]
+}
diff --git a/data/dungeon/MtThunderPeak/pokemon_found.json b/data/dungeon/MtThunderPeak/pokemon_found.json
index 964e37f..22f230e 100644
--- a/data/dungeon/MtThunderPeak/pokemon_found.json
+++ b/data/dungeon/MtThunderPeak/pokemon_found.json
@@ -1,59 +1,59 @@
-{
- "tables": [{
- "name": "MtThunderPeak_1F_2F_Pokemon",
- "pokemon": [{
- "species": "SPECIES_GROWLITHE",
- "level": 10,
- "probability": 2000
- },
- {
- "species": "SPECIES_ELECTABUZZ",
- "level": 12,
- "probability": 2000
- },
- {
- "species": "SPECIES_AMPHAROS",
- "level": 12,
- "probability": 2000
- },
- {
- "species": "SPECIES_GLIGAR",
- "level": 12,
- "probability": 2000
- },
- {
- "species": "SPECIES_MANECTRIC",
- "level": 9,
- "probability": 2000
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "MtThunderPeak_3F_Pokemon",
- "pokemon": [{
- "species": "SPECIES_ZAPDOS",
- "level": 25,
- "probability": 10000
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }]
-}
+{
+ "tables": [{
+ "name": "MtThunderPeak_1F_2F_Pokemon",
+ "pokemon": [{
+ "species": "SPECIES_GROWLITHE",
+ "level": 10,
+ "probability": 2000
+ },
+ {
+ "species": "SPECIES_ELECTABUZZ",
+ "level": 12,
+ "probability": 2000
+ },
+ {
+ "species": "SPECIES_AMPHAROS",
+ "level": 12,
+ "probability": 2000
+ },
+ {
+ "species": "SPECIES_GLIGAR",
+ "level": 12,
+ "probability": 2000
+ },
+ {
+ "species": "SPECIES_MANECTRIC",
+ "level": 9,
+ "probability": 2000
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "MtThunderPeak_3F_Pokemon",
+ "pokemon": [{
+ "species": "SPECIES_ZAPDOS",
+ "level": 25,
+ "probability": 10000
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }]
+}
diff --git a/data/dungeon/MurkyCave/floor_id.json b/data/dungeon/MurkyCave/floor_id.json
index 54a95aa..1dfc130 100644
--- a/data/dungeon/MurkyCave/floor_id.json
+++ b/data/dungeon/MurkyCave/floor_id.json
@@ -1,176 +1,176 @@
-{
- "name": "MurkyCaveFloorID",
- "tables": [
- {
- "MainData": 977,
- "Pokemon": 449,
- "Traps": 63,
- "Items": 111,
- "KecleonShop": 19,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 978,
- "Pokemon": 449,
- "Traps": 63,
- "Items": 111,
- "KecleonShop": 19,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 979,
- "Pokemon": 450,
- "Traps": 63,
- "Items": 111,
- "KecleonShop": 19,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 980,
- "Pokemon": 450,
- "Traps": 63,
- "Items": 112,
- "KecleonShop": 19,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 981,
- "Pokemon": 451,
- "Traps": 63,
- "Items": 112,
- "KecleonShop": 19,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 982,
- "Pokemon": 452,
- "Traps": 63,
- "Items": 112,
- "KecleonShop": 19,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 983,
- "Pokemon": 453,
- "Traps": 63,
- "Items": 112,
- "KecleonShop": 19,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 984,
- "Pokemon": 453,
- "Traps": 63,
- "Items": 112,
- "KecleonShop": 19,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 985,
- "Pokemon": 453,
- "Traps": 63,
- "Items": 112,
- "KecleonShop": 19,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 986,
- "Pokemon": 454,
- "Traps": 63,
- "Items": 112,
- "KecleonShop": 19,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 987,
- "Pokemon": 455,
- "Traps": 63,
- "Items": 112,
- "KecleonShop": 19,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 988,
- "Pokemon": 456,
- "Traps": 63,
- "Items": 112,
- "KecleonShop": 19,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 989,
- "Pokemon": 457,
- "Traps": 63,
- "Items": 112,
- "KecleonShop": 19,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 990,
- "Pokemon": 458,
- "Traps": 63,
- "Items": 112,
- "KecleonShop": 19,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 991,
- "Pokemon": 459,
- "Traps": 63,
- "Items": 112,
- "KecleonShop": 19,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 992,
- "Pokemon": 459,
- "Traps": 63,
- "Items": 112,
- "KecleonShop": 19,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 993,
- "Pokemon": 459,
- "Traps": 63,
- "Items": 112,
- "KecleonShop": 19,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 994,
- "Pokemon": 459,
- "Traps": 63,
- "Items": 112,
- "KecleonShop": 19,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 995,
- "Pokemon": 459,
- "Traps": 85,
- "Items": 112,
- "KecleonShop": 19,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- }
- ]
-}
+{
+ "name": "MurkyCaveFloorID",
+ "tables": [
+ {
+ "MainData": 977,
+ "Pokemon": 449,
+ "Traps": 63,
+ "Items": 111,
+ "KecleonShop": 19,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 978,
+ "Pokemon": 449,
+ "Traps": 63,
+ "Items": 111,
+ "KecleonShop": 19,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 979,
+ "Pokemon": 450,
+ "Traps": 63,
+ "Items": 111,
+ "KecleonShop": 19,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 980,
+ "Pokemon": 450,
+ "Traps": 63,
+ "Items": 112,
+ "KecleonShop": 19,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 981,
+ "Pokemon": 451,
+ "Traps": 63,
+ "Items": 112,
+ "KecleonShop": 19,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 982,
+ "Pokemon": 452,
+ "Traps": 63,
+ "Items": 112,
+ "KecleonShop": 19,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 983,
+ "Pokemon": 453,
+ "Traps": 63,
+ "Items": 112,
+ "KecleonShop": 19,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 984,
+ "Pokemon": 453,
+ "Traps": 63,
+ "Items": 112,
+ "KecleonShop": 19,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 985,
+ "Pokemon": 453,
+ "Traps": 63,
+ "Items": 112,
+ "KecleonShop": 19,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 986,
+ "Pokemon": 454,
+ "Traps": 63,
+ "Items": 112,
+ "KecleonShop": 19,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 987,
+ "Pokemon": 455,
+ "Traps": 63,
+ "Items": 112,
+ "KecleonShop": 19,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 988,
+ "Pokemon": 456,
+ "Traps": 63,
+ "Items": 112,
+ "KecleonShop": 19,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 989,
+ "Pokemon": 457,
+ "Traps": 63,
+ "Items": 112,
+ "KecleonShop": 19,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 990,
+ "Pokemon": 458,
+ "Traps": 63,
+ "Items": 112,
+ "KecleonShop": 19,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 991,
+ "Pokemon": 459,
+ "Traps": 63,
+ "Items": 112,
+ "KecleonShop": 19,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 992,
+ "Pokemon": 459,
+ "Traps": 63,
+ "Items": 112,
+ "KecleonShop": 19,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 993,
+ "Pokemon": 459,
+ "Traps": 63,
+ "Items": 112,
+ "KecleonShop": 19,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 994,
+ "Pokemon": 459,
+ "Traps": 63,
+ "Items": 112,
+ "KecleonShop": 19,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 995,
+ "Pokemon": 459,
+ "Traps": 85,
+ "Items": 112,
+ "KecleonShop": 19,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ }
+ ]
+}
diff --git a/data/dungeon/NorthernRange/floor_id.json b/data/dungeon/NorthernRange/floor_id.json
index 86a4c82..27ca365 100644
--- a/data/dungeon/NorthernRange/floor_id.json
+++ b/data/dungeon/NorthernRange/floor_id.json
@@ -1,230 +1,230 @@
-{
- "name": "NorthernRangeFloorID",
- "tables": [
- {
- "MainData": 703,
- "Pokemon": 327,
- "Traps": 62,
- "Items": 84,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 704,
- "Pokemon": 327,
- "Traps": 62,
- "Items": 84,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 705,
- "Pokemon": 327,
- "Traps": 62,
- "Items": 84,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 706,
- "Pokemon": 327,
- "Traps": 62,
- "Items": 85,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 707,
- "Pokemon": 327,
- "Traps": 62,
- "Items": 85,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 708,
- "Pokemon": 328,
- "Traps": 62,
- "Items": 85,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 709,
- "Pokemon": 329,
- "Traps": 62,
- "Items": 85,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 710,
- "Pokemon": 330,
- "Traps": 62,
- "Items": 85,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 711,
- "Pokemon": 330,
- "Traps": 62,
- "Items": 85,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 712,
- "Pokemon": 330,
- "Traps": 62,
- "Items": 85,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 713,
- "Pokemon": 330,
- "Traps": 62,
- "Items": 85,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 714,
- "Pokemon": 331,
- "Traps": 62,
- "Items": 85,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 715,
- "Pokemon": 331,
- "Traps": 62,
- "Items": 85,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 716,
- "Pokemon": 332,
- "Traps": 62,
- "Items": 85,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 717,
- "Pokemon": 332,
- "Traps": 62,
- "Items": 85,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 718,
- "Pokemon": 332,
- "Traps": 62,
- "Items": 85,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 719,
- "Pokemon": 333,
- "Traps": 62,
- "Items": 85,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 720,
- "Pokemon": 334,
- "Traps": 62,
- "Items": 85,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 721,
- "Pokemon": 335,
- "Traps": 62,
- "Items": 85,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 722,
- "Pokemon": 336,
- "Traps": 62,
- "Items": 85,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 723,
- "Pokemon": 337,
- "Traps": 61,
- "Items": 85,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 724,
- "Pokemon": 337,
- "Traps": 61,
- "Items": 85,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 725,
- "Pokemon": 337,
- "Traps": 61,
- "Items": 86,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 726,
- "Pokemon": 337,
- "Traps": 61,
- "Items": 86,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 727,
- "Pokemon": 338,
- "Traps": 61,
- "Items": 86,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- }
- ]
-}
+{
+ "name": "NorthernRangeFloorID",
+ "tables": [
+ {
+ "MainData": 703,
+ "Pokemon": 327,
+ "Traps": 62,
+ "Items": 84,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 704,
+ "Pokemon": 327,
+ "Traps": 62,
+ "Items": 84,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 705,
+ "Pokemon": 327,
+ "Traps": 62,
+ "Items": 84,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 706,
+ "Pokemon": 327,
+ "Traps": 62,
+ "Items": 85,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 707,
+ "Pokemon": 327,
+ "Traps": 62,
+ "Items": 85,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 708,
+ "Pokemon": 328,
+ "Traps": 62,
+ "Items": 85,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 709,
+ "Pokemon": 329,
+ "Traps": 62,
+ "Items": 85,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 710,
+ "Pokemon": 330,
+ "Traps": 62,
+ "Items": 85,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 711,
+ "Pokemon": 330,
+ "Traps": 62,
+ "Items": 85,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 712,
+ "Pokemon": 330,
+ "Traps": 62,
+ "Items": 85,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 713,
+ "Pokemon": 330,
+ "Traps": 62,
+ "Items": 85,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 714,
+ "Pokemon": 331,
+ "Traps": 62,
+ "Items": 85,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 715,
+ "Pokemon": 331,
+ "Traps": 62,
+ "Items": 85,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 716,
+ "Pokemon": 332,
+ "Traps": 62,
+ "Items": 85,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 717,
+ "Pokemon": 332,
+ "Traps": 62,
+ "Items": 85,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 718,
+ "Pokemon": 332,
+ "Traps": 62,
+ "Items": 85,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 719,
+ "Pokemon": 333,
+ "Traps": 62,
+ "Items": 85,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 720,
+ "Pokemon": 334,
+ "Traps": 62,
+ "Items": 85,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 721,
+ "Pokemon": 335,
+ "Traps": 62,
+ "Items": 85,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 722,
+ "Pokemon": 336,
+ "Traps": 62,
+ "Items": 85,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 723,
+ "Pokemon": 337,
+ "Traps": 61,
+ "Items": 85,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 724,
+ "Pokemon": 337,
+ "Traps": 61,
+ "Items": 85,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 725,
+ "Pokemon": 337,
+ "Traps": 61,
+ "Items": 86,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 726,
+ "Pokemon": 337,
+ "Traps": 61,
+ "Items": 86,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 727,
+ "Pokemon": 338,
+ "Traps": 61,
+ "Items": 86,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ }
+ ]
+}
diff --git a/data/dungeon/NorthwindField/floor_id.json b/data/dungeon/NorthwindField/floor_id.json
index b4a4cd8..e5a2481 100644
--- a/data/dungeon/NorthwindField/floor_id.json
+++ b/data/dungeon/NorthwindField/floor_id.json
@@ -1,275 +1,275 @@
-{
- "name": "NorthwindFieldFloorID",
- "tables": [
- {
- "MainData": 870,
- "Pokemon": 395,
- "Traps": 72,
- "Items": 100,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 871,
- "Pokemon": 395,
- "Traps": 72,
- "Items": 100,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 872,
- "Pokemon": 396,
- "Traps": 72,
- "Items": 100,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 873,
- "Pokemon": 396,
- "Traps": 72,
- "Items": 100,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 874,
- "Pokemon": 397,
- "Traps": 72,
- "Items": 100,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 875,
- "Pokemon": 397,
- "Traps": 72,
- "Items": 100,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 876,
- "Pokemon": 398,
- "Traps": 72,
- "Items": 100,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 877,
- "Pokemon": 399,
- "Traps": 72,
- "Items": 100,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 878,
- "Pokemon": 399,
- "Traps": 72,
- "Items": 100,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 879,
- "Pokemon": 400,
- "Traps": 73,
- "Items": 100,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 880,
- "Pokemon": 401,
- "Traps": 74,
- "Items": 100,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 881,
- "Pokemon": 401,
- "Traps": 74,
- "Items": 100,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 882,
- "Pokemon": 401,
- "Traps": 74,
- "Items": 100,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 883,
- "Pokemon": 401,
- "Traps": 74,
- "Items": 100,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 884,
- "Pokemon": 401,
- "Traps": 74,
- "Items": 100,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 885,
- "Pokemon": 401,
- "Traps": 74,
- "Items": 100,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 886,
- "Pokemon": 402,
- "Traps": 74,
- "Items": 100,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 887,
- "Pokemon": 402,
- "Traps": 74,
- "Items": 100,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 888,
- "Pokemon": 403,
- "Traps": 74,
- "Items": 100,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 889,
- "Pokemon": 404,
- "Traps": 74,
- "Items": 100,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 890,
- "Pokemon": 403,
- "Traps": 74,
- "Items": 100,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 891,
- "Pokemon": 403,
- "Traps": 74,
- "Items": 100,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 892,
- "Pokemon": 405,
- "Traps": 74,
- "Items": 100,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 893,
- "Pokemon": 405,
- "Traps": 74,
- "Items": 100,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 894,
- "Pokemon": 406,
- "Traps": 74,
- "Items": 100,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 895,
- "Pokemon": 407,
- "Traps": 74,
- "Items": 100,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 896,
- "Pokemon": 408,
- "Traps": 74,
- "Items": 100,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 897,
- "Pokemon": 409,
- "Traps": 74,
- "Items": 100,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 898,
- "Pokemon": 410,
- "Traps": 74,
- "Items": 101,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 899,
- "Pokemon": 411,
- "Traps": 74,
- "Items": 101,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- }
- ]
-}
+{
+ "name": "NorthwindFieldFloorID",
+ "tables": [
+ {
+ "MainData": 870,
+ "Pokemon": 395,
+ "Traps": 72,
+ "Items": 100,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 871,
+ "Pokemon": 395,
+ "Traps": 72,
+ "Items": 100,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 872,
+ "Pokemon": 396,
+ "Traps": 72,
+ "Items": 100,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 873,
+ "Pokemon": 396,
+ "Traps": 72,
+ "Items": 100,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 874,
+ "Pokemon": 397,
+ "Traps": 72,
+ "Items": 100,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 875,
+ "Pokemon": 397,
+ "Traps": 72,
+ "Items": 100,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 876,
+ "Pokemon": 398,
+ "Traps": 72,
+ "Items": 100,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 877,
+ "Pokemon": 399,
+ "Traps": 72,
+ "Items": 100,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 878,
+ "Pokemon": 399,
+ "Traps": 72,
+ "Items": 100,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 879,
+ "Pokemon": 400,
+ "Traps": 73,
+ "Items": 100,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 880,
+ "Pokemon": 401,
+ "Traps": 74,
+ "Items": 100,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 881,
+ "Pokemon": 401,
+ "Traps": 74,
+ "Items": 100,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 882,
+ "Pokemon": 401,
+ "Traps": 74,
+ "Items": 100,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 883,
+ "Pokemon": 401,
+ "Traps": 74,
+ "Items": 100,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 884,
+ "Pokemon": 401,
+ "Traps": 74,
+ "Items": 100,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 885,
+ "Pokemon": 401,
+ "Traps": 74,
+ "Items": 100,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 886,
+ "Pokemon": 402,
+ "Traps": 74,
+ "Items": 100,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 887,
+ "Pokemon": 402,
+ "Traps": 74,
+ "Items": 100,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 888,
+ "Pokemon": 403,
+ "Traps": 74,
+ "Items": 100,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 889,
+ "Pokemon": 404,
+ "Traps": 74,
+ "Items": 100,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 890,
+ "Pokemon": 403,
+ "Traps": 74,
+ "Items": 100,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 891,
+ "Pokemon": 403,
+ "Traps": 74,
+ "Items": 100,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 892,
+ "Pokemon": 405,
+ "Traps": 74,
+ "Items": 100,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 893,
+ "Pokemon": 405,
+ "Traps": 74,
+ "Items": 100,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 894,
+ "Pokemon": 406,
+ "Traps": 74,
+ "Items": 100,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 895,
+ "Pokemon": 407,
+ "Traps": 74,
+ "Items": 100,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 896,
+ "Pokemon": 408,
+ "Traps": 74,
+ "Items": 100,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 897,
+ "Pokemon": 409,
+ "Traps": 74,
+ "Items": 100,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 898,
+ "Pokemon": 410,
+ "Traps": 74,
+ "Items": 101,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 899,
+ "Pokemon": 411,
+ "Traps": 74,
+ "Items": 101,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ }
+ ]
+}
diff --git a/data/dungeon/OddityCave/floor_id.json b/data/dungeon/OddityCave/floor_id.json
index 3ab0136..3c6b0ea 100644
--- a/data/dungeon/OddityCave/floor_id.json
+++ b/data/dungeon/OddityCave/floor_id.json
@@ -1,140 +1,140 @@
-{
- "name": "OddityCaveFloorID",
- "tables": [
- {
- "MainData": 1036,
- "Pokemon": 481,
- "Traps": 62,
- "Items": 119,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 109
- },
- {
- "MainData": 1037,
- "Pokemon": 481,
- "Traps": 62,
- "Items": 119,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 109
- },
- {
- "MainData": 1038,
- "Pokemon": 481,
- "Traps": 62,
- "Items": 119,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 109
- },
- {
- "MainData": 1039,
- "Pokemon": 482,
- "Traps": 62,
- "Items": 120,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 109
- },
- {
- "MainData": 1040,
- "Pokemon": 483,
- "Traps": 62,
- "Items": 120,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 109
- },
- {
- "MainData": 1041,
- "Pokemon": 484,
- "Traps": 62,
- "Items": 120,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 1042,
- "Pokemon": 485,
- "Traps": 62,
- "Items": 120,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 1043,
- "Pokemon": 486,
- "Traps": 62,
- "Items": 120,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 1044,
- "Pokemon": 486,
- "Traps": 62,
- "Items": 120,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 1045,
- "Pokemon": 487,
- "Traps": 62,
- "Items": 120,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 1046,
- "Pokemon": 488,
- "Traps": 62,
- "Items": 120,
- "KecleonShop": 28,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1047,
- "Pokemon": 488,
- "Traps": 62,
- "Items": 120,
- "KecleonShop": 28,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1048,
- "Pokemon": 489,
- "Traps": 62,
- "Items": 120,
- "KecleonShop": 28,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1049,
- "Pokemon": 490,
- "Traps": 62,
- "Items": 120,
- "KecleonShop": 28,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1050,
- "Pokemon": 490,
- "Traps": 62,
- "Items": 120,
- "KecleonShop": 28,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- }
- ]
-}
+{
+ "name": "OddityCaveFloorID",
+ "tables": [
+ {
+ "MainData": 1036,
+ "Pokemon": 481,
+ "Traps": 62,
+ "Items": 119,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 109
+ },
+ {
+ "MainData": 1037,
+ "Pokemon": 481,
+ "Traps": 62,
+ "Items": 119,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 109
+ },
+ {
+ "MainData": 1038,
+ "Pokemon": 481,
+ "Traps": 62,
+ "Items": 119,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 109
+ },
+ {
+ "MainData": 1039,
+ "Pokemon": 482,
+ "Traps": 62,
+ "Items": 120,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 109
+ },
+ {
+ "MainData": 1040,
+ "Pokemon": 483,
+ "Traps": 62,
+ "Items": 120,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 109
+ },
+ {
+ "MainData": 1041,
+ "Pokemon": 484,
+ "Traps": 62,
+ "Items": 120,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1042,
+ "Pokemon": 485,
+ "Traps": 62,
+ "Items": 120,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1043,
+ "Pokemon": 486,
+ "Traps": 62,
+ "Items": 120,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1044,
+ "Pokemon": 486,
+ "Traps": 62,
+ "Items": 120,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1045,
+ "Pokemon": 487,
+ "Traps": 62,
+ "Items": 120,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1046,
+ "Pokemon": 488,
+ "Traps": 62,
+ "Items": 120,
+ "KecleonShop": 28,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1047,
+ "Pokemon": 488,
+ "Traps": 62,
+ "Items": 120,
+ "KecleonShop": 28,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1048,
+ "Pokemon": 489,
+ "Traps": 62,
+ "Items": 120,
+ "KecleonShop": 28,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1049,
+ "Pokemon": 490,
+ "Traps": 62,
+ "Items": 120,
+ "KecleonShop": 28,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1050,
+ "Pokemon": 490,
+ "Traps": 62,
+ "Items": 120,
+ "KecleonShop": 28,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ }
+ ]
+}
diff --git a/data/dungeon/PitfallValley/floor_id.json b/data/dungeon/PitfallValley/floor_id.json
index 1a52a7e..0b06593 100644
--- a/data/dungeon/PitfallValley/floor_id.json
+++ b/data/dungeon/PitfallValley/floor_id.json
@@ -1,230 +1,230 @@
-{
- "name": "PitfallValleyFloorID",
- "tables": [
- {
- "MainData": 678,
- "Pokemon": 317,
- "Traps": 59,
- "Items": 84,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 679,
- "Pokemon": 317,
- "Traps": 59,
- "Items": 84,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 680,
- "Pokemon": 317,
- "Traps": 59,
- "Items": 84,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 681,
- "Pokemon": 318,
- "Traps": 59,
- "Items": 85,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 682,
- "Pokemon": 318,
- "Traps": 59,
- "Items": 85,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 683,
- "Pokemon": 318,
- "Traps": 59,
- "Items": 85,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 684,
- "Pokemon": 319,
- "Traps": 59,
- "Items": 85,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 685,
- "Pokemon": 319,
- "Traps": 59,
- "Items": 85,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 686,
- "Pokemon": 320,
- "Traps": 59,
- "Items": 85,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 687,
- "Pokemon": 321,
- "Traps": 59,
- "Items": 85,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 688,
- "Pokemon": 321,
- "Traps": 59,
- "Items": 85,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 689,
- "Pokemon": 321,
- "Traps": 59,
- "Items": 85,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 690,
- "Pokemon": 322,
- "Traps": 59,
- "Items": 85,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 691,
- "Pokemon": 322,
- "Traps": 59,
- "Items": 85,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 692,
- "Pokemon": 323,
- "Traps": 59,
- "Items": 85,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 693,
- "Pokemon": 324,
- "Traps": 59,
- "Items": 85,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 694,
- "Pokemon": 324,
- "Traps": 59,
- "Items": 85,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 695,
- "Pokemon": 324,
- "Traps": 59,
- "Items": 85,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 696,
- "Pokemon": 325,
- "Traps": 59,
- "Items": 85,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 697,
- "Pokemon": 325,
- "Traps": 59,
- "Items": 85,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 698,
- "Pokemon": 326,
- "Traps": 60,
- "Items": 85,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 699,
- "Pokemon": 326,
- "Traps": 60,
- "Items": 85,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 700,
- "Pokemon": 326,
- "Traps": 60,
- "Items": 86,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 701,
- "Pokemon": 326,
- "Traps": 60,
- "Items": 86,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 702,
- "Pokemon": 326,
- "Traps": 61,
- "Items": 86,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- }
- ]
-}
+{
+ "name": "PitfallValleyFloorID",
+ "tables": [
+ {
+ "MainData": 678,
+ "Pokemon": 317,
+ "Traps": 59,
+ "Items": 84,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 679,
+ "Pokemon": 317,
+ "Traps": 59,
+ "Items": 84,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 680,
+ "Pokemon": 317,
+ "Traps": 59,
+ "Items": 84,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 681,
+ "Pokemon": 318,
+ "Traps": 59,
+ "Items": 85,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 682,
+ "Pokemon": 318,
+ "Traps": 59,
+ "Items": 85,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 683,
+ "Pokemon": 318,
+ "Traps": 59,
+ "Items": 85,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 684,
+ "Pokemon": 319,
+ "Traps": 59,
+ "Items": 85,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 685,
+ "Pokemon": 319,
+ "Traps": 59,
+ "Items": 85,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 686,
+ "Pokemon": 320,
+ "Traps": 59,
+ "Items": 85,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 687,
+ "Pokemon": 321,
+ "Traps": 59,
+ "Items": 85,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 688,
+ "Pokemon": 321,
+ "Traps": 59,
+ "Items": 85,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 689,
+ "Pokemon": 321,
+ "Traps": 59,
+ "Items": 85,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 690,
+ "Pokemon": 322,
+ "Traps": 59,
+ "Items": 85,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 691,
+ "Pokemon": 322,
+ "Traps": 59,
+ "Items": 85,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 692,
+ "Pokemon": 323,
+ "Traps": 59,
+ "Items": 85,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 693,
+ "Pokemon": 324,
+ "Traps": 59,
+ "Items": 85,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 694,
+ "Pokemon": 324,
+ "Traps": 59,
+ "Items": 85,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 695,
+ "Pokemon": 324,
+ "Traps": 59,
+ "Items": 85,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 696,
+ "Pokemon": 325,
+ "Traps": 59,
+ "Items": 85,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 697,
+ "Pokemon": 325,
+ "Traps": 59,
+ "Items": 85,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 698,
+ "Pokemon": 326,
+ "Traps": 60,
+ "Items": 85,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 699,
+ "Pokemon": 326,
+ "Traps": 60,
+ "Items": 85,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 700,
+ "Pokemon": 326,
+ "Traps": 60,
+ "Items": 86,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 701,
+ "Pokemon": 326,
+ "Traps": 60,
+ "Items": 86,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 702,
+ "Pokemon": 326,
+ "Traps": 61,
+ "Items": 86,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ }
+ ]
+}
diff --git a/data/dungeon/PurityForest/floor_id.json b/data/dungeon/PurityForest/floor_id.json
index b60b18c..17cfa6b 100644
--- a/data/dungeon/PurityForest/floor_id.json
+++ b/data/dungeon/PurityForest/floor_id.json
@@ -1,896 +1,896 @@
-{
- "name": "PurityForestFloorID",
- "tables": [
- {
- "MainData": 1664,
- "Pokemon": 750,
- "Traps": 137,
- "Items": 168,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1665,
- "Pokemon": 751,
- "Traps": 137,
- "Items": 168,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1666,
- "Pokemon": 752,
- "Traps": 30,
- "Items": 168,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1667,
- "Pokemon": 753,
- "Traps": 30,
- "Items": 171,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1668,
- "Pokemon": 754,
- "Traps": 30,
- "Items": 171,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1669,
- "Pokemon": 755,
- "Traps": 30,
- "Items": 171,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1670,
- "Pokemon": 756,
- "Traps": 30,
- "Items": 171,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1671,
- "Pokemon": 757,
- "Traps": 30,
- "Items": 171,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1672,
- "Pokemon": 758,
- "Traps": 30,
- "Items": 171,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1673,
- "Pokemon": 759,
- "Traps": 95,
- "Items": 171,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1674,
- "Pokemon": 760,
- "Traps": 96,
- "Items": 171,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1675,
- "Pokemon": 761,
- "Traps": 96,
- "Items": 171,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1676,
- "Pokemon": 762,
- "Traps": 96,
- "Items": 171,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1677,
- "Pokemon": 763,
- "Traps": 96,
- "Items": 171,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1678,
- "Pokemon": 764,
- "Traps": 96,
- "Items": 171,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1679,
- "Pokemon": 765,
- "Traps": 96,
- "Items": 171,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1680,
- "Pokemon": 766,
- "Traps": 96,
- "Items": 171,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1681,
- "Pokemon": 767,
- "Traps": 96,
- "Items": 171,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1682,
- "Pokemon": 768,
- "Traps": 96,
- "Items": 171,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1683,
- "Pokemon": 769,
- "Traps": 138,
- "Items": 172,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1684,
- "Pokemon": 770,
- "Traps": 139,
- "Items": 171,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1685,
- "Pokemon": 771,
- "Traps": 139,
- "Items": 171,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1686,
- "Pokemon": 772,
- "Traps": 139,
- "Items": 171,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1687,
- "Pokemon": 773,
- "Traps": 139,
- "Items": 171,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1688,
- "Pokemon": 774,
- "Traps": 139,
- "Items": 171,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1689,
- "Pokemon": 775,
- "Traps": 139,
- "Items": 171,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1690,
- "Pokemon": 776,
- "Traps": 139,
- "Items": 171,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1691,
- "Pokemon": 777,
- "Traps": 139,
- "Items": 171,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1692,
- "Pokemon": 778,
- "Traps": 139,
- "Items": 171,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1693,
- "Pokemon": 779,
- "Traps": 99,
- "Items": 171,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1694,
- "Pokemon": 780,
- "Traps": 100,
- "Items": 171,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1695,
- "Pokemon": 781,
- "Traps": 100,
- "Items": 171,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1696,
- "Pokemon": 782,
- "Traps": 100,
- "Items": 171,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1697,
- "Pokemon": 783,
- "Traps": 100,
- "Items": 171,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1698,
- "Pokemon": 784,
- "Traps": 100,
- "Items": 171,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1699,
- "Pokemon": 785,
- "Traps": 100,
- "Items": 171,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1700,
- "Pokemon": 786,
- "Traps": 100,
- "Items": 171,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1701,
- "Pokemon": 787,
- "Traps": 100,
- "Items": 171,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1702,
- "Pokemon": 788,
- "Traps": 100,
- "Items": 171,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1703,
- "Pokemon": 789,
- "Traps": 101,
- "Items": 171,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1704,
- "Pokemon": 790,
- "Traps": 101,
- "Items": 171,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1705,
- "Pokemon": 791,
- "Traps": 101,
- "Items": 171,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1706,
- "Pokemon": 792,
- "Traps": 101,
- "Items": 171,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1707,
- "Pokemon": 793,
- "Traps": 101,
- "Items": 171,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1708,
- "Pokemon": 794,
- "Traps": 101,
- "Items": 171,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1709,
- "Pokemon": 795,
- "Traps": 101,
- "Items": 171,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1710,
- "Pokemon": 796,
- "Traps": 101,
- "Items": 171,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1711,
- "Pokemon": 797,
- "Traps": 101,
- "Items": 171,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1712,
- "Pokemon": 798,
- "Traps": 101,
- "Items": 171,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1713,
- "Pokemon": 799,
- "Traps": 140,
- "Items": 173,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1714,
- "Pokemon": 800,
- "Traps": 141,
- "Items": 173,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1715,
- "Pokemon": 801,
- "Traps": 141,
- "Items": 173,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1716,
- "Pokemon": 802,
- "Traps": 141,
- "Items": 173,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1717,
- "Pokemon": 803,
- "Traps": 141,
- "Items": 173,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1718,
- "Pokemon": 804,
- "Traps": 141,
- "Items": 173,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1719,
- "Pokemon": 805,
- "Traps": 141,
- "Items": 173,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1720,
- "Pokemon": 806,
- "Traps": 141,
- "Items": 173,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1721,
- "Pokemon": 807,
- "Traps": 141,
- "Items": 173,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1722,
- "Pokemon": 808,
- "Traps": 141,
- "Items": 173,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1723,
- "Pokemon": 809,
- "Traps": 142,
- "Items": 174,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1724,
- "Pokemon": 810,
- "Traps": 142,
- "Items": 174,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1725,
- "Pokemon": 811,
- "Traps": 142,
- "Items": 174,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1726,
- "Pokemon": 812,
- "Traps": 142,
- "Items": 174,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1727,
- "Pokemon": 813,
- "Traps": 142,
- "Items": 174,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1728,
- "Pokemon": 814,
- "Traps": 142,
- "Items": 174,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1729,
- "Pokemon": 814,
- "Traps": 142,
- "Items": 174,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1730,
- "Pokemon": 814,
- "Traps": 142,
- "Items": 174,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1731,
- "Pokemon": 814,
- "Traps": 142,
- "Items": 174,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1732,
- "Pokemon": 815,
- "Traps": 142,
- "Items": 174,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1733,
- "Pokemon": 816,
- "Traps": 143,
- "Items": 174,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1734,
- "Pokemon": 817,
- "Traps": 144,
- "Items": 174,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1735,
- "Pokemon": 818,
- "Traps": 144,
- "Items": 174,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1736,
- "Pokemon": 819,
- "Traps": 145,
- "Items": 174,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1737,
- "Pokemon": 820,
- "Traps": 146,
- "Items": 174,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1738,
- "Pokemon": 820,
- "Traps": 144,
- "Items": 174,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1739,
- "Pokemon": 821,
- "Traps": 144,
- "Items": 174,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1740,
- "Pokemon": 822,
- "Traps": 144,
- "Items": 174,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1741,
- "Pokemon": 823,
- "Traps": 144,
- "Items": 174,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1742,
- "Pokemon": 824,
- "Traps": 147,
- "Items": 174,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1743,
- "Pokemon": 825,
- "Traps": 111,
- "Items": 174,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1744,
- "Pokemon": 826,
- "Traps": 111,
- "Items": 174,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1745,
- "Pokemon": 826,
- "Traps": 111,
- "Items": 174,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1746,
- "Pokemon": 827,
- "Traps": 111,
- "Items": 174,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1747,
- "Pokemon": 827,
- "Traps": 111,
- "Items": 174,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1748,
- "Pokemon": 828,
- "Traps": 111,
- "Items": 174,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1749,
- "Pokemon": 829,
- "Traps": 111,
- "Items": 174,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1750,
- "Pokemon": 829,
- "Traps": 111,
- "Items": 174,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1751,
- "Pokemon": 830,
- "Traps": 111,
- "Items": 174,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1752,
- "Pokemon": 831,
- "Traps": 111,
- "Items": 174,
- "KecleonShop": 169,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1753,
- "Pokemon": 832,
- "Traps": 111,
- "Items": 174,
- "KecleonShop": 175,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1754,
- "Pokemon": 832,
- "Traps": 111,
- "Items": 174,
- "KecleonShop": 175,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1755,
- "Pokemon": 832,
- "Traps": 111,
- "Items": 174,
- "KecleonShop": 175,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1756,
- "Pokemon": 833,
- "Traps": 111,
- "Items": 174,
- "KecleonShop": 175,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1757,
- "Pokemon": 834,
- "Traps": 111,
- "Items": 174,
- "KecleonShop": 175,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1758,
- "Pokemon": 835,
- "Traps": 111,
- "Items": 174,
- "KecleonShop": 175,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1759,
- "Pokemon": 835,
- "Traps": 111,
- "Items": 174,
- "KecleonShop": 175,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1760,
- "Pokemon": 836,
- "Traps": 111,
- "Items": 174,
- "KecleonShop": 175,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1761,
- "Pokemon": 837,
- "Traps": 111,
- "Items": 174,
- "KecleonShop": 175,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- },
- {
- "MainData": 1762,
- "Pokemon": 838,
- "Traps": 111,
- "Items": 174,
- "KecleonShop": 175,
- "MonsterRoomItems": 170,
- "BuriedItems": 57
- }
- ]
-}
+{
+ "name": "PurityForestFloorID",
+ "tables": [
+ {
+ "MainData": 1664,
+ "Pokemon": 750,
+ "Traps": 137,
+ "Items": 168,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1665,
+ "Pokemon": 751,
+ "Traps": 137,
+ "Items": 168,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1666,
+ "Pokemon": 752,
+ "Traps": 30,
+ "Items": 168,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1667,
+ "Pokemon": 753,
+ "Traps": 30,
+ "Items": 171,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1668,
+ "Pokemon": 754,
+ "Traps": 30,
+ "Items": 171,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1669,
+ "Pokemon": 755,
+ "Traps": 30,
+ "Items": 171,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1670,
+ "Pokemon": 756,
+ "Traps": 30,
+ "Items": 171,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1671,
+ "Pokemon": 757,
+ "Traps": 30,
+ "Items": 171,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1672,
+ "Pokemon": 758,
+ "Traps": 30,
+ "Items": 171,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1673,
+ "Pokemon": 759,
+ "Traps": 95,
+ "Items": 171,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1674,
+ "Pokemon": 760,
+ "Traps": 96,
+ "Items": 171,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1675,
+ "Pokemon": 761,
+ "Traps": 96,
+ "Items": 171,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1676,
+ "Pokemon": 762,
+ "Traps": 96,
+ "Items": 171,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1677,
+ "Pokemon": 763,
+ "Traps": 96,
+ "Items": 171,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1678,
+ "Pokemon": 764,
+ "Traps": 96,
+ "Items": 171,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1679,
+ "Pokemon": 765,
+ "Traps": 96,
+ "Items": 171,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1680,
+ "Pokemon": 766,
+ "Traps": 96,
+ "Items": 171,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1681,
+ "Pokemon": 767,
+ "Traps": 96,
+ "Items": 171,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1682,
+ "Pokemon": 768,
+ "Traps": 96,
+ "Items": 171,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1683,
+ "Pokemon": 769,
+ "Traps": 138,
+ "Items": 172,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1684,
+ "Pokemon": 770,
+ "Traps": 139,
+ "Items": 171,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1685,
+ "Pokemon": 771,
+ "Traps": 139,
+ "Items": 171,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1686,
+ "Pokemon": 772,
+ "Traps": 139,
+ "Items": 171,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1687,
+ "Pokemon": 773,
+ "Traps": 139,
+ "Items": 171,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1688,
+ "Pokemon": 774,
+ "Traps": 139,
+ "Items": 171,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1689,
+ "Pokemon": 775,
+ "Traps": 139,
+ "Items": 171,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1690,
+ "Pokemon": 776,
+ "Traps": 139,
+ "Items": 171,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1691,
+ "Pokemon": 777,
+ "Traps": 139,
+ "Items": 171,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1692,
+ "Pokemon": 778,
+ "Traps": 139,
+ "Items": 171,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1693,
+ "Pokemon": 779,
+ "Traps": 99,
+ "Items": 171,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1694,
+ "Pokemon": 780,
+ "Traps": 100,
+ "Items": 171,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1695,
+ "Pokemon": 781,
+ "Traps": 100,
+ "Items": 171,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1696,
+ "Pokemon": 782,
+ "Traps": 100,
+ "Items": 171,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1697,
+ "Pokemon": 783,
+ "Traps": 100,
+ "Items": 171,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1698,
+ "Pokemon": 784,
+ "Traps": 100,
+ "Items": 171,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1699,
+ "Pokemon": 785,
+ "Traps": 100,
+ "Items": 171,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1700,
+ "Pokemon": 786,
+ "Traps": 100,
+ "Items": 171,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1701,
+ "Pokemon": 787,
+ "Traps": 100,
+ "Items": 171,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1702,
+ "Pokemon": 788,
+ "Traps": 100,
+ "Items": 171,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1703,
+ "Pokemon": 789,
+ "Traps": 101,
+ "Items": 171,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1704,
+ "Pokemon": 790,
+ "Traps": 101,
+ "Items": 171,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1705,
+ "Pokemon": 791,
+ "Traps": 101,
+ "Items": 171,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1706,
+ "Pokemon": 792,
+ "Traps": 101,
+ "Items": 171,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1707,
+ "Pokemon": 793,
+ "Traps": 101,
+ "Items": 171,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1708,
+ "Pokemon": 794,
+ "Traps": 101,
+ "Items": 171,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1709,
+ "Pokemon": 795,
+ "Traps": 101,
+ "Items": 171,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1710,
+ "Pokemon": 796,
+ "Traps": 101,
+ "Items": 171,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1711,
+ "Pokemon": 797,
+ "Traps": 101,
+ "Items": 171,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1712,
+ "Pokemon": 798,
+ "Traps": 101,
+ "Items": 171,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1713,
+ "Pokemon": 799,
+ "Traps": 140,
+ "Items": 173,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1714,
+ "Pokemon": 800,
+ "Traps": 141,
+ "Items": 173,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1715,
+ "Pokemon": 801,
+ "Traps": 141,
+ "Items": 173,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1716,
+ "Pokemon": 802,
+ "Traps": 141,
+ "Items": 173,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1717,
+ "Pokemon": 803,
+ "Traps": 141,
+ "Items": 173,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1718,
+ "Pokemon": 804,
+ "Traps": 141,
+ "Items": 173,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1719,
+ "Pokemon": 805,
+ "Traps": 141,
+ "Items": 173,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1720,
+ "Pokemon": 806,
+ "Traps": 141,
+ "Items": 173,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1721,
+ "Pokemon": 807,
+ "Traps": 141,
+ "Items": 173,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1722,
+ "Pokemon": 808,
+ "Traps": 141,
+ "Items": 173,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1723,
+ "Pokemon": 809,
+ "Traps": 142,
+ "Items": 174,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1724,
+ "Pokemon": 810,
+ "Traps": 142,
+ "Items": 174,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1725,
+ "Pokemon": 811,
+ "Traps": 142,
+ "Items": 174,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1726,
+ "Pokemon": 812,
+ "Traps": 142,
+ "Items": 174,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1727,
+ "Pokemon": 813,
+ "Traps": 142,
+ "Items": 174,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1728,
+ "Pokemon": 814,
+ "Traps": 142,
+ "Items": 174,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1729,
+ "Pokemon": 814,
+ "Traps": 142,
+ "Items": 174,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1730,
+ "Pokemon": 814,
+ "Traps": 142,
+ "Items": 174,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1731,
+ "Pokemon": 814,
+ "Traps": 142,
+ "Items": 174,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1732,
+ "Pokemon": 815,
+ "Traps": 142,
+ "Items": 174,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1733,
+ "Pokemon": 816,
+ "Traps": 143,
+ "Items": 174,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1734,
+ "Pokemon": 817,
+ "Traps": 144,
+ "Items": 174,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1735,
+ "Pokemon": 818,
+ "Traps": 144,
+ "Items": 174,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1736,
+ "Pokemon": 819,
+ "Traps": 145,
+ "Items": 174,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1737,
+ "Pokemon": 820,
+ "Traps": 146,
+ "Items": 174,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1738,
+ "Pokemon": 820,
+ "Traps": 144,
+ "Items": 174,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1739,
+ "Pokemon": 821,
+ "Traps": 144,
+ "Items": 174,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1740,
+ "Pokemon": 822,
+ "Traps": 144,
+ "Items": 174,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1741,
+ "Pokemon": 823,
+ "Traps": 144,
+ "Items": 174,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1742,
+ "Pokemon": 824,
+ "Traps": 147,
+ "Items": 174,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1743,
+ "Pokemon": 825,
+ "Traps": 111,
+ "Items": 174,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1744,
+ "Pokemon": 826,
+ "Traps": 111,
+ "Items": 174,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1745,
+ "Pokemon": 826,
+ "Traps": 111,
+ "Items": 174,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1746,
+ "Pokemon": 827,
+ "Traps": 111,
+ "Items": 174,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1747,
+ "Pokemon": 827,
+ "Traps": 111,
+ "Items": 174,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1748,
+ "Pokemon": 828,
+ "Traps": 111,
+ "Items": 174,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1749,
+ "Pokemon": 829,
+ "Traps": 111,
+ "Items": 174,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1750,
+ "Pokemon": 829,
+ "Traps": 111,
+ "Items": 174,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1751,
+ "Pokemon": 830,
+ "Traps": 111,
+ "Items": 174,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1752,
+ "Pokemon": 831,
+ "Traps": 111,
+ "Items": 174,
+ "KecleonShop": 169,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1753,
+ "Pokemon": 832,
+ "Traps": 111,
+ "Items": 174,
+ "KecleonShop": 175,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1754,
+ "Pokemon": 832,
+ "Traps": 111,
+ "Items": 174,
+ "KecleonShop": 175,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1755,
+ "Pokemon": 832,
+ "Traps": 111,
+ "Items": 174,
+ "KecleonShop": 175,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1756,
+ "Pokemon": 833,
+ "Traps": 111,
+ "Items": 174,
+ "KecleonShop": 175,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1757,
+ "Pokemon": 834,
+ "Traps": 111,
+ "Items": 174,
+ "KecleonShop": 175,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1758,
+ "Pokemon": 835,
+ "Traps": 111,
+ "Items": 174,
+ "KecleonShop": 175,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1759,
+ "Pokemon": 835,
+ "Traps": 111,
+ "Items": 174,
+ "KecleonShop": 175,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1760,
+ "Pokemon": 836,
+ "Traps": 111,
+ "Items": 174,
+ "KecleonShop": 175,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1761,
+ "Pokemon": 837,
+ "Traps": 111,
+ "Items": 174,
+ "KecleonShop": 175,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 1762,
+ "Pokemon": 838,
+ "Traps": 111,
+ "Items": 174,
+ "KecleonShop": 175,
+ "MonsterRoomItems": 170,
+ "BuriedItems": 57
+ }
+ ]
+}
diff --git a/data/dungeon/RemainsIsland/floor_id.json b/data/dungeon/RemainsIsland/floor_id.json
index 77b9b20..62383f7 100644
--- a/data/dungeon/RemainsIsland/floor_id.json
+++ b/data/dungeon/RemainsIsland/floor_id.json
@@ -1,185 +1,185 @@
-{
- "name": "RemainsIslandFloorID",
- "tables": [
- {
- "MainData": 1051,
- "Pokemon": 491,
- "Traps": 62,
- "Items": 119,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 109
- },
- {
- "MainData": 1052,
- "Pokemon": 491,
- "Traps": 62,
- "Items": 119,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 109
- },
- {
- "MainData": 1053,
- "Pokemon": 491,
- "Traps": 62,
- "Items": 119,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 109
- },
- {
- "MainData": 1054,
- "Pokemon": 492,
- "Traps": 62,
- "Items": 120,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 109
- },
- {
- "MainData": 1055,
- "Pokemon": 493,
- "Traps": 62,
- "Items": 120,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 109
- },
- {
- "MainData": 1056,
- "Pokemon": 493,
- "Traps": 62,
- "Items": 120,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 109
- },
- {
- "MainData": 1057,
- "Pokemon": 494,
- "Traps": 62,
- "Items": 120,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 109
- },
- {
- "MainData": 1058,
- "Pokemon": 494,
- "Traps": 62,
- "Items": 120,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 109
- },
- {
- "MainData": 1059,
- "Pokemon": 495,
- "Traps": 62,
- "Items": 120,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 109
- },
- {
- "MainData": 1060,
- "Pokemon": 496,
- "Traps": 62,
- "Items": 120,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 109
- },
- {
- "MainData": 1061,
- "Pokemon": 496,
- "Traps": 62,
- "Items": 120,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 109
- },
- {
- "MainData": 1062,
- "Pokemon": 496,
- "Traps": 62,
- "Items": 120,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 109
- },
- {
- "MainData": 1063,
- "Pokemon": 497,
- "Traps": 62,
- "Items": 120,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 109
- },
- {
- "MainData": 1064,
- "Pokemon": 498,
- "Traps": 62,
- "Items": 120,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 109
- },
- {
- "MainData": 1065,
- "Pokemon": 499,
- "Traps": 62,
- "Items": 120,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 109
- },
- {
- "MainData": 1066,
- "Pokemon": 500,
- "Traps": 62,
- "Items": 120,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 109
- },
- {
- "MainData": 1067,
- "Pokemon": 500,
- "Traps": 62,
- "Items": 120,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 109
- },
- {
- "MainData": 1068,
- "Pokemon": 500,
- "Traps": 62,
- "Items": 120,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 109
- },
- {
- "MainData": 1069,
- "Pokemon": 500,
- "Traps": 62,
- "Items": 120,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 109
- },
- {
- "MainData": 1070,
- "Pokemon": 501,
- "Traps": 62,
- "Items": 120,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 109
- }
- ]
-}
+{
+ "name": "RemainsIslandFloorID",
+ "tables": [
+ {
+ "MainData": 1051,
+ "Pokemon": 491,
+ "Traps": 62,
+ "Items": 119,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 109
+ },
+ {
+ "MainData": 1052,
+ "Pokemon": 491,
+ "Traps": 62,
+ "Items": 119,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 109
+ },
+ {
+ "MainData": 1053,
+ "Pokemon": 491,
+ "Traps": 62,
+ "Items": 119,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 109
+ },
+ {
+ "MainData": 1054,
+ "Pokemon": 492,
+ "Traps": 62,
+ "Items": 120,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 109
+ },
+ {
+ "MainData": 1055,
+ "Pokemon": 493,
+ "Traps": 62,
+ "Items": 120,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 109
+ },
+ {
+ "MainData": 1056,
+ "Pokemon": 493,
+ "Traps": 62,
+ "Items": 120,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 109
+ },
+ {
+ "MainData": 1057,
+ "Pokemon": 494,
+ "Traps": 62,
+ "Items": 120,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 109
+ },
+ {
+ "MainData": 1058,
+ "Pokemon": 494,
+ "Traps": 62,
+ "Items": 120,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 109
+ },
+ {
+ "MainData": 1059,
+ "Pokemon": 495,
+ "Traps": 62,
+ "Items": 120,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 109
+ },
+ {
+ "MainData": 1060,
+ "Pokemon": 496,
+ "Traps": 62,
+ "Items": 120,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 109
+ },
+ {
+ "MainData": 1061,
+ "Pokemon": 496,
+ "Traps": 62,
+ "Items": 120,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 109
+ },
+ {
+ "MainData": 1062,
+ "Pokemon": 496,
+ "Traps": 62,
+ "Items": 120,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 109
+ },
+ {
+ "MainData": 1063,
+ "Pokemon": 497,
+ "Traps": 62,
+ "Items": 120,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 109
+ },
+ {
+ "MainData": 1064,
+ "Pokemon": 498,
+ "Traps": 62,
+ "Items": 120,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 109
+ },
+ {
+ "MainData": 1065,
+ "Pokemon": 499,
+ "Traps": 62,
+ "Items": 120,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 109
+ },
+ {
+ "MainData": 1066,
+ "Pokemon": 500,
+ "Traps": 62,
+ "Items": 120,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 109
+ },
+ {
+ "MainData": 1067,
+ "Pokemon": 500,
+ "Traps": 62,
+ "Items": 120,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 109
+ },
+ {
+ "MainData": 1068,
+ "Pokemon": 500,
+ "Traps": 62,
+ "Items": 120,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 109
+ },
+ {
+ "MainData": 1069,
+ "Pokemon": 500,
+ "Traps": 62,
+ "Items": 120,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 109
+ },
+ {
+ "MainData": 1070,
+ "Pokemon": 501,
+ "Traps": 62,
+ "Items": 120,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 109
+ }
+ ]
+}
diff --git a/data/dungeon/RockPath/floor_id.json b/data/dungeon/RockPath/floor_id.json
index 5a6666e..6c8aed9 100644
--- a/data/dungeon/RockPath/floor_id.json
+++ b/data/dungeon/RockPath/floor_id.json
@@ -1,41 +1,41 @@
-{
- "name": "RockPathFloorID",
- "tables": [
- {
- "MainData": 1121,
- "Pokemon": 521,
- "Traps": 10,
- "Items": 123,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1122,
- "Pokemon": 521,
- "Traps": 10,
- "Items": 123,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1123,
- "Pokemon": 521,
- "Traps": 10,
- "Items": 123,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1124,
- "Pokemon": 521,
- "Traps": 10,
- "Items": 123,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- }
- ]
-}
+{
+ "name": "RockPathFloorID",
+ "tables": [
+ {
+ "MainData": 1121,
+ "Pokemon": 521,
+ "Traps": 10,
+ "Items": 123,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1122,
+ "Pokemon": 521,
+ "Traps": 10,
+ "Items": 123,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1123,
+ "Pokemon": 521,
+ "Traps": 10,
+ "Items": 123,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1124,
+ "Pokemon": 521,
+ "Traps": 10,
+ "Items": 123,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ }
+ ]
+}
diff --git a/data/dungeon/SilentChasm/floor_id.json b/data/dungeon/SilentChasm/floor_id.json
index 4ae1414..4f90018 100644
--- a/data/dungeon/SilentChasm/floor_id.json
+++ b/data/dungeon/SilentChasm/floor_id.json
@@ -1,86 +1,86 @@
-{
- "name": "SilentChasmFloorID",
- "tables": [
- {
- "MainData": 30,
- "Pokemon": 22,
- "Traps": 1,
- "Items": 13,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 31,
- "Pokemon": 22,
- "Traps": 1,
- "Items": 13,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 32,
- "Pokemon": 22,
- "Traps": 1,
- "Items": 13,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 33,
- "Pokemon": 23,
- "Traps": 1,
- "Items": 14,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 34,
- "Pokemon": 24,
- "Traps": 1,
- "Items": 14,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 35,
- "Pokemon": 25,
- "Traps": 1,
- "Items": 14,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 36,
- "Pokemon": 26,
- "Traps": 1,
- "Items": 14,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 37,
- "Pokemon": 27,
- "Traps": 1,
- "Items": 14,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 38,
- "Pokemon": 28,
- "Traps": 1,
- "Items": 14,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- }
- ]
-}
+{
+ "name": "SilentChasmFloorID",
+ "tables": [
+ {
+ "MainData": 30,
+ "Pokemon": 22,
+ "Traps": 1,
+ "Items": 13,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 31,
+ "Pokemon": 22,
+ "Traps": 1,
+ "Items": 13,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 32,
+ "Pokemon": 22,
+ "Traps": 1,
+ "Items": 13,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 33,
+ "Pokemon": 23,
+ "Traps": 1,
+ "Items": 14,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 34,
+ "Pokemon": 24,
+ "Traps": 1,
+ "Items": 14,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 35,
+ "Pokemon": 25,
+ "Traps": 1,
+ "Items": 14,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 36,
+ "Pokemon": 26,
+ "Traps": 1,
+ "Items": 14,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 37,
+ "Pokemon": 27,
+ "Traps": 1,
+ "Items": 14,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 38,
+ "Pokemon": 28,
+ "Traps": 1,
+ "Items": 14,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ }
+ ]
+}
diff --git a/data/dungeon/SilentChasm/pokemon_found.json b/data/dungeon/SilentChasm/pokemon_found.json
index 6cbcca8..5edadea 100644
--- a/data/dungeon/SilentChasm/pokemon_found.json
+++ b/data/dungeon/SilentChasm/pokemon_found.json
@@ -1,316 +1,316 @@
-{
- "tables": [{
- "name": "SilentChasm_1F_3F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_WEEDLE",
- "level": 8,
- "probability": 1667
- },
- {
- "species": "SPECIES_GLOOM",
- "level": 10,
- "probability": 1000
- },
- {
- "species": "SPECIES_FARFETCHD",
- "level": 10,
- "probability": 2666
- },
- {
- "species": "SPECIES_YANMA",
- "level": 10,
- "probability": 2000
- },
- {
- "species": "SPECIES_TEDDIURSA",
- "level": 10,
- "probability": 2667
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "SilentChasm_4F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_WEEDLE",
- "level": 8,
- "probability": 2778
- },
- {
- "species": "SPECIES_GLOOM",
- "level": 10,
- "probability": 1666
- },
- {
- "species": "SPECIES_YANMA",
- "level": 10,
- "probability": 3334
- },
- {
- "species": "SPECIES_DUSTOX",
- "level": 10,
- "probability": 2222
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "SilentChasm_5F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_WEEDLE",
- "level": 8,
- "probability": 1515
- },
- {
- "species": "SPECIES_GLOOM",
- "level": 10,
- "probability": 909
- },
- {
- "species": "SPECIES_POLIWAG",
- "level": 10,
- "probability": 909
- },
- {
- "species": "SPECIES_YANMA",
- "level": 10,
- "probability": 1819
- },
- {
- "species": "SPECIES_HOUNDOUR",
- "level": 11,
- "probability": 2424
- },
- {
- "species": "SPECIES_DUSTOX",
- "level": 10,
- "probability": 2424
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "SilentChasm_6F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_WEEDLE",
- "level": 8,
- "probability": 1064
- },
- {
- "species": "SPECIES_GLOOM",
- "level": 10,
- "probability": 638
- },
- {
- "species": "SPECIES_POLIWAG",
- "level": 10,
- "probability": 638
- },
- {
- "species": "SPECIES_SPINARAK",
- "level": 11,
- "probability": 1277
- },
- {
- "species": "SPECIES_YANMA",
- "level": 10,
- "probability": 1277
- },
- {
- "species": "SPECIES_HOUNDOUR",
- "level": 11,
- "probability": 1702
- },
- {
- "species": "SPECIES_DUSTOX",
- "level": 10,
- "probability": 1702
- },
- {
- "species": "SPECIES_TRAPINCH",
- "level": 11,
- "probability": 1702
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "SilentChasm_7F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_GLOOM",
- "level": 10,
- "probability": 652
- },
- {
- "species": "SPECIES_PARAS",
- "level": 11,
- "probability": 870
- },
- {
- "species": "SPECIES_POLIWAG",
- "level": 10,
- "probability": 652
- },
- {
- "species": "SPECIES_SPINARAK",
- "level": 11,
- "probability": 1304
- },
- {
- "species": "SPECIES_YANMA",
- "level": 10,
- "probability": 1305
- },
- {
- "species": "SPECIES_HOUNDOUR",
- "level": 11,
- "probability": 1739
- },
- {
- "species": "SPECIES_DUSTOX",
- "level": 10,
- "probability": 1739
- },
- {
- "species": "SPECIES_TRAPINCH",
- "level": 11,
- "probability": 1739
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "SilentChasm_8F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_GLOOM",
- "level": 10,
- "probability": 1000
- },
- {
- "species": "SPECIES_PARAS",
- "level": 11,
- "probability": 1333
- },
- {
- "species": "SPECIES_POLIWAG",
- "level": 10,
- "probability": 1000
- },
- {
- "species": "SPECIES_SPINARAK",
- "level": 11,
- "probability": 2000
- },
- {
- "species": "SPECIES_YANMA",
- "level": 10,
- "probability": 2000
- },
- {
- "species": "SPECIES_TRAPINCH",
- "level": 11,
- "probability": 2667
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "SilentChasm_9F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_BEEDRILL",
- "level": 10,
- "probability": 1724
- },
- {
- "species": "SPECIES_GLOOM",
- "level": 10,
- "probability": 1035
- },
- {
- "species": "SPECIES_PARAS",
- "level": 11,
- "probability": 1379
- },
- {
- "species": "SPECIES_POLIWAG",
- "level": 10,
- "probability": 1034
- },
- {
- "species": "SPECIES_SPINARAK",
- "level": 11,
- "probability": 2069
- },
- {
- "species": "SPECIES_TRAPINCH",
- "level": 11,
- "probability": 2759
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }]
-}
+{
+ "tables": [{
+ "name": "SilentChasm_1F_3F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_WEEDLE",
+ "level": 8,
+ "probability": 1667
+ },
+ {
+ "species": "SPECIES_GLOOM",
+ "level": 10,
+ "probability": 1000
+ },
+ {
+ "species": "SPECIES_FARFETCHD",
+ "level": 10,
+ "probability": 2666
+ },
+ {
+ "species": "SPECIES_YANMA",
+ "level": 10,
+ "probability": 2000
+ },
+ {
+ "species": "SPECIES_TEDDIURSA",
+ "level": 10,
+ "probability": 2667
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "SilentChasm_4F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_WEEDLE",
+ "level": 8,
+ "probability": 2778
+ },
+ {
+ "species": "SPECIES_GLOOM",
+ "level": 10,
+ "probability": 1666
+ },
+ {
+ "species": "SPECIES_YANMA",
+ "level": 10,
+ "probability": 3334
+ },
+ {
+ "species": "SPECIES_DUSTOX",
+ "level": 10,
+ "probability": 2222
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "SilentChasm_5F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_WEEDLE",
+ "level": 8,
+ "probability": 1515
+ },
+ {
+ "species": "SPECIES_GLOOM",
+ "level": 10,
+ "probability": 909
+ },
+ {
+ "species": "SPECIES_POLIWAG",
+ "level": 10,
+ "probability": 909
+ },
+ {
+ "species": "SPECIES_YANMA",
+ "level": 10,
+ "probability": 1819
+ },
+ {
+ "species": "SPECIES_HOUNDOUR",
+ "level": 11,
+ "probability": 2424
+ },
+ {
+ "species": "SPECIES_DUSTOX",
+ "level": 10,
+ "probability": 2424
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "SilentChasm_6F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_WEEDLE",
+ "level": 8,
+ "probability": 1064
+ },
+ {
+ "species": "SPECIES_GLOOM",
+ "level": 10,
+ "probability": 638
+ },
+ {
+ "species": "SPECIES_POLIWAG",
+ "level": 10,
+ "probability": 638
+ },
+ {
+ "species": "SPECIES_SPINARAK",
+ "level": 11,
+ "probability": 1277
+ },
+ {
+ "species": "SPECIES_YANMA",
+ "level": 10,
+ "probability": 1277
+ },
+ {
+ "species": "SPECIES_HOUNDOUR",
+ "level": 11,
+ "probability": 1702
+ },
+ {
+ "species": "SPECIES_DUSTOX",
+ "level": 10,
+ "probability": 1702
+ },
+ {
+ "species": "SPECIES_TRAPINCH",
+ "level": 11,
+ "probability": 1702
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "SilentChasm_7F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_GLOOM",
+ "level": 10,
+ "probability": 652
+ },
+ {
+ "species": "SPECIES_PARAS",
+ "level": 11,
+ "probability": 870
+ },
+ {
+ "species": "SPECIES_POLIWAG",
+ "level": 10,
+ "probability": 652
+ },
+ {
+ "species": "SPECIES_SPINARAK",
+ "level": 11,
+ "probability": 1304
+ },
+ {
+ "species": "SPECIES_YANMA",
+ "level": 10,
+ "probability": 1305
+ },
+ {
+ "species": "SPECIES_HOUNDOUR",
+ "level": 11,
+ "probability": 1739
+ },
+ {
+ "species": "SPECIES_DUSTOX",
+ "level": 10,
+ "probability": 1739
+ },
+ {
+ "species": "SPECIES_TRAPINCH",
+ "level": 11,
+ "probability": 1739
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "SilentChasm_8F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_GLOOM",
+ "level": 10,
+ "probability": 1000
+ },
+ {
+ "species": "SPECIES_PARAS",
+ "level": 11,
+ "probability": 1333
+ },
+ {
+ "species": "SPECIES_POLIWAG",
+ "level": 10,
+ "probability": 1000
+ },
+ {
+ "species": "SPECIES_SPINARAK",
+ "level": 11,
+ "probability": 2000
+ },
+ {
+ "species": "SPECIES_YANMA",
+ "level": 10,
+ "probability": 2000
+ },
+ {
+ "species": "SPECIES_TRAPINCH",
+ "level": 11,
+ "probability": 2667
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "SilentChasm_9F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_BEEDRILL",
+ "level": 10,
+ "probability": 1724
+ },
+ {
+ "species": "SPECIES_GLOOM",
+ "level": 10,
+ "probability": 1035
+ },
+ {
+ "species": "SPECIES_PARAS",
+ "level": 11,
+ "probability": 1379
+ },
+ {
+ "species": "SPECIES_POLIWAG",
+ "level": 10,
+ "probability": 1034
+ },
+ {
+ "species": "SPECIES_SPINARAK",
+ "level": 11,
+ "probability": 2069
+ },
+ {
+ "species": "SPECIES_TRAPINCH",
+ "level": 11,
+ "probability": 2759
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }]
+}
diff --git a/data/dungeon/SilverTrench/floor_id.json b/data/dungeon/SilverTrench/floor_id.json
index becad21..18be825 100644
--- a/data/dungeon/SilverTrench/floor_id.json
+++ b/data/dungeon/SilverTrench/floor_id.json
@@ -1,896 +1,896 @@
-{
- "name": "SilverTrenchFloorID",
- "tables": [
- {
- "MainData": 227,
- "Pokemon": 128,
- "Traps": 6,
- "Items": 50,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 228,
- "Pokemon": 128,
- "Traps": 6,
- "Items": 50,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 229,
- "Pokemon": 128,
- "Traps": 6,
- "Items": 50,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 230,
- "Pokemon": 128,
- "Traps": 6,
- "Items": 50,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 231,
- "Pokemon": 129,
- "Traps": 6,
- "Items": 50,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 232,
- "Pokemon": 130,
- "Traps": 6,
- "Items": 50,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 233,
- "Pokemon": 130,
- "Traps": 6,
- "Items": 50,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 234,
- "Pokemon": 130,
- "Traps": 6,
- "Items": 50,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 235,
- "Pokemon": 131,
- "Traps": 6,
- "Items": 50,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 236,
- "Pokemon": 132,
- "Traps": 6,
- "Items": 51,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 237,
- "Pokemon": 132,
- "Traps": 6,
- "Items": 51,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 238,
- "Pokemon": 132,
- "Traps": 6,
- "Items": 51,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 239,
- "Pokemon": 132,
- "Traps": 6,
- "Items": 51,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 240,
- "Pokemon": 133,
- "Traps": 6,
- "Items": 51,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 241,
- "Pokemon": 134,
- "Traps": 6,
- "Items": 51,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 242,
- "Pokemon": 134,
- "Traps": 6,
- "Items": 51,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 243,
- "Pokemon": 134,
- "Traps": 6,
- "Items": 51,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 244,
- "Pokemon": 134,
- "Traps": 6,
- "Items": 51,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 245,
- "Pokemon": 134,
- "Traps": 6,
- "Items": 51,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 246,
- "Pokemon": 135,
- "Traps": 6,
- "Items": 51,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 247,
- "Pokemon": 136,
- "Traps": 6,
- "Items": 52,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 248,
- "Pokemon": 136,
- "Traps": 6,
- "Items": 52,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 249,
- "Pokemon": 136,
- "Traps": 6,
- "Items": 52,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 250,
- "Pokemon": 137,
- "Traps": 6,
- "Items": 52,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 251,
- "Pokemon": 138,
- "Traps": 6,
- "Items": 52,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 252,
- "Pokemon": 139,
- "Traps": 6,
- "Items": 52,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 253,
- "Pokemon": 139,
- "Traps": 6,
- "Items": 52,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 254,
- "Pokemon": 139,
- "Traps": 6,
- "Items": 52,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 255,
- "Pokemon": 139,
- "Traps": 6,
- "Items": 52,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 256,
- "Pokemon": 140,
- "Traps": 6,
- "Items": 52,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 257,
- "Pokemon": 141,
- "Traps": 6,
- "Items": 53,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 258,
- "Pokemon": 141,
- "Traps": 6,
- "Items": 53,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 259,
- "Pokemon": 141,
- "Traps": 6,
- "Items": 53,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 260,
- "Pokemon": 142,
- "Traps": 6,
- "Items": 53,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 261,
- "Pokemon": 143,
- "Traps": 6,
- "Items": 53,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 262,
- "Pokemon": 144,
- "Traps": 6,
- "Items": 53,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 263,
- "Pokemon": 145,
- "Traps": 6,
- "Items": 53,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 264,
- "Pokemon": 145,
- "Traps": 6,
- "Items": 53,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 265,
- "Pokemon": 145,
- "Traps": 6,
- "Items": 53,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 266,
- "Pokemon": 146,
- "Traps": 6,
- "Items": 53,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 267,
- "Pokemon": 147,
- "Traps": 6,
- "Items": 54,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 268,
- "Pokemon": 147,
- "Traps": 6,
- "Items": 54,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 269,
- "Pokemon": 147,
- "Traps": 6,
- "Items": 54,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 270,
- "Pokemon": 147,
- "Traps": 6,
- "Items": 54,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 271,
- "Pokemon": 148,
- "Traps": 6,
- "Items": 54,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 272,
- "Pokemon": 148,
- "Traps": 6,
- "Items": 54,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 273,
- "Pokemon": 148,
- "Traps": 6,
- "Items": 54,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 274,
- "Pokemon": 148,
- "Traps": 6,
- "Items": 54,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 275,
- "Pokemon": 148,
- "Traps": 6,
- "Items": 54,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 276,
- "Pokemon": 149,
- "Traps": 6,
- "Items": 54,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 277,
- "Pokemon": 150,
- "Traps": 6,
- "Items": 54,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 278,
- "Pokemon": 150,
- "Traps": 6,
- "Items": 54,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 279,
- "Pokemon": 150,
- "Traps": 6,
- "Items": 54,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 280,
- "Pokemon": 150,
- "Traps": 6,
- "Items": 54,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 281,
- "Pokemon": 151,
- "Traps": 6,
- "Items": 54,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 282,
- "Pokemon": 151,
- "Traps": 6,
- "Items": 54,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 283,
- "Pokemon": 151,
- "Traps": 6,
- "Items": 54,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 284,
- "Pokemon": 151,
- "Traps": 6,
- "Items": 54,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 285,
- "Pokemon": 151,
- "Traps": 6,
- "Items": 54,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 286,
- "Pokemon": 152,
- "Traps": 6,
- "Items": 54,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 287,
- "Pokemon": 153,
- "Traps": 6,
- "Items": 54,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 288,
- "Pokemon": 153,
- "Traps": 6,
- "Items": 54,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 289,
- "Pokemon": 153,
- "Traps": 6,
- "Items": 54,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 290,
- "Pokemon": 153,
- "Traps": 6,
- "Items": 54,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 291,
- "Pokemon": 154,
- "Traps": 6,
- "Items": 54,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 292,
- "Pokemon": 154,
- "Traps": 6,
- "Items": 54,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 293,
- "Pokemon": 154,
- "Traps": 6,
- "Items": 54,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 294,
- "Pokemon": 154,
- "Traps": 6,
- "Items": 54,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 295,
- "Pokemon": 154,
- "Traps": 6,
- "Items": 54,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 296,
- "Pokemon": 155,
- "Traps": 6,
- "Items": 54,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 297,
- "Pokemon": 156,
- "Traps": 6,
- "Items": 55,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 298,
- "Pokemon": 156,
- "Traps": 6,
- "Items": 55,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 299,
- "Pokemon": 156,
- "Traps": 6,
- "Items": 55,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 300,
- "Pokemon": 156,
- "Traps": 6,
- "Items": 55,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 301,
- "Pokemon": 156,
- "Traps": 6,
- "Items": 55,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 302,
- "Pokemon": 156,
- "Traps": 6,
- "Items": 55,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 303,
- "Pokemon": 156,
- "Traps": 6,
- "Items": 55,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 304,
- "Pokemon": 156,
- "Traps": 6,
- "Items": 55,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 305,
- "Pokemon": 156,
- "Traps": 6,
- "Items": 55,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 306,
- "Pokemon": 157,
- "Traps": 6,
- "Items": 55,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 307,
- "Pokemon": 158,
- "Traps": 6,
- "Items": 55,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 308,
- "Pokemon": 158,
- "Traps": 6,
- "Items": 55,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 309,
- "Pokemon": 158,
- "Traps": 6,
- "Items": 55,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 310,
- "Pokemon": 158,
- "Traps": 6,
- "Items": 55,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 311,
- "Pokemon": 158,
- "Traps": 6,
- "Items": 55,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 312,
- "Pokemon": 158,
- "Traps": 6,
- "Items": 55,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 313,
- "Pokemon": 158,
- "Traps": 6,
- "Items": 55,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 314,
- "Pokemon": 158,
- "Traps": 6,
- "Items": 55,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 315,
- "Pokemon": 158,
- "Traps": 6,
- "Items": 55,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 316,
- "Pokemon": 159,
- "Traps": 6,
- "Items": 55,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 317,
- "Pokemon": 159,
- "Traps": 6,
- "Items": 55,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 318,
- "Pokemon": 159,
- "Traps": 6,
- "Items": 55,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 319,
- "Pokemon": 159,
- "Traps": 6,
- "Items": 55,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 320,
- "Pokemon": 159,
- "Traps": 6,
- "Items": 55,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 321,
- "Pokemon": 159,
- "Traps": 6,
- "Items": 55,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 322,
- "Pokemon": 159,
- "Traps": 6,
- "Items": 55,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 323,
- "Pokemon": 159,
- "Traps": 6,
- "Items": 55,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 324,
- "Pokemon": 159,
- "Traps": 6,
- "Items": 55,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 325,
- "Pokemon": 160,
- "Traps": 6,
- "Items": 55,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- }
- ]
-}
+{
+ "name": "SilverTrenchFloorID",
+ "tables": [
+ {
+ "MainData": 227,
+ "Pokemon": 128,
+ "Traps": 6,
+ "Items": 50,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 228,
+ "Pokemon": 128,
+ "Traps": 6,
+ "Items": 50,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 229,
+ "Pokemon": 128,
+ "Traps": 6,
+ "Items": 50,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 230,
+ "Pokemon": 128,
+ "Traps": 6,
+ "Items": 50,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 231,
+ "Pokemon": 129,
+ "Traps": 6,
+ "Items": 50,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 232,
+ "Pokemon": 130,
+ "Traps": 6,
+ "Items": 50,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 233,
+ "Pokemon": 130,
+ "Traps": 6,
+ "Items": 50,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 234,
+ "Pokemon": 130,
+ "Traps": 6,
+ "Items": 50,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 235,
+ "Pokemon": 131,
+ "Traps": 6,
+ "Items": 50,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 236,
+ "Pokemon": 132,
+ "Traps": 6,
+ "Items": 51,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 237,
+ "Pokemon": 132,
+ "Traps": 6,
+ "Items": 51,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 238,
+ "Pokemon": 132,
+ "Traps": 6,
+ "Items": 51,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 239,
+ "Pokemon": 132,
+ "Traps": 6,
+ "Items": 51,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 240,
+ "Pokemon": 133,
+ "Traps": 6,
+ "Items": 51,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 241,
+ "Pokemon": 134,
+ "Traps": 6,
+ "Items": 51,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 242,
+ "Pokemon": 134,
+ "Traps": 6,
+ "Items": 51,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 243,
+ "Pokemon": 134,
+ "Traps": 6,
+ "Items": 51,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 244,
+ "Pokemon": 134,
+ "Traps": 6,
+ "Items": 51,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 245,
+ "Pokemon": 134,
+ "Traps": 6,
+ "Items": 51,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 246,
+ "Pokemon": 135,
+ "Traps": 6,
+ "Items": 51,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 247,
+ "Pokemon": 136,
+ "Traps": 6,
+ "Items": 52,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 248,
+ "Pokemon": 136,
+ "Traps": 6,
+ "Items": 52,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 249,
+ "Pokemon": 136,
+ "Traps": 6,
+ "Items": 52,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 250,
+ "Pokemon": 137,
+ "Traps": 6,
+ "Items": 52,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 251,
+ "Pokemon": 138,
+ "Traps": 6,
+ "Items": 52,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 252,
+ "Pokemon": 139,
+ "Traps": 6,
+ "Items": 52,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 253,
+ "Pokemon": 139,
+ "Traps": 6,
+ "Items": 52,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 254,
+ "Pokemon": 139,
+ "Traps": 6,
+ "Items": 52,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 255,
+ "Pokemon": 139,
+ "Traps": 6,
+ "Items": 52,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 256,
+ "Pokemon": 140,
+ "Traps": 6,
+ "Items": 52,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 257,
+ "Pokemon": 141,
+ "Traps": 6,
+ "Items": 53,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 258,
+ "Pokemon": 141,
+ "Traps": 6,
+ "Items": 53,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 259,
+ "Pokemon": 141,
+ "Traps": 6,
+ "Items": 53,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 260,
+ "Pokemon": 142,
+ "Traps": 6,
+ "Items": 53,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 261,
+ "Pokemon": 143,
+ "Traps": 6,
+ "Items": 53,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 262,
+ "Pokemon": 144,
+ "Traps": 6,
+ "Items": 53,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 263,
+ "Pokemon": 145,
+ "Traps": 6,
+ "Items": 53,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 264,
+ "Pokemon": 145,
+ "Traps": 6,
+ "Items": 53,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 265,
+ "Pokemon": 145,
+ "Traps": 6,
+ "Items": 53,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 266,
+ "Pokemon": 146,
+ "Traps": 6,
+ "Items": 53,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 267,
+ "Pokemon": 147,
+ "Traps": 6,
+ "Items": 54,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 268,
+ "Pokemon": 147,
+ "Traps": 6,
+ "Items": 54,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 269,
+ "Pokemon": 147,
+ "Traps": 6,
+ "Items": 54,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 270,
+ "Pokemon": 147,
+ "Traps": 6,
+ "Items": 54,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 271,
+ "Pokemon": 148,
+ "Traps": 6,
+ "Items": 54,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 272,
+ "Pokemon": 148,
+ "Traps": 6,
+ "Items": 54,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 273,
+ "Pokemon": 148,
+ "Traps": 6,
+ "Items": 54,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 274,
+ "Pokemon": 148,
+ "Traps": 6,
+ "Items": 54,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 275,
+ "Pokemon": 148,
+ "Traps": 6,
+ "Items": 54,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 276,
+ "Pokemon": 149,
+ "Traps": 6,
+ "Items": 54,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 277,
+ "Pokemon": 150,
+ "Traps": 6,
+ "Items": 54,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 278,
+ "Pokemon": 150,
+ "Traps": 6,
+ "Items": 54,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 279,
+ "Pokemon": 150,
+ "Traps": 6,
+ "Items": 54,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 280,
+ "Pokemon": 150,
+ "Traps": 6,
+ "Items": 54,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 281,
+ "Pokemon": 151,
+ "Traps": 6,
+ "Items": 54,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 282,
+ "Pokemon": 151,
+ "Traps": 6,
+ "Items": 54,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 283,
+ "Pokemon": 151,
+ "Traps": 6,
+ "Items": 54,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 284,
+ "Pokemon": 151,
+ "Traps": 6,
+ "Items": 54,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 285,
+ "Pokemon": 151,
+ "Traps": 6,
+ "Items": 54,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 286,
+ "Pokemon": 152,
+ "Traps": 6,
+ "Items": 54,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 287,
+ "Pokemon": 153,
+ "Traps": 6,
+ "Items": 54,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 288,
+ "Pokemon": 153,
+ "Traps": 6,
+ "Items": 54,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 289,
+ "Pokemon": 153,
+ "Traps": 6,
+ "Items": 54,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 290,
+ "Pokemon": 153,
+ "Traps": 6,
+ "Items": 54,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 291,
+ "Pokemon": 154,
+ "Traps": 6,
+ "Items": 54,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 292,
+ "Pokemon": 154,
+ "Traps": 6,
+ "Items": 54,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 293,
+ "Pokemon": 154,
+ "Traps": 6,
+ "Items": 54,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 294,
+ "Pokemon": 154,
+ "Traps": 6,
+ "Items": 54,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 295,
+ "Pokemon": 154,
+ "Traps": 6,
+ "Items": 54,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 296,
+ "Pokemon": 155,
+ "Traps": 6,
+ "Items": 54,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 297,
+ "Pokemon": 156,
+ "Traps": 6,
+ "Items": 55,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 298,
+ "Pokemon": 156,
+ "Traps": 6,
+ "Items": 55,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 299,
+ "Pokemon": 156,
+ "Traps": 6,
+ "Items": 55,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 300,
+ "Pokemon": 156,
+ "Traps": 6,
+ "Items": 55,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 301,
+ "Pokemon": 156,
+ "Traps": 6,
+ "Items": 55,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 302,
+ "Pokemon": 156,
+ "Traps": 6,
+ "Items": 55,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 303,
+ "Pokemon": 156,
+ "Traps": 6,
+ "Items": 55,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 304,
+ "Pokemon": 156,
+ "Traps": 6,
+ "Items": 55,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 305,
+ "Pokemon": 156,
+ "Traps": 6,
+ "Items": 55,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 306,
+ "Pokemon": 157,
+ "Traps": 6,
+ "Items": 55,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 307,
+ "Pokemon": 158,
+ "Traps": 6,
+ "Items": 55,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 308,
+ "Pokemon": 158,
+ "Traps": 6,
+ "Items": 55,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 309,
+ "Pokemon": 158,
+ "Traps": 6,
+ "Items": 55,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 310,
+ "Pokemon": 158,
+ "Traps": 6,
+ "Items": 55,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 311,
+ "Pokemon": 158,
+ "Traps": 6,
+ "Items": 55,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 312,
+ "Pokemon": 158,
+ "Traps": 6,
+ "Items": 55,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 313,
+ "Pokemon": 158,
+ "Traps": 6,
+ "Items": 55,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 314,
+ "Pokemon": 158,
+ "Traps": 6,
+ "Items": 55,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 315,
+ "Pokemon": 158,
+ "Traps": 6,
+ "Items": 55,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 316,
+ "Pokemon": 159,
+ "Traps": 6,
+ "Items": 55,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 317,
+ "Pokemon": 159,
+ "Traps": 6,
+ "Items": 55,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 318,
+ "Pokemon": 159,
+ "Traps": 6,
+ "Items": 55,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 319,
+ "Pokemon": 159,
+ "Traps": 6,
+ "Items": 55,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 320,
+ "Pokemon": 159,
+ "Traps": 6,
+ "Items": 55,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 321,
+ "Pokemon": 159,
+ "Traps": 6,
+ "Items": 55,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 322,
+ "Pokemon": 159,
+ "Traps": 6,
+ "Items": 55,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 323,
+ "Pokemon": 159,
+ "Traps": 6,
+ "Items": 55,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 324,
+ "Pokemon": 159,
+ "Traps": 6,
+ "Items": 55,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 325,
+ "Pokemon": 160,
+ "Traps": 6,
+ "Items": 55,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ }
+ ]
+}
diff --git a/data/dungeon/SinisterWoods/floor_id.json b/data/dungeon/SinisterWoods/floor_id.json
index 06e47dc..ca7f97f 100644
--- a/data/dungeon/SinisterWoods/floor_id.json
+++ b/data/dungeon/SinisterWoods/floor_id.json
@@ -1,122 +1,122 @@
-{
- "name": "SinisterWoodsFloorID",
- "tables": [
- {
- "MainData": 17,
- "Pokemon": 10,
- "Traps": 2,
- "Items": 11,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 18,
- "Pokemon": 11,
- "Traps": 2,
- "Items": 11,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 19,
- "Pokemon": 12,
- "Traps": 2,
- "Items": 11,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 20,
- "Pokemon": 13,
- "Traps": 2,
- "Items": 12,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 21,
- "Pokemon": 14,
- "Traps": 2,
- "Items": 12,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 22,
- "Pokemon": 15,
- "Traps": 2,
- "Items": 12,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 23,
- "Pokemon": 16,
- "Traps": 2,
- "Items": 12,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 24,
- "Pokemon": 17,
- "Traps": 2,
- "Items": 12,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 25,
- "Pokemon": 17,
- "Traps": 2,
- "Items": 12,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 26,
- "Pokemon": 18,
- "Traps": 2,
- "Items": 12,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 27,
- "Pokemon": 19,
- "Traps": 2,
- "Items": 12,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 28,
- "Pokemon": 20,
- "Traps": 2,
- "Items": 12,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 29,
- "Pokemon": 21,
- "Traps": 2,
- "Items": 12,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- }
- ]
-}
+{
+ "name": "SinisterWoodsFloorID",
+ "tables": [
+ {
+ "MainData": 17,
+ "Pokemon": 10,
+ "Traps": 2,
+ "Items": 11,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 18,
+ "Pokemon": 11,
+ "Traps": 2,
+ "Items": 11,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 19,
+ "Pokemon": 12,
+ "Traps": 2,
+ "Items": 11,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 20,
+ "Pokemon": 13,
+ "Traps": 2,
+ "Items": 12,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 21,
+ "Pokemon": 14,
+ "Traps": 2,
+ "Items": 12,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 22,
+ "Pokemon": 15,
+ "Traps": 2,
+ "Items": 12,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 23,
+ "Pokemon": 16,
+ "Traps": 2,
+ "Items": 12,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 24,
+ "Pokemon": 17,
+ "Traps": 2,
+ "Items": 12,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 25,
+ "Pokemon": 17,
+ "Traps": 2,
+ "Items": 12,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 26,
+ "Pokemon": 18,
+ "Traps": 2,
+ "Items": 12,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 27,
+ "Pokemon": 19,
+ "Traps": 2,
+ "Items": 12,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 28,
+ "Pokemon": 20,
+ "Traps": 2,
+ "Items": 12,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 29,
+ "Pokemon": 21,
+ "Traps": 2,
+ "Items": 12,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ }
+ ]
+}
diff --git a/data/dungeon/SinisterWoods/pokemon_found.json b/data/dungeon/SinisterWoods/pokemon_found.json
index c15682d..f9f1d69 100644
--- a/data/dungeon/SinisterWoods/pokemon_found.json
+++ b/data/dungeon/SinisterWoods/pokemon_found.json
@@ -1,446 +1,446 @@
-{
- "tables": [{
- "name": "SinisterWoods_1F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_ODDISH",
- "level": 7,
- "probability": 1579
- },
- {
- "species": "SPECIES_SUDOWOODO",
- "level": 7,
- "probability": 4210
- },
- {
- "species": "SPECIES_SWINUB",
- "level": 8,
- "probability": 4211
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "SinisterWoods_2F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_ODDISH",
- "level": 7,
- "probability": 1364
- },
- {
- "species": "SPECIES_SUDOWOODO",
- "level": 7,
- "probability": 3636
- },
- {
- "species": "SPECIES_SUNFLORA",
- "level": 8,
- "probability": 1364
- },
- {
- "species": "SPECIES_SWINUB",
- "level": 8,
- "probability": 3636
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "SinisterWoods_3F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_ODDISH",
- "level": 7,
- "probability": 1000
- },
- {
- "species": "SPECIES_SENTRET",
- "level": 6,
- "probability": 2667
- },
- {
- "species": "SPECIES_SUDOWOODO",
- "level": 7,
- "probability": 2666
- },
- {
- "species": "SPECIES_SUNFLORA",
- "level": 8,
- "probability": 1000
- },
- {
- "species": "SPECIES_SWINUB",
- "level": 8,
- "probability": 2667
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "SinisterWoods_4F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_ODDISH",
- "level": 7,
- "probability": 937
- },
- {
- "species": "SPECIES_SENTRET",
- "level": 6,
- "probability": 2500
- },
- {
- "species": "SPECIES_SUDOWOODO",
- "level": 7,
- "probability": 2500
- },
- {
- "species": "SPECIES_SUNFLORA",
- "level": 8,
- "probability": 938
- },
- {
- "species": "SPECIES_SILCOON",
- "level": 8,
- "probability": 1562
- },
- {
- "species": "SPECIES_CASCOON",
- "level": 8,
- "probability": 1563
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "SinisterWoods_5F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_SENTRET",
- "level": 6,
- "probability": 3810
- },
- {
- "species": "SPECIES_SUNFLORA",
- "level": 8,
- "probability": 1428
- },
- {
- "species": "SPECIES_SILCOON",
- "level": 8,
- "probability": 2381
- },
- {
- "species": "SPECIES_CASCOON",
- "level": 8,
- "probability": 2381
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "SinisterWoods_6F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_SENTRET",
- "level": 6,
- "probability": 2759
- },
- {
- "species": "SPECIES_SUNFLORA",
- "level": 8,
- "probability": 1034
- },
- {
- "species": "SPECIES_SILCOON",
- "level": 8,
- "probability": 1724
- },
- {
- "species": "SPECIES_CASCOON",
- "level": 8,
- "probability": 1724
- },
- {
- "species": "SPECIES_SHROOMISH",
- "level": 9,
- "probability": 2759
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "SinisterWoods_7F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_LEDYBA",
- "level": 7,
- "probability": 2400
- },
- {
- "species": "SPECIES_SUNFLORA",
- "level": 8,
- "probability": 1200
- },
- {
- "species": "SPECIES_LINOONE",
- "level": 8,
- "probability": 3200
- },
- {
- "species": "SPECIES_SHROOMISH",
- "level": 9,
- "probability": 3200
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "SinisterWoods_8F_9F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_SCYTHER",
- "level": 10,
- "probability": 2286
- },
- {
- "species": "SPECIES_LEDYBA",
- "level": 7,
- "probability": 1714
- },
- {
- "species": "SPECIES_WOOPER",
- "level": 10,
- "probability": 1429
- },
- {
- "species": "SPECIES_LINOONE",
- "level": 8,
- "probability": 2285
- },
- {
- "species": "SPECIES_SHROOMISH",
- "level": 9,
- "probability": 2286
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "SinisterWoods_10F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_EXEGGUTOR",
- "level": 8,
- "probability": 1569
- },
- {
- "species": "SPECIES_SCYTHER",
- "level": 10,
- "probability": 1568
- },
- {
- "species": "SPECIES_HOOTHOOT",
- "level": 6,
- "probability": 1569
- },
- {
- "species": "SPECIES_LEDYBA",
- "level": 7,
- "probability": 1176
- },
- {
- "species": "SPECIES_WOOPER",
- "level": 10,
- "probability": 981
- },
- {
- "species": "SPECIES_SHROOMISH",
- "level": 9,
- "probability": 1568
- },
- {
- "species": "SPECIES_SLAKOTH",
- "level": 8,
- "probability": 1569
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "SinisterWoods_11F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_EXEGGUTOR",
- "level": 8,
- "probability": 2000
- },
- {
- "species": "SPECIES_SCYTHER",
- "level": 10,
- "probability": 2000
- },
- {
- "species": "SPECIES_HOOTHOOT",
- "level": 6,
- "probability": 2000
- },
- {
- "species": "SPECIES_SHROOMISH",
- "level": 9,
- "probability": 2000
- },
- {
- "species": "SPECIES_SLAKOTH",
- "level": 8,
- "probability": 2000
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "SinisterWoods_12F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_EXEGGUTOR",
- "level": 8,
- "probability": 2500
- },
- {
- "species": "SPECIES_HOOTHOOT",
- "level": 6,
- "probability": 2500
- },
- {
- "species": "SPECIES_SHROOMISH",
- "level": 9,
- "probability": 2500
- },
- {
- "species": "SPECIES_SLAKOTH",
- "level": 8,
- "probability": 2500
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "SinisterWoods_13F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_EKANS",
- "level": 15,
- "probability": 3333
- },
- {
- "species": "SPECIES_GENGAR",
- "level": 15,
- "probability": 3334
- },
- {
- "species": "SPECIES_MEDICHAM",
- "level": 12,
- "probability": 3333
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }]
-}
+{
+ "tables": [{
+ "name": "SinisterWoods_1F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_ODDISH",
+ "level": 7,
+ "probability": 1579
+ },
+ {
+ "species": "SPECIES_SUDOWOODO",
+ "level": 7,
+ "probability": 4210
+ },
+ {
+ "species": "SPECIES_SWINUB",
+ "level": 8,
+ "probability": 4211
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "SinisterWoods_2F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_ODDISH",
+ "level": 7,
+ "probability": 1364
+ },
+ {
+ "species": "SPECIES_SUDOWOODO",
+ "level": 7,
+ "probability": 3636
+ },
+ {
+ "species": "SPECIES_SUNFLORA",
+ "level": 8,
+ "probability": 1364
+ },
+ {
+ "species": "SPECIES_SWINUB",
+ "level": 8,
+ "probability": 3636
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "SinisterWoods_3F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_ODDISH",
+ "level": 7,
+ "probability": 1000
+ },
+ {
+ "species": "SPECIES_SENTRET",
+ "level": 6,
+ "probability": 2667
+ },
+ {
+ "species": "SPECIES_SUDOWOODO",
+ "level": 7,
+ "probability": 2666
+ },
+ {
+ "species": "SPECIES_SUNFLORA",
+ "level": 8,
+ "probability": 1000
+ },
+ {
+ "species": "SPECIES_SWINUB",
+ "level": 8,
+ "probability": 2667
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "SinisterWoods_4F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_ODDISH",
+ "level": 7,
+ "probability": 937
+ },
+ {
+ "species": "SPECIES_SENTRET",
+ "level": 6,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_SUDOWOODO",
+ "level": 7,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_SUNFLORA",
+ "level": 8,
+ "probability": 938
+ },
+ {
+ "species": "SPECIES_SILCOON",
+ "level": 8,
+ "probability": 1562
+ },
+ {
+ "species": "SPECIES_CASCOON",
+ "level": 8,
+ "probability": 1563
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "SinisterWoods_5F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_SENTRET",
+ "level": 6,
+ "probability": 3810
+ },
+ {
+ "species": "SPECIES_SUNFLORA",
+ "level": 8,
+ "probability": 1428
+ },
+ {
+ "species": "SPECIES_SILCOON",
+ "level": 8,
+ "probability": 2381
+ },
+ {
+ "species": "SPECIES_CASCOON",
+ "level": 8,
+ "probability": 2381
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "SinisterWoods_6F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_SENTRET",
+ "level": 6,
+ "probability": 2759
+ },
+ {
+ "species": "SPECIES_SUNFLORA",
+ "level": 8,
+ "probability": 1034
+ },
+ {
+ "species": "SPECIES_SILCOON",
+ "level": 8,
+ "probability": 1724
+ },
+ {
+ "species": "SPECIES_CASCOON",
+ "level": 8,
+ "probability": 1724
+ },
+ {
+ "species": "SPECIES_SHROOMISH",
+ "level": 9,
+ "probability": 2759
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "SinisterWoods_7F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_LEDYBA",
+ "level": 7,
+ "probability": 2400
+ },
+ {
+ "species": "SPECIES_SUNFLORA",
+ "level": 8,
+ "probability": 1200
+ },
+ {
+ "species": "SPECIES_LINOONE",
+ "level": 8,
+ "probability": 3200
+ },
+ {
+ "species": "SPECIES_SHROOMISH",
+ "level": 9,
+ "probability": 3200
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "SinisterWoods_8F_9F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_SCYTHER",
+ "level": 10,
+ "probability": 2286
+ },
+ {
+ "species": "SPECIES_LEDYBA",
+ "level": 7,
+ "probability": 1714
+ },
+ {
+ "species": "SPECIES_WOOPER",
+ "level": 10,
+ "probability": 1429
+ },
+ {
+ "species": "SPECIES_LINOONE",
+ "level": 8,
+ "probability": 2285
+ },
+ {
+ "species": "SPECIES_SHROOMISH",
+ "level": 9,
+ "probability": 2286
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "SinisterWoods_10F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_EXEGGUTOR",
+ "level": 8,
+ "probability": 1569
+ },
+ {
+ "species": "SPECIES_SCYTHER",
+ "level": 10,
+ "probability": 1568
+ },
+ {
+ "species": "SPECIES_HOOTHOOT",
+ "level": 6,
+ "probability": 1569
+ },
+ {
+ "species": "SPECIES_LEDYBA",
+ "level": 7,
+ "probability": 1176
+ },
+ {
+ "species": "SPECIES_WOOPER",
+ "level": 10,
+ "probability": 981
+ },
+ {
+ "species": "SPECIES_SHROOMISH",
+ "level": 9,
+ "probability": 1568
+ },
+ {
+ "species": "SPECIES_SLAKOTH",
+ "level": 8,
+ "probability": 1569
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "SinisterWoods_11F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_EXEGGUTOR",
+ "level": 8,
+ "probability": 2000
+ },
+ {
+ "species": "SPECIES_SCYTHER",
+ "level": 10,
+ "probability": 2000
+ },
+ {
+ "species": "SPECIES_HOOTHOOT",
+ "level": 6,
+ "probability": 2000
+ },
+ {
+ "species": "SPECIES_SHROOMISH",
+ "level": 9,
+ "probability": 2000
+ },
+ {
+ "species": "SPECIES_SLAKOTH",
+ "level": 8,
+ "probability": 2000
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "SinisterWoods_12F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_EXEGGUTOR",
+ "level": 8,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_HOOTHOOT",
+ "level": 6,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_SHROOMISH",
+ "level": 9,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_SLAKOTH",
+ "level": 8,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "SinisterWoods_13F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_EKANS",
+ "level": 15,
+ "probability": 3333
+ },
+ {
+ "species": "SPECIES_GENGAR",
+ "level": 15,
+ "probability": 3334
+ },
+ {
+ "species": "SPECIES_MEDICHAM",
+ "level": 12,
+ "probability": 3333
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }]
+}
diff --git a/data/dungeon/SkyTower/floor_id.json b/data/dungeon/SkyTower/floor_id.json
index e019e4d..e1bbcd0 100644
--- a/data/dungeon/SkyTower/floor_id.json
+++ b/data/dungeon/SkyTower/floor_id.json
@@ -1,230 +1,230 @@
-{
- "name": "SkyTowerFloorID",
- "tables": [
- {
- "MainData": 153,
- "Pokemon": 97,
- "Traps": 0,
- "Items": 41,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 154,
- "Pokemon": 97,
- "Traps": 0,
- "Items": 41,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 155,
- "Pokemon": 97,
- "Traps": 0,
- "Items": 41,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 156,
- "Pokemon": 97,
- "Traps": 0,
- "Items": 42,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 157,
- "Pokemon": 97,
- "Traps": 0,
- "Items": 42,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 158,
- "Pokemon": 98,
- "Traps": 0,
- "Items": 42,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 159,
- "Pokemon": 99,
- "Traps": 0,
- "Items": 42,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 160,
- "Pokemon": 99,
- "Traps": 0,
- "Items": 42,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 161,
- "Pokemon": 100,
- "Traps": 0,
- "Items": 42,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 162,
- "Pokemon": 101,
- "Traps": 0,
- "Items": 42,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 163,
- "Pokemon": 101,
- "Traps": 0,
- "Items": 42,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 164,
- "Pokemon": 102,
- "Traps": 0,
- "Items": 42,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 165,
- "Pokemon": 102,
- "Traps": 0,
- "Items": 42,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 166,
- "Pokemon": 102,
- "Traps": 0,
- "Items": 42,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 167,
- "Pokemon": 103,
- "Traps": 0,
- "Items": 42,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 168,
- "Pokemon": 103,
- "Traps": 0,
- "Items": 42,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 169,
- "Pokemon": 104,
- "Traps": 0,
- "Items": 42,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 170,
- "Pokemon": 105,
- "Traps": 0,
- "Items": 42,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 171,
- "Pokemon": 105,
- "Traps": 0,
- "Items": 42,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 172,
- "Pokemon": 106,
- "Traps": 0,
- "Items": 42,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 173,
- "Pokemon": 107,
- "Traps": 0,
- "Items": 42,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 174,
- "Pokemon": 108,
- "Traps": 0,
- "Items": 42,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 175,
- "Pokemon": 108,
- "Traps": 0,
- "Items": 42,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 176,
- "Pokemon": 109,
- "Traps": 0,
- "Items": 42,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 177,
- "Pokemon": 109,
- "Traps": 0,
- "Items": 42,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- }
- ]
-}
+{
+ "name": "SkyTowerFloorID",
+ "tables": [
+ {
+ "MainData": 153,
+ "Pokemon": 97,
+ "Traps": 0,
+ "Items": 41,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 154,
+ "Pokemon": 97,
+ "Traps": 0,
+ "Items": 41,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 155,
+ "Pokemon": 97,
+ "Traps": 0,
+ "Items": 41,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 156,
+ "Pokemon": 97,
+ "Traps": 0,
+ "Items": 42,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 157,
+ "Pokemon": 97,
+ "Traps": 0,
+ "Items": 42,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 158,
+ "Pokemon": 98,
+ "Traps": 0,
+ "Items": 42,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 159,
+ "Pokemon": 99,
+ "Traps": 0,
+ "Items": 42,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 160,
+ "Pokemon": 99,
+ "Traps": 0,
+ "Items": 42,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 161,
+ "Pokemon": 100,
+ "Traps": 0,
+ "Items": 42,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 162,
+ "Pokemon": 101,
+ "Traps": 0,
+ "Items": 42,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 163,
+ "Pokemon": 101,
+ "Traps": 0,
+ "Items": 42,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 164,
+ "Pokemon": 102,
+ "Traps": 0,
+ "Items": 42,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 165,
+ "Pokemon": 102,
+ "Traps": 0,
+ "Items": 42,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 166,
+ "Pokemon": 102,
+ "Traps": 0,
+ "Items": 42,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 167,
+ "Pokemon": 103,
+ "Traps": 0,
+ "Items": 42,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 168,
+ "Pokemon": 103,
+ "Traps": 0,
+ "Items": 42,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 169,
+ "Pokemon": 104,
+ "Traps": 0,
+ "Items": 42,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 170,
+ "Pokemon": 105,
+ "Traps": 0,
+ "Items": 42,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 171,
+ "Pokemon": 105,
+ "Traps": 0,
+ "Items": 42,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 172,
+ "Pokemon": 106,
+ "Traps": 0,
+ "Items": 42,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 173,
+ "Pokemon": 107,
+ "Traps": 0,
+ "Items": 42,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 174,
+ "Pokemon": 108,
+ "Traps": 0,
+ "Items": 42,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 175,
+ "Pokemon": 108,
+ "Traps": 0,
+ "Items": 42,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 176,
+ "Pokemon": 109,
+ "Traps": 0,
+ "Items": 42,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 177,
+ "Pokemon": 109,
+ "Traps": 0,
+ "Items": 42,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ }
+ ]
+}
diff --git a/data/dungeon/SkyTower/pokemon_found.json b/data/dungeon/SkyTower/pokemon_found.json
index 5adce68..e38ad03 100644
--- a/data/dungeon/SkyTower/pokemon_found.json
+++ b/data/dungeon/SkyTower/pokemon_found.json
@@ -1,466 +1,466 @@
-{
- "tables": [{
- "name": "SkyTower_1F_5F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_FORRETRESS",
- "level": 23,
- "probability": 2581
- },
- {
- "species": "SPECIES_MASQUERAIN",
- "level": 27,
- "probability": 1290
- },
- {
- "species": "SPECIES_SHEDINJA",
- "level": 5,
- "probability": 968
- },
- {
- "species": "SPECIES_LUNATONE",
- "level": 24,
- "probability": 2580
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_SHUPPET",
- "level": 28,
- "probability": 2581
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "SkyTower_6F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_FORRETRESS",
- "level": 23,
- "probability": 2857
- },
- {
- "species": "SPECIES_MASQUERAIN",
- "level": 27,
- "probability": 1429
- },
- {
- "species": "SPECIES_LUNATONE",
- "level": 24,
- "probability": 2857
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_SHUPPET",
- "level": 28,
- "probability": 2857
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "SkyTower_7F_8F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_MASQUERAIN",
- "level": 27,
- "probability": 2000
- },
- {
- "species": "SPECIES_LUNATONE",
- "level": 24,
- "probability": 4000
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DUSKULL",
- "level": 27,
- "probability": 4000
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "SkyTower_9F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_KOFFING",
- "level": 24,
- "probability": 3333
- },
- {
- "species": "SPECIES_LUNATONE",
- "level": 24,
- "probability": 3334
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DUSKULL",
- "level": 27,
- "probability": 3333
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "SkyTower_10F_11F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_KOFFING",
- "level": 24,
- "probability": 2581
- },
- {
- "species": "SPECIES_LEDIAN",
- "level": 24,
- "probability": 2258
- },
- {
- "species": "SPECIES_LUNATONE",
- "level": 24,
- "probability": 2580
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DUSKULL",
- "level": 27,
- "probability": 2581
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "SkyTower_12F_14F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_KOFFING",
- "level": 24,
- "probability": 2051
- },
- {
- "species": "SPECIES_LEDIAN",
- "level": 24,
- "probability": 1795
- },
- {
- "species": "SPECIES_ALTARIA",
- "level": 24,
- "probability": 2051
- },
- {
- "species": "SPECIES_SOLROCK",
- "level": 24,
- "probability": 2052
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DUSKULL",
- "level": 27,
- "probability": 2051
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "SkyTower_15F_16F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_KOFFING",
- "level": 24,
- "probability": 2051
- },
- {
- "species": "SPECIES_LEDIAN",
- "level": 24,
- "probability": 1795
- },
- {
- "species": "SPECIES_SCIZOR",
- "level": 24,
- "probability": 2051
- },
- {
- "species": "SPECIES_ALTARIA",
- "level": 24,
- "probability": 2052
- },
- {
- "species": "SPECIES_SOLROCK",
- "level": 24,
- "probability": 2051
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "SkyTower_17F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_LEDIAN",
- "level": 24,
- "probability": 1795
- },
- {
- "species": "SPECIES_SCIZOR",
- "level": 24,
- "probability": 2051
- },
- {
- "species": "SPECIES_ALTARIA",
- "level": 24,
- "probability": 2051
- },
- {
- "species": "SPECIES_SOLROCK",
- "level": 24,
- "probability": 2052
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DUSCLOPS",
- "level": 24,
- "probability": 2051
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "SkyTower_18F_19F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_SCIZOR",
- "level": 24,
- "probability": 2500
- },
- {
- "species": "SPECIES_ALTARIA",
- "level": 24,
- "probability": 2500
- },
- {
- "species": "SPECIES_SOLROCK",
- "level": 24,
- "probability": 2500
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DUSCLOPS",
- "level": 24,
- "probability": 2500
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "SkyTower_20F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_VENOMOTH",
- "level": 18,
- "probability": 2500
- },
- {
- "species": "SPECIES_SCIZOR",
- "level": 24,
- "probability": 2500
- },
- {
- "species": "SPECIES_SOLROCK",
- "level": 24,
- "probability": 2500
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DUSCLOPS",
- "level": 24,
- "probability": 2500
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "SkyTower_21F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_VENOMOTH",
- "level": 18,
- "probability": 2222
- },
- {
- "species": "SPECIES_AERODACTYL",
- "level": 25,
- "probability": 2222
- },
- {
- "species": "SPECIES_SCIZOR",
- "level": 24,
- "probability": 2223
- },
- {
- "species": "SPECIES_FLYGON",
- "level": 27,
- "probability": 1111
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DUSCLOPS",
- "level": 24,
- "probability": 2222
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "SkyTower_22F_23F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_VENOMOTH",
- "level": 18,
- "probability": 2500
- },
- {
- "species": "SPECIES_AERODACTYL",
- "level": 25,
- "probability": 2500
- },
- {
- "species": "SPECIES_FLYGON",
- "level": 27,
- "probability": 1250
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DUSCLOPS",
- "level": 24,
- "probability": 2500
- },
- {
- "species": "SPECIES_TROPIUS",
- "level": 27,
- "probability": 1250
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "SkyTower_24F_25F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_VENOMOTH",
- "level": 18,
- "probability": 3333
- },
- {
- "species": "SPECIES_AERODACTYL",
- "level": 25,
- "probability": 3334
- },
- {
- "species": "SPECIES_FLYGON",
- "level": 27,
- "probability": 1666
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_TROPIUS",
- "level": 27,
- "probability": 1667
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }
- ]
-}
+{
+ "tables": [{
+ "name": "SkyTower_1F_5F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_FORRETRESS",
+ "level": 23,
+ "probability": 2581
+ },
+ {
+ "species": "SPECIES_MASQUERAIN",
+ "level": 27,
+ "probability": 1290
+ },
+ {
+ "species": "SPECIES_SHEDINJA",
+ "level": 5,
+ "probability": 968
+ },
+ {
+ "species": "SPECIES_LUNATONE",
+ "level": 24,
+ "probability": 2580
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_SHUPPET",
+ "level": 28,
+ "probability": 2581
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "SkyTower_6F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_FORRETRESS",
+ "level": 23,
+ "probability": 2857
+ },
+ {
+ "species": "SPECIES_MASQUERAIN",
+ "level": 27,
+ "probability": 1429
+ },
+ {
+ "species": "SPECIES_LUNATONE",
+ "level": 24,
+ "probability": 2857
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_SHUPPET",
+ "level": 28,
+ "probability": 2857
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "SkyTower_7F_8F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_MASQUERAIN",
+ "level": 27,
+ "probability": 2000
+ },
+ {
+ "species": "SPECIES_LUNATONE",
+ "level": 24,
+ "probability": 4000
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DUSKULL",
+ "level": 27,
+ "probability": 4000
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "SkyTower_9F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_KOFFING",
+ "level": 24,
+ "probability": 3333
+ },
+ {
+ "species": "SPECIES_LUNATONE",
+ "level": 24,
+ "probability": 3334
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DUSKULL",
+ "level": 27,
+ "probability": 3333
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "SkyTower_10F_11F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_KOFFING",
+ "level": 24,
+ "probability": 2581
+ },
+ {
+ "species": "SPECIES_LEDIAN",
+ "level": 24,
+ "probability": 2258
+ },
+ {
+ "species": "SPECIES_LUNATONE",
+ "level": 24,
+ "probability": 2580
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DUSKULL",
+ "level": 27,
+ "probability": 2581
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "SkyTower_12F_14F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_KOFFING",
+ "level": 24,
+ "probability": 2051
+ },
+ {
+ "species": "SPECIES_LEDIAN",
+ "level": 24,
+ "probability": 1795
+ },
+ {
+ "species": "SPECIES_ALTARIA",
+ "level": 24,
+ "probability": 2051
+ },
+ {
+ "species": "SPECIES_SOLROCK",
+ "level": 24,
+ "probability": 2052
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DUSKULL",
+ "level": 27,
+ "probability": 2051
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "SkyTower_15F_16F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_KOFFING",
+ "level": 24,
+ "probability": 2051
+ },
+ {
+ "species": "SPECIES_LEDIAN",
+ "level": 24,
+ "probability": 1795
+ },
+ {
+ "species": "SPECIES_SCIZOR",
+ "level": 24,
+ "probability": 2051
+ },
+ {
+ "species": "SPECIES_ALTARIA",
+ "level": 24,
+ "probability": 2052
+ },
+ {
+ "species": "SPECIES_SOLROCK",
+ "level": 24,
+ "probability": 2051
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "SkyTower_17F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_LEDIAN",
+ "level": 24,
+ "probability": 1795
+ },
+ {
+ "species": "SPECIES_SCIZOR",
+ "level": 24,
+ "probability": 2051
+ },
+ {
+ "species": "SPECIES_ALTARIA",
+ "level": 24,
+ "probability": 2051
+ },
+ {
+ "species": "SPECIES_SOLROCK",
+ "level": 24,
+ "probability": 2052
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DUSCLOPS",
+ "level": 24,
+ "probability": 2051
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "SkyTower_18F_19F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_SCIZOR",
+ "level": 24,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_ALTARIA",
+ "level": 24,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_SOLROCK",
+ "level": 24,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DUSCLOPS",
+ "level": 24,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "SkyTower_20F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_VENOMOTH",
+ "level": 18,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_SCIZOR",
+ "level": 24,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_SOLROCK",
+ "level": 24,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DUSCLOPS",
+ "level": 24,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "SkyTower_21F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_VENOMOTH",
+ "level": 18,
+ "probability": 2222
+ },
+ {
+ "species": "SPECIES_AERODACTYL",
+ "level": 25,
+ "probability": 2222
+ },
+ {
+ "species": "SPECIES_SCIZOR",
+ "level": 24,
+ "probability": 2223
+ },
+ {
+ "species": "SPECIES_FLYGON",
+ "level": 27,
+ "probability": 1111
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DUSCLOPS",
+ "level": 24,
+ "probability": 2222
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "SkyTower_22F_23F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_VENOMOTH",
+ "level": 18,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_AERODACTYL",
+ "level": 25,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_FLYGON",
+ "level": 27,
+ "probability": 1250
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DUSCLOPS",
+ "level": 24,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_TROPIUS",
+ "level": 27,
+ "probability": 1250
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "SkyTower_24F_25F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_VENOMOTH",
+ "level": 18,
+ "probability": 3333
+ },
+ {
+ "species": "SPECIES_AERODACTYL",
+ "level": 25,
+ "probability": 3334
+ },
+ {
+ "species": "SPECIES_FLYGON",
+ "level": 27,
+ "probability": 1666
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_TROPIUS",
+ "level": 27,
+ "probability": 1667
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }
+ ]
+}
diff --git a/data/dungeon/SkyTowerSummit/floor_id.json b/data/dungeon/SkyTowerSummit/floor_id.json
index e3b3769..88f7042 100644
--- a/data/dungeon/SkyTowerSummit/floor_id.json
+++ b/data/dungeon/SkyTowerSummit/floor_id.json
@@ -1,86 +1,86 @@
-{
- "name": "SkyTowerSummitFloorID",
- "tables": [
- {
- "MainData": 178,
- "Pokemon": 110,
- "Traps": 5,
- "Items": 43,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 179,
- "Pokemon": 110,
- "Traps": 5,
- "Items": 43,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 180,
- "Pokemon": 110,
- "Traps": 5,
- "Items": 43,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 181,
- "Pokemon": 110,
- "Traps": 5,
- "Items": 44,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 182,
- "Pokemon": 110,
- "Traps": 5,
- "Items": 44,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 183,
- "Pokemon": 110,
- "Traps": 5,
- "Items": 44,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 184,
- "Pokemon": 110,
- "Traps": 5,
- "Items": 44,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 185,
- "Pokemon": 110,
- "Traps": 5,
- "Items": 44,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 186,
- "Pokemon": 111,
- "Traps": 5,
- "Items": 44,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- }
- ]
-}
+{
+ "name": "SkyTowerSummitFloorID",
+ "tables": [
+ {
+ "MainData": 178,
+ "Pokemon": 110,
+ "Traps": 5,
+ "Items": 43,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 179,
+ "Pokemon": 110,
+ "Traps": 5,
+ "Items": 43,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 180,
+ "Pokemon": 110,
+ "Traps": 5,
+ "Items": 43,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 181,
+ "Pokemon": 110,
+ "Traps": 5,
+ "Items": 44,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 182,
+ "Pokemon": 110,
+ "Traps": 5,
+ "Items": 44,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 183,
+ "Pokemon": 110,
+ "Traps": 5,
+ "Items": 44,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 184,
+ "Pokemon": 110,
+ "Traps": 5,
+ "Items": 44,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 185,
+ "Pokemon": 110,
+ "Traps": 5,
+ "Items": 44,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 186,
+ "Pokemon": 111,
+ "Traps": 5,
+ "Items": 44,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ }
+ ]
+}
diff --git a/data/dungeon/SkyTowerSummit/pokemon_found.json b/data/dungeon/SkyTowerSummit/pokemon_found.json
index 8146ec3..75237dc 100644
--- a/data/dungeon/SkyTowerSummit/pokemon_found.json
+++ b/data/dungeon/SkyTowerSummit/pokemon_found.json
@@ -1,66 +1,66 @@
-{
- "tables": [{
- "name": "SkyTowerSummit_1F_8F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_AERODACTYL",
- "level": 25,
- "probability": 1667
- },
- {
- "species": "SPECIES_FLYGON",
- "level": 27,
- "probability": 1666
- },
- {
- "species": "SPECIES_CLAYDOL",
- "level": 26,
- "probability": 1667
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_TROPIUS",
- "level": 27,
- "probability": 1667
- },
- {
- "species": "SPECIES_SALAMENCE",
- "level": 29,
- "probability": 1666
- },
- {
- "species": "SPECIES_METAGROSS",
- "level": 30,
- "probability": 1667
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "SkyTowerSummit_9F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_RAYQUAZA",
- "level": 35,
- "probability": 10000
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }]
-}
+{
+ "tables": [{
+ "name": "SkyTowerSummit_1F_8F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_AERODACTYL",
+ "level": 25,
+ "probability": 1667
+ },
+ {
+ "species": "SPECIES_FLYGON",
+ "level": 27,
+ "probability": 1666
+ },
+ {
+ "species": "SPECIES_CLAYDOL",
+ "level": 26,
+ "probability": 1667
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_TROPIUS",
+ "level": 27,
+ "probability": 1667
+ },
+ {
+ "species": "SPECIES_SALAMENCE",
+ "level": 29,
+ "probability": 1666
+ },
+ {
+ "species": "SPECIES_METAGROSS",
+ "level": 30,
+ "probability": 1667
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "SkyTowerSummit_9F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_RAYQUAZA",
+ "level": 35,
+ "probability": 10000
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }]
+}
diff --git a/data/dungeon/SnowPath/floor_id.json b/data/dungeon/SnowPath/floor_id.json
index 6cc72ec..e7c8b23 100644
--- a/data/dungeon/SnowPath/floor_id.json
+++ b/data/dungeon/SnowPath/floor_id.json
@@ -1,41 +1,41 @@
-{
- "name": "SnowPathFloorID",
- "tables": [
- {
- "MainData": 1125,
- "Pokemon": 522,
- "Traps": 10,
- "Items": 124,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1126,
- "Pokemon": 523,
- "Traps": 10,
- "Items": 124,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1127,
- "Pokemon": 524,
- "Traps": 10,
- "Items": 124,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1128,
- "Pokemon": 525,
- "Traps": 10,
- "Items": 125,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- }
- ]
-}
+{
+ "name": "SnowPathFloorID",
+ "tables": [
+ {
+ "MainData": 1125,
+ "Pokemon": 522,
+ "Traps": 10,
+ "Items": 124,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1126,
+ "Pokemon": 523,
+ "Traps": 10,
+ "Items": 124,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1127,
+ "Pokemon": 524,
+ "Traps": 10,
+ "Items": 124,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1128,
+ "Pokemon": 525,
+ "Traps": 10,
+ "Items": 125,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ }
+ ]
+}
diff --git a/data/dungeon/SolarCave/floor_id.json b/data/dungeon/SolarCave/floor_id.json
index fc8d677..b742d12 100644
--- a/data/dungeon/SolarCave/floor_id.json
+++ b/data/dungeon/SolarCave/floor_id.json
@@ -1,185 +1,185 @@
-{
- "name": "SolarCaveFloorID",
- "tables": [
- {
- "MainData": 900,
- "Pokemon": 412,
- "Traps": 75,
- "Items": 102,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 901,
- "Pokemon": 412,
- "Traps": 76,
- "Items": 102,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 902,
- "Pokemon": 412,
- "Traps": 77,
- "Items": 102,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 903,
- "Pokemon": 413,
- "Traps": 78,
- "Items": 102,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 904,
- "Pokemon": 414,
- "Traps": 79,
- "Items": 102,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 905,
- "Pokemon": 415,
- "Traps": 80,
- "Items": 102,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 906,
- "Pokemon": 416,
- "Traps": 81,
- "Items": 102,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 907,
- "Pokemon": 417,
- "Traps": 81,
- "Items": 102,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 908,
- "Pokemon": 418,
- "Traps": 81,
- "Items": 102,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 909,
- "Pokemon": 419,
- "Traps": 81,
- "Items": 103,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 910,
- "Pokemon": 420,
- "Traps": 82,
- "Items": 103,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 911,
- "Pokemon": 421,
- "Traps": 82,
- "Items": 103,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 912,
- "Pokemon": 422,
- "Traps": 82,
- "Items": 103,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 913,
- "Pokemon": 422,
- "Traps": 82,
- "Items": 103,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 914,
- "Pokemon": 423,
- "Traps": 82,
- "Items": 103,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 915,
- "Pokemon": 424,
- "Traps": 83,
- "Items": 104,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 916,
- "Pokemon": 425,
- "Traps": 83,
- "Items": 104,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 917,
- "Pokemon": 426,
- "Traps": 83,
- "Items": 104,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 918,
- "Pokemon": 426,
- "Traps": 83,
- "Items": 104,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 919,
- "Pokemon": 426,
- "Traps": 84,
- "Items": 104,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- }
- ]
-}
+{
+ "name": "SolarCaveFloorID",
+ "tables": [
+ {
+ "MainData": 900,
+ "Pokemon": 412,
+ "Traps": 75,
+ "Items": 102,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 901,
+ "Pokemon": 412,
+ "Traps": 76,
+ "Items": 102,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 902,
+ "Pokemon": 412,
+ "Traps": 77,
+ "Items": 102,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 903,
+ "Pokemon": 413,
+ "Traps": 78,
+ "Items": 102,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 904,
+ "Pokemon": 414,
+ "Traps": 79,
+ "Items": 102,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 905,
+ "Pokemon": 415,
+ "Traps": 80,
+ "Items": 102,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 906,
+ "Pokemon": 416,
+ "Traps": 81,
+ "Items": 102,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 907,
+ "Pokemon": 417,
+ "Traps": 81,
+ "Items": 102,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 908,
+ "Pokemon": 418,
+ "Traps": 81,
+ "Items": 102,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 909,
+ "Pokemon": 419,
+ "Traps": 81,
+ "Items": 103,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 910,
+ "Pokemon": 420,
+ "Traps": 82,
+ "Items": 103,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 911,
+ "Pokemon": 421,
+ "Traps": 82,
+ "Items": 103,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 912,
+ "Pokemon": 422,
+ "Traps": 82,
+ "Items": 103,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 913,
+ "Pokemon": 422,
+ "Traps": 82,
+ "Items": 103,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 914,
+ "Pokemon": 423,
+ "Traps": 82,
+ "Items": 103,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 915,
+ "Pokemon": 424,
+ "Traps": 83,
+ "Items": 104,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 916,
+ "Pokemon": 425,
+ "Traps": 83,
+ "Items": 104,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 917,
+ "Pokemon": 426,
+ "Traps": 83,
+ "Items": 104,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 918,
+ "Pokemon": 426,
+ "Traps": 83,
+ "Items": 104,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 919,
+ "Pokemon": 426,
+ "Traps": 84,
+ "Items": 104,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ }
+ ]
+}
diff --git a/data/dungeon/SouthernCavern/floor_id.json b/data/dungeon/SouthernCavern/floor_id.json
index de99089..b169550 100644
--- a/data/dungeon/SouthernCavern/floor_id.json
+++ b/data/dungeon/SouthernCavern/floor_id.json
@@ -1,455 +1,455 @@
-{
- "name": "SouthernCavernFloorID",
- "tables": [
- {
- "MainData": 760,
- "Pokemon": 345,
- "Traps": 65,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 761,
- "Pokemon": 345,
- "Traps": 65,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 762,
- "Pokemon": 345,
- "Traps": 65,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 763,
- "Pokemon": 345,
- "Traps": 65,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 764,
- "Pokemon": 346,
- "Traps": 65,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 765,
- "Pokemon": 346,
- "Traps": 65,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 766,
- "Pokemon": 347,
- "Traps": 65,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 767,
- "Pokemon": 348,
- "Traps": 65,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 768,
- "Pokemon": 348,
- "Traps": 65,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 769,
- "Pokemon": 349,
- "Traps": 66,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 770,
- "Pokemon": 350,
- "Traps": 66,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 771,
- "Pokemon": 351,
- "Traps": 66,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 772,
- "Pokemon": 351,
- "Traps": 66,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 773,
- "Pokemon": 351,
- "Traps": 66,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 774,
- "Pokemon": 352,
- "Traps": 66,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 775,
- "Pokemon": 353,
- "Traps": 66,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 776,
- "Pokemon": 353,
- "Traps": 66,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 777,
- "Pokemon": 353,
- "Traps": 66,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 778,
- "Pokemon": 353,
- "Traps": 66,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 779,
- "Pokemon": 354,
- "Traps": 66,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 780,
- "Pokemon": 355,
- "Traps": 66,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 781,
- "Pokemon": 355,
- "Traps": 66,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 782,
- "Pokemon": 356,
- "Traps": 66,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 783,
- "Pokemon": 356,
- "Traps": 66,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 784,
- "Pokemon": 357,
- "Traps": 66,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 785,
- "Pokemon": 358,
- "Traps": 66,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 786,
- "Pokemon": 359,
- "Traps": 66,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 787,
- "Pokemon": 359,
- "Traps": 66,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 788,
- "Pokemon": 359,
- "Traps": 66,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 789,
- "Pokemon": 359,
- "Traps": 67,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 790,
- "Pokemon": 360,
- "Traps": 68,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 791,
- "Pokemon": 361,
- "Traps": 68,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 792,
- "Pokemon": 361,
- "Traps": 68,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 793,
- "Pokemon": 361,
- "Traps": 68,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 794,
- "Pokemon": 361,
- "Traps": 68,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 795,
- "Pokemon": 361,
- "Traps": 68,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 796,
- "Pokemon": 362,
- "Traps": 68,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 797,
- "Pokemon": 362,
- "Traps": 68,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 798,
- "Pokemon": 362,
- "Traps": 68,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 799,
- "Pokemon": 363,
- "Traps": 69,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 800,
- "Pokemon": 364,
- "Traps": 69,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 801,
- "Pokemon": 364,
- "Traps": 69,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 802,
- "Pokemon": 364,
- "Traps": 69,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 803,
- "Pokemon": 364,
- "Traps": 69,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 804,
- "Pokemon": 364,
- "Traps": 69,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 805,
- "Pokemon": 365,
- "Traps": 69,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 806,
- "Pokemon": 365,
- "Traps": 69,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 807,
- "Pokemon": 365,
- "Traps": 69,
- "Items": 93,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 808,
- "Pokemon": 365,
- "Traps": 69,
- "Items": 95,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- },
- {
- "MainData": 809,
- "Pokemon": 365,
- "Traps": 70,
- "Items": 95,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 57
- }
- ]
-}
+{
+ "name": "SouthernCavernFloorID",
+ "tables": [
+ {
+ "MainData": 760,
+ "Pokemon": 345,
+ "Traps": 65,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 761,
+ "Pokemon": 345,
+ "Traps": 65,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 762,
+ "Pokemon": 345,
+ "Traps": 65,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 763,
+ "Pokemon": 345,
+ "Traps": 65,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 764,
+ "Pokemon": 346,
+ "Traps": 65,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 765,
+ "Pokemon": 346,
+ "Traps": 65,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 766,
+ "Pokemon": 347,
+ "Traps": 65,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 767,
+ "Pokemon": 348,
+ "Traps": 65,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 768,
+ "Pokemon": 348,
+ "Traps": 65,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 769,
+ "Pokemon": 349,
+ "Traps": 66,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 770,
+ "Pokemon": 350,
+ "Traps": 66,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 771,
+ "Pokemon": 351,
+ "Traps": 66,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 772,
+ "Pokemon": 351,
+ "Traps": 66,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 773,
+ "Pokemon": 351,
+ "Traps": 66,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 774,
+ "Pokemon": 352,
+ "Traps": 66,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 775,
+ "Pokemon": 353,
+ "Traps": 66,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 776,
+ "Pokemon": 353,
+ "Traps": 66,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 777,
+ "Pokemon": 353,
+ "Traps": 66,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 778,
+ "Pokemon": 353,
+ "Traps": 66,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 779,
+ "Pokemon": 354,
+ "Traps": 66,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 780,
+ "Pokemon": 355,
+ "Traps": 66,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 781,
+ "Pokemon": 355,
+ "Traps": 66,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 782,
+ "Pokemon": 356,
+ "Traps": 66,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 783,
+ "Pokemon": 356,
+ "Traps": 66,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 784,
+ "Pokemon": 357,
+ "Traps": 66,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 785,
+ "Pokemon": 358,
+ "Traps": 66,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 786,
+ "Pokemon": 359,
+ "Traps": 66,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 787,
+ "Pokemon": 359,
+ "Traps": 66,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 788,
+ "Pokemon": 359,
+ "Traps": 66,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 789,
+ "Pokemon": 359,
+ "Traps": 67,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 790,
+ "Pokemon": 360,
+ "Traps": 68,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 791,
+ "Pokemon": 361,
+ "Traps": 68,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 792,
+ "Pokemon": 361,
+ "Traps": 68,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 793,
+ "Pokemon": 361,
+ "Traps": 68,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 794,
+ "Pokemon": 361,
+ "Traps": 68,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 795,
+ "Pokemon": 361,
+ "Traps": 68,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 796,
+ "Pokemon": 362,
+ "Traps": 68,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 797,
+ "Pokemon": 362,
+ "Traps": 68,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 798,
+ "Pokemon": 362,
+ "Traps": 68,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 799,
+ "Pokemon": 363,
+ "Traps": 69,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 800,
+ "Pokemon": 364,
+ "Traps": 69,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 801,
+ "Pokemon": 364,
+ "Traps": 69,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 802,
+ "Pokemon": 364,
+ "Traps": 69,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 803,
+ "Pokemon": 364,
+ "Traps": 69,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 804,
+ "Pokemon": 364,
+ "Traps": 69,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 805,
+ "Pokemon": 365,
+ "Traps": 69,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 806,
+ "Pokemon": 365,
+ "Traps": 69,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 807,
+ "Pokemon": 365,
+ "Traps": 69,
+ "Items": 93,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 808,
+ "Pokemon": 365,
+ "Traps": 69,
+ "Items": 95,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ },
+ {
+ "MainData": 809,
+ "Pokemon": 365,
+ "Traps": 70,
+ "Items": 95,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 57
+ }
+ ]
+}
diff --git a/data/dungeon/StormySea/floor_id.json b/data/dungeon/StormySea/floor_id.json
index 0828d7b..c740654 100644
--- a/data/dungeon/StormySea/floor_id.json
+++ b/data/dungeon/StormySea/floor_id.json
@@ -1,365 +1,365 @@
-{
- "name": "StormySeaFloorID",
- "tables": [
- {
- "MainData": 187,
- "Pokemon": 112,
- "Traps": 4,
- "Items": 45,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 188,
- "Pokemon": 112,
- "Traps": 4,
- "Items": 45,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 189,
- "Pokemon": 112,
- "Traps": 4,
- "Items": 45,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 190,
- "Pokemon": 112,
- "Traps": 4,
- "Items": 45,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 191,
- "Pokemon": 112,
- "Traps": 4,
- "Items": 45,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 192,
- "Pokemon": 113,
- "Traps": 4,
- "Items": 45,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 193,
- "Pokemon": 113,
- "Traps": 4,
- "Items": 45,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 194,
- "Pokemon": 113,
- "Traps": 4,
- "Items": 45,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 195,
- "Pokemon": 114,
- "Traps": 4,
- "Items": 45,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 196,
- "Pokemon": 115,
- "Traps": 4,
- "Items": 47,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 197,
- "Pokemon": 116,
- "Traps": 4,
- "Items": 47,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 198,
- "Pokemon": 116,
- "Traps": 4,
- "Items": 47,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 199,
- "Pokemon": 116,
- "Traps": 4,
- "Items": 47,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 200,
- "Pokemon": 116,
- "Traps": 4,
- "Items": 47,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 201,
- "Pokemon": 117,
- "Traps": 4,
- "Items": 47,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 202,
- "Pokemon": 117,
- "Traps": 4,
- "Items": 47,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 203,
- "Pokemon": 117,
- "Traps": 4,
- "Items": 47,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 204,
- "Pokemon": 118,
- "Traps": 4,
- "Items": 47,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 205,
- "Pokemon": 118,
- "Traps": 4,
- "Items": 47,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 206,
- "Pokemon": 119,
- "Traps": 4,
- "Items": 47,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 207,
- "Pokemon": 119,
- "Traps": 4,
- "Items": 48,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 208,
- "Pokemon": 119,
- "Traps": 4,
- "Items": 48,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 209,
- "Pokemon": 119,
- "Traps": 4,
- "Items": 48,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 210,
- "Pokemon": 119,
- "Traps": 4,
- "Items": 48,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 211,
- "Pokemon": 120,
- "Traps": 4,
- "Items": 48,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 212,
- "Pokemon": 120,
- "Traps": 4,
- "Items": 48,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 213,
- "Pokemon": 121,
- "Traps": 4,
- "Items": 48,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 214,
- "Pokemon": 122,
- "Traps": 4,
- "Items": 48,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 215,
- "Pokemon": 122,
- "Traps": 4,
- "Items": 48,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 216,
- "Pokemon": 123,
- "Traps": 4,
- "Items": 48,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 217,
- "Pokemon": 124,
- "Traps": 4,
- "Items": 49,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 218,
- "Pokemon": 124,
- "Traps": 4,
- "Items": 49,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 219,
- "Pokemon": 124,
- "Traps": 4,
- "Items": 49,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 220,
- "Pokemon": 125,
- "Traps": 4,
- "Items": 49,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 221,
- "Pokemon": 126,
- "Traps": 4,
- "Items": 49,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 222,
- "Pokemon": 126,
- "Traps": 4,
- "Items": 49,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 223,
- "Pokemon": 126,
- "Traps": 4,
- "Items": 49,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 224,
- "Pokemon": 126,
- "Traps": 4,
- "Items": 49,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 225,
- "Pokemon": 126,
- "Traps": 4,
- "Items": 49,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 226,
- "Pokemon": 127,
- "Traps": 4,
- "Items": 49,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- }
- ]
-}
+{
+ "name": "StormySeaFloorID",
+ "tables": [
+ {
+ "MainData": 187,
+ "Pokemon": 112,
+ "Traps": 4,
+ "Items": 45,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 188,
+ "Pokemon": 112,
+ "Traps": 4,
+ "Items": 45,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 189,
+ "Pokemon": 112,
+ "Traps": 4,
+ "Items": 45,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 190,
+ "Pokemon": 112,
+ "Traps": 4,
+ "Items": 45,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 191,
+ "Pokemon": 112,
+ "Traps": 4,
+ "Items": 45,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 192,
+ "Pokemon": 113,
+ "Traps": 4,
+ "Items": 45,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 193,
+ "Pokemon": 113,
+ "Traps": 4,
+ "Items": 45,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 194,
+ "Pokemon": 113,
+ "Traps": 4,
+ "Items": 45,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 195,
+ "Pokemon": 114,
+ "Traps": 4,
+ "Items": 45,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 196,
+ "Pokemon": 115,
+ "Traps": 4,
+ "Items": 47,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 197,
+ "Pokemon": 116,
+ "Traps": 4,
+ "Items": 47,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 198,
+ "Pokemon": 116,
+ "Traps": 4,
+ "Items": 47,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 199,
+ "Pokemon": 116,
+ "Traps": 4,
+ "Items": 47,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 200,
+ "Pokemon": 116,
+ "Traps": 4,
+ "Items": 47,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 201,
+ "Pokemon": 117,
+ "Traps": 4,
+ "Items": 47,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 202,
+ "Pokemon": 117,
+ "Traps": 4,
+ "Items": 47,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 203,
+ "Pokemon": 117,
+ "Traps": 4,
+ "Items": 47,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 204,
+ "Pokemon": 118,
+ "Traps": 4,
+ "Items": 47,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 205,
+ "Pokemon": 118,
+ "Traps": 4,
+ "Items": 47,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 206,
+ "Pokemon": 119,
+ "Traps": 4,
+ "Items": 47,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 207,
+ "Pokemon": 119,
+ "Traps": 4,
+ "Items": 48,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 208,
+ "Pokemon": 119,
+ "Traps": 4,
+ "Items": 48,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 209,
+ "Pokemon": 119,
+ "Traps": 4,
+ "Items": 48,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 210,
+ "Pokemon": 119,
+ "Traps": 4,
+ "Items": 48,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 211,
+ "Pokemon": 120,
+ "Traps": 4,
+ "Items": 48,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 212,
+ "Pokemon": 120,
+ "Traps": 4,
+ "Items": 48,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 213,
+ "Pokemon": 121,
+ "Traps": 4,
+ "Items": 48,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 214,
+ "Pokemon": 122,
+ "Traps": 4,
+ "Items": 48,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 215,
+ "Pokemon": 122,
+ "Traps": 4,
+ "Items": 48,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 216,
+ "Pokemon": 123,
+ "Traps": 4,
+ "Items": 48,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 217,
+ "Pokemon": 124,
+ "Traps": 4,
+ "Items": 49,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 218,
+ "Pokemon": 124,
+ "Traps": 4,
+ "Items": 49,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 219,
+ "Pokemon": 124,
+ "Traps": 4,
+ "Items": 49,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 220,
+ "Pokemon": 125,
+ "Traps": 4,
+ "Items": 49,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 221,
+ "Pokemon": 126,
+ "Traps": 4,
+ "Items": 49,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 222,
+ "Pokemon": 126,
+ "Traps": 4,
+ "Items": 49,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 223,
+ "Pokemon": 126,
+ "Traps": 4,
+ "Items": 49,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 224,
+ "Pokemon": 126,
+ "Traps": 4,
+ "Items": 49,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 225,
+ "Pokemon": 126,
+ "Traps": 4,
+ "Items": 49,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 226,
+ "Pokemon": 127,
+ "Traps": 4,
+ "Items": 49,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ }
+ ]
+}
diff --git a/data/dungeon/ThunderwaveCave/floor_id.json b/data/dungeon/ThunderwaveCave/floor_id.json
index 1a5898b..a90b7cb 100644
--- a/data/dungeon/ThunderwaveCave/floor_id.json
+++ b/data/dungeon/ThunderwaveCave/floor_id.json
@@ -1,50 +1,50 @@
-{
- "name": "ThunderwaveCaveFloorID",
- "tables": [
- {
- "MainData": 3,
- "Pokemon": 2,
- "Traps": 1,
- "Items": 6,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 4,
- "Pokemon": 2,
- "Traps": 1,
- "Items": 6,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 5,
- "Pokemon": 3,
- "Traps": 1,
- "Items": 6,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 6,
- "Pokemon": 4,
- "Traps": 1,
- "Items": 7,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 7,
- "Pokemon": 4,
- "Traps": 1,
- "Items": 7,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- }
- ]
-}
+{
+ "name": "ThunderwaveCaveFloorID",
+ "tables": [
+ {
+ "MainData": 3,
+ "Pokemon": 2,
+ "Traps": 1,
+ "Items": 6,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 4,
+ "Pokemon": 2,
+ "Traps": 1,
+ "Items": 6,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 5,
+ "Pokemon": 3,
+ "Traps": 1,
+ "Items": 6,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 6,
+ "Pokemon": 4,
+ "Traps": 1,
+ "Items": 7,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 7,
+ "Pokemon": 4,
+ "Traps": 1,
+ "Items": 7,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ }
+ ]
+}
diff --git a/data/dungeon/ThunderwaveCave/pokemon_found.json b/data/dungeon/ThunderwaveCave/pokemon_found.json
index e22ea7b..676857b 100644
--- a/data/dungeon/ThunderwaveCave/pokemon_found.json
+++ b/data/dungeon/ThunderwaveCave/pokemon_found.json
@@ -1,100 +1,100 @@
-{
- "tables": [{
- "name": "ThunderwaveCave_1F_2F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_RATTATA",
- "level": 3,
- "probability": 5000
- },
- {
- "species": "SPECIES_NIDORAN_F",
- "level": 4,
- "probability": 2500
- },
- {
- "species": "SPECIES_POOCHYENA",
- "level": 3,
- "probability": 2500
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "ThunderwaveCave_3F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_RATTATA",
- "level": 3,
- "probability": 4167
- },
- {
- "species": "SPECIES_NIDORAN_F",
- "level": 4,
- "probability": 2083
- },
- {
- "species": "SPECIES_VOLTORB",
- "level": 3,
- "probability": 1667
- },
- {
- "species": "SPECIES_POOCHYENA",
- "level": 3,
- "probability": 2083
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "ThunderwaveCave_4F_5F_Pokemon",
- "pokemon": [
- {
- "species": "SPECIES_VOLTORB",
- "level": 3,
- "probability": 3846
- },
- {
- "species": "SPECIES_ELEKID",
- "level": 4,
- "probability": 3077
- },
- {
- "species": "SPECIES_PLUSLE",
- "level": 3,
- "probability": 1539
- },
- {
- "species": "SPECIES_MINUN",
- "level": 3,
- "probability": 1538
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }]
-}
+{
+ "tables": [{
+ "name": "ThunderwaveCave_1F_2F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_RATTATA",
+ "level": 3,
+ "probability": 5000
+ },
+ {
+ "species": "SPECIES_NIDORAN_F",
+ "level": 4,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_POOCHYENA",
+ "level": 3,
+ "probability": 2500
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "ThunderwaveCave_3F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_RATTATA",
+ "level": 3,
+ "probability": 4167
+ },
+ {
+ "species": "SPECIES_NIDORAN_F",
+ "level": 4,
+ "probability": 2083
+ },
+ {
+ "species": "SPECIES_VOLTORB",
+ "level": 3,
+ "probability": 1667
+ },
+ {
+ "species": "SPECIES_POOCHYENA",
+ "level": 3,
+ "probability": 2083
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "ThunderwaveCave_4F_5F_Pokemon",
+ "pokemon": [
+ {
+ "species": "SPECIES_VOLTORB",
+ "level": 3,
+ "probability": 3846
+ },
+ {
+ "species": "SPECIES_ELEKID",
+ "level": 4,
+ "probability": 3077
+ },
+ {
+ "species": "SPECIES_PLUSLE",
+ "level": 3,
+ "probability": 1539
+ },
+ {
+ "species": "SPECIES_MINUN",
+ "level": 3,
+ "probability": 1538
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }]
+}
diff --git a/data/dungeon/TinyWoods/floor_id.json b/data/dungeon/TinyWoods/floor_id.json
index 5326904..4471594 100644
--- a/data/dungeon/TinyWoods/floor_id.json
+++ b/data/dungeon/TinyWoods/floor_id.json
@@ -1,32 +1,32 @@
-{
- "name": "TinyWoodsFloorID",
- "tables": [
- {
- "MainData": 0,
- "Pokemon": 0,
- "Traps": 0,
- "Items": 0,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1,
- "Pokemon": 0,
- "Traps": 0,
- "Items": 4,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 2,
- "Pokemon": 1,
- "Traps": 0,
- "Items": 5,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- }
- ]
-}
+{
+ "name": "TinyWoodsFloorID",
+ "tables": [
+ {
+ "MainData": 0,
+ "Pokemon": 0,
+ "Traps": 0,
+ "Items": 0,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1,
+ "Pokemon": 0,
+ "Traps": 0,
+ "Items": 4,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 2,
+ "Pokemon": 1,
+ "Traps": 0,
+ "Items": 5,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ }
+ ]
+}
diff --git a/data/dungeon/TinyWoods/pokemon_found.json b/data/dungeon/TinyWoods/pokemon_found.json
index 79b8844..4f28076 100644
--- a/data/dungeon/TinyWoods/pokemon_found.json
+++ b/data/dungeon/TinyWoods/pokemon_found.json
@@ -1,64 +1,64 @@
-{
- "tables": [{
- "name": "TinyWoods1F_2F_Pokemon",
- "pokemon": [{
- "species": "SPECIES_PIDGEY",
- "level": 1,
- "probability": 3333
- },
- {
- "species": "SPECIES_SUNKERN",
- "level": 1,
- "probability": 3334
- },
- {
- "species": "SPECIES_WURMPLE",
- "level": 1,
- "probability": 3333
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }, {
- "name": "TinyWoods3F_Pokemon",
- "pokemon": [{
- "species": "SPECIES_PIDGEY",
- "level": 1,
- "probability": 2857
- },
- {
- "species": "SPECIES_EXEGGCUTE",
- "level": 1,
- "probability": 1429
- },
- {
- "species": "SPECIES_SUNKERN",
- "level": 1,
- "probability": 2857
- },
- {
- "species": "SPECIES_WURMPLE",
- "level": 1,
- "probability": 2857
- },
- {
- "species": "SPECIES_KECLEON",
- "level": 90,
- "probability": 0
- },
- {
- "species": "SPECIES_DECOY",
- "level": 1,
- "probability": 0
- }
- ]
- }]
-}
+{
+ "tables": [{
+ "name": "TinyWoods1F_2F_Pokemon",
+ "pokemon": [{
+ "species": "SPECIES_PIDGEY",
+ "level": 1,
+ "probability": 3333
+ },
+ {
+ "species": "SPECIES_SUNKERN",
+ "level": 1,
+ "probability": 3334
+ },
+ {
+ "species": "SPECIES_WURMPLE",
+ "level": 1,
+ "probability": 3333
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }, {
+ "name": "TinyWoods3F_Pokemon",
+ "pokemon": [{
+ "species": "SPECIES_PIDGEY",
+ "level": 1,
+ "probability": 2857
+ },
+ {
+ "species": "SPECIES_EXEGGCUTE",
+ "level": 1,
+ "probability": 1429
+ },
+ {
+ "species": "SPECIES_SUNKERN",
+ "level": 1,
+ "probability": 2857
+ },
+ {
+ "species": "SPECIES_WURMPLE",
+ "level": 1,
+ "probability": 2857
+ },
+ {
+ "species": "SPECIES_KECLEON",
+ "level": 90,
+ "probability": 0
+ },
+ {
+ "species": "SPECIES_DECOY",
+ "level": 1,
+ "probability": 0
+ }
+ ]
+ }]
+}
diff --git a/data/dungeon/UnownRelic/floor_id.json b/data/dungeon/UnownRelic/floor_id.json
index 4e57902..caa3d81 100644
--- a/data/dungeon/UnownRelic/floor_id.json
+++ b/data/dungeon/UnownRelic/floor_id.json
@@ -1,104 +1,104 @@
-{
- "name": "UnownRelicFloorID",
- "tables": [
- {
- "MainData": 1340,
- "Pokemon": 600,
- "Traps": 7,
- "Items": 154,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 155
- },
- {
- "MainData": 1341,
- "Pokemon": 601,
- "Traps": 7,
- "Items": 154,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 155
- },
- {
- "MainData": 1342,
- "Pokemon": 602,
- "Traps": 7,
- "Items": 154,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 155
- },
- {
- "MainData": 1343,
- "Pokemon": 603,
- "Traps": 7,
- "Items": 156,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 155
- },
- {
- "MainData": 1344,
- "Pokemon": 604,
- "Traps": 7,
- "Items": 156,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 155
- },
- {
- "MainData": 1345,
- "Pokemon": 605,
- "Traps": 7,
- "Items": 156,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 155
- },
- {
- "MainData": 1346,
- "Pokemon": 606,
- "Traps": 7,
- "Items": 156,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 155
- },
- {
- "MainData": 1347,
- "Pokemon": 607,
- "Traps": 7,
- "Items": 156,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 155
- },
- {
- "MainData": 1348,
- "Pokemon": 608,
- "Traps": 7,
- "Items": 156,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 155
- },
- {
- "MainData": 1349,
- "Pokemon": 609,
- "Traps": 9,
- "Items": 156,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 155
- },
- {
- "MainData": 1350,
- "Pokemon": 610,
- "Traps": 9,
- "Items": 156,
- "KecleonShop": 1,
- "MonsterRoomItems": 46,
- "BuriedItems": 155
- }
- ]
-}
+{
+ "name": "UnownRelicFloorID",
+ "tables": [
+ {
+ "MainData": 1340,
+ "Pokemon": 600,
+ "Traps": 7,
+ "Items": 154,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 155
+ },
+ {
+ "MainData": 1341,
+ "Pokemon": 601,
+ "Traps": 7,
+ "Items": 154,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 155
+ },
+ {
+ "MainData": 1342,
+ "Pokemon": 602,
+ "Traps": 7,
+ "Items": 154,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 155
+ },
+ {
+ "MainData": 1343,
+ "Pokemon": 603,
+ "Traps": 7,
+ "Items": 156,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 155
+ },
+ {
+ "MainData": 1344,
+ "Pokemon": 604,
+ "Traps": 7,
+ "Items": 156,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 155
+ },
+ {
+ "MainData": 1345,
+ "Pokemon": 605,
+ "Traps": 7,
+ "Items": 156,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 155
+ },
+ {
+ "MainData": 1346,
+ "Pokemon": 606,
+ "Traps": 7,
+ "Items": 156,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 155
+ },
+ {
+ "MainData": 1347,
+ "Pokemon": 607,
+ "Traps": 7,
+ "Items": 156,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 155
+ },
+ {
+ "MainData": 1348,
+ "Pokemon": 608,
+ "Traps": 7,
+ "Items": 156,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 155
+ },
+ {
+ "MainData": 1349,
+ "Pokemon": 609,
+ "Traps": 9,
+ "Items": 156,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 155
+ },
+ {
+ "MainData": 1350,
+ "Pokemon": 610,
+ "Traps": 9,
+ "Items": 156,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 155
+ }
+ ]
+}
diff --git a/data/dungeon/UproarForest/floor_id.json b/data/dungeon/UproarForest/floor_id.json
index f9c5723..d09025d 100644
--- a/data/dungeon/UproarForest/floor_id.json
+++ b/data/dungeon/UproarForest/floor_id.json
@@ -1,95 +1,95 @@
-{
- "name": "UproarForestFloorID",
- "tables": [
- {
- "MainData": 1026,
- "Pokemon": 475,
- "Traps": 10,
- "Items": 115,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 1027,
- "Pokemon": 475,
- "Traps": 10,
- "Items": 115,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 1028,
- "Pokemon": 475,
- "Traps": 10,
- "Items": 115,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 1029,
- "Pokemon": 476,
- "Traps": 10,
- "Items": 116,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 1030,
- "Pokemon": 477,
- "Traps": 10,
- "Items": 116,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 1031,
- "Pokemon": 478,
- "Traps": 10,
- "Items": 116,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 1032,
- "Pokemon": 479,
- "Traps": 10,
- "Items": 116,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 1033,
- "Pokemon": 480,
- "Traps": 10,
- "Items": 116,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 1034,
- "Pokemon": 480,
- "Traps": 10,
- "Items": 117,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 1035,
- "Pokemon": 480,
- "Traps": 10,
- "Items": 118,
- "KecleonShop": 37,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- }
- ]
-}
+{
+ "name": "UproarForestFloorID",
+ "tables": [
+ {
+ "MainData": 1026,
+ "Pokemon": 475,
+ "Traps": 10,
+ "Items": 115,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1027,
+ "Pokemon": 475,
+ "Traps": 10,
+ "Items": 115,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1028,
+ "Pokemon": 475,
+ "Traps": 10,
+ "Items": 115,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1029,
+ "Pokemon": 476,
+ "Traps": 10,
+ "Items": 116,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1030,
+ "Pokemon": 477,
+ "Traps": 10,
+ "Items": 116,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1031,
+ "Pokemon": 478,
+ "Traps": 10,
+ "Items": 116,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1032,
+ "Pokemon": 479,
+ "Traps": 10,
+ "Items": 116,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1033,
+ "Pokemon": 480,
+ "Traps": 10,
+ "Items": 116,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1034,
+ "Pokemon": 480,
+ "Traps": 10,
+ "Items": 117,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 1035,
+ "Pokemon": 480,
+ "Traps": 10,
+ "Items": 118,
+ "KecleonShop": 37,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ }
+ ]
+}
diff --git a/data/dungeon/WaterfallPond/floor_id.json b/data/dungeon/WaterfallPond/floor_id.json
index f8994f8..7c039c8 100644
--- a/data/dungeon/WaterfallPond/floor_id.json
+++ b/data/dungeon/WaterfallPond/floor_id.json
@@ -1,176 +1,176 @@
-{
- "name": "WaterfallPondFloorID",
- "tables": [
- {
- "MainData": 1321,
- "Pokemon": 585,
- "Traps": 93,
- "Items": 151,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1322,
- "Pokemon": 585,
- "Traps": 93,
- "Items": 151,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1323,
- "Pokemon": 586,
- "Traps": 93,
- "Items": 151,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1324,
- "Pokemon": 587,
- "Traps": 93,
- "Items": 152,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1325,
- "Pokemon": 587,
- "Traps": 93,
- "Items": 152,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1326,
- "Pokemon": 588,
- "Traps": 93,
- "Items": 152,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1327,
- "Pokemon": 589,
- "Traps": 93,
- "Items": 152,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1328,
- "Pokemon": 590,
- "Traps": 93,
- "Items": 152,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1329,
- "Pokemon": 591,
- "Traps": 93,
- "Items": 152,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1330,
- "Pokemon": 591,
- "Traps": 93,
- "Items": 152,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1331,
- "Pokemon": 592,
- "Traps": 93,
- "Items": 152,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1332,
- "Pokemon": 593,
- "Traps": 93,
- "Items": 152,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1333,
- "Pokemon": 594,
- "Traps": 93,
- "Items": 152,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1334,
- "Pokemon": 595,
- "Traps": 93,
- "Items": 152,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1335,
- "Pokemon": 596,
- "Traps": 93,
- "Items": 152,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1336,
- "Pokemon": 597,
- "Traps": 93,
- "Items": 152,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1337,
- "Pokemon": 598,
- "Traps": 93,
- "Items": 152,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1338,
- "Pokemon": 598,
- "Traps": 93,
- "Items": 153,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- },
- {
- "MainData": 1339,
- "Pokemon": 599,
- "Traps": 93,
- "Items": 153,
- "KecleonShop": 1,
- "MonsterRoomItems": 2,
- "BuriedItems": 3
- }
- ]
-}
+{
+ "name": "WaterfallPondFloorID",
+ "tables": [
+ {
+ "MainData": 1321,
+ "Pokemon": 585,
+ "Traps": 93,
+ "Items": 151,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1322,
+ "Pokemon": 585,
+ "Traps": 93,
+ "Items": 151,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1323,
+ "Pokemon": 586,
+ "Traps": 93,
+ "Items": 151,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1324,
+ "Pokemon": 587,
+ "Traps": 93,
+ "Items": 152,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1325,
+ "Pokemon": 587,
+ "Traps": 93,
+ "Items": 152,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1326,
+ "Pokemon": 588,
+ "Traps": 93,
+ "Items": 152,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1327,
+ "Pokemon": 589,
+ "Traps": 93,
+ "Items": 152,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1328,
+ "Pokemon": 590,
+ "Traps": 93,
+ "Items": 152,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1329,
+ "Pokemon": 591,
+ "Traps": 93,
+ "Items": 152,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1330,
+ "Pokemon": 591,
+ "Traps": 93,
+ "Items": 152,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1331,
+ "Pokemon": 592,
+ "Traps": 93,
+ "Items": 152,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1332,
+ "Pokemon": 593,
+ "Traps": 93,
+ "Items": 152,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1333,
+ "Pokemon": 594,
+ "Traps": 93,
+ "Items": 152,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1334,
+ "Pokemon": 595,
+ "Traps": 93,
+ "Items": 152,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1335,
+ "Pokemon": 596,
+ "Traps": 93,
+ "Items": 152,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1336,
+ "Pokemon": 597,
+ "Traps": 93,
+ "Items": 152,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1337,
+ "Pokemon": 598,
+ "Traps": 93,
+ "Items": 152,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1338,
+ "Pokemon": 598,
+ "Traps": 93,
+ "Items": 153,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 1339,
+ "Pokemon": 599,
+ "Traps": 93,
+ "Items": 153,
+ "KecleonShop": 1,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 3
+ }
+ ]
+}
diff --git a/data/dungeon/WesternCave/floor_id.json b/data/dungeon/WesternCave/floor_id.json
index 84ed4c5..dbf7683 100644
--- a/data/dungeon/WesternCave/floor_id.json
+++ b/data/dungeon/WesternCave/floor_id.json
@@ -1,896 +1,896 @@
-{
- "name": "WesternCaveFloorID",
- "tables": [
- {
- "MainData": 350,
- "Pokemon": 163,
- "Traps": 11,
- "Items": 60,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 351,
- "Pokemon": 163,
- "Traps": 11,
- "Items": 60,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 352,
- "Pokemon": 164,
- "Traps": 11,
- "Items": 60,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 353,
- "Pokemon": 165,
- "Traps": 11,
- "Items": 60,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 354,
- "Pokemon": 165,
- "Traps": 11,
- "Items": 60,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 355,
- "Pokemon": 166,
- "Traps": 11,
- "Items": 60,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 356,
- "Pokemon": 167,
- "Traps": 11,
- "Items": 60,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 357,
- "Pokemon": 168,
- "Traps": 11,
- "Items": 60,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 358,
- "Pokemon": 168,
- "Traps": 11,
- "Items": 60,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 359,
- "Pokemon": 169,
- "Traps": 11,
- "Items": 63,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 360,
- "Pokemon": 170,
- "Traps": 11,
- "Items": 63,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 361,
- "Pokemon": 171,
- "Traps": 11,
- "Items": 63,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 362,
- "Pokemon": 172,
- "Traps": 11,
- "Items": 63,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 363,
- "Pokemon": 173,
- "Traps": 11,
- "Items": 63,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 364,
- "Pokemon": 174,
- "Traps": 11,
- "Items": 63,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 365,
- "Pokemon": 174,
- "Traps": 11,
- "Items": 63,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 366,
- "Pokemon": 175,
- "Traps": 11,
- "Items": 63,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 367,
- "Pokemon": 175,
- "Traps": 11,
- "Items": 63,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 368,
- "Pokemon": 176,
- "Traps": 11,
- "Items": 63,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 369,
- "Pokemon": 177,
- "Traps": 11,
- "Items": 63,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 370,
- "Pokemon": 178,
- "Traps": 11,
- "Items": 63,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 371,
- "Pokemon": 178,
- "Traps": 11,
- "Items": 63,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 372,
- "Pokemon": 178,
- "Traps": 11,
- "Items": 63,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 373,
- "Pokemon": 178,
- "Traps": 11,
- "Items": 63,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 374,
- "Pokemon": 178,
- "Traps": 11,
- "Items": 63,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 375,
- "Pokemon": 178,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 376,
- "Pokemon": 179,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 377,
- "Pokemon": 180,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 378,
- "Pokemon": 181,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 379,
- "Pokemon": 182,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 380,
- "Pokemon": 183,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 381,
- "Pokemon": 183,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 382,
- "Pokemon": 183,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 383,
- "Pokemon": 183,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 384,
- "Pokemon": 183,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 385,
- "Pokemon": 184,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 386,
- "Pokemon": 185,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 387,
- "Pokemon": 186,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 388,
- "Pokemon": 187,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 389,
- "Pokemon": 188,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 390,
- "Pokemon": 189,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 391,
- "Pokemon": 189,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 392,
- "Pokemon": 189,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 393,
- "Pokemon": 189,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 394,
- "Pokemon": 190,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 395,
- "Pokemon": 190,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 396,
- "Pokemon": 190,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 397,
- "Pokemon": 190,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 398,
- "Pokemon": 191,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 399,
- "Pokemon": 192,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 400,
- "Pokemon": 192,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 401,
- "Pokemon": 192,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 402,
- "Pokemon": 192,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 403,
- "Pokemon": 193,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 404,
- "Pokemon": 193,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 405,
- "Pokemon": 193,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 406,
- "Pokemon": 193,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 407,
- "Pokemon": 193,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 408,
- "Pokemon": 194,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 409,
- "Pokemon": 195,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 410,
- "Pokemon": 196,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 411,
- "Pokemon": 197,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 412,
- "Pokemon": 197,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 413,
- "Pokemon": 197,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 414,
- "Pokemon": 197,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 415,
- "Pokemon": 197,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 416,
- "Pokemon": 197,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 417,
- "Pokemon": 197,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 418,
- "Pokemon": 198,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 419,
- "Pokemon": 199,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 420,
- "Pokemon": 199,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 421,
- "Pokemon": 199,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 422,
- "Pokemon": 199,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 423,
- "Pokemon": 199,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 424,
- "Pokemon": 199,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 425,
- "Pokemon": 199,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 426,
- "Pokemon": 199,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 427,
- "Pokemon": 199,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 428,
- "Pokemon": 200,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 429,
- "Pokemon": 201,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 430,
- "Pokemon": 201,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 431,
- "Pokemon": 201,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 432,
- "Pokemon": 201,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 433,
- "Pokemon": 201,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 434,
- "Pokemon": 201,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 435,
- "Pokemon": 201,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 436,
- "Pokemon": 202,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 437,
- "Pokemon": 202,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 438,
- "Pokemon": 203,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 439,
- "Pokemon": 203,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 440,
- "Pokemon": 203,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 441,
- "Pokemon": 204,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 442,
- "Pokemon": 204,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 443,
- "Pokemon": 204,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 444,
- "Pokemon": 204,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 445,
- "Pokemon": 204,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 446,
- "Pokemon": 204,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 447,
- "Pokemon": 204,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- },
- {
- "MainData": 448,
- "Pokemon": 205,
- "Traps": 11,
- "Items": 64,
- "KecleonShop": 61,
- "MonsterRoomItems": 46,
- "BuriedItems": 62
- }
- ]
-}
+{
+ "name": "WesternCaveFloorID",
+ "tables": [
+ {
+ "MainData": 350,
+ "Pokemon": 163,
+ "Traps": 11,
+ "Items": 60,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 351,
+ "Pokemon": 163,
+ "Traps": 11,
+ "Items": 60,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 352,
+ "Pokemon": 164,
+ "Traps": 11,
+ "Items": 60,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 353,
+ "Pokemon": 165,
+ "Traps": 11,
+ "Items": 60,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 354,
+ "Pokemon": 165,
+ "Traps": 11,
+ "Items": 60,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 355,
+ "Pokemon": 166,
+ "Traps": 11,
+ "Items": 60,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 356,
+ "Pokemon": 167,
+ "Traps": 11,
+ "Items": 60,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 357,
+ "Pokemon": 168,
+ "Traps": 11,
+ "Items": 60,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 358,
+ "Pokemon": 168,
+ "Traps": 11,
+ "Items": 60,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 359,
+ "Pokemon": 169,
+ "Traps": 11,
+ "Items": 63,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 360,
+ "Pokemon": 170,
+ "Traps": 11,
+ "Items": 63,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 361,
+ "Pokemon": 171,
+ "Traps": 11,
+ "Items": 63,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 362,
+ "Pokemon": 172,
+ "Traps": 11,
+ "Items": 63,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 363,
+ "Pokemon": 173,
+ "Traps": 11,
+ "Items": 63,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 364,
+ "Pokemon": 174,
+ "Traps": 11,
+ "Items": 63,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 365,
+ "Pokemon": 174,
+ "Traps": 11,
+ "Items": 63,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 366,
+ "Pokemon": 175,
+ "Traps": 11,
+ "Items": 63,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 367,
+ "Pokemon": 175,
+ "Traps": 11,
+ "Items": 63,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 368,
+ "Pokemon": 176,
+ "Traps": 11,
+ "Items": 63,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 369,
+ "Pokemon": 177,
+ "Traps": 11,
+ "Items": 63,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 370,
+ "Pokemon": 178,
+ "Traps": 11,
+ "Items": 63,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 371,
+ "Pokemon": 178,
+ "Traps": 11,
+ "Items": 63,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 372,
+ "Pokemon": 178,
+ "Traps": 11,
+ "Items": 63,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 373,
+ "Pokemon": 178,
+ "Traps": 11,
+ "Items": 63,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 374,
+ "Pokemon": 178,
+ "Traps": 11,
+ "Items": 63,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 375,
+ "Pokemon": 178,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 376,
+ "Pokemon": 179,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 377,
+ "Pokemon": 180,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 378,
+ "Pokemon": 181,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 379,
+ "Pokemon": 182,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 380,
+ "Pokemon": 183,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 381,
+ "Pokemon": 183,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 382,
+ "Pokemon": 183,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 383,
+ "Pokemon": 183,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 384,
+ "Pokemon": 183,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 385,
+ "Pokemon": 184,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 386,
+ "Pokemon": 185,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 387,
+ "Pokemon": 186,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 388,
+ "Pokemon": 187,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 389,
+ "Pokemon": 188,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 390,
+ "Pokemon": 189,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 391,
+ "Pokemon": 189,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 392,
+ "Pokemon": 189,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 393,
+ "Pokemon": 189,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 394,
+ "Pokemon": 190,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 395,
+ "Pokemon": 190,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 396,
+ "Pokemon": 190,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 397,
+ "Pokemon": 190,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 398,
+ "Pokemon": 191,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 399,
+ "Pokemon": 192,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 400,
+ "Pokemon": 192,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 401,
+ "Pokemon": 192,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 402,
+ "Pokemon": 192,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 403,
+ "Pokemon": 193,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 404,
+ "Pokemon": 193,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 405,
+ "Pokemon": 193,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 406,
+ "Pokemon": 193,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 407,
+ "Pokemon": 193,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 408,
+ "Pokemon": 194,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 409,
+ "Pokemon": 195,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 410,
+ "Pokemon": 196,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 411,
+ "Pokemon": 197,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 412,
+ "Pokemon": 197,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 413,
+ "Pokemon": 197,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 414,
+ "Pokemon": 197,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 415,
+ "Pokemon": 197,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 416,
+ "Pokemon": 197,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 417,
+ "Pokemon": 197,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 418,
+ "Pokemon": 198,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 419,
+ "Pokemon": 199,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 420,
+ "Pokemon": 199,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 421,
+ "Pokemon": 199,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 422,
+ "Pokemon": 199,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 423,
+ "Pokemon": 199,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 424,
+ "Pokemon": 199,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 425,
+ "Pokemon": 199,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 426,
+ "Pokemon": 199,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 427,
+ "Pokemon": 199,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 428,
+ "Pokemon": 200,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 429,
+ "Pokemon": 201,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 430,
+ "Pokemon": 201,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 431,
+ "Pokemon": 201,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 432,
+ "Pokemon": 201,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 433,
+ "Pokemon": 201,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 434,
+ "Pokemon": 201,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 435,
+ "Pokemon": 201,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 436,
+ "Pokemon": 202,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 437,
+ "Pokemon": 202,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 438,
+ "Pokemon": 203,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 439,
+ "Pokemon": 203,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 440,
+ "Pokemon": 203,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 441,
+ "Pokemon": 204,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 442,
+ "Pokemon": 204,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 443,
+ "Pokemon": 204,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 444,
+ "Pokemon": 204,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 445,
+ "Pokemon": 204,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 446,
+ "Pokemon": 204,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 447,
+ "Pokemon": 204,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ },
+ {
+ "MainData": 448,
+ "Pokemon": 205,
+ "Traps": 11,
+ "Items": 64,
+ "KecleonShop": 61,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 62
+ }
+ ]
+}
diff --git a/data/dungeon/WishCave/floor_id.json b/data/dungeon/WishCave/floor_id.json
index c1898ee..9a2ef71 100644
--- a/data/dungeon/WishCave/floor_id.json
+++ b/data/dungeon/WishCave/floor_id.json
@@ -1,896 +1,896 @@
-{
- "name": "WishCaveFloorID",
- "tables": [
- {
- "MainData": 480,
- "Pokemon": 215,
- "Traps": 30,
- "Items": 74,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 481,
- "Pokemon": 216,
- "Traps": 30,
- "Items": 74,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 482,
- "Pokemon": 216,
- "Traps": 30,
- "Items": 74,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 483,
- "Pokemon": 217,
- "Traps": 30,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 484,
- "Pokemon": 218,
- "Traps": 31,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 485,
- "Pokemon": 218,
- "Traps": 31,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 486,
- "Pokemon": 219,
- "Traps": 31,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 487,
- "Pokemon": 220,
- "Traps": 31,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 488,
- "Pokemon": 220,
- "Traps": 31,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 489,
- "Pokemon": 220,
- "Traps": 32,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 490,
- "Pokemon": 221,
- "Traps": 33,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 491,
- "Pokemon": 222,
- "Traps": 33,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 492,
- "Pokemon": 223,
- "Traps": 32,
- "Items": 76,
- "KecleonShop": 77,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 493,
- "Pokemon": 224,
- "Traps": 32,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 494,
- "Pokemon": 225,
- "Traps": 32,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 495,
- "Pokemon": 225,
- "Traps": 32,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 496,
- "Pokemon": 226,
- "Traps": 32,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 497,
- "Pokemon": 227,
- "Traps": 32,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 498,
- "Pokemon": 227,
- "Traps": 32,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 499,
- "Pokemon": 228,
- "Traps": 34,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 500,
- "Pokemon": 229,
- "Traps": 35,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 501,
- "Pokemon": 229,
- "Traps": 35,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 502,
- "Pokemon": 229,
- "Traps": 35,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 503,
- "Pokemon": 229,
- "Traps": 35,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 504,
- "Pokemon": 229,
- "Traps": 35,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 505,
- "Pokemon": 230,
- "Traps": 35,
- "Items": 76,
- "KecleonShop": 77,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 506,
- "Pokemon": 230,
- "Traps": 35,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 507,
- "Pokemon": 230,
- "Traps": 35,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 508,
- "Pokemon": 231,
- "Traps": 35,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 509,
- "Pokemon": 231,
- "Traps": 36,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 510,
- "Pokemon": 232,
- "Traps": 36,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 511,
- "Pokemon": 232,
- "Traps": 36,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 512,
- "Pokemon": 233,
- "Traps": 36,
- "Items": 76,
- "KecleonShop": 77,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 513,
- "Pokemon": 234,
- "Traps": 36,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 514,
- "Pokemon": 234,
- "Traps": 36,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 515,
- "Pokemon": 235,
- "Traps": 36,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 516,
- "Pokemon": 235,
- "Traps": 36,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 517,
- "Pokemon": 236,
- "Traps": 36,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 518,
- "Pokemon": 237,
- "Traps": 36,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 519,
- "Pokemon": 237,
- "Traps": 37,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 520,
- "Pokemon": 238,
- "Traps": 37,
- "Items": 76,
- "KecleonShop": 77,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 521,
- "Pokemon": 239,
- "Traps": 37,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 522,
- "Pokemon": 240,
- "Traps": 37,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 523,
- "Pokemon": 241,
- "Traps": 37,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 524,
- "Pokemon": 242,
- "Traps": 37,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 525,
- "Pokemon": 243,
- "Traps": 37,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 526,
- "Pokemon": 244,
- "Traps": 37,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 527,
- "Pokemon": 244,
- "Traps": 37,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 528,
- "Pokemon": 244,
- "Traps": 37,
- "Items": 76,
- "KecleonShop": 77,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 529,
- "Pokemon": 245,
- "Traps": 38,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 530,
- "Pokemon": 246,
- "Traps": 39,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 531,
- "Pokemon": 246,
- "Traps": 39,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 532,
- "Pokemon": 247,
- "Traps": 39,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 533,
- "Pokemon": 248,
- "Traps": 39,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 534,
- "Pokemon": 248,
- "Traps": 39,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 535,
- "Pokemon": 249,
- "Traps": 39,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 536,
- "Pokemon": 250,
- "Traps": 39,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 537,
- "Pokemon": 251,
- "Traps": 39,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 538,
- "Pokemon": 252,
- "Traps": 39,
- "Items": 76,
- "KecleonShop": 77,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 539,
- "Pokemon": 253,
- "Traps": 40,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 540,
- "Pokemon": 254,
- "Traps": 40,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 541,
- "Pokemon": 255,
- "Traps": 40,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 542,
- "Pokemon": 255,
- "Traps": 40,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 543,
- "Pokemon": 256,
- "Traps": 40,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 544,
- "Pokemon": 257,
- "Traps": 40,
- "Items": 76,
- "KecleonShop": 77,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 545,
- "Pokemon": 257,
- "Traps": 40,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 546,
- "Pokemon": 257,
- "Traps": 40,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 547,
- "Pokemon": 257,
- "Traps": 40,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 548,
- "Pokemon": 257,
- "Traps": 40,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 549,
- "Pokemon": 258,
- "Traps": 41,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 550,
- "Pokemon": 259,
- "Traps": 42,
- "Items": 76,
- "KecleonShop": 77,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 551,
- "Pokemon": 260,
- "Traps": 42,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 552,
- "Pokemon": 260,
- "Traps": 43,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 553,
- "Pokemon": 261,
- "Traps": 44,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 554,
- "Pokemon": 261,
- "Traps": 42,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 555,
- "Pokemon": 262,
- "Traps": 42,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 556,
- "Pokemon": 263,
- "Traps": 42,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 557,
- "Pokemon": 264,
- "Traps": 42,
- "Items": 76,
- "KecleonShop": 77,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 558,
- "Pokemon": 265,
- "Traps": 45,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 559,
- "Pokemon": 266,
- "Traps": 46,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 560,
- "Pokemon": 267,
- "Traps": 47,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 561,
- "Pokemon": 267,
- "Traps": 47,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 562,
- "Pokemon": 268,
- "Traps": 47,
- "Items": 76,
- "KecleonShop": 77,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 563,
- "Pokemon": 268,
- "Traps": 47,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 564,
- "Pokemon": 269,
- "Traps": 47,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 565,
- "Pokemon": 270,
- "Traps": 47,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 566,
- "Pokemon": 270,
- "Traps": 47,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 567,
- "Pokemon": 270,
- "Traps": 47,
- "Items": 76,
- "KecleonShop": 78,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 568,
- "Pokemon": 271,
- "Traps": 47,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 569,
- "Pokemon": 272,
- "Traps": 47,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 570,
- "Pokemon": 272,
- "Traps": 47,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 571,
- "Pokemon": 272,
- "Traps": 47,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 572,
- "Pokemon": 272,
- "Traps": 47,
- "Items": 76,
- "KecleonShop": 78,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 573,
- "Pokemon": 273,
- "Traps": 47,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 574,
- "Pokemon": 273,
- "Traps": 47,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 575,
- "Pokemon": 274,
- "Traps": 47,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 576,
- "Pokemon": 275,
- "Traps": 47,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 577,
- "Pokemon": 276,
- "Traps": 47,
- "Items": 76,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- },
- {
- "MainData": 578,
- "Pokemon": 277,
- "Traps": 47,
- "Items": 79,
- "KecleonShop": 75,
- "MonsterRoomItems": 46,
- "BuriedItems": 3
- }
- ]
-}
+{
+ "name": "WishCaveFloorID",
+ "tables": [
+ {
+ "MainData": 480,
+ "Pokemon": 215,
+ "Traps": 30,
+ "Items": 74,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 481,
+ "Pokemon": 216,
+ "Traps": 30,
+ "Items": 74,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 482,
+ "Pokemon": 216,
+ "Traps": 30,
+ "Items": 74,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 483,
+ "Pokemon": 217,
+ "Traps": 30,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 484,
+ "Pokemon": 218,
+ "Traps": 31,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 485,
+ "Pokemon": 218,
+ "Traps": 31,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 486,
+ "Pokemon": 219,
+ "Traps": 31,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 487,
+ "Pokemon": 220,
+ "Traps": 31,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 488,
+ "Pokemon": 220,
+ "Traps": 31,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 489,
+ "Pokemon": 220,
+ "Traps": 32,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 490,
+ "Pokemon": 221,
+ "Traps": 33,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 491,
+ "Pokemon": 222,
+ "Traps": 33,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 492,
+ "Pokemon": 223,
+ "Traps": 32,
+ "Items": 76,
+ "KecleonShop": 77,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 493,
+ "Pokemon": 224,
+ "Traps": 32,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 494,
+ "Pokemon": 225,
+ "Traps": 32,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 495,
+ "Pokemon": 225,
+ "Traps": 32,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 496,
+ "Pokemon": 226,
+ "Traps": 32,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 497,
+ "Pokemon": 227,
+ "Traps": 32,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 498,
+ "Pokemon": 227,
+ "Traps": 32,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 499,
+ "Pokemon": 228,
+ "Traps": 34,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 500,
+ "Pokemon": 229,
+ "Traps": 35,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 501,
+ "Pokemon": 229,
+ "Traps": 35,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 502,
+ "Pokemon": 229,
+ "Traps": 35,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 503,
+ "Pokemon": 229,
+ "Traps": 35,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 504,
+ "Pokemon": 229,
+ "Traps": 35,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 505,
+ "Pokemon": 230,
+ "Traps": 35,
+ "Items": 76,
+ "KecleonShop": 77,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 506,
+ "Pokemon": 230,
+ "Traps": 35,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 507,
+ "Pokemon": 230,
+ "Traps": 35,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 508,
+ "Pokemon": 231,
+ "Traps": 35,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 509,
+ "Pokemon": 231,
+ "Traps": 36,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 510,
+ "Pokemon": 232,
+ "Traps": 36,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 511,
+ "Pokemon": 232,
+ "Traps": 36,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 512,
+ "Pokemon": 233,
+ "Traps": 36,
+ "Items": 76,
+ "KecleonShop": 77,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 513,
+ "Pokemon": 234,
+ "Traps": 36,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 514,
+ "Pokemon": 234,
+ "Traps": 36,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 515,
+ "Pokemon": 235,
+ "Traps": 36,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 516,
+ "Pokemon": 235,
+ "Traps": 36,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 517,
+ "Pokemon": 236,
+ "Traps": 36,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 518,
+ "Pokemon": 237,
+ "Traps": 36,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 519,
+ "Pokemon": 237,
+ "Traps": 37,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 520,
+ "Pokemon": 238,
+ "Traps": 37,
+ "Items": 76,
+ "KecleonShop": 77,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 521,
+ "Pokemon": 239,
+ "Traps": 37,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 522,
+ "Pokemon": 240,
+ "Traps": 37,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 523,
+ "Pokemon": 241,
+ "Traps": 37,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 524,
+ "Pokemon": 242,
+ "Traps": 37,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 525,
+ "Pokemon": 243,
+ "Traps": 37,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 526,
+ "Pokemon": 244,
+ "Traps": 37,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 527,
+ "Pokemon": 244,
+ "Traps": 37,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 528,
+ "Pokemon": 244,
+ "Traps": 37,
+ "Items": 76,
+ "KecleonShop": 77,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 529,
+ "Pokemon": 245,
+ "Traps": 38,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 530,
+ "Pokemon": 246,
+ "Traps": 39,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 531,
+ "Pokemon": 246,
+ "Traps": 39,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 532,
+ "Pokemon": 247,
+ "Traps": 39,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 533,
+ "Pokemon": 248,
+ "Traps": 39,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 534,
+ "Pokemon": 248,
+ "Traps": 39,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 535,
+ "Pokemon": 249,
+ "Traps": 39,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 536,
+ "Pokemon": 250,
+ "Traps": 39,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 537,
+ "Pokemon": 251,
+ "Traps": 39,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 538,
+ "Pokemon": 252,
+ "Traps": 39,
+ "Items": 76,
+ "KecleonShop": 77,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 539,
+ "Pokemon": 253,
+ "Traps": 40,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 540,
+ "Pokemon": 254,
+ "Traps": 40,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 541,
+ "Pokemon": 255,
+ "Traps": 40,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 542,
+ "Pokemon": 255,
+ "Traps": 40,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 543,
+ "Pokemon": 256,
+ "Traps": 40,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 544,
+ "Pokemon": 257,
+ "Traps": 40,
+ "Items": 76,
+ "KecleonShop": 77,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 545,
+ "Pokemon": 257,
+ "Traps": 40,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 546,
+ "Pokemon": 257,
+ "Traps": 40,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 547,
+ "Pokemon": 257,
+ "Traps": 40,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 548,
+ "Pokemon": 257,
+ "Traps": 40,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 549,
+ "Pokemon": 258,
+ "Traps": 41,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 550,
+ "Pokemon": 259,
+ "Traps": 42,
+ "Items": 76,
+ "KecleonShop": 77,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 551,
+ "Pokemon": 260,
+ "Traps": 42,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 552,
+ "Pokemon": 260,
+ "Traps": 43,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 553,
+ "Pokemon": 261,
+ "Traps": 44,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 554,
+ "Pokemon": 261,
+ "Traps": 42,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 555,
+ "Pokemon": 262,
+ "Traps": 42,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 556,
+ "Pokemon": 263,
+ "Traps": 42,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 557,
+ "Pokemon": 264,
+ "Traps": 42,
+ "Items": 76,
+ "KecleonShop": 77,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 558,
+ "Pokemon": 265,
+ "Traps": 45,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 559,
+ "Pokemon": 266,
+ "Traps": 46,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 560,
+ "Pokemon": 267,
+ "Traps": 47,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 561,
+ "Pokemon": 267,
+ "Traps": 47,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 562,
+ "Pokemon": 268,
+ "Traps": 47,
+ "Items": 76,
+ "KecleonShop": 77,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 563,
+ "Pokemon": 268,
+ "Traps": 47,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 564,
+ "Pokemon": 269,
+ "Traps": 47,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 565,
+ "Pokemon": 270,
+ "Traps": 47,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 566,
+ "Pokemon": 270,
+ "Traps": 47,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 567,
+ "Pokemon": 270,
+ "Traps": 47,
+ "Items": 76,
+ "KecleonShop": 78,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 568,
+ "Pokemon": 271,
+ "Traps": 47,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 569,
+ "Pokemon": 272,
+ "Traps": 47,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 570,
+ "Pokemon": 272,
+ "Traps": 47,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 571,
+ "Pokemon": 272,
+ "Traps": 47,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 572,
+ "Pokemon": 272,
+ "Traps": 47,
+ "Items": 76,
+ "KecleonShop": 78,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 573,
+ "Pokemon": 273,
+ "Traps": 47,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 574,
+ "Pokemon": 273,
+ "Traps": 47,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 575,
+ "Pokemon": 274,
+ "Traps": 47,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 576,
+ "Pokemon": 275,
+ "Traps": 47,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 577,
+ "Pokemon": 276,
+ "Traps": 47,
+ "Items": 76,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ },
+ {
+ "MainData": 578,
+ "Pokemon": 277,
+ "Traps": 47,
+ "Items": 79,
+ "KecleonShop": 75,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 3
+ }
+ ]
+}
diff --git a/data/dungeon/WondrousSea/floor_id.json b/data/dungeon/WondrousSea/floor_id.json
index 93274a2..6c47397 100644
--- a/data/dungeon/WondrousSea/floor_id.json
+++ b/data/dungeon/WondrousSea/floor_id.json
@@ -1,113 +1,113 @@
-{
- "name": "WondrousSeaFloorID",
- "tables": [
- {
- "MainData": 965,
- "Pokemon": 448,
- "Traps": 63,
- "Items": 87,
- "KecleonShop": 19,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 966,
- "Pokemon": 448,
- "Traps": 63,
- "Items": 87,
- "KecleonShop": 19,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 967,
- "Pokemon": 448,
- "Traps": 63,
- "Items": 87,
- "KecleonShop": 19,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 968,
- "Pokemon": 448,
- "Traps": 63,
- "Items": 88,
- "KecleonShop": 19,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 969,
- "Pokemon": 448,
- "Traps": 63,
- "Items": 88,
- "KecleonShop": 19,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 970,
- "Pokemon": 448,
- "Traps": 63,
- "Items": 88,
- "KecleonShop": 19,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 971,
- "Pokemon": 448,
- "Traps": 63,
- "Items": 88,
- "KecleonShop": 19,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 972,
- "Pokemon": 448,
- "Traps": 63,
- "Items": 88,
- "KecleonShop": 19,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 973,
- "Pokemon": 448,
- "Traps": 63,
- "Items": 88,
- "KecleonShop": 19,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 974,
- "Pokemon": 448,
- "Traps": 63,
- "Items": 88,
- "KecleonShop": 19,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 975,
- "Pokemon": 448,
- "Traps": 63,
- "Items": 88,
- "KecleonShop": 19,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- },
- {
- "MainData": 976,
- "Pokemon": 448,
- "Traps": 85,
- "Items": 88,
- "KecleonShop": 19,
- "MonsterRoomItems": 2,
- "BuriedItems": 66
- }
- ]
-}
+{
+ "name": "WondrousSeaFloorID",
+ "tables": [
+ {
+ "MainData": 965,
+ "Pokemon": 448,
+ "Traps": 63,
+ "Items": 87,
+ "KecleonShop": 19,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 966,
+ "Pokemon": 448,
+ "Traps": 63,
+ "Items": 87,
+ "KecleonShop": 19,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 967,
+ "Pokemon": 448,
+ "Traps": 63,
+ "Items": 87,
+ "KecleonShop": 19,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 968,
+ "Pokemon": 448,
+ "Traps": 63,
+ "Items": 88,
+ "KecleonShop": 19,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 969,
+ "Pokemon": 448,
+ "Traps": 63,
+ "Items": 88,
+ "KecleonShop": 19,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 970,
+ "Pokemon": 448,
+ "Traps": 63,
+ "Items": 88,
+ "KecleonShop": 19,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 971,
+ "Pokemon": 448,
+ "Traps": 63,
+ "Items": 88,
+ "KecleonShop": 19,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 972,
+ "Pokemon": 448,
+ "Traps": 63,
+ "Items": 88,
+ "KecleonShop": 19,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 973,
+ "Pokemon": 448,
+ "Traps": 63,
+ "Items": 88,
+ "KecleonShop": 19,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 974,
+ "Pokemon": 448,
+ "Traps": 63,
+ "Items": 88,
+ "KecleonShop": 19,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 975,
+ "Pokemon": 448,
+ "Traps": 63,
+ "Items": 88,
+ "KecleonShop": 19,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 976,
+ "Pokemon": 448,
+ "Traps": 85,
+ "Items": 88,
+ "KecleonShop": 19,
+ "MonsterRoomItems": 2,
+ "BuriedItems": 66
+ }
+ ]
+}
diff --git a/data/dungeon/WyvernHill/floor_id.json b/data/dungeon/WyvernHill/floor_id.json
index b64db48..33e728a 100644
--- a/data/dungeon/WyvernHill/floor_id.json
+++ b/data/dungeon/WyvernHill/floor_id.json
@@ -1,275 +1,275 @@
-{
- "name": "WyvernHillFloorID",
- "tables": [
- {
- "MainData": 810,
- "Pokemon": 366,
- "Traps": 7,
- "Items": 96,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 811,
- "Pokemon": 366,
- "Traps": 7,
- "Items": 96,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 812,
- "Pokemon": 366,
- "Traps": 7,
- "Items": 96,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 813,
- "Pokemon": 367,
- "Traps": 7,
- "Items": 96,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 814,
- "Pokemon": 368,
- "Traps": 7,
- "Items": 96,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 815,
- "Pokemon": 369,
- "Traps": 7,
- "Items": 96,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 816,
- "Pokemon": 369,
- "Traps": 7,
- "Items": 96,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 817,
- "Pokemon": 369,
- "Traps": 7,
- "Items": 96,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 818,
- "Pokemon": 370,
- "Traps": 7,
- "Items": 96,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 819,
- "Pokemon": 371,
- "Traps": 9,
- "Items": 96,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 820,
- "Pokemon": 371,
- "Traps": 9,
- "Items": 96,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 821,
- "Pokemon": 372,
- "Traps": 9,
- "Items": 96,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 822,
- "Pokemon": 373,
- "Traps": 9,
- "Items": 96,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 823,
- "Pokemon": 373,
- "Traps": 9,
- "Items": 96,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 824,
- "Pokemon": 373,
- "Traps": 9,
- "Items": 96,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 825,
- "Pokemon": 374,
- "Traps": 9,
- "Items": 96,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 826,
- "Pokemon": 375,
- "Traps": 9,
- "Items": 96,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 827,
- "Pokemon": 375,
- "Traps": 9,
- "Items": 96,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 828,
- "Pokemon": 375,
- "Traps": 9,
- "Items": 96,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 829,
- "Pokemon": 375,
- "Traps": 9,
- "Items": 96,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 830,
- "Pokemon": 376,
- "Traps": 9,
- "Items": 96,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 831,
- "Pokemon": 377,
- "Traps": 9,
- "Items": 96,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 832,
- "Pokemon": 377,
- "Traps": 9,
- "Items": 96,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 833,
- "Pokemon": 378,
- "Traps": 9,
- "Items": 96,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 834,
- "Pokemon": 379,
- "Traps": 9,
- "Items": 96,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 835,
- "Pokemon": 379,
- "Traps": 9,
- "Items": 96,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 836,
- "Pokemon": 379,
- "Traps": 9,
- "Items": 96,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 837,
- "Pokemon": 379,
- "Traps": 9,
- "Items": 96,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 838,
- "Pokemon": 379,
- "Traps": 9,
- "Items": 97,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- },
- {
- "MainData": 839,
- "Pokemon": 380,
- "Traps": 71,
- "Items": 97,
- "KecleonShop": 94,
- "MonsterRoomItems": 46,
- "BuriedItems": 66
- }
- ]
-}
+{
+ "name": "WyvernHillFloorID",
+ "tables": [
+ {
+ "MainData": 810,
+ "Pokemon": 366,
+ "Traps": 7,
+ "Items": 96,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 811,
+ "Pokemon": 366,
+ "Traps": 7,
+ "Items": 96,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 812,
+ "Pokemon": 366,
+ "Traps": 7,
+ "Items": 96,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 813,
+ "Pokemon": 367,
+ "Traps": 7,
+ "Items": 96,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 814,
+ "Pokemon": 368,
+ "Traps": 7,
+ "Items": 96,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 815,
+ "Pokemon": 369,
+ "Traps": 7,
+ "Items": 96,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 816,
+ "Pokemon": 369,
+ "Traps": 7,
+ "Items": 96,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 817,
+ "Pokemon": 369,
+ "Traps": 7,
+ "Items": 96,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 818,
+ "Pokemon": 370,
+ "Traps": 7,
+ "Items": 96,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 819,
+ "Pokemon": 371,
+ "Traps": 9,
+ "Items": 96,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 820,
+ "Pokemon": 371,
+ "Traps": 9,
+ "Items": 96,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 821,
+ "Pokemon": 372,
+ "Traps": 9,
+ "Items": 96,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 822,
+ "Pokemon": 373,
+ "Traps": 9,
+ "Items": 96,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 823,
+ "Pokemon": 373,
+ "Traps": 9,
+ "Items": 96,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 824,
+ "Pokemon": 373,
+ "Traps": 9,
+ "Items": 96,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 825,
+ "Pokemon": 374,
+ "Traps": 9,
+ "Items": 96,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 826,
+ "Pokemon": 375,
+ "Traps": 9,
+ "Items": 96,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 827,
+ "Pokemon": 375,
+ "Traps": 9,
+ "Items": 96,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 828,
+ "Pokemon": 375,
+ "Traps": 9,
+ "Items": 96,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 829,
+ "Pokemon": 375,
+ "Traps": 9,
+ "Items": 96,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 830,
+ "Pokemon": 376,
+ "Traps": 9,
+ "Items": 96,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 831,
+ "Pokemon": 377,
+ "Traps": 9,
+ "Items": 96,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 832,
+ "Pokemon": 377,
+ "Traps": 9,
+ "Items": 96,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 833,
+ "Pokemon": 378,
+ "Traps": 9,
+ "Items": 96,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 834,
+ "Pokemon": 379,
+ "Traps": 9,
+ "Items": 96,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 835,
+ "Pokemon": 379,
+ "Traps": 9,
+ "Items": 96,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 836,
+ "Pokemon": 379,
+ "Traps": 9,
+ "Items": 96,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 837,
+ "Pokemon": 379,
+ "Traps": 9,
+ "Items": 96,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 838,
+ "Pokemon": 379,
+ "Traps": 9,
+ "Items": 97,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ },
+ {
+ "MainData": 839,
+ "Pokemon": 380,
+ "Traps": 71,
+ "Items": 97,
+ "KecleonShop": 94,
+ "MonsterRoomItems": 46,
+ "BuriedItems": 66
+ }
+ ]
+}
diff --git a/include/constants/ability.h b/include/constants/ability.h
new file mode 100644
index 0000000..27f87fc
--- /dev/null
+++ b/include/constants/ability.h
@@ -0,0 +1,84 @@
+#ifndef GUARD_CONSTANTS_ABILITY_H
+#define GUARD_CONSTANTS_ABILITY_H
+
+enum Ability
+{
+ ABILITY_STENCH = 0x1,
+ ABILITY_THICK_FAT = 0x2,
+ ABILITY_RAIN_DISH = 0x3,
+ ABILITY_DRIZZLE = 0x4,
+ ABILITY_ARENA_TRAP = 0x5,
+ ABILITY_INTIMIDATE = 0x6,
+ ABILITY_ROCK_HEAD = 0x7,
+ ABILITY_AIR_LOCK = 0x8,
+ ABILITY_HYPER_CUTTER = 0x9,
+ ABILITY_SHADOW_TAG = 0xA,
+ ABILITY_SPEED_BOOST = 0xB,
+ ABILITY_BATTLE_ARMOR = 0xC,
+ ABILITY_STURDY = 0xD,
+ ABILITY_SUCTION_CUPS = 0xE,
+ ABILITY_CLEAR_BODY = 0xF,
+ ABILITY_TORRENT = 0x10,
+ ABILITY_GUTS = 0x11,
+ ABILITY_ROUGH_SKIN = 0x12,
+ ABILITY_SHELL_ARMOR = 0x13,
+ ABILITY_NATURAL_CURE = 0x14,
+ ABILITY_DAMP = 0x15,
+ ABILITY_LIMBER = 0x16,
+ ABILITY_MAGNET_PULL = 0x17,
+ ABILITY_WHITE_SMOKE = 0x18,
+ ABILITY_SYNCHRONIZE = 0x19,
+ ABILITY_OVERGROW = 0x1A,
+ ABILITY_SWIFT_SWIM = 0x1B,
+ ABILITY_SAND_STREAM = 0x1C,
+ ABILITY_SAND_VEIL = 0x1D,
+ ABILITY_KEEN_EYE = 0x1E,
+ ABILITY_INNER_FOCUS = 0x1F,
+ ABILITY_STATIC = 0x20,
+ ABILITY_SHED_SKIN = 0x21,
+ ABILITY_HUGE_POWER = 0x22,
+ ABILITY_VOLT_ABSORB = 0x23,
+ ABILITY_WATER_ABSORB = 0x24,
+ ABILITY_FORECAST = 0x25,
+ ABILITY_SERENE_GRACE = 0x26,
+ ABILITY_POISON_POINT = 0x27,
+ ABILITY_TRACE = 0x28,
+ ABILITY_OBLIVIOUS = 0x29,
+ ABILITY_TRUANT = 0x2A,
+ ABILITY_RUN_AWAY = 0x2B,
+ ABILITY_STICKY_HOLD = 0x2C,
+ ABILITY_CLOUD_NINE = 0x2D,
+ ABILITY_ILLUMINATE = 0x2E,
+ ABILITY_EARLY_BIRD = 0x2F,
+ ABILITY_HUSTLE = 0x30,
+ ABILITY_DROUGHT = 0x31,
+ ABILITY_LIGHTNINGROD = 0x32,
+ ABILITY_COMPOUNDEYES = 0x33,
+ ABILITY_MARVEL_SCALE = 0x34,
+ ABILITY_WONDER_GUARD = 0x35,
+ ABILITY_INSOMNIA = 0x36,
+ ABILITY_LEVITATE = 0x37,
+ ABILITY_PLUS = 0x38,
+ ABILITY_PRESSURE = 0x39,
+ ABILITY_LIQUID_OOZE = 0x3A,
+ ABILITY_COLOR_CHANGE = 0x3B,
+ ABILITY_SOUNDPROOF = 0x3C,
+ ABILITY_EFFECT_SPORE = 0x3D,
+ ABILITY_FLAME_BODY = 0x3E,
+ ABILITY_MINUS = 0x3F,
+ ABILITY_OWN_TEMPO = 0x40,
+ ABILITY_MAGMA_ARMOR = 0x41,
+ ABILITY_WATER_VEIL = 0x42,
+ ABILITY_SWARM = 0x43,
+ ABILITY_CUTE_CHARM = 0x44,
+ ABILITY_IMMUNITY = 0x45,
+ ABILITY_BLAZE = 0x46,
+ ABILITY_PICKUP = 0x47,
+ ABILITY_FLASH_FIRE = 0x48,
+ ABILITY_VITAL_SPIRIT = 0x49,
+ ABILITY_CHLOROPHYLL = 0x4A,
+ ABILITY_PURE_POWER = 0x4B,
+ ABILITY_SHIELD_DUST = 0x4C
+};
+
+#endif
diff --git a/include/constants/direction.h b/include/constants/direction.h
new file mode 100644
index 0000000..5f2bfb3
--- /dev/null
+++ b/include/constants/direction.h
@@ -0,0 +1,16 @@
+#ifndef GUARD_CONSTANTS_DIRECTION_H
+#define GUARD_CONSTANTS_DIRECTION_H
+
+enum Direction
+{
+ DIRECTION_SOUTH,
+ DIRECTION_SOUTHEAST,
+ DIRECTION_EAST,
+ DIRECTION_NORTHEAST,
+ DIRECTION_NORTH,
+ DIRECTION_NORTHWEST,
+ DIRECTION_WEST,
+ DIRECTION_SOUTHWEST
+};
+
+#endif
diff --git a/include/constants/dungeon.h b/include/constants/dungeon.h
new file mode 100644
index 0000000..19f5340
--- /dev/null
+++ b/include/constants/dungeon.h
@@ -0,0 +1,106 @@
+#ifndef GUARD_CONSTANTS_DUNGEON_H
+#define GUARD_CONSTANTS_DUNGEON_H
+
+enum Dungeon
+{
+ DUNGEON_TINY_WOODS = 0,
+ DUNGEON_THUNDERWAVE_CAVE = 1,
+ DUNGEON_MT_STEEL = 2,
+ DUNGEON_SINISTER_WOODS = 3,
+ DUNGEON_SILENT_CHASM = 4,
+ DUNGEON_MT_THUNDER = 5,
+ DUNGEON_MT_THUNDER_PEAK = 6,
+ DUNGEON_GREAT_CANYON = 7,
+ DUNGEON_LAPIS_CAVE = 8,
+ DUNGEON_MT_BLAZE = 9,
+ DUNGEON_MT_BLAZE_PEAK = 10,
+ DUNGEON_FROSTY_FOREST = 11,
+ DUNGEON_FROSTY_GROTTO = 12,
+ DUNGEON_MT_FREEZE = 13,
+ DUNGEON_MT_FREEZE_PEAK = 14,
+ DUNGEON_MAGMA_CAVERN = 15,
+ DUNGEON_MAGMA_CAVERN_PIT = 16,
+ DUNGEON_SKY_TOWER = 17,
+ DUNGEON_SKY_TOWER_SUMMIT = 18,
+ DUNGEON_STORMY_SEA = 19,
+ DUNGEON_SILVER_TRENCH = 20,
+ DUNGEON_METEOR_CAVE = 21,
+ DUNGEON_MT_FREEZE_PEAK_2 = 22, // Duplicate
+ DUNGEON_WESTERN_CAVE = 23,
+ DUNGEON_BOSS_3 = 24,
+ DUNGEON_BOSS_4 = 25,
+ DUNGEON_WISH_CAVE = 26,
+ DUNGEON_BURIED_RELIC = 27,
+ DUNGEON_PITFALL_VALLEY = 28,
+ DUNGEON_NORTHERN_RANGE = 29,
+ DUNGEON_BOSS_9 = 30,
+ DUNGEON_DESERT_REGION = 31,
+ DUNGEON_SOUTHERN_CAVERN = 32,
+ DUNGEON_WYVERN_HILL = 33,
+ DUNGEON_FIERY_FIELD = 34,
+ DUNGEON_NORTHWIND_FIELD = 35,
+ DUNGEON_SOLAR_CAVE = 36,
+ DUNGEON_LIGHTNING_FIELD = 37,
+ DUNGEON_DARKNIGHT_RELIC = 38,
+ DUNGEON_WONDROUS_SEA = 39,
+ DUNGEON_MURKY_CAVE = 40,
+ DUNGEON_GRAND_SEA = 41,
+ DUNGEON_UPROAR_FOREST = 42,
+ DUNGEON_ODDITY_CAVE = 43,
+ DUNGEON_REMAINS_ISLAND = 44,
+ DUNGEON_MARVELOUS_SEA = 45,
+ DUNGEON_FANTASY_STRAIT = 46,
+ DUNGEON_ROCK_PATH = 47,
+ DUNGEON_SNOW_PATH = 48,
+ DUNGEON_AUTOPILOT = 49,
+ DUNGEON_D50 = 50,
+ DUNGEON_D51 = 51,
+ DUNGEON_NORMAL_MAZE = 52,
+ DUNGEON_HOWLING_FOREST = 53,
+ DUNGEON_D54 = 54,
+ DUNGEON_POISON_MAZE = 55,
+ DUNGEON_WATERFALL_POND = 56,
+ DUNGEON_UNKNOWN_RELIC = 57,
+ DUNGEON_JOYOUS_TOWER = 58,
+ DUNGEON_FAR_OFF_SEA = 59,
+ DUNGEON_MT_FARAWAY = 60,
+ DUNGEON_D61 = 61,
+ DUNGEON_PURITY_FOREST = 62,
+ DUNGEON_OUT_ON_RESCUE = 63,
+ DUNGEON_JOIN_LOCATION_LEADER = 64, // Displays as "???".
+ DUNGEON_JOIN_LOCATION_PARTNER = 65, // Displays as "Tiny Woods".
+ DUNGEON_UNKNOWN_WORLD = 66,
+ DUNGEON_FROSTY_GROTTO_2 = 67, // Duplicate
+ DUNGEON_HOWLING_FOREST_2 = 68, // Duplicate
+ DUNGEON_POKEMON_SQUARE = 69,
+ DUNGEON_POKEMON_SQUARE_2 = 70, // Duplicate
+ DUNGEON_RESCUE_TEAM_BASE = 71,
+ DUNGEON_RESCUE_TEAM_BASE_2 = 72, // Duplicate
+ DUNGEON_AGB_SLOT = 73,
+ DUNGEON_JOIN_LOCATION_CLIENT_POKEMON = 74,
+ DUNGEON_NORMAL_MAZE_2 = 75, // Duplicate
+ DUNGEON_FIRE_MAZE = 76,
+ DUNGEON_WATER_MAZE = 77,
+ DUNGEON_GRASS_MAZE = 78,
+ DUNGEON_ELECTRIC_MAZE = 79,
+ DUNGEON_ICE_MAZE = 80,
+ DUNGEON_FIGHTING_MAZE = 81,
+ DUNGEON_GROUND_MAZE = 82,
+ DUNGEON_FLYING_MAZE = 83,
+ DUNGEON_PSYCHIC_MAZE = 84,
+ DUNGEON_POISON_MAZE_2 = 85, // Duplicate
+ DUNGEON_BUG_MAZE = 86,
+ DUNGEON_ROCK_MAZE = 87,
+ DUNGEON_GHOST_MAZE = 88,
+ DUNGEON_DRAGON_MAZE = 89,
+ DUNGEON_DARK_MAZE = 90,
+ DUNGEON_STEEL_MAZE = 91,
+ DUNGEON_TEAM_SHIFTY = 92,
+ DUNGEON_TEAM_CONSTRICTOR = 93,
+ DUNGEON_TEAM_HYDRO = 94,
+ DUNGEON_TEAM_RUMBLEROCK = 95,
+ DUNGEON_RESCUE_TEAM_2 = 96,
+ DUNGEON_RESCUE_TEAM_MAZE = 97,
+};
+
+#endif
diff --git a/include/constants/dungeon_action.h b/include/constants/dungeon_action.h
new file mode 100644
index 0000000..f5e0290
--- /dev/null
+++ b/include/constants/dungeon_action.h
@@ -0,0 +1,44 @@
+#ifndef GUARD_CONSTANTS_DUNGEON_ACTION_H
+#define GUARD_CONSTANTS_DUNGEON_ACTION_H
+
+enum DungeonAction
+{
+ DUNGEON_ACTION_WAIT = 0x1,
+ DUNGEON_ACTION_WALK = 0x2,
+ // Switching between Pokémon in the moves menu.
+ DUNGEON_ACTION_NEXT_POKEMON_MOVES = 0x6,
+ DUNGEON_ACTION_PREVIOUS_POKEMON_MOVES = 0x7,
+ DUNGEON_ACTION_PLACE_ITEM = 0x8,
+ // Some actions are different between the leader and AI-controlled Pokémon.
+ DUNGEON_ACTION_TAKE_ITEM_LEADER = 0x9, // Picking up an item underfoot.
+ DUNGEON_ACTION_THROW_ITEM_LEADER = 0xB,
+ DUNGEON_ACTION_CONSUME_ITEM_LEADER = 0xD,
+ DUNGEON_ACTION_USE_ITEM_LEADER = 0x12,
+ DUNGEON_ACTION_TALK_FIELD = 0x13, // Talking to another Pokémon by facing them and interacting.
+ DUNGEON_ACTION_USE_MOVE_LEADER = 0x14,
+ DUNGEON_ACTION_USE_MOVE_AI = 0x15,
+ DUNGEON_ACTION_STRUGGLE = 0x17, // Using the Struggle move.
+ DUNGEON_ACTION_CHECK_MOVES = 0x19,
+ DUNGEON_ACTION_CHANGE_TACTICS = 0x1A,
+ DUNGEON_ACTION_CHECK_POKEMON_SUMMARY = 0x1B,
+ DUNGEON_ACTION_TALK_MENU = 0x1C, // Talking to another Pokémon via the menu.
+ DUNGEON_ACTION_SET_MOVE = 0x1E, // Registering a move.
+ DUNGEON_ACTION_CONSUME_ITEM_AI = 0x23,
+ DUNGEON_ACTION_THROW_ITEM_AI = 0x24,
+ DUNGEON_ACTION_THROW_STRAIGHT_THROWN_ITEM_LEADER = 0x27,
+ DUNGEON_ACTION_USE_LINK_BOX = 0x2C,
+ DUNGEON_ACTION_GIVE_UP = 0x2E,
+ DUNGEON_ACTION_CHANGE_IQ_SKILLS = 0x30,
+ DUNGEON_ACTION_USE_ORB = 0x31,
+ DUNGEON_ACTION_REGULAR_ATTACK = 0x32,
+ DUNGEON_ACTION_UNSET_MOVE = 0x33,
+ DUNGEON_ACTION_GIVE_HELD_ITEM = 0x36,
+ DUNGEON_ACTION_TAKE_HELD_ITEM = 0x37,
+ DUNGEON_ACTION_HAVE_SECOND_THOUGHTS = 0x39, // Happens with invalid actions, like attempting to eat a non-consumable item.
+ DUNGEON_ACTION_SET_ITEM = 0x3C,
+ DUNGEON_ACTION_UNSET_ITEM = 0x3D,
+ DUNGEON_ACTION_TAKE_ITEM_AI = 0x3F,
+ DUNGEON_ACTION_THROW_ARC_THROWN_ITEM_LEADER = 0x41, // Throwing Gravelerocks and Geo Pebbles.
+};
+
+#endif
diff --git a/include/constants/iq_skill.h b/include/constants/iq_skill.h
new file mode 100644
index 0000000..759c350
--- /dev/null
+++ b/include/constants/iq_skill.h
@@ -0,0 +1,31 @@
+#ifndef GUARD_CONSTANTS_IQ_SKILL_H
+#define GUARD_CONSTANTS_IQ_SKILL_H
+
+enum IQSkill
+{
+ IQ_SKILL_TYPE_ADVANTAGE_MASTER = 0x1,
+ IQ_SKILL_ITEM_CATCHER = 0x2,
+ IQ_SKILL_COURSE_CHECKER = 0x3,
+ IQ_SKILL_SURE_HIT_ATTACKER = 0x4,
+ IQ_SKILL_QUICK_DODGER = 0x5,
+ IQ_SKILL_PP_CHECKER = 0x6,
+ IQ_SKILL_NONTRAITOR = 0x7,
+ IQ_SKILL_STATUS_CHECKER = 0x8,
+ IQ_SKILL_EXP_GO_GETTER = 0x9,
+ IQ_SKILL_EFFICIENCY_EXPERT = 0xA,
+ IQ_SKILL_WEAK_TYPE_PICKER = 0xB,
+ IQ_SKILL_ALL_TERRAIN_HIKER = 0xC,
+ IQ_SKILL_SUPER_MOBILE = 0xD,
+ IQ_SKILL_TRAP_AVOIDER = 0xE,
+ IQ_SKILL_HOUSE_AVOIDER = 0xF,
+ IQ_SKILL_ENERGY_SAVER = 0x10,
+ IQ_SKILL_NONSLEEPER = 0x11,
+ IQ_SKILL_SELF_CURER = 0x12,
+ IQ_SKILL_TRAP_SEER = 0x13,
+ IQ_SKILL_LAVA_EVADER = 0x14,
+ IQ_SKILL_DEDICATED_TRAVELER = 0x15,
+ IQ_SKILL_ITEM_MASTER = 0x16,
+ IQ_SKILL_EXCLUSIVE_MOVE_USER = 0x17
+};
+
+#endif
diff --git a/include/constants/move.h b/include/constants/move.h
new file mode 100644
index 0000000..6f1ea70
--- /dev/null
+++ b/include/constants/move.h
@@ -0,0 +1,474 @@
+#ifndef GUARD_CONSTANTS_MOVE_H
+#define GUARD_CONSTANTS_MOVE_H
+
+enum MoveFlags
+{
+ MOVE_FLAG_EXISTS = 1 << 0,
+ MOVE_FLAG_LINKED = 1 << 1, // This move is linked with the previous move in the Pokémon's moveset.
+ MOVE_FLAG_ENABLED = 1 << 2, // Enabled for the AI to use.
+ MOVE_FLAG_SET = 1 << 3, // This move can be triggered by pressing L+A instead of having to go to the move menu.
+ MOVE_FLAG_LAST_USED = 1 << 4, // The most recent move used by the Pokémon.
+ MOVE_FLAG_DISABLED = 1 << 5 // Disabled by an effect like Taunt.
+};
+
+struct MoveData
+{
+ u8 fill0[0x8 - 0x0];
+ // Determines the range of moves.
+ /* 0x8 */ u16 targetingFlags;
+ /* 0xA */ u16 aiTargetingFlags; // The AI consider certain moves to have different range than they actually do.
+ /* 0xC */ u8 maxPP;
+ /* 0xD */ u8 defaultMoveWeight;
+ u8 fillE[0x10 - 0xE];
+ // Used by the AI to determine how often to use Spikes.
+ // Values exist for all other moves, though they seem to be unused.
+ /* 0x10 */ u8 moveUseChance;
+ u8 fill11[0x17 - 0x11];
+ /* 0x17 */ bool8 cannotHitFrozen; // Used by Status Checker to determine if a move can be used on a frozen target.
+ /* 0x18 */ bool8 dealsDirectDamage;
+};
+
+struct PokemonMove
+{
+ u8 moveFlags;
+ bool8 sealed;
+ u16 moveID;
+ u8 pp;
+ u8 powerBoost; // How much the move is boosted by Ginsengs.
+};
+
+enum TargetingFlag
+{
+ TARGETING_FLAG_TARGET_OTHER = 0x0,
+ TARGETING_FLAG_HEAL_TEAM = 0x1,
+ TARGETING_FLAG_SWAP_POSITIONS = 0x2,
+ TARGETING_FLAG_ATTACK_ALL = 0x5,
+ TARGETING_FLAG_BOOST_TEAM = 0x6,
+ TARGETING_FLAG_DONT_USE = 0xF,
+ TARGETING_FLAG_TARGET_FRONTAL_CONE = 0x10,
+ TARGETING_FLAG_TARGET_AROUND = 0x20,
+ TARGETING_FLAG_TARGET_ROOM = 0x30,
+ TARGETING_FLAG_TARGET_2_TILES_AHEAD = 0x40,
+ TARGETING_FLAG_TARGET_LINE = 0x50,
+ TARGETING_FLAG_TARGET_FLOOR = 0x60,
+ TARGETING_FLAG_SELF_HEAL = 0x70,
+ TARGETING_FLAG_CUT_CORNERS = 0x80,
+ TARGETING_FLAG_SET_TRAP = 0x100,
+ TARGETING_FLAG_HEAL_HP = 0x200,
+ TARGETING_FLAG_HEAL_STATUS = 0x300,
+ TARGETING_FLAG_DREAM_EATER = 0x400,
+ TARGETING_FLAG_HEAL_ALL = 0x500,
+ TARGETING_FLAG_EXPOSE = 0x600,
+};
+
+enum MoveID
+{
+ MOVE_IRON_TAIL = 0x1,
+ MOVE_ICE_BALL = 0x2,
+ MOVE_YAWN = 0x3,
+ MOVE_LOVELY_KISS = 0x4,
+ MOVE_NIGHTMARE = 0x5,
+ MOVE_MORNING_SUN = 0x6,
+ MOVE_VITAL_THROW = 0x7,
+ MOVE_DIG = 0x8,
+ MOVE_THRASH = 0x9,
+ MOVE_SWEET_SCENT = 0xA,
+ MOVE_CHARM = 0xB,
+ MOVE_RAIN_DANCE = 0xC,
+ MOVE_CONFUSE_RAY = 0xD,
+ MOVE_HAIL = 0xE,
+ MOVE_AROMATHERAPY = 0xF,
+ MOVE_BUBBLE = 0x10,
+ MOVE_ENCORE = 0x11,
+ MOVE_CUT = 0x12,
+ MOVE_RAGE = 0x13,
+ MOVE_SUPER_FANG = 0x14,
+ MOVE_PAIN_SPLIT = 0x15,
+ MOVE_TORMENT = 0x16,
+ MOVE_STRING_SHOT = 0x17,
+ MOVE_SWAGGER = 0x18,
+ MOVE_SNORE = 0x19,
+ MOVE_HEAL_BELL = 0x1A,
+ MOVE_SCREECH = 0x1B,
+ MOVE_ROCK_THROW = 0x1C,
+ MOVE_ROCK_SMASH = 0x1D,
+ MOVE_ROCK_SLIDE = 0x1E,
+ MOVE_WEATHER_BALL = 0x1F,
+ MOVE_WHIRLPOOL = 0x20,
+ MOVE_FAKE_TEARS = 0x21,
+ MOVE_SING = 0x22,
+ MOVE_SPITE = 0x23,
+ MOVE_AIR_CUTTER = 0x24,
+ MOVE_SMOKESCREEN = 0x25,
+ MOVE_PURSUIT = 0x26,
+ MOVE_DOUBLESLAP = 0x27,
+ MOVE_MIRROR_MOVE = 0x28,
+ MOVE_OVERHEAT = 0x29,
+ MOVE_AURORA_BEAM = 0x2A,
+ MOVE_MEMENTO = 0x2B,
+ MOVE_OCTAZOOKA = 0x2C,
+ MOVE_FLATTER = 0x2D,
+ MOVE_ASTONISH = 0x2E,
+ MOVE_WILL_O_WISP = 0x2F,
+ MOVE_RETURN = 0x30,
+ MOVE_GRUDGE = 0x31,
+ MOVE_STRENGTH = 0x32,
+ MOVE_COUNTER = 0x33,
+ MOVE_FLAME_WHEEL = 0x34,
+ MOVE_FLAMETHROWER = 0x35,
+ MOVE_ODOR_SLEUTH = 0x36,
+ MOVE_SHARPEN = 0x37,
+ MOVE_DOUBLE_TEAM = 0x38,
+ MOVE_GUST = 0x39,
+ MOVE_HARDEN = 0x3A,
+ MOVE_DISABLE = 0x3B,
+ MOVE_RAZOR_WIND = 0x3C,
+ MOVE_BIDE = 0x3D,
+ MOVE_CRUNCH = 0x3E,
+ MOVE_BITE = 0x3F,
+ MOVE_THUNDER = 0x40,
+ MOVE_THUNDERPUNCH = 0x41,
+ MOVE_ENDEAVOR = 0x42,
+ MOVE_FACADE = 0x43,
+ MOVE_KARATE_CHOP = 0x44,
+ MOVE_CLAMP = 0x45,
+ MOVE_WITHDRAW = 0x46,
+ MOVE_CONSTRICT = 0x47,
+ MOVE_BRICK_BREAK = 0x48,
+ MOVE_ROCK_TOMB = 0x49,
+ MOVE_FOCUS_ENERGY = 0x4A,
+ MOVE_FOCUS_PUNCH = 0x4B,
+ MOVE_GIGA_DRAIN = 0x4C,
+ MOVE_REVERSAL = 0x4D,
+ MOVE_SMELLINGSALT = 0x4E,
+ MOVE_SPORE = 0x4F,
+ MOVE_LEECH_LIFE = 0x50,
+ MOVE_SLASH = 0x51,
+ MOVE_SILVER_WIND = 0x52,
+ MOVE_METAL_SOUND = 0x53,
+ MOVE_GRASSWHISTLE = 0x54,
+ MOVE_TICKLE = 0x55,
+ MOVE_SPIDER_WEB = 0x56,
+ MOVE_CRABHAMMER = 0x57,
+ MOVE_HAZE = 0x58,
+ MOVE_MEAN_LOOK = 0x59,
+ MOVE_CROSS_CHOP = 0x5A,
+ MOVE_OUTRAGE = 0x5B,
+ MOVE_LOW_KICK = 0x5C,
+ MOVE_ANCIENTPOWER = 0x5D,
+ MOVE_SYNTHESIS = 0x5E,
+ MOVE_AGILITY = 0x5F,
+ MOVE_RAPID_SPIN = 0x60,
+ MOVE_ICY_WIND = 0x61,
+ MOVE_MIND_READER = 0x62,
+ MOVE_COSMIC_POWER = 0x63,
+ MOVE_SKY_ATTACK = 0x64,
+ MOVE_POWDER_SNOW = 0x65,
+ MOVE_FOLLOW_ME = 0x66,
+ MOVE_METEOR_MASH = 0x67,
+ MOVE_ENDURE = 0x68,
+ MOVE_ROLLOUT = 0x69,
+ MOVE_SCARY_FACE = 0x6A,
+ MOVE_PSYBEAM = 0x6B,
+ MOVE_PSYWAVE = 0x6C,
+ MOVE_PSYCHIC = 0x6D,
+ MOVE_PSYCHO_BOOST = 0x6E,
+ MOVE_HYPNOSIS = 0x6F,
+ MOVE_UPROAR = 0x70,
+ MOVE_WATER_SPOUT = 0x71,
+ MOVE_SIGNAL_BEAM = 0x72,
+ MOVE_PSYCH_UP = 0x73,
+ MOVE_SUBMISSION = 0x74,
+ MOVE_RECOVER = 0x75,
+ MOVE_EARTHQUAKE = 0x76,
+ MOVE_NATURE_POWER = 0x77,
+ MOVE_LICK = 0x78,
+ MOVE_FLAIL = 0x79,
+ MOVE_TAIL_WHIP = 0x7A,
+ MOVE_SELFDESTRUCT = 0x7B,
+ MOVE_STUN_SPORE = 0x7C,
+ MOVE_BIND = 0x7D,
+ MOVE_SHADOW_PUNCH = 0x7E,
+ MOVE_SHADOW_BALL = 0x7F,
+ MOVE_CHARGE = 0x80,
+ MOVE_THUNDERBOLT = 0x81,
+ MOVE_MIST = 0x82,
+ MOVE_FISSURE = 0x83,
+ MOVE_EXTREMESPEED = 0x84,
+ MOVE_EXTRASENSORY = 0x85,
+ MOVE_SAFEGUARD = 0x86,
+ MOVE_ABSORB = 0x87,
+ MOVE_SKY_UPPERCUT = 0x88,
+ MOVE_SKILL_SWAP = 0x89,
+ MOVE_SKETCH = 0x8A,
+ MOVE_HEADBUTT = 0x8B,
+ MOVE_DOUBLE_EDGE = 0x8C,
+ MOVE_SANDSTORM = 0x8D,
+ MOVE_SAND_ATTACK = 0x8E,
+ MOVE_SAND_TOMB = 0x8F,
+ MOVE_SPARK = 0x90,
+ MOVE_SWIFT = 0x91,
+ MOVE_KINESIS = 0x92,
+ MOVE_SMOG = 0x93,
+ MOVE_GROWTH = 0x94,
+ MOVE_SACRED_FIRE = 0x95,
+ MOVE_SHEER_COLD = 0x96,
+ MOVE_SOLARBEAM = 0x97,
+ MOVE_SONICBOOM = 0x98,
+ MOVE_FLY = 0x99,
+ MOVE_TACKLE = 0x9A,
+ MOVE_EXPLOSION = 0x9B,
+ MOVE_DIVE = 0x9C,
+ MOVE_FIRE_BLAST = 0x9D,
+ MOVE_WATERFALL = 0x9E,
+ MOVE_MUDDY_WATER = 0x9F,
+ MOVE_STOCKPILE = 0xA0,
+ MOVE_SLAM = 0xA1,
+ MOVE_TWISTER = 0xA2,
+ MOVE_BULLET_SEED = 0xA3,
+ MOVE_TWINEEDLE = 0xA4,
+ MOVE_SOFTBOILED = 0xA5,
+ MOVE_EGG_BOMB = 0xA6,
+ MOVE_FAINT_ATTACK = 0xA7,
+ MOVE_BARRAGE = 0xA8,
+ MOVE_MINIMIZE = 0xA9,
+ MOVE_SEISMIC_TOSS = 0xAA,
+ MOVE_SUPERSONIC = 0xAB,
+ MOVE_TAUNT = 0xAC,
+ MOVE_MOONLIGHT = 0xAD,
+ MOVE_PECK = 0xAE,
+ MOVE_ARM_THRUST = 0xAF,
+ MOVE_HORN_ATTACK = 0xB0,
+ MOVE_HORN_DRILL = 0xB1,
+ MOVE_WING_ATTACK = 0xB2,
+ MOVE_AERIAL_ACE = 0xB3,
+ MOVE_ICICLE_SPEAR = 0xB4,
+ MOVE_SWORDS_DANCE = 0xB5,
+ MOVE_VINE_WHIP = 0xB6,
+ MOVE_CONVERSION = 0xB7,
+ MOVE_CONVERSION_2 = 0xB8,
+ MOVE_HELPING_HAND = 0xB9,
+ MOVE_IRON_DEFENSE = 0xBA,
+ MOVE_TELEPORT = 0xBB,
+ MOVE_THUNDERSHOCK = 0xBC,
+ MOVE_SHOCK_WAVE = 0xBD,
+ MOVE_QUICK_ATTACK = 0xBE,
+ MOVE_SWEET_KISS = 0xBF,
+ MOVE_THUNDER_WAVE = 0xC0,
+ MOVE_ZAP_CANNON = 0xC1,
+ MOVE_BLOCK = 0xC2,
+ MOVE_HOWL = 0xC3,
+ MOVE_POISON_GAS = 0xC4,
+ MOVE_TOXIC = 0xC5,
+ MOVE_POISON_FANG = 0xC6,
+ MOVE_POISONPOWDER = 0xC7,
+ MOVE_POISON_STING = 0xC8,
+ MOVE_SPIKE_CANNON = 0xC9,
+ MOVE_ACID_ARMOR = 0xCA,
+ MOVE_TAKE_DOWN = 0xCB,
+ MOVE_JUMP_KICK = 0xCC,
+ MOVE_BOUNCE = 0xCD,
+ MOVE_HI_JUMP_KICK = 0xCE,
+ MOVE_TRI_ATTACK = 0xCF,
+ MOVE_DRAGON_CLAW = 0xD0,
+ MOVE_TRICK = 0xD1,
+ MOVE_TRIPLE_KICK = 0xD2,
+ MOVE_DRILL_PECK = 0xD3,
+ MOVE_MUD_SPORT = 0xD4,
+ MOVE_MUD_SLAP = 0xD5,
+ MOVE_THIEF = 0xD6,
+ MOVE_AMNESIA = 0xD7,
+ MOVE_NIGHT_SHADE = 0xD8,
+ MOVE_GROWL = 0xD9,
+ MOVE_SLACK_OFF = 0xDA,
+ MOVE_SURF = 0xDB,
+ MOVE_ROLE_PLAY = 0xDC,
+ MOVE_NEEDLE_ARM = 0xDD,
+ MOVE_DOUBLE_KICK = 0xDE,
+ MOVE_SUNNY_DAY = 0xDF,
+ MOVE_LEER = 0xE0,
+ MOVE_WISH = 0xE1,
+ MOVE_FAKE_OUT = 0xE2,
+ MOVE_SLEEP_TALK = 0xE3,
+ MOVE_PAY_DAY = 0xE4,
+ MOVE_ASSIST = 0xE5,
+ MOVE_HEAT_WAVE = 0xE6,
+ MOVE_SLEEP_POWDER = 0xE7,
+ MOVE_REST = 0xE8,
+ MOVE_INGRAIN = 0xE9,
+ MOVE_CONFUSION = 0xEA,
+ MOVE_BODY_SLAM = 0xEB,
+ MOVE_SWALLOW = 0xEC,
+ MOVE_CURSE = 0xED,
+ MOVE_FRENZY_PLANT = 0xEE,
+ MOVE_HYDRO_CANNON = 0xEF,
+ MOVE_HYDRO_PUMP = 0xF0,
+ MOVE_HYPER_VOICE = 0xF1,
+ MOVE_HYPER_BEAM = 0xF2,
+ MOVE_SUPERPOWER = 0xF3,
+ MOVE_STEEL_WING = 0xF4,
+ MOVE_SPIT_UP = 0xF5,
+ MOVE_DYNAMICPUNCH = 0xF6,
+ MOVE_GUILLOTINE = 0xF7,
+ MOVE_VICEGRIP = 0xF8,
+ MOVE_KNOCK_OFF = 0xF9,
+ MOVE_POUND = 0xFA,
+ MOVE_RAZOR_LEAF = 0xFB,
+ MOVE_BATON_PASS = 0xFC,
+ MOVE_PETAL_DANCE = 0xFD,
+ MOVE_SPLASH = 0xFE,
+ MOVE_BUBBLEBEAM = 0xFF,
+ MOVE_DOOM_DESIRE = 0x100,
+ MOVE_BELLY_DRUM = 0x101,
+ MOVE_BARRIER = 0x102,
+ MOVE_LIGHT_SCREEN = 0x103,
+ MOVE_SCRATCH = 0x104,
+ MOVE_HYPER_FANG = 0x105,
+ MOVE_EMBER = 0x106,
+ MOVE_SECRET_POWER = 0x107,
+ MOVE_DIZZY_PUNCH = 0x108,
+ MOVE_BULK_UP = 0x109,
+ MOVE_IMPRISON = 0x10A,
+ MOVE_FEATHERDANCE = 0x10B,
+ MOVE_WHIRLWIND = 0x10C,
+ MOVE_BEAT_UP = 0x10D,
+ MOVE_BLIZZARD = 0x10E,
+ MOVE_STOMP = 0x10F,
+ MOVE_BLAST_BURN = 0x110,
+ MOVE_FLASH = 0x111,
+ MOVE_TEETER_DANCE = 0x112,
+ MOVE_CRUSH_CLAW = 0x113,
+ MOVE_BLAZE_KICK = 0x114,
+ MOVE_PRESENT = 0x115,
+ MOVE_ERUPTION = 0x116,
+ MOVE_SLUDGE = 0x117,
+ MOVE_SLUDGE_BOMB = 0x118,
+ MOVE_GLARE = 0x119,
+ MOVE_TRANSFORM = 0x11A,
+ MOVE_POISON_TAIL = 0x11B,
+ MOVE_ROAR = 0x11C,
+ MOVE_BONE_RUSH = 0x11D,
+ MOVE_CAMOUFLAGE = 0x11E,
+ MOVE_COVET = 0x11F,
+ MOVE_TAIL_GLOW = 0x120,
+ MOVE_BONE_CLUB = 0x121,
+ MOVE_BONEMERANG = 0x122,
+ MOVE_FIRE_SPIN = 0x123,
+ MOVE_FIRE_PUNCH = 0x124,
+ MOVE_PERISH_SONG = 0x125,
+ MOVE_WRAP = 0x126,
+ MOVE_SPIKES = 0x127,
+ MOVE_MAGNITUDE = 0x128,
+ MOVE_MAGICAL_LEAF = 0x129,
+ MOVE_MAGIC_COAT = 0x12A,
+ MOVE_MUD_SHOT = 0x12B,
+ MOVE_MACH_PUNCH = 0x12C,
+ MOVE_PROTECT = 0x12D,
+ MOVE_DEFENSE_CURL = 0x12E,
+ MOVE_ROLLING_KICK = 0x12F,
+ MOVE_SUBSTITUTE = 0x130,
+ MOVE_DETECT = 0x131,
+ MOVE_PIN_MISSILE = 0x132,
+ MOVE_WATER_SPORT = 0x133,
+ MOVE_WATER_GUN = 0x134,
+ MOVE_MIST_BALL = 0x135,
+ MOVE_WATER_PULSE = 0x136,
+ MOVE_FURY_ATTACK = 0x137,
+ MOVE_FURY_SWIPES = 0x138,
+ MOVE_DESTINY_BOND = 0x139,
+ MOVE_FALSE_SWIPE = 0x13A,
+ MOVE_FORESIGHT = 0x13B,
+ MOVE_MIRROR_COAT = 0x13C,
+ MOVE_FUTURE_SIGHT = 0x13D,
+ MOVE_MILK_DRINK = 0x13E,
+ MOVE_CALM_MIND = 0x13F,
+ MOVE_MEGA_DRAIN = 0x140,
+ MOVE_MEGA_KICK = 0x141,
+ MOVE_MEGA_PUNCH = 0x142,
+ MOVE_MEGAHORN = 0x143,
+ MOVE_HIDDEN_POWER = 0x144,
+ MOVE_METAL_CLAW = 0x145,
+ MOVE_ATTRACT = 0x146,
+ MOVE_MIMIC = 0x147,
+ MOVE_FRUSTRATION = 0x148,
+ MOVE_LEECH_SEED = 0x149,
+ MOVE_METRONOME = 0x14A,
+ MOVE_DREAM_EATER = 0x14B,
+ MOVE_ACID = 0x14C,
+ MOVE_MEDITATE = 0x14D,
+ MOVE_SNATCH = 0x14E,
+ MOVE_LUSTER_PURGE = 0x14F,
+ MOVE_LEAF_BLADE = 0x150,
+ MOVE_RECYCLE = 0x151,
+ MOVE_REFLECT = 0x152,
+ MOVE_REFRESH = 0x153,
+ MOVE_REVENGE = 0x154,
+ MOVE_DRAGON_RAGE = 0x155,
+ MOVE_DRAGONBREATH = 0x156,
+ MOVE_DRAGON_DANCE = 0x157,
+ MOVE_ICE_PUNCH = 0x158,
+ MOVE_ICE_BEAM = 0x159,
+ MOVE_FURY_CUTTER = 0x15A,
+ MOVE_COMET_PUNCH = 0x15B,
+ MOVE_SKULL_BASH = 0x15C,
+ MOVE_LOCK_ON = 0x15D,
+ MOVE_ROCK_BLAST = 0x15E,
+ MOVE_COTTON_SPORE = 0x15F,
+ MOVE_STRUGGLE = 0x160,
+ MOVE_AEROBLAST = 0x161,
+ MOVE_VOLT_TACKLE = 0x162,
+ MOVE_REGULAR_ATTACK = 0x163,
+ MOVE_WIDE_SLASH = 0x168,
+ MOVE_EXCAVATE = 0x169, // Unused
+ MOVE_SPIN_SLASH = 0x16A, // Unused
+ // Orb effects
+ MOVE_SEE_TRAP = 0x16B,
+ MOVE_TAKEAWAY = 0x16C,
+ MOVE_REBOUND = 0x16D,
+ MOVE_BLOOP_SLASH = 0x16E,
+ MOVE_SWITCHER = 0x16F,
+ MOVE_BLOWBACK = 0x170,
+ MOVE_WARP = 0x171,
+ MOVE_TRANSFER = 0x172,
+ MOVE_SLOW_DOWN = 0x173,
+ MOVE_SPEED_BOOST = 0x174,
+ MOVE_SEARCHLIGHT = 0x175,
+ MOVE_PETRIFY = 0x176,
+ MOVE_STAY_AWAY = 0x177,
+ MOVE_POUNCE = 0x178,
+ MOVE_TRAWL = 0x179,
+ MOVE_CLEANSE = 0x17A,
+ MOVE_OBSERVER = 0x17B,
+ MOVE_DECOY_MAKER = 0x17C,
+ MOVE_SIESTA = 0x17D,
+ MOVE_TOTTER = 0x17E,
+ MOVE_TWO_EDGE = 0x17F,
+ MOVE_NO_MOVE = 0x180,
+ MOVE_ESCAPE = 0x181,
+ MOVE_SCAN = 0x182,
+ MOVE_POWER_EARS = 0x183,
+ MOVE_DROUGHT = 0x184,
+ MOVE_TRAP_BUSTER = 0x185,
+ MOVE_WILD_CALL = 0x186,
+ MOVE_INVISIFY = 0x187,
+ MOVE_ONE_SHOT = 0x188,
+ MOVE_HP_GAUGE = 0x189,
+ MOVE_VACUUM_CUT = 0x18A,
+ MOVE_REVIVER = 0x18B,
+ MOVE_SHOCKER = 0x18C,
+ MOVE_ECHO = 0x18D,
+ MOVE_FAMISH = 0x18E,
+ MOVE_ONE_ROOM = 0x18F,
+ MOVE_FILL_IN = 0x190,
+ MOVE_TRAPPER = 0x191,
+ MOVE_POSSESS = 0x192,
+ MOVE_ITEMIZE = 0x193,
+ MOVE_HURL = 0x196,
+ MOVE_MOBILE = 0x197,
+ MOVE_ITEM_TOSS = 0x198,
+ MOVE_SEE_STAIRS = 0x199,
+ MOVE_LONG_TOSS = 0x19A,
+ MOVE_PIERCE = 0x19B
+};
+
+#endif
diff --git a/include/constants/status.h b/include/constants/status.h
new file mode 100644
index 0000000..8445731
--- /dev/null
+++ b/include/constants/status.h
@@ -0,0 +1,124 @@
+#ifndef GUARD_CONSTANTS_STATUS_H
+#define GUARD_CONSTANTS_STATUS_H
+
+enum SleepStatus
+{
+ SLEEP_STATUS_SLEEP = 1,
+ SLEEP_STATUS_SLEEPLESS = 2,
+ SLEEP_STATUS_NIGHTMARE = 3,
+ SLEEP_STATUS_YAWNING = 4,
+ SLEEP_STATUS_NAPPING = 5
+};
+
+enum NonVolatileStatus
+{
+ NON_VOLATILE_STATUS_BURNED = 1,
+ NON_VOLATILE_STATUS_POISONED = 2,
+ NON_VOLATILE_STATUS_BADLY_POISONED = 3,
+ NON_VOLATILE_STATUS_PARALYZED = 4
+};
+
+enum ImmobilizeStatus
+{
+ IMMOBILIZE_STATUS_FROZEN = 1,
+ IMMOBILIZE_STATUS_IMMOBILIZED = 2,
+ IMMOBILIZE_STATUS_WRAPPED_AROUND_FOE = 3,
+ IMMOBILIZE_STATUS_WRAPPED_BY_FOE = 4,
+ IMMOBILIZE_STATUS_INGRAIN = 5,
+ IMMOBILIZE_STATUS_PETRIFIED = 6,
+ IMMOBILIZE_STATUS_SQUEEZED = 7
+};
+
+enum ChargingStatus
+{
+ CHARGING_STATUS_BIDE = 0x1,
+ CHARGING_STATUS_SOLARBEAM = 0x2,
+ CHARGING_STATUS_SKY_ATTACK = 0x3,
+ CHARGING_STATUS_RAZOR_WIND = 0x4,
+ CHARGING_STATUS_FOCUS_PUNCH = 0x5,
+ CHARGING_STATUS_SKULL_BASH = 0x6,
+ CHARGING_STATUS_FLY = 0x7,
+ CHARGING_STATUS_BOUNCE = 0x8,
+ CHARGING_STATUS_DIVE = 0x9,
+ CHARGING_STATUS_DIG = 0xA,
+ CHARGING_STATUS_CHARGE = 0xB,
+ CHARGING_STATUS_RAGE = 0xC
+};
+
+enum ProtectionStatus
+{
+ PROTECTION_STATUS_REFLECT = 0x1,
+ PROTECTION_STATUS_SAFEGUARD = 0x2,
+ PROTECTION_STATUS_LIGHT_SCREEN = 0x3,
+ PROTECTION_STATUS_COUNTER = 0x4,
+ PROTECTION_STATUS_MAGIC_COAT = 0x5,
+ PROTECTION_STATUS_WISH = 0x6,
+ PROTECTION_STATUS_PROTECT = 0x7,
+ PROTECTION_STATUS_MIRROR_COAT = 0x8,
+ PROTECTION_STATUS_ENDURE = 0x9,
+ PROTECTION_STATUS_MINI_COUNTER = 0xA,
+ PROTECTION_STATUS_MIRROR_MOVE = 0xB,
+ PROTECTION_STATUS_CONVERSION_2 = 0xC,
+ PROTECTION_STATUS_VITAL_THROW = 0xD,
+ PROTECTION_STATUS_MIST = 0xE
+};
+
+enum WaitingStatus
+{
+ WAITING_STATUS_CURSED = 1,
+ WAITING_STATUS_DECOY = 2,
+ WAITING_STATUS_SNATCH = 3
+};
+
+enum LinkedStatus
+{
+ LINKED_STATUS_LEECH_SEED = 1,
+ LINKED_STATUS_DESTINY_BOND = 2
+};
+
+enum MoveStatus
+{
+ MOVE_STATUS_SURE_SHOT = 1,
+ MOVE_STATUS_WHIFFER = 2,
+ MOVE_STATUS_SET_DAMAGE = 3,
+ MOVE_STATUS_FOCUS_ENERGY = 4
+};
+
+enum ItemStatus
+{
+ ITEM_STATUS_LONG_TOSS = 1,
+ ITEM_STATUS_PIERCE = 2
+};
+
+enum TransformStatus
+{
+ TRANSFORM_STATUS_INVISIBLE = 1,
+ TRANSFORM_STATUS_TRANSFORMED = 2,
+ TRANSFORM_STATUS_MOBILE = 3
+};
+
+enum EyesightStatus
+{
+ EYESIGHT_STATUS_BLINKER = 1,
+ EYESIGHT_STATUS_CROSS_EYED = 2,
+ EYESIGHT_STATUS_EYEDROPS = 3
+};
+
+enum VolatileStatus
+{
+ VOLATILE_STATUS_CRINGING = 1,
+ VOLATILE_STATUS_CONFUSED = 2,
+ VOLATILE_STATUS_PAUSED = 3,
+ VOLATILE_STATUS_COWERING = 4,
+ VOLATILE_STATUS_TAUNTED = 5,
+ VOLATILE_STATUS_ENCORE = 6,
+ VOLATILE_STATUS_INFATUATED = 7
+};
+
+enum TargetingDecoy
+{
+ TARGETING_DECOY_TEAM = 1,
+ TARGETING_DECOY_WILD = 2
+};
+
+#endif
diff --git a/include/constants/tactic.h b/include/constants/tactic.h
new file mode 100644
index 0000000..4d24b01
--- /dev/null
+++ b/include/constants/tactic.h
@@ -0,0 +1,19 @@
+#ifndef GUARD_CONSTANTS_TACTIC_H
+#define GUARD_CONSTANTS_TACTIC_H
+
+enum Tactic
+{
+ TACTIC_LETS_GO_TOGETHER = 0x0,
+ TACTIC_GO_THE_OTHER_WAY = 0x1,
+ TACTIC_GO_AFTER_FOES = 0x2,
+ TACTIC_AVOID_THE_FIRST_HIT = 0x3,
+ TACTIC_ALL_FOR_ONE = 0x4, // Unused
+ TACTIC_GROUP_SAFETY = 0x5, // Unused
+ TACTIC_AVOID_TROUBLE = 0x6,
+ TACTIC_BE_PATIENT = 0x7,
+ TACTIC_KEEP_YOUR_DISTANCE = 0x8,
+ TACTIC_WAIT_THERE = 0x9,
+ TACTIC_GET_AWAY = 0xA
+};
+
+#endif
diff --git a/include/constants/trap.h b/include/constants/trap.h
new file mode 100644
index 0000000..cbc3454
--- /dev/null
+++ b/include/constants/trap.h
@@ -0,0 +1,28 @@
+#ifndef GUARD_CONSTANTS_TRAP_H
+#define GUARD_CONSTANTS_TRAP_H
+
+enum TrapType
+{
+ TRIP_TRAP = 0x0,
+ MUD_TRAP = 0x1,
+ STICKY_TRAP = 0x2,
+ GRIMY_TRAP = 0x3,
+ SUMMON_TRAP = 0x4,
+ PITFALL_TRAP = 0x5,
+ WARP_TRAP = 0x6,
+ WHIRLWIND_TRAP = 0x7,
+ SPIN_TRAP = 0x8,
+ SLUMBER_TRAP = 0x9,
+ SLOW_TRAP = 0xA,
+ SEAL_TRAP = 0xB,
+ POISON_TRAP = 0xC,
+ SELFDESTRUCT_TRAP = 0xD,
+ EXPLOSION_TRAP = 0xE,
+ PP_ZERO_TRAP = 0xF,
+ CHESTNUT_TRAP = 0x10,
+ WONDER_TILE = 0x11,
+ POKEMON_TRAP = 0x12,
+ SPIKE_TRAP = 0x13
+};
+
+#endif
diff --git a/include/constants/type.h b/include/constants/type.h
new file mode 100644
index 0000000..8c982fd
--- /dev/null
+++ b/include/constants/type.h
@@ -0,0 +1,25 @@
+#ifndef GUARD_CONSTANTS_TYPE_H
+#define GUARD_CONSTANTS_TYPE_H
+
+enum Type
+{
+ TYPE_NORMAL = 0x1,
+ TYPE_FIRE = 0x2,
+ TYPE_WATER = 0x3,
+ TYPE_GRASS = 0x4,
+ TYPE_ELECTRIC = 0x5,
+ TYPE_ICE = 0x6,
+ TYPE_FIGHTING = 0x7,
+ TYPE_POISON = 0x8,
+ TYPE_GROUND = 0x9,
+ TYPE_FLYING = 0xA,
+ TYPE_PSYCHIC = 0xB,
+ TYPE_BUG = 0xC,
+ TYPE_ROCK = 0xD,
+ TYPE_GHOST = 0xE,
+ TYPE_DRAGON = 0xF,
+ TYPE_DARK = 0x10,
+ TYPE_STEEL = 0x11
+};
+
+#endif
diff --git a/include/dungeon_entity.h b/include/dungeon_entity.h
index 9f3033c..e7d0fc1 100644
--- a/include/dungeon_entity.h
+++ b/include/dungeon_entity.h
@@ -1,44 +1,227 @@
#ifndef GUARD_DUNGEON_ENTITY_H
#define GUARD_DUNGEON_ENTITY_H
-struct subStruct_8048524
+#include "item.h"
+#include "constants/move.h"
+
+struct DungeonEntityData
{
- /* 0x0 */ u8 unk0;
- /* 0x1 */ u8 unk1;
- /* 0x2 */ s16 species;
- /* 0x4 */ s16 transformSpecies;
+ // This has different purposes for Pokémon, items, and traps.
+ // Pokemon: MovementFlag
+ // Items: ItemFlag
+ // Traps: TrapType
+ /* 0x0 */ u8 flags;
+ /* 0x1 */ bool8 moving;
+ /* 0x2 */ u16 entityID; // Pokémon species or item ID.
+ // Everything from here on only applies to Pokémon.
+ /* 0x4 */ u16 transformSpecies; // Shows a different Pokémon when using Transform.
/* 0x6 */ bool8 isEnemy;
/* 0x7 */ bool8 isLeader;
- /* 0x8 */ u8 shopKeeper;
+ /* 0x8 */ u8 shopkeeperMode;
/* 0x9 */ u8 level;
- /* 0xA */ u16 partyIndex;
+ /* 0xA */ u8 partyIndex; // Leader is 0, partner is 1, etc.
+ u8 fillB;
/* 0xC */ u16 IQ;
/* 0xE */ s16 HP;
- /* 0x10 */ s16 maxHP;
- /* 0x12 */ s16 bossHPBackup;
- u8 fill14[0x46 - 0x14];
+ /* 0x10 */ u16 maxHP;
+ // Bosses have higher HP than normal for their level. This is the max HP they would normally have given their level.
+ /* 0x12 */ u16 originalHP;
+ /* 0x14 */ u8 attack;
+ /* 0x15 */ u8 specialAttack;
+ /* 0x16 */ u8 defense;
+ /* 0x17 */ u8 specialDefense;
+ /* 0x18 */ u32 expPoints;
+ // Temporary stat boosts/drops from effects like Growl or Swords Dance.
+ // These start at 10 and are in the range [1, 19].
+ /* 0x1C */ s16 attackStage;
+ /* 0x1E */ s16 specialAttackStage;
+ /* 0x20 */ s16 defenseStage;
+ /* 0x22 */ s16 specialDefenseStage;
+ /* 0x24 */ s16 accuracyStage;
+ /* 0x26 */ s16 evasionStage;
+ // // When a Fire-type move is used on a Pokémon with Flash Fire, this value increases the power of the Pokémon's Fire-type moves.
+ /* 0x28 */ s16 flashFireBoost;
+ u8 fill2A[0x2C - 0x2A];
+ // These start at 0x1000, and are halved by certain moves like Screech to lower the corresponding stat.
+ /* 0x2C */ s32 attackMultiplier;
+ /* 0x30 */ s32 specialAttackMultiplier;
+ /* 0x34 */ s32 defenseMultiplier;
+ /* 0x38 */ s32 specialDefenseMultiplier;
+ u8 fill3C[0x3E - 0x3C];
+ /* 0x3E */ u8 hiddenPowerType;
+ u8 fill3F;
+ /* 0x40 */ u8 joinLocation; // Uses the dungeon index in dungeon.h.
+ u8 fill41[0x44 - 0x41];
+ /* 0x44 */ u16 action;
/* 0x46 */ s8 facingDir;
- u8 fill47[0x8C - 0x47];
- u8 unk8C[4];
- u8 fill90[0xA4 - 0x90];
+ u8 fill47;
+ // Additional parameter alongside actionIndex. Used for things like indiciating which move a Pokémon should use from its moveset.
+ /* 0x48 */ u8 actionUseIndex;
+ u8 fill49[0x4C - 0x49];
+ // Position of the Pokémon the last time it threw an item.
+ /* 0x4C */ s16 lastItemThrowPositionX;
+ /* 0x4E */ s16 lastItemThrowPositionY;
+ u8 fill50[0x58 - 0x50];
+ // Position of the target that the Pokémon wants throw an item at.
+ /* 0x58 */ s16 itemTargetPositionX;
+ /* 0x5A */ s16 itemTargetPositionY;
+ /* 0x5C */ u8 type1;
+ /* 0x5D */ u8 type2;
+ /* 0x5E */ u8 ability1;
+ /* 0x5F */ u8 ability2;
+ // Same format as ItemSlot struct.
+ /* 0x60 */ u8 heldItemFlags;
+ /* 0x61 */ u8 heldItemNumItems;
+ /* 0x62 */ u8 heldItemIndex;
+ u8 fill63[0x68 - 0x63];
+ /* 0x68 */ s16 previousPosition1X;
+ /* 0x6A */ s16 previousPosition1Y;
+ /* 0x6C */ s16 previousPosition2X;
+ /* 0x6E */ s16 previousPosition2Y;
+ /* 0x70 */ s16 previousPosition3X;
+ /* 0x72 */ s16 previousPosition3Y;
+ /* 0x74 */ s16 previousPosition4X;
+ /* 0x76 */ s16 previousPosition4Y;
+ /* 0x78 */ u8 movementAction;
+ /* 0x79 */ bool8 notAdjacentToTarget;
+ /* 0x7A */ bool8 hasTarget;
+ /* 0x7B */ bool8 turnAround;
+ /* 0x7C */ u16 targetPokemonSpawnIndex;
+ u8 fill7E[0x80 - 0x7E];
+ /* 0x80 */ u32 targetPokemon;
+ u8 fill84[0x88 - 0x84];
+ /* 0x88 */ s16 targetMovePositionX;
+ /* 0x8A */ s16 targetMovePositionY;
+ // Bitwise flags corresponding to selected IQ skills.
+ /* 0x8C */ u8 IQSkillsSelected[4]; // IQ skills selected in the IQ skills menu.
+ /* 0x90 */ u8 IQSkillsEnabled[4];
+ /* 0x94 */ u8 tactics;
+ u8 fill95[0xA4 - 0x95];
/* 0xA4 */ u8 clientFlags;
- u8 fillA5[0xAC - 0xA5];
- /* 0xAC */ u8 statusCondition;
- u8 fillAD[0xF7 - 0xAD];
+ u8 fillA5[0xA8 - 0xA5];
+ // Statuses are split into groups based on which ones can't overlap.
+ // See status.h for which statuses are in each group.
+ /* 0xA8 */ u8 sleepStatus;
+ /* 0xA9 */ u8 sleepStatusTurnsLeft;
+ u8 fillAA[0xAC - 0xAA];
+ /* 0xAC */ u8 nonVolatileStatus;
+ /* 0xAD */ u8 nonVolatileStatusTurnsLeft;
+ /* 0xAE */ u8 nonVolatileStatusDamageTimer;
+ u8 fillAF;
+ /* 0xB0 */ u8 immobilizeStatus;
+ u8 fillB1[0xB8 - 0xB1];
+ /* 0xB8 */ u8 immobilizeStatusTurnsLeft;
+ /* 0xB9 */ u8 immobilizeStatusDamageTimer;
+ u8 fillBA[0xBC - 0xBA];
+ /* 0xBC */ u8 volatileStatus;
+ /* 0xBD */ u8 volatileStatusTurnsLeft;
+ u8 fillBE[0xC0 - 0xBE];
+ /* 0xC0 */ u8 chargingStatus;
+ /* 0xC1 */ u8 chargingStatusTurnsLeft;
+ /* 0xC2 */ u8 chargingStatusMoveIndex; // The position of the move in the Pokémon's moveset that triggered the status.
+ u8 fillC3;
+ /* 0xC4 */ u8 protectionStatus;
+ /* 0xC5 */ u8 protectionStatusTurnsLeft;
+ u8 fillC6[0xC8 - 0xC6];
+ /* 0xC8 */ u8 waitingStatus;
+ /* 0xC9 */ bool8 enemyDecoy; // True if the Pokémon is a decoy and a wild Pokémon (i.e., not an allied Pokémon).
+ u8 fillCA;
+ /* 0xCB */ u8 waitingStatusTurnsLeft;
+ /* 0xCC */ u8 cursedDamageTimer;
+ u8 fillCD[0xD0 - 0xCD];
+ /* 0xD0 */ u8 linkedStatus;
+ u8 fillD1[0xD9 - 0xD1];
+ /* 0xD9 */ u8 linkedStatusTurnsLeft;
+ /* 0xDA */ u8 linkedStatusDamageTimer;
+ u8 fillDB;
+ /* 0xDC */ u8 moveStatus;
+ /* 0xDD */ u8 moveStatusTurnsLeft;
+ u8 fillDE[0xE0 - 0xDE];
+ /* 0xE0 */ u8 itemStatus;
+ u8 fillE1[0xE4 - 0xE1];
+ /* 0xE4 */ u8 transformStatus;
+ /* 0xE5 */ u8 transformStatusTurnsLeft;
+ u8 fillE6[0xE8 - 0xE6];
+ /* 0xE8 */ u8 eyesightStatus;
+ u8 fillE9;
+ /* 0xEA */ u8 eyesightStatusTurnsLeft;
+ u8 fillEB;
+ /* 0xEC */ bool8 muzzledStatus;
+ /* 0xED */ u8 muzzledTurnsLeft;
+ u8 fillEE[0xF0 - 0xEE];
+ /* 0xF0 */ bool8 radarStatus;
+ /* 0xF1 */ bool8 scanningStatus;
+ /* 0xF2 */ bool8 stairSpotterStatus;
+ u8 fillF3;
+ /* 0xF4 */ bool8 grudgeStatus;
+ /* 0xF5 */ bool8 exposedStatus;
+ u8 fillF7;
/* 0xF7 */ bool8 isBoss;
- u8 fillF8[0xFB - 0xF8];
+ u8 fillF8[0xFA - 0xF8];
+ /* 0xFA */ u8 terrifiedTurnsLeft; // Doubles as a bool for whether the Pokémon is terrified.
u8 unkFB;
- u8 fillFC[0x112 - 0xFC];
+ /* 0xFC */ bool8 forceUseItem; // If true, an AI Pokémon is forced to try using their held item next turn. Unknown when this is set in regular gameplay.
+ /* 0xFD */ u8 perishSongTimer; // When this reaches 0, the Pokémon faints from Perish Song. Doubles as a bool for whether the Pokémon is afflicted by Perish Song.
+ u8 fillFE[0x100 - 0xFE];
+ /* 0x100 */ u8 targetingDecoy; // If the Pokémon is targeting a decoy, this indicates whether the decoy target is a team or wild Pokémon.
+ u8 fill101[0x104 - 0x101];
+ /* 0x104 */ u8 movementSpeed;
+ u8 fill105[0x108 - 0x105];
+ // The turn counter for movement speed up/down is split into five timers each. Multiple timers are used if the Pokémon is affected by multiple
+ // speed-up/slow effects at once, like using Agility twice.
+ /* 0x108 */ u8 speedUpTurnsLeft[5];
+ /* 0x10D */ u8 slowTurnsLeft[5];
/* 0x112 */ u8 stockpileCount;
- u8 fill113[0x13C - 0x113];
+ u8 fill113;
+ // When true, an AI Pokémon will move in a random direction every turn.
+ // Unclear where this is set in-game; it is not set by statuses (e.g., confusion) or mission clients.
+ /* 0x114 */ bool8 moveRandomly;
+ u8 fill115[0x118 - 0x115];
+ /* 0x118 */ struct PokemonMove moves[4];
+ /* 0x138 */ u8 struggleMoveFlags;
+ u8 fill139[0x13C - 0x139];
/* 0x13C */ u32 belly;
- u8 fill140[0x15C - 0x140];
+ /* 0x140 */ u32 maxBelly;
+ /* 0x144 */ bool8 movingIntoTarget; // True if an AI Pokémon is following another Pokémon and is already adjacent to them.
+ /* 0x145 */ bool8 recalculateFollow; // Used by the AI to defer a movement decision until after all other Pokémon have moved.
+ u8 fill146;
+ /* 0x147 */ bool8 waiting; // True if an AI Pokémon decided to do nothing this turn.
+ /* 0x148 */ bool8 attacking;
+ u8 fill149[0x14E - 0x149];
+ /* 0x14E */ u16 visualFlags;
+ /* 0x150 */ u16 previousVisualFlags;
+ u8 fill152[0x15C - 0x152];
u8 unk15C;
u8 unk15D;
u8 unk15E;
u8 unk15F;
- u8 fill160[0x174 - 0x160];
+ u8 fill160[0x16C - 0x160];
+ /* 0x16C */ s16 targetPositionX;
+ /* 0x16E */ s16 targetPositionY;
+ /* 0x170 */ s16 posPixelX;
+ /* 0x172 */ s16 posPixelY;
u32 unk174;
+ u8 fill178[0x184 - 0x178];
+ // Previous value of targetPosition for movement, 1 and 2 moves ago.
+ /* 0x184 */ s16 previousTargetMovePosition1X;
+ /* 0x186 */ s16 previousTargetMovePosition1Y;
+ /* 0x188 */ s32 previousTargetMovePosition2X;
+ /* 0x18C */ s32 previousTargetMovePosition2Y;
+ /* 0x190 */ u8 lastMoveDirection; // The last direction that the Pokémon moved in.
+ u8 fill191[0x194 - 0x191];
+ // Number of tiles that the Pokémon moved last, multiplied by 0x100.
+ /* 0x194 */ s32 lastMoveIncrementX;
+ /* 0x198 */ s32 lastMoveIncrementY;
+ /* 0x19C */ u8 walkAnimationCounter; // Set when the Pokémon starts moving, and counts down until the Pokémon's walk animation stops.
+ u8 fill19D[0x1F4 - 0x19D];
+ /* 0x1F4 */ u8 numMoveTiles; // Number of tiles to move in a turn. Can be greater than 1 if the user's movement speed is boosted.
+ u8 fill1F5;
+ /* 0x1F6 */ bool8 notMoving;
+ u8 fill1F7[0x1FA - 0x1F7];
+ /* 0x1FA */ u8 mobileTurnTimer; // When a Pokémon can pass through walls in a hallway, this counts up to 200 before the Pokémon turns in a random direction.
+ u8 fill1FB;
+ /* 0x1FC */ u16 expGainedInTurn; // Used to accumulate experience when multiple enemies are defeated in one turn.
+ u8 fill1FE[0x208 - 0x1FE];
};
// Used for Pokémon, items, and traps.
@@ -57,7 +240,7 @@ struct DungeonEntity
/* 0x14 */ s32 prevPosPixelX;
/* 0x18 */ s32 prevPosPixelY;
u8 fill1C[0x20 - 0x1C];
- /* 0x20 */ bool8 active; // Turned off when a Pokémon faints.
+ /* 0x20 */ bool8 visible; // Turned off when a Pokémon faints.
u8 fill21[0x25 - 0x21];
/* 0x25 */ u8 roomIndex;
// The global spawn index counter starts at 10. Each Pokémon that spawns increments the counter and
@@ -89,10 +272,10 @@ struct DungeonEntity
u8 fill52[0x54 - 0x52];
/* 0x54 */ u16 spriteGlobalIndex;
u8 fill56[0x6C - 0x56];
- /* 0x6C */ u8 facingDirection;
- /* 0x6D */ u8 facingDirection2; // Duplicate of 0x6C?
+ /* 0x6C */ u8 facingDir;
+ /* 0x6D */ u8 facingDir2; // Duplicate of 0x6C?
u8 fill6D[0x70 - 0x6D];
- struct subStruct_8048524 *unk70;
+ /* 0x70 */ struct DungeonEntityData *entityData;
};
enum EntityType
@@ -102,16 +285,42 @@ enum EntityType
ENTITY_TRAP = 3
};
-enum FacingDirection
+enum MovementFlag
+{
+ MOVEMENT_FLAG_SWAPPED_PLACES = 1 << 5,
+ MOVEMENT_FLAG_SWAPPED_PLACES_PETRIFIED = 1 << 15 // Set if the Pokémon is petrified and the leader cures them by swapping places.
+};
+
+enum ShopkeeperMode
+{
+ SHOPKEEPER_FRIENDLY = 1,
+ // These two modes trigger if an explosion damages the shopkeeper. The shopkeeper attacks the side that damaged it.
+ SHOPKEEPER_AGGRESSIVE_TO_WILD = 2,
+ SHOPKEEPER_AGGRESSIVE_TO_PLAYER = 3
+};
+
+enum MovementAction
+{
+ MOVEMENT_ACTION_FOLLOW = 1,
+ MOVEMENT_ACTION_WANDER = 2,
+ MOVEMENT_ACTION_RUN_AWAY_WANDER = 3,
+ MOVEMENT_ACTION_EXIT_ROOM = 4,
+ MOVEMENT_ACTION_RUN_AWAY_FROM_ENEMY = 5,
+ MOVEMENT_ACTION_FACE_RANDOM_DIRECTION = 6,
+ MOVEMENT_ACTION_TAKE_ITEM = 7
+};
+
+enum ClientFlag
+{
+ CLIENT_FLAGS_CLIENT = 1, // Used for mission clients that need rescuing.
+ CLIENT_FLAGS_DONT_MOVE = 3 // Used for Diglett in the Skarmory boss fight.
+};
+
+enum VisualFlag
{
- SOUTH,
- SOUTHEAST,
- EAST,
- NORTHEAST,
- NORTH,
- NORTHWEST,
- WEST,
- SOUTHWEST
+ // Set if Run Away's visual effect (green smoke cloud) has been triggered on this floor.
+ // Prevents the effect from showing again if the Pokémon stops running away and then starts running away again.
+ VISUAL_FLAG_RUN_AWAY = 2
};
#endif
diff --git a/include/dungeon_global_data.h b/include/dungeon_global_data.h
new file mode 100644
index 0000000..17f4b3a
--- /dev/null
+++ b/include/dungeon_global_data.h
@@ -0,0 +1,93 @@
+#ifndef GUARD_DUNGEON_DATA_H
+#define GUARD_DUNGEON_DATA_H
+
+#define DUNGEON_MAX_SIZE_X 55
+#define DUNGEON_MAX_SIZE_Y 31
+
+#include "constants/species.h"
+#include "dungeon_entity.h"
+#include "map.h"
+
+struct DungeonGlobalData
+{
+ u8 unk0;
+ u8 unk1;
+ u8 unk2;
+ u8 unk3;
+ u8 unk4;
+ u8 fill5[0x7 - 0x5];
+ u8 unk7;
+ u8 fill8[0xF - 0x8];
+ /* 0xF */ bool8 inputAllowed; // Whether the game is currently accepting input. Set to false while action animations play.
+ u8 fill10;
+ u8 unk11;
+ u8 fill12[0x16D - 0x12];
+ u8 unk16D;
+ u8 fill16E[0x179 - 0x16E];
+ /* 0x179 */ bool8 pokemonExposed; // True if a Pokémon on the floor has the Exposed status.
+ u8 fill17A[0x645 - 0x17A];
+ /* 0x645 */ u8 floorNumber;
+ u8 fill646[0x65C - 0x646];
+ u8 unk65C;
+ u8 fill65D[0x660 - 0x65D];
+ /* 0x660 */ u8 speedTurnCounter; // Handles turn order when Pokémon have different movement speeds.
+ u8 fill661[0x666 - 0x661];
+ /* 0x666 */ u16 turnsLeft; // Turns remaining before getting swept out of the dungeon.
+ u8 fill668[0x66A - 0x668];
+ u16 unk66A;
+ u8 fill66C[0x671 - 0x66C];
+ /* 0x671 */ bool8 monsterHouseActive;
+ u8 fill672[0x363C - 0x672];
+ /* 0x363C */ u8 expYieldRankings[NUM_SPECIES];
+ u8 fill37E3[0x37FC - 0x37D9];
+ /* 0x37FC */ bool8 decoyActive;
+ u8 fill37FD[0x3A0E - 0x37FD];
+ /* 0x3A0E */ s16 tileset;
+ u8 fill3A10[0x3A14 - 0x3A10];
+ /* 0x3A14 */ s16 bossBattleIndex;
+ u8 fill3A16[0x3A18 - 0x3A16];
+ /* 0x3A18 */ struct MapTile mapTiles[DUNGEON_MAX_SIZE_X * DUNGEON_MAX_SIZE_Y];
+ u8 fill54BC[0xE23C - 0xD9F0];
+ s16 unkE23C;
+ s16 unkE23E;
+ u8 fillE240[0xE264 - 0xE240];
+ /* 0xE264 */ u8 weather; // Uses the weather constants in weather.h.
+ u8 unkE265;
+ /* 0xE266 */ u8 weatherDamageTimer; // Timer for applying sandstorm/hail damage periodically.
+ u8 fillE266[0xE26B - 0xE267];
+ u8 unkE26B;
+ u8 weatherTurnsLeft;
+ u8 fillE26D[0xE270 - 0xE26D];
+ /* 0xE270 */ u8 startingWeather; // The weather at the start of the floor. If the weather changes, then expires, revert back to the starting weather.
+ u8 fillE271[0xE277 - 0xE271];
+ /* 0xE277 */ u8 mudSportTurnsLeft;
+ /* 0xE278 */ u8 waterSportTurnsLeft;
+ u8 fillE279[0xE8C0 - 0xE279];
+ /* 0xE8C0 */ u32 mapEntityPointers[DUNGEON_MAX_SIZE_X * DUNGEON_MAX_SIZE_Y];
+ u8 fill10364[0x10844 - 0x10364];
+ /* 0x10844 */ u16 numRoomExits[MAX_ROOM_COUNT];
+ u8 fill10874[0x10884 - 0x10874];
+ /* 0x10884 */ struct RoomExit roomExits[MAX_ROOM_COUNT][32]; // Arrays of room exits for each room.
+ u8 fill11444[0x1356C - 0x11484];
+ u8 unk1356C;
+ u8 fill1356D[0x1357C - 0x1356D];
+ /* 0x1357C */ struct DungeonEntity *teamPokemon[4];
+ /* 0x1358C */ struct DungeonEntity *wildPokemon[0x10];
+ /* 0x135CC */ struct DungeonEntity *allPokemon[0x14]; // Contains both team and wild Pokémon
+ /* 0x1361C */ struct DungeonEntity *clientPokemon[2]; // Not sure how large this array is.
+ u8 fill13624[0x181F8 - 0x13624];
+ /* 0x181F8 */ struct DungeonEntity *leader; // Pointer to the team leader.
+ u32 unk181FC;
+ u32 unk18200;
+ u32 unk18204;
+ u8 unk18208;
+ /* 0x18209 */ u8 visibility; // Dungeon light level.
+ /* 0x1820A */ bool8 displayBlinker; // Blacks out the screen when the player has the Blinker status.
+ u8 unk1820B;
+ u32 unk1820C;
+ /* 0x18210 */ bool8 displayCrossEyed; // Displays Subsitute and flower sprites when the player has the Cross-Eyed status.
+ u8 fill18211[0x18217 - 0x18211];
+ u8 unk18217;
+};
+
+#endif
diff --git a/include/gUnknown_203B418.h b/include/gUnknown_203B418.h
deleted file mode 100644
index e022b4b..0000000
--- a/include/gUnknown_203B418.h
+++ /dev/null
@@ -1,47 +0,0 @@
-#ifndef GUARD_GUNKNOWN_203B418_H
-#define GUARD_GUNKNOWN_203B418_H
-
-#include "dungeon_entity.h"
-
-struct unkStruct_203B418
-{
- u8 unk0;
- u8 unk1;
- u8 unk2;
- u8 unk3;
- u8 unk4;
- u8 fill5[2];
- u8 unk7;
- u8 fill8[0x11 - 8];
- u8 unk11;
- u8 fill12[0x16D - 0x12];
- u8 unk16D;
- u8 fill16E[0x65C - 0x16E];
- u8 unk65C;
- u8 fill65D[0x66A - 0x65D];
- u16 unk66A;
- u8 fill66B[0xE23C - 0x66C];
- s16 unkE23C;
- s16 unkE23E;
- u8 fillE240[0xE265 - 0xE240];
- u8 unkE265;
- u8 fillE266[0xE26B - 0xE266];
- u8 unkE26B;
- u8 unkE26C;
- u8 fillE26D[0x1356C - 0xE26D];
- u8 unk1356C;
- u8 fill1356D[0x1358C - 0x1356D];
- struct DungeonEntity *unk1358C[0x10];
- u8 fill135CC[0x181FC - 0x135CC];
- u32 unk181FC;
- u32 unk18200;
- u32 unk18204;
- u8 unk18208[3];
- u8 unk1820B;
- u32 unk1820C;
- u32 unk18210;
- u8 padding2[3];
- u8 unk18217;
-};
-
-#endif
diff --git a/include/item.h b/include/item.h
index 84f9de2..1d81116 100644
--- a/include/item.h
+++ b/include/item.h
@@ -12,8 +12,11 @@ struct Item
/* 0xD */ u8 icon;
/* 0xE */ u16 fill;
/* 0x10 */ u8 *descriptionPointer;
- /* 0x14 */ bool8 unkFood1[2];
- /* 0x16 */ u8 throwDmg;
+ // Determines how the AI can use the item.
+ // Index 0: Item can be used on self.
+ // Index 1: Item can be thrown at allies.
+ // Index 2: Item can be thrown at enemies.
+ /* 0x14 */ bool8 aiFlags[3];
/* 0x17 */ u8 fill2;
/* 0x18 */ s16 move;
/* 0x1A */ u8 order; // Numbered order they are in storage
@@ -25,7 +28,7 @@ struct Item
struct ItemSlot
{
- u8 unk0; // some sort of flags, bit 0 seems to indicate an empty slot
+ u8 itemFlags;
u8 numItems;
u8 itemIndex;
};
@@ -84,6 +87,14 @@ enum ItemCategory
ITEM_CATEGORY_ORBS
};
+enum ItemFlag
+{
+ ITEM_FLAG_EXISTS = 1 << 0,
+ ITEM_FLAG_FOR_SALE = 1 << 1,
+ ITEM_FLAG_STICKY = 1 << 3,
+ ITEM_FLAG_SET = 1 << 4 // This item can be thrown by pressing L+R instead of having to go to the bag menu.
+};
+
// see https://bulbapedia.bulbagarden.net/wiki/List_of_items_by_index_number_(Rescue_Team)
enum ItemID {
ITEM_ID_NOTHING,
@@ -343,7 +354,7 @@ u8 GetItemPalette(u8 itemIndex);
u8 GetItemCategory(u8 itemIndex);
u32 GetItemUnkThrow(u8 itemIndex, u32 r1);
u8 *GetItemDescription(u8 itemIndex);
-u32 GetItemUnkFood(u8 itemIndex, u32 r1);
+u32 GetItemAIFlags(u8 itemIndex, u32 r1);
s32 GetNumberOfFilledInventorySlots(void);
bool8 IsThrowableItem(u8 itemIndex);
void xxx_init_itemslot_8090A8C(struct ItemSlot *param_1,u8 itemIndex,u8 param_3);
diff --git a/include/map.h b/include/map.h
new file mode 100644
index 0000000..d3d1ed9
--- /dev/null
+++ b/include/map.h
@@ -0,0 +1,61 @@
+#ifndef GUARD_MAP_H
+#define GUARD_MAP_H
+
+#include "dungeon_entity.h"
+
+#define MAX_ROOM_COUNT 24 // Empirical max, not sure if the code supports any more.
+
+struct MapTile
+{
+ /* 0x0 */ u8 tileFlags;
+ /* 0x1 */ bool8 stairs;
+ u8 fill2[0x9 - 0x2];
+ /* 0x9 */ u8 roomIndex;
+ // Bitwise flags for whether Pokémon can move to an adjacent tile. Bits correspond to directions in direction.h.
+ // Different sets of flags are used for Pokémon that can cross special terrain.
+ /* 0xA */ u8 canMoveAdjacent;
+ /* 0xB */ u8 canMoveAdjacentLiquid;
+ /* 0xC */ u8 canMoveAdjacentCrevice;
+ /* 0xD */ u8 canMoveAdjacentWall;
+ u8 fillE[0x10 - 0xE];
+ /* 0x10 */ struct DungeonEntity *pokemon; // Pokémon on the tile.
+ /* 0x14 */ struct DungeonEntity *mapObject; // Item or trap on the tile.
+};
+
+struct MapRoom
+{
+ u8 fill0[0x2 - 0x0];
+ // All coordinates are inclusive.
+ /* 0x2 */ s16 startX;
+ /* 0x4 */ s16 startY;
+ /* 0x6 */ s16 endX;
+ /* 0x8 */ s16 endY;
+ u8 fillA[0x1C - 0xA];
+};
+
+struct RoomExit
+{
+ s16 x;
+ s16 y;
+};
+
+enum TileFlag
+{
+ TILE_TYPE_FLOOR = 1 << 0,
+ TILE_TYPE_LIQUID = 1 << 2, // Water or lava depending on the dungeon.
+ TILE_TYPE_ROOM_EXIT = 1 << 3,
+ TILE_TYPE_MAP_EDGE = 1 << 4,
+ TILE_TYPE_SHOP = 1 << 5,
+ TILE_TYPE_MONSTER_HOUSE = 1 << 6,
+ TILE_TYPE_STAIRS = 1 << 9
+};
+
+enum CrossableTerrain
+{
+ CROSSABLE_TERRAIN_REGULAR = 0,
+ CROSSABLE_TERRAIN_LIQUID = 1,
+ CROSSABLE_TERRAIN_CREVICE = 2,
+ CROSSABLE_TERRAIN_WALL = 3,
+};
+
+#endif
diff --git a/include/pokemon.h b/include/pokemon.h
index 874aa93..3df33b6 100644
--- a/include/pokemon.h
+++ b/include/pokemon.h
@@ -24,7 +24,7 @@ struct unkPokeSubStruct_4 {
u16 fill6;
};
-struct unkPokeSubStruct_2C
+struct unkPokeSubStruct_2C
{
u8 unk0;
u8 fill1;
@@ -138,13 +138,13 @@ struct gPokemon
/* 0x10 */ u16 dialogue_sprites;
/* 0x12 */ u8 unk12;
/* 0x13 */ u8 types[2];
- /* 0x15 */ u8 walkable_tiles;
+ /* 0x15 */ u8 walkable_tiles; // Uses the CrossableTerrain enum in map.h.
/* 0x16 */ u8 friend_area;
/* 0x17 */ u8 abilities[2];
/* 0x19 */ u8 shadow_size;
/* 0x1A */ u8 unk1A;
/* 0x1B */ u8 unk1B;
- /* 0x1C */ bool8 isMoving;
+ /* 0x1C */ bool8 isMoving; // Set to false for Pokémon who don't move unless they're the leader, like Kakuna.
/* 0x1D */ u8 unk1D;
/* 0x1E */ u16 base_hp;
/* 0x20 */ s32 base_exp;
@@ -155,7 +155,7 @@ struct gPokemon
/* 0x30 */ u8 unk30;
/* 0x31 */ u8 unk31;
/* 0x32 */ u8 unk32;
- /* 0x33 */ bool8 unk33;
+ /* 0x33 */ bool8 toolboxEnabled; // If false, the AI can't use items. Doesn't seem to be used, as it's true for all Pokémon.
/* 0x34 */ struct EvolveStruct1 pre;
/* 0x38 */ struct EvolveNeeds need;
/* 0x3C */ s16 dexInternal[2]; // dexNo and internalNo
@@ -165,7 +165,7 @@ struct gPokemon
// https://www.pokecommunity.com/showthread.php?t=407371
-struct LevelData
+struct LevelData
{
s32 expRequired;
u8 gainHP;
@@ -177,19 +177,18 @@ struct LevelData
u16 fillA;
};
-struct unkStruct_808E218_arg
+struct unkStruct_808E218_arg
{
u16 unk0[NUM_SPECIES];
u32 count;
};
-struct unkStruct_808E218
+struct unkStruct_808E218
{
// leveldata? (same size)
struct unkStruct_808E6F4 unk0[3];
};
-
void LoadMonsterParameters(void);
struct unkStruct_203B45C *GetRecruitedPokemon(void);
void InitializeRecruitedPokemon(void);
@@ -212,7 +211,7 @@ u16 GetLowKickDmg(s16 index);
u16 GetSizeOrbDmg(s16 index);
u8 GetFriendArea(s16 index);
u16 GetBaseHP(s16 index);
-bool8 GetUnk33(s16 index);
+bool8 IsToolboxEnabled(s16 index);
u8 GetUnk12(s16 index);
s16 GetPokemonEvolveFrom(s16 index);
u16 GetPokemonAttSpatt(s16 index, u32 r1);
@@ -237,4 +236,4 @@ void SavePokemonStruct(struct unkStruct_8094924* a1, struct PokemonStruct* pokem
void RestorePokemonStruct(struct unkStruct_8094924*, struct PokemonStruct*);
-#endif // GUARD_POKEMON_H
+#endif // GUARD_POKEMON_H
diff --git a/src/code_8040094.c b/src/code_8040094.c
index fc5abb1..4db3e6c 100644
--- a/src/code_8040094.c
+++ b/src/code_8040094.c
@@ -1,10 +1,10 @@
#include "global.h"
#include "play_time.h"
#include "file_system.h"
-#include "gUnknown_203B418.h"
+#include "dungeon_global_data.h"
extern struct PlayTimeStruct *gPlayTimeRef;
-extern struct unkStruct_203B418 *gUnknown_203B418;
+extern struct DungeonGlobalData *gDungeonGlobalData;
extern s32 gUnknown_80F6568[];
extern u8 gUnknown_202EE01;
extern const char gUnknown_80F6604; // "zmappat"
@@ -41,8 +41,8 @@ void sub_804002C(u32 param_1)
int innerCounter;
int iVar3;
int iVar4;
-
- gUnknown_203B418->unk1820B = 1;
+
+ gDungeonGlobalData->unk1820B = 1;
iVar3 = 0;
do {
innerCounter = 0;
@@ -62,7 +62,7 @@ void sub_804002C(u32 param_1)
void sub_8040094(u8 r0)
{
- gUnknown_203B418->unk18217 = r0;
+ gDungeonGlobalData->unk18217 = r0;
sub_803F7BC();
sub_80060EC();
IncrementPlayTime(gPlayTimeRef);
@@ -76,15 +76,15 @@ void sub_8040094(u8 r0)
void sub_80400D4(void)
{
s32 temp;
- temp = gUnknown_203B418->unk18200;
+ temp = gDungeonGlobalData->unk18200;
if(temp == 0)
return;
if(temp > 0x1E)
temp = 0x1F;
- gUnknown_203B418->unk181FC = gUnknown_80F6568[temp];
- gUnknown_203B418->unk18200--;
- if(gUnknown_203B418->unk18200 == 0)
- gUnknown_203B418->unk18200 = gUnknown_203B418->unk18204;
+ gDungeonGlobalData->unk181FC = gUnknown_80F6568[temp];
+ gDungeonGlobalData->unk18200--;
+ if(gDungeonGlobalData->unk18200 == 0)
+ gDungeonGlobalData->unk18200 = gDungeonGlobalData->unk18204;
}
void sub_8040124(void)
diff --git a/src/code_8041AD0.c b/src/code_8041AD0.c
index 9874f48..6388af1 100644
--- a/src/code_8041AD0.c
+++ b/src/code_8041AD0.c
@@ -1,6 +1,6 @@
#include "global.h"
#include "dungeon_entity.h"
-#include "gUnknown_203B418.h"
+#include "dungeon_global_data.h"
struct unkStruct_80420E8
{
@@ -9,7 +9,7 @@ struct unkStruct_80420E8
u32 unk8;
};
-extern struct unkStruct_203B418 *gUnknown_203B418;
+extern struct DungeonGlobalData *gDungeonGlobalData;
extern void sub_803ED30(u8, struct DungeonEntity *r0, u8, u8);
@@ -289,7 +289,7 @@ void sub_8041D5C(struct DungeonEntity *r0)
{
return;
}
- sub_803ED30(r0->unk70->stockpileCount , r0, 1, 0xB);
+ sub_803ED30(r0->entityData->stockpileCount, r0, 1, 0xB);
}
void sub_8041D84(struct DungeonEntity * r0)
@@ -594,7 +594,7 @@ void sub_80420E8(struct DungeonEntity *r0, struct unkStruct_80420E8 *r1)
u32 temp;
u32 arg;
temp = r1->unk8;
- if(gUnknown_203B418->unk16D != 0)
+ if(gDungeonGlobalData->unk16D != 0)
temp = sub_806F62C(r1->unk8);
switch(temp)
{
@@ -675,7 +675,7 @@ void sub_8042208(struct DungeonEntity *r0, u8 r1)
void sub_8042238(u32 r0, struct DungeonEntity *r1)
{
- if(r1->unk70->isEnemy)
+ if(r1->entityData->isEnemy)
PlaySoundEffect(0x157);
else
PlaySoundEffect(0x156);
diff --git a/src/code_8048480.c b/src/code_8048480.c
index 470de97..675751e 100644
--- a/src/code_8048480.c
+++ b/src/code_8048480.c
@@ -1,5 +1,6 @@
#include "global.h"
#include "dungeon_entity.h"
+#include "constants/status.h"
extern u32 gUnknown_80F89F4;
extern u8 gAvailablePokemonNames[0x58];
@@ -81,7 +82,7 @@ void sub_804841C(struct DungeonEntity *r0, struct DungeonEntity *r1)
void sub_8048428(struct DungeonEntity *r0, struct DungeonEntity *r1)
{
- if(r1->unk70->statusCondition == 4) // 4 - Paralyzed??
+ if(r1->entityData->nonVolatileStatus == NON_VOLATILE_STATUS_PARALYZED)
sub_807A290(r0, r1);
else
// Pointer to "But nothing happened!"
@@ -90,7 +91,7 @@ void sub_8048428(struct DungeonEntity *r0, struct DungeonEntity *r1)
void sub_8048450(struct DungeonEntity *r0, struct DungeonEntity *r1)
{
- if((u8)(r1->unk70->statusCondition - 2) <= 1)
+ if((u8)(r1->entityData->nonVolatileStatus - 2) <= 1)
sub_807A290(r0, r1);
else
// Pointer to "But nothing happened!"
@@ -135,7 +136,7 @@ void sub_80484DC(struct DungeonEntity *r0, struct DungeonEntity *r1)
void sub_80484E8(struct DungeonEntity *r0, struct DungeonEntity *r1)
{
- if(r1->unk70->statusCondition == 1) // 1 - Burn??
+ if(r1->entityData->nonVolatileStatus == NON_VOLATILE_STATUS_BURNED)
sub_807A290(r0, r1);
else
{
diff --git a/src/code_80521D0_1.c b/src/code_80521D0_1.c
index d71de9a..ecb0ec1 100644
--- a/src/code_80521D0_1.c
+++ b/src/code_80521D0_1.c
@@ -1,14 +1,15 @@
#include "global.h"
-#include "gUnknown_203B418.h"
+#include "dungeon_global_data.h"
#include "dungeon_entity.h"
#include "friend_area.h"
#include "constants/friend_area.h"
#include "pokemon.h"
+#include "constants/direction.h"
extern struct DungeonEntity *sub_8085480(void);
extern struct DungeonEntity *sub_8085680(u32);
extern char gUnknown_202E038[0x50];
-extern struct unkStruct_203B418 *gUnknown_203B418;
+extern struct DungeonGlobalData *gDungeonGlobalData;
extern u32 gUnknown_202EDC8;
extern u32 gUnknown_81062A8;
@@ -148,11 +149,11 @@ struct unk8049590
};
extern struct unk8049590 *sub_8049590(u32, u32);
-extern void sub_806BFC0(struct subStruct_8048524 *, u32);
+extern void sub_806BFC0(struct DungeonEntityData *, u32);
void sub_808BBA8(struct DungeonEntity *param_1)
{
- sub_806BFC0(param_1->unk70,0);
+ sub_806BFC0(param_1->entityData,0);
}
void sub_808BBB8(struct DungeonEntity *param_1)
@@ -172,10 +173,10 @@ void sub_808BBB8(struct DungeonEntity *param_1)
iVar2 = 0x100;
}
if (iVar1 < 0) break;
- param_1->unk70->unk174 = iVar1;
+ param_1->entityData->unk174 = iVar1;
sub_803E46C(0x46);
}
- param_1->unk70->unk174 = 0;
+ param_1->entityData->unk174 = 0;
}
void sub_808BC20(struct DungeonEntity * param_1)
@@ -187,7 +188,7 @@ void sub_808BC20(struct DungeonEntity * param_1)
sub_8085918(param_1,uVar1 & 7);
sub_803E708(3,0x46);
}
- param_1->unk70->unk15E = 1;
+ param_1->entityData->unk15E = 1;
PlaySoundEffect(0x27f);
sub_80861F8(99,param_1,1);
}
@@ -196,7 +197,7 @@ void JirachiWishGrantDialogue(struct DungeonEntity *param_1)
{
u32 uVar2;
- param_1->unk70->unk15D = 1;
+ param_1->entityData->unk15D = 1;
// Nnnnnnnnnn!
sub_8052910(&gUnknown_81058A8);
PlaySoundEffect(0x375);
@@ -216,7 +217,7 @@ void sub_808BCE4(void)
{
struct unk8049590 *puVar1;
- puVar1 = sub_8049590(gUnknown_203B418->unkE23C, gUnknown_203B418->unkE23E);
+ puVar1 = sub_8049590(gDungeonGlobalData->unkE23C, gDungeonGlobalData->unkE23E);
puVar1->unk0 &= 0xfffc;
puVar1->unk0 |= 16;
puVar1->unk0 &= 0xfdff;
@@ -230,7 +231,7 @@ void sub_808BD38(void)
{
struct unk8049590 *puVar1;
- puVar1 = sub_8049590(gUnknown_203B418->unkE23C, gUnknown_203B418->unkE23E);
+ puVar1 = sub_8049590(gDungeonGlobalData->unkE23C, gDungeonGlobalData->unkE23E);
puVar1->unk0 &= 0xfffc;
puVar1->unk0 |= 1;
puVar1->unk0 &= 0xffef;
@@ -291,7 +292,7 @@ void sub_808BDEC(void)
sub_8068FE0(uVar3,0x21c,0);
}
else {
- gUnknown_203B418->unk7 = 1;
+ gDungeonGlobalData->unk7 = 1;
sub_8085918(uVar3,0);
}
sub_8085860(iVar2->posWorldX,iVar2->posWorldY - 3);
@@ -301,7 +302,7 @@ void sub_808BDEC(void)
void sub_808BE70(u8 param_1,u8 param_2)
{
if ((param_2 == 0x33) && (param_1 == 0x1B)) {
- gUnknown_203B418->unk2 = 1;
+ gDungeonGlobalData->unk2 = 1;
}
}
@@ -408,7 +409,7 @@ void sub_808C0CC(void)
sub_8085C54(0,0,0,1,1);
sub_803E9D0();
sub_803E46C(0x46);
- gUnknown_203B418->unk7 = 0;
+ gDungeonGlobalData->unk7 = 0;
sub_808BFA0();
}
@@ -429,7 +430,7 @@ void sub_808C10C(void)
sub_8068FE0(uVar2,0x21c,0);
}
else {
- gUnknown_203B418->unk7 = 1;
+ gDungeonGlobalData->unk7 = 1;
sub_8085918(uVar2,0);
}
sub_8085860(iVar1->posWorldX,iVar1->posWorldY);
@@ -444,7 +445,7 @@ void sub_808C10C(void)
void sub_808C1A4(u8 param_1,u8 param_2)
{
if ((param_2 == 0x34) && (param_1 == 0x1C)) {
- gUnknown_203B418->unk2 = 1;
+ gDungeonGlobalData->unk2 = 1;
sub_8083E88(0x23);
}
}
@@ -463,7 +464,7 @@ void KyogrePreFightDialogue(void)
sub_803E708(10,0x46);
sub_8052910(&gUnknown_81062A8);
sub_803E708(10,0x46);
- gUnknown_203B418->unk2 = 1;
+ gDungeonGlobalData->unk2 = 1;
}
else {
sub_8052910(&gUnknown_8106074);
@@ -530,7 +531,7 @@ void sub_808C360(void)
sub_8085C54(0,0,0,1,1);
sub_803E9D0();
sub_803E46C(0x46);
- gUnknown_203B418->unk7 = 0;
+ gDungeonGlobalData->unk7 = 0;
KyogreScreenFlash();
}
@@ -547,7 +548,7 @@ void sub_808C3A0(void)
sub_808563C(sub_808C590);
}
else {
- gUnknown_203B418->unk7 = 1;
+ gDungeonGlobalData->unk7 = 1;
sub_808563C(sub_808C5A0);
}
sub_8085860(iVar2->posWorldX,iVar2->posWorldY - 3);
@@ -557,7 +558,7 @@ void sub_808C3A0(void)
void sub_808C414(u8 param_1,u8 param_2)
{
if ((param_2 == 0x35) && (param_1 == 0x1D)) {
- gUnknown_203B418->unk2 = 1;
+ gDungeonGlobalData->unk2 = 1;
sub_8083E88(0x1a);
}
}
@@ -617,7 +618,7 @@ void sub_808C550(void)
sub_8085C54(0,0,0,1,1);
sub_803E9D0();
sub_803E46C(0x46);
- gUnknown_203B418->unk7 = 0;
+ gDungeonGlobalData->unk7 = 0;
DeoxysScreenFlash();
}
@@ -781,7 +782,7 @@ void CelebiJoinDialogue(void)
}
sub_8083ED8(0x1e);
sub_803E708(0x1e,0x46);
- gUnknown_203B418->unk2 = 1;
+ gDungeonGlobalData->unk2 = 1;
}
#else
NAKED
@@ -1065,7 +1066,7 @@ void CelebiJoinDialogue(void)
"_0808C8D0: .4byte gUnknown_8106500\n"
"_0808C8D4: .4byte gUnknown_8106534\n"
"_0808C8D8: .4byte gUnknown_8106560\n"
-"_0808C8DC: .4byte gUnknown_203B418");
+"_0808C8DC: .4byte gDungeonGlobalData");
}
#endif
@@ -1076,11 +1077,11 @@ void sub_808C8E0(struct DungeonEntity *param_1)
PlaySoundEffect(0x1a5);
sub_806CDD4(param_1, 0, 0);
for(iVar1 = 0; iVar1 < 16; iVar1++){
- param_1->unk70->unk174 = iVar1 * 256;
+ param_1->entityData->unk174 = iVar1 * 256;
sub_803E46C(0x46);
}
for(iVar1 = 16; iVar1 < 200; iVar1 += 4){
- param_1->unk70->unk174 = iVar1 * 256;
+ param_1->entityData->unk174 = iVar1 * 256;
sub_803E46C(0x46);
}
sub_8086A3C(param_1);
@@ -1100,14 +1101,14 @@ void sub_808C948(struct DungeonEntity *param_1, u8 param_2)
if (param_2 == 0x37) {
flag = FALSE;
for(iVar3 = 0; iVar3 < 0x10; iVar3++){
- iVar2 = gUnknown_203B418->unk1358C[iVar3];
+ iVar2 = gDungeonGlobalData->wildPokemon[iVar3];
if ((iVar2 != param_1) && (sub_80450E0(iVar2) != 0)) {
flag = TRUE;
break;
}
}
if (!flag) {
- gUnknown_203B418->unk2 = 1;
+ gDungeonGlobalData->unk2 = 1;
}
}
}
@@ -1122,7 +1123,7 @@ void sub_808C998(void)
void sub_808C9B0(struct DungeonEntity *param_1)
{
- param_1->unk70->facingDir = NORTH;
+ param_1->entityData->facingDir = DIRECTION_NORTH;
sub_806CE68(param_1, 4);
}
@@ -1191,8 +1192,8 @@ void MedichamRescueDialogue(void)
sub_803E708(0x20, 0x46);
sub_8042B0C(temp);
sub_8068FE0(temp, 0x21C, 0);
- gUnknown_203B418->unk4 = 1;
- gUnknown_203B418->unk11 = 4;
+ gDungeonGlobalData->unk4 = 1;
+ gDungeonGlobalData->unk11 = 4;
}
void sub_808CB5C(void)
@@ -1281,8 +1282,8 @@ void SmeargleRescueDialogue(void)
sub_803E708(0x20, 0x46);
sub_8042B0C(temp);
sub_8068FE0(temp, 0x21C, 0);
- gUnknown_203B418->unk4 = 1;
- gUnknown_203B418->unk11 = 4;
+ gDungeonGlobalData->unk4 = 1;
+ gDungeonGlobalData->unk11 = 4;
}
diff --git a/src/code_8057824.c b/src/code_8057824.c
index c80aa55..9d0e673 100644
--- a/src/code_8057824.c
+++ b/src/code_8057824.c
@@ -1,8 +1,8 @@
#include "global.h"
-#include "gUnknown_203B418.h"
+#include "dungeon_global_data.h"
#include "dungeon_entity.h"
-extern struct unkStruct_203B418 *gUnknown_203B418;
+extern struct DungeonGlobalData *gDungeonGlobalData;
extern u32 gUnknown_80FCF74;
extern u32 gUnknown_80FCF80;
@@ -49,7 +49,7 @@ bool32 sub_805783C(struct DungeonEntity *param_1, struct DungeonEntity *param_2)
bool32 sub_805785C(struct DungeonEntity *param_1, struct DungeonEntity *param_2)
{
- gUnknown_203B418->unkE26B = gUnknown_80F4F42;
+ gDungeonGlobalData->unkE26B = gUnknown_80F4F42;
if (sub_807EAA0(1,0) == '\0') {
// The weather remains unchanged
sub_80522F4(param_1,param_2,gUnknown_80FCF74);
@@ -59,7 +59,7 @@ bool32 sub_805785C(struct DungeonEntity *param_1, struct DungeonEntity *param_2)
bool32 sub_80578A4(struct DungeonEntity *param_1, struct DungeonEntity *param_2)
{
- gUnknown_203B418->unkE26C = gUnknown_80F4F42;
+ gDungeonGlobalData->weatherTurnsLeft = gUnknown_80F4F42;
if (sub_807EAA0(1,0) == '\0') {
// The weather remains unchanged
sub_80522F4(param_1,param_2,gUnknown_80FCF80);
@@ -105,7 +105,7 @@ bool32 sub_8057974(struct DungeonEntity *param_1, struct DungeonEntity *param_2,
s32 newHP;
u8 local_24;
- newHP = param_2->unk70->HP / 2;
+ newHP = param_2->entityData->HP / 2;
local_24 = 0;
if (newHP != 0) {
sub_806F370(param_1,param_2,newHP,1,&local_24,sub_8092B00(param_3),sub_8057600(param_3,param_4),0,1,0);
diff --git a/src/code_8057824_1.c b/src/code_8057824_1.c
index 29ab09e..d88918f 100644
--- a/src/code_8057824_1.c
+++ b/src/code_8057824_1.c
@@ -1,10 +1,11 @@
#include "global.h"
-#include "gUnknown_203B418.h"
+#include "dungeon_global_data.h"
#include "dungeon_entity.h"
#include "pokemon.h"
#include "item.h"
+#include "constants/direction.h"
-extern struct unkStruct_203B418 *gUnknown_203B418;
+extern struct DungeonGlobalData *gDungeonGlobalData;
extern u32 gUnknown_202EDC8;
extern u8 gUnknown_202E038[0x50];
@@ -424,13 +425,13 @@ void sub_8087704(struct DungeonEntity *param_1)
{
int iVar1;
- param_1->unk70->unk15C = 1;
- param_1->unk70->unk15E = 0;
- param_1->unk70->unk174 = 200;
+ param_1->entityData->unk15C = 1;
+ param_1->entityData->unk15E = 0;
+ param_1->entityData->unk174 = 200;
PlaySoundEffect(0x1ea);
for(iVar1 = 200; iVar1 >= 0; iVar1 -= 5)
{
- param_1->unk70->unk174 = iVar1 * 256;
+ param_1->entityData->unk174 = iVar1 * 256;
sub_803E46C(0x46);
}
sub_803E708(0x1e,0x46);
@@ -523,7 +524,7 @@ void sub_80878F4(char param_1, s32 param_2)
{
if ((((param_2 * 0x1000000) + 0xF6000000U) >> 0x18 < 3) && (param_1 == 0x9)) {
sub_8097FA8(0x7);
- gUnknown_203B418->unk2 = 1;
+ gDungeonGlobalData->unk2 = 1;
}
}
@@ -656,7 +657,7 @@ void MoltresPostStoryPreFightDialogue(void)
sub_803E708(10,0x46);
sub_8052910(&gUnknown_8100D3C);
sub_803E708(10,0x46);
- gUnknown_203B418->unk2 = 1;
+ gDungeonGlobalData->unk2 = 1;
}
else {
sub_8052910(&gUnknown_810232C);
@@ -682,14 +683,14 @@ void sub_8087D30(struct DungeonEntity * param_1)
{
s32 iVar1;
- param_1->unk70->unk15C = 1;
- param_1->unk70->unk15E = 0;
- param_1->unk70->unk174 = 0xc800;
+ param_1->entityData->unk15C = 1;
+ param_1->entityData->unk15E = 0;
+ param_1->entityData->unk174 = 0xc800;
PlaySoundEffect(0x1f8);
iVar1 = 200;
for(iVar1 = 200; iVar1 >= 0; iVar1 -= 5)
{
- param_1->unk70->unk174 = iVar1 * 256;
+ param_1->entityData->unk174 = iVar1 * 256;
sub_803E46C(0x46);
}
}
@@ -943,7 +944,7 @@ void sub_8088088(char param_1, s32 param_2)
{
if ((((param_2 * 0x1000000) + 0xF3000000U) >> 0x18 < 3) && (param_1 == 0xD)) {
sub_8097FA8(0x9);
- gUnknown_203B418->unk2 = 1;
+ gDungeonGlobalData->unk2 = 1;
}
}
@@ -997,7 +998,7 @@ void ArticunoPreFightDialogue(void)
sub_8052910(&gUnknown_810272C);
sub_803E708(10,0x46);
PlaySoundEffect(0); // snow flurry
- gUnknown_203B418->unkE265 = 7;
+ gDungeonGlobalData->unkE265 = 7;
sub_807EAA0(0,1);
PlaySoundEffect(0x1ee); // flash effect?
sub_8088574();
@@ -1032,7 +1033,7 @@ void ArticunoReFightDialogue(void)
iVar1 = sub_8085480();
uVar2 = sub_8085680(0xd);
- gUnknown_203B418->unkE265 = 7;
+ gDungeonGlobalData->unkE265 = 7;
sub_807EAA0(0,1);
sub_803E708(10,0x46);
sub_8052910(&gUnknown_81028D4);
@@ -1059,7 +1060,7 @@ void ArticunoPostStoryPreFightDialogue(void)
sub_80866C4(&gUnknown_8102A9C);
}
else {
- gUnknown_203B418->unkE265 = 7;
+ gDungeonGlobalData->unkE265 = 7;
sub_807EAA0(0,1);
ArticunoScreenFlash();
sub_8086738();
@@ -1088,12 +1089,12 @@ void sub_8088484(struct DungeonEntity *param_1)
{
int iVar1;
- param_1->unk70->unk15C = 1;
- param_1->unk70->unk15E = 0;
+ param_1->entityData->unk15C = 1;
+ param_1->entityData->unk15E = 0;
PlaySoundEffect(0x1ea);
for(iVar1 = 250; iVar1 >= 0; iVar1 -= 5)
{
- param_1->unk70->unk174 = iVar1 * 256;
+ param_1->entityData->unk174 = iVar1 * 256;
sub_8085C54(iVar1,iVar1,iVar1 / 2,1,0);
sub_803E46C(0x46);
}
@@ -1141,7 +1142,7 @@ void sub_80885A0(void)
sub_8083ED8(0x3c);
sub_803E708(0x3c,0x46);
sub_8083F14();
- gUnknown_203B418->unk7 = 1;
+ gDungeonGlobalData->unk7 = 1;
}
void sub_80885C4(void)
@@ -1160,7 +1161,7 @@ void sub_80885C4(void)
void sub_8088608(void)
{
- gUnknown_203B418->unk2 = 1;
+ gDungeonGlobalData->unk2 = 1;
}
void sub_8088618(void)
@@ -1255,7 +1256,7 @@ void sub_8088818(char param_1, s32 param_2)
{
if ((((param_2 * 0x1000000) + 0xEE000000U) >> 0x18 < 3) && (param_1 == 0xE)) {
sub_8097FA8(0xC);
- gUnknown_203B418->unk2 = 1;
+ gDungeonGlobalData->unk2 = 1;
}
}
@@ -1597,8 +1598,8 @@ void MagmaCavernMidDialogue(void)
// Hey! $m0!
// Over there!
sub_8052910(&gUnknown_8102C30);
- iVar3->unk70->unk15E = 0;
- iVar4->unk70->unk15E =0;
+ iVar3->entityData->unk15E = 0;
+ iVar4->entityData->unk15E =0;
local_20[0] = (iVar3->posPixelX + iVar4->posPixelX) / 2;
local_20[1] = (iVar3->posPixelY + iVar4->posPixelY) / 2 + 0x800;
sub_80858AC(local_20,0x20);
@@ -1657,7 +1658,7 @@ void MagmaCavernMidDialogue(void)
// Be careful!
sub_8052910(&gUnknown_8102E54);
sub_803E708(10,0x46);
- gUnknown_203B418->unk2 = 1;
+ gDungeonGlobalData->unk2 = 1;
}
void sub_8089168(void)
@@ -1680,14 +1681,14 @@ void sub_808919C(struct DungeonEntity *r0)
void sub_80891B0(struct DungeonEntity *r0)
{
sub_806CDD4(r0, 0, 4);
- r0->unk70->unk15F = 1;
+ r0->entityData->unk15F = 1;
}
void sub_80891D0(struct DungeonEntity *r0)
{
sub_806CDD4(r0, 7, 4);
- r0->unk70->unk15F = 0;
+ r0->entityData->unk15F = 0;
}
void sub_80891F0(void)
@@ -1802,7 +1803,7 @@ void sub_80893B4(char param_1, s32 param_2)
{
if ((((param_2 * 0x1000000) + 0xE9000000U) >> 0x18 < 3) && (param_1 == 0xF)) {
sub_8097FA8(0xF);
- gUnknown_203B418->unk2 = 1;
+ gDungeonGlobalData->unk2 = 1;
}
}
@@ -1903,7 +1904,7 @@ void sub_8089620(struct DungeonEntity *param_1)
s32 iVar1;
s32 iVar2;
- param_1->unk70->unk15E = 0;
+ param_1->entityData->unk15E = 0;
iVar2 = 51200;
iVar1 = 0x600;
PlaySoundEffect(0x1f8);
@@ -1914,10 +1915,10 @@ void sub_8089620(struct DungeonEntity *param_1)
iVar1 = 0x14;
}
if (iVar2 < 0) break;
- param_1->unk70->unk174 = iVar2;
+ param_1->entityData->unk174 = iVar2;
sub_803E46C(0x46);
}
- param_1->unk70->unk174 = 0;
+ param_1->entityData->unk174 = 0;
}
void RayquazaScreenFlash(void)
@@ -1983,15 +1984,15 @@ void sub_8089788(struct DungeonEntity *param_1, u8 param_2, s32 param_3)
if ((((param_3 * 0x1000000) + 0xe6000000U) >> 0x18) < 2) {
for(iVar3 = 0; iVar3 < 0x10; iVar3++)
{
- iVar2 = gUnknown_203B418->unk1358C[iVar3];
- if ((sub_80450E0(iVar2) != '\0') && (iVar2 != param_1) && (iVar2->unk70->clientFlags == param_2)) {
+ iVar2 = gDungeonGlobalData->wildPokemon[iVar3];
+ if ((sub_80450E0(iVar2) != '\0') && (iVar2 != param_1) && (iVar2->entityData->clientFlags == param_2)) {
return;
}
}
// WTF is this??
if(!unk1){
sub_8097FA8(0x11);
- gUnknown_203B418->unk2 = 1;
+ gDungeonGlobalData->unk2 = 1;
}
}
}
@@ -2075,7 +2076,7 @@ void sub_8089914(void)
iVar1 = sub_8085480();
uVar2 = sub_8085680(0x11);
sub_8083F14();
- gUnknown_203B418->unk7 = 1;
+ gDungeonGlobalData->unk7 = 1;
sub_80854D4();
sub_8085930(4);
sub_80855E4(sub_8086A3C);
@@ -2101,7 +2102,7 @@ void sub_8089978(void)
sub_8068FE0(uVar3,0x21c,0);
}
else {
- gUnknown_203B418->unk7 = 1;
+ gDungeonGlobalData->unk7 = 1;
sub_8085918(uVar3,0);
sub_8086A3C(uVar3);
}
@@ -2113,7 +2114,7 @@ void sub_8089A00(char param_1, s32 param_2)
{
if ((((param_2 * 0x1000000) + 0xE3000000U) >> 0x18 < 3) && (param_1 == 0x11)) {
sub_8097FA8(0x13);
- gUnknown_203B418->unk2 = 1;
+ gDungeonGlobalData->unk2 = 1;
}
}
@@ -2176,7 +2177,7 @@ void sub_8089B64(struct DungeonEntity *param_1)
s32 iVar1;
s32 iVar2;
- param_1->unk70->unk15E = 0;
+ param_1->entityData->unk15E = 0;
iVar2 = 51200;
iVar1 = 0x400;
PlaySoundEffect(0x1f8);
@@ -2187,10 +2188,10 @@ void sub_8089B64(struct DungeonEntity *param_1)
iVar1 = 0x1e;
}
if (iVar2 < 0) break;
- param_1->unk70->unk174 = iVar2;
+ param_1->entityData->unk174 = iVar2;
sub_803E46C(0x46);
}
- param_1->unk70->unk174 = 0;
+ param_1->entityData->unk174 = 0;
}
void MewtwoScreenFlash(void)
@@ -2260,7 +2261,7 @@ void sub_8089CFC(char param_1,int param_2)
{
if ((((param_2 * 0x1000000) + 0xE0000000U) >> 0x18 < 3) && (param_1 == 0x12)) {
sub_8097FA8(0x15);
- gUnknown_203B418->unk2 = 1;
+ gDungeonGlobalData->unk2 = 1;
}
}
@@ -2406,7 +2407,7 @@ void sub_8089FF0(char param_1,int param_2)
{
if ((((param_2 * 0x1000000) + 0xdD000000U) >> 0x18 < 3) && (param_1 == 0x13)) {
sub_8097FA8(0x17);
- gUnknown_203B418->unk2 = 1;
+ gDungeonGlobalData->unk2 = 1;
}
}
@@ -2421,7 +2422,7 @@ void RaikouPreFightDialogue(void)
sub_8052910(&gUnknown_8104450);
RaikouScreenFlash();
sub_8052910(&gUnknown_81044B4);
- gUnknown_203B418->unkE265 = 4;
+ gDungeonGlobalData->unkE265 = 4;
sub_807EAA0(0,1);
sub_803E708(10,70);
sub_8052910(&gUnknown_8104510);
@@ -2443,7 +2444,7 @@ void RaikouPreFightDialogue1(void)
iVar2 = sub_8085480();
uVar3 = sub_8085680(0x13);
- gUnknown_203B418->unkE265 = 4;
+ gDungeonGlobalData->unkE265 = 4;
sub_807EAA0(0,1);
RaikouScreenFlash();
sub_8052910(&gUnknown_81045F8);
@@ -2467,7 +2468,7 @@ void RaikouPreFightDialogue2(void)
sub_80866C4(&gUnknown_8104778);
}
else {
- gUnknown_203B418->unkE265 = 4;
+ gDungeonGlobalData->unkE265 = 4;
sub_807EAA0(0,1);
sub_8052910(&gUnknown_81046CC);
RaikouScreenFlash();
@@ -2562,7 +2563,7 @@ void sub_808A36C(char param_1,int param_2)
{
if ((((param_2 * 0x1000000) + 0xda000000U) >> 0x18 < 3) && (param_1 == 0x14)) {
sub_8097FA8(0x19);
- gUnknown_203B418->unk2 = 1;
+ gDungeonGlobalData->unk2 = 1;
}
}
@@ -2638,7 +2639,7 @@ void sub_808A528(struct DungeonEntity * param_1)
s32 iVar1;
s32 iVar2;
- param_1->unk70->unk15E = 0;
+ param_1->entityData->unk15E = 0;
iVar2 = 51200;
iVar1 = 3072;
PlaySoundEffect(0x1f8);
@@ -2649,10 +2650,10 @@ void sub_808A528(struct DungeonEntity * param_1)
iVar1 = 20;
}
if (iVar2 < 0) break;
- param_1->unk70->unk174 = iVar2;
+ param_1->entityData->unk174 = iVar2;
sub_803E46C(70);
}
- param_1->unk70->unk174 = 0;
+ param_1->entityData->unk174 = 0;
}
void SuicuneScreenFlash(void)
@@ -2726,7 +2727,7 @@ void sub_808A6E8(char param_1, s32 param_2)
{
if ((((param_2 * 0x1000000) + 0xd7000000U) >> 0x18 < 2) && (param_1 == 0x15)) {
sub_8097FA8(0x1A);
- gUnknown_203B418->unk2 = 1;
+ gDungeonGlobalData->unk2 = 1;
}
}
@@ -2817,7 +2818,7 @@ void sub_808A904(struct DungeonEntity * param_1)
s32 iVar1;
s32 iVar2;
- param_1->unk70->unk15E = 0;
+ param_1->entityData->unk15E = 0;
iVar2 = 51200;
iVar1 = 3072;
PlaySoundEffect(0x1f8);
@@ -2828,10 +2829,10 @@ void sub_808A904(struct DungeonEntity * param_1)
iVar1 = 20;
}
if (iVar2 < 0) break;
- param_1->unk70->unk174 = iVar2;
+ param_1->entityData->unk174 = iVar2;
sub_803E46C(70);
}
- param_1->unk70->unk174 = 0;
+ param_1->entityData->unk174 = 0;
}
void HoOhScreenFlash(void)
@@ -2912,7 +2913,7 @@ void sub_808AAF0(char param_1, s32 param_2)
{
if ((((param_2 * 0x1000000) + 0xd5000000U) >> 0x18 < 3) && (param_1 == 0x16)) {
sub_8097FA8(0x1c);
- gUnknown_203B418->unk2 = 1;
+ gDungeonGlobalData->unk2 = 1;
}
}
@@ -3292,7 +3293,7 @@ void sub_808B1CC(u8 r0)
"\tstrb r0, [r1, 0x2]\n"
"\tb _0808B2A8\n"
"\t.align 2, 0\n"
-"_0808B21C: .4byte gUnknown_203B418\n"
+"_0808B21C: .4byte gDungeonGlobalData\n"
"_0808B220: .4byte 0x00000684\n"
"_0808B224: .4byte 0xffff0000\n"
"_0808B228: .4byte 0x00000686\n"
@@ -3362,7 +3363,7 @@ void sub_808B1CC(u8 r0)
void sub_808B2B0(struct DungeonEntity *r0)
{
- r0->unk70->facingDir = NORTH;
+ r0->entityData->facingDir = DIRECTION_NORTH;
sub_806CE68(r0, 4);
}
@@ -3437,17 +3438,17 @@ void sub_808B3E4(u8 param_1,u8 param_2,u8 param_3)
if (((((param_2 * 0x1000000) + 0xcf000000U) >> 0x18) < 2) && (param_1 == 0x1A)){
sub_8097FA8(0x1e);
if (param_3 != 0) {
- gUnknown_203B418->unk2 = 1;
+ gDungeonGlobalData->unk2 = 1;
}
else {
- uVar1 = gUnknown_203B418->unk1356C;
+ uVar1 = gDungeonGlobalData->unk1356C;
if (sub_80860A8(0x36) != 0) {
JirachiWish();
}
else {
sub_808B50C();
}
- gUnknown_203B418->unk1356C = uVar1;
+ gDungeonGlobalData->unk1356C = uVar1;
sub_8040A84();
}
}
@@ -3481,7 +3482,7 @@ void sub_808B3E4(u8 param_1, u8 param_2, u8 param_3)
"\tstrb r0, [r1, 0x2]\n"
"\tb _0808B44E\n"
"\t.align 2, 0\n"
-"_0808B414: .4byte gUnknown_203B418\n"
+"_0808B414: .4byte gDungeonGlobalData\n"
"_0808B418:\n"
"\tldr r0, _0808B434\n"
"\tldr r0, [r0]\n"
@@ -3496,7 +3497,7 @@ void sub_808B3E4(u8 param_1, u8 param_2, u8 param_3)
"\tbl JirachiWish\n"
"\tb _0808B440\n"
"\t.align 2, 0\n"
-"_0808B434: .4byte gUnknown_203B418\n"
+"_0808B434: .4byte gDungeonGlobalData\n"
"_0808B438: .4byte 0x0001356c\n"
"_0808B43C:\n"
"\tbl sub_808B50C\n"
@@ -3512,7 +3513,7 @@ void sub_808B3E4(u8 param_1, u8 param_2, u8 param_3)
"\tpop {r0}\n"
"\tbx r0\n"
"\t.align 2, 0\n"
-"_0808B454: .4byte gUnknown_203B418\n"
+"_0808B454: .4byte gDungeonGlobalData\n"
"_0808B458: .4byte 0x0001356c");
}
#endif
@@ -3553,8 +3554,8 @@ void sub_808B50C(void)
sub_80855E4(sub_808BBA8);
sub_808BBA8(iVar1);
sub_8041888(0);
- iVar1->unk70->unk15C = 1;
- iVar1->unk70->unk15E = 0;
+ iVar1->entityData->unk15C = 1;
+ iVar1->entityData->unk15E = 0;
sub_80861B8(iVar1,0xe,0);
sub_8083ED8(0x1e);
sub_803E708(0x1e,70);
@@ -3569,5 +3570,5 @@ void sub_808B50C(void)
sub_808BC20(iVar1);
sub_8052910(&gUnknown_81055F4);
sub_803E708(10,70);
- gUnknown_203B418->unk2 = 1;
+ gDungeonGlobalData->unk2 = 1;
}
diff --git a/src/code_80869E4.c b/src/code_80869E4.c
index 9718195..f7ffdb6 100644
--- a/src/code_80869E4.c
+++ b/src/code_80869E4.c
@@ -1,7 +1,8 @@
#include "global.h"
#include "dungeon_entity.h"
-#include "gUnknown_203B418.h"
+#include "dungeon_global_data.h"
#include "random.h"
+#include "constants/direction.h"
struct unkStruct_202F3D0
{
@@ -14,7 +15,7 @@ struct unkStruct_202F3D0
};
EWRAM_DATA struct unkStruct_202F3D0 gUnknown_202F3D0;
-extern struct unkStruct_203B418 *gUnknown_203B418;
+extern struct DungeonGlobalData *gDungeonGlobalData;
s8 sub_8002984(s8, u8);
void sub_803E708(u32, u32);
@@ -76,7 +77,7 @@ void sub_8086310(struct DungeonEntity *r0)
sub_804535C(r0, array);
sub_806CE68(r0, 0);
sub_8086A3C(r0);
- r0->active = 0;
+ r0->visible = 0;
}
void sub_8086348(struct DungeonEntity *r0)
@@ -314,7 +315,7 @@ void sub_80866C4(u32 r0)
sub_8052910(r0);
sub_803E708(0xA, 0x46);
sub_8086494();
- gUnknown_203B418->unk2 = 1;
+ gDungeonGlobalData->unk2 = 1;
}
void sub_80866FC(void)
@@ -375,7 +376,7 @@ void sub_8086794(void)
}
}
sub_803E46C(0x46);
- gUnknown_203B418->unk7 = 0;
+ gDungeonGlobalData->unk7 = 0;
}
void sub_80867F4(void)
@@ -438,24 +439,24 @@ void sub_8086854(void)
}
if(gUnknown_202F3D0.unk5 != 0)
gUnknown_202F3D0.unk5--;
- gUnknown_203B418->unk181FC = gUnknown_8107314[gUnknown_202F3D0.unk5];
+ gDungeonGlobalData->unk181FC = gUnknown_8107314[gUnknown_202F3D0.unk5];
}
else
{
- gUnknown_203B418->unk181FC = 0;
+ gDungeonGlobalData->unk181FC = 0;
}
}
void sub_80868F4(struct DungeonEntity *r0)
{
- r0->unk70->unk15C = 1;
- r0->unk70->unk15D = 1;
+ r0->entityData->unk15C = 1;
+ r0->entityData->unk15D = 1;
}
void sub_8086910(struct DungeonEntity *r0)
{
- r0->unk70->unk15C = 0;
- r0->unk70->unk15D = 0;
+ r0->entityData->unk15C = 0;
+ r0->entityData->unk15D = 0;
}
void sub_808692C(void)
@@ -478,7 +479,7 @@ void SpriteLookAroundEffect(struct DungeonEntity *r0)
s8 r4;
s8 r3;
- r4 = sub_8002984(r0->unk70->facingDir, 4);
+ r4 = sub_8002984(r0->entityData->facingDir, 4);
sub_80869E4(r0, 4, 2, r4);
diff --git a/src/code_8086A3C.c b/src/code_8086A3C.c
index d740ccd..63c2d44 100644
--- a/src/code_8086A3C.c
+++ b/src/code_8086A3C.c
@@ -1,9 +1,9 @@
#include "global.h"
#include "dungeon_entity.h"
-#include "gUnknown_203B418.h"
+#include "dungeon_global_data.h"
#include "pokemon.h"
-extern struct unkStruct_203B418 *gUnknown_203B418;
+extern struct DungeonGlobalData *gDungeonGlobalData;
extern void sub_807191C(struct DungeonEntity *);
extern struct DungeonEntity *sub_8085480(void);
extern struct DungeonEntity *sub_8085680(u32);
@@ -23,47 +23,47 @@ extern void sub_8097FA8(u32);
void sub_8086A3C(struct DungeonEntity *param_1)
{
- param_1->unk70->unk15C = 1;
- param_1->unk70->unk15E = 1;
+ param_1->entityData->unk15C = 1;
+ param_1->entityData->unk15E = 1;
}
void sub_8086A54(struct DungeonEntity *param_1)
{
- param_1->unk70->unk15C = 1;
- param_1->unk70->unk15E = 0;
+ param_1->entityData->unk15C = 1;
+ param_1->entityData->unk15E = 0;
}
void SetupBossFightHP(struct DungeonEntity *param_1, s32 newHP, u16 param_3)
{
// NOTE: needed two of these to match.. very dumb
- struct subStruct_8048524 *iVar1;
- struct subStruct_8048524 *iVar2;
-
- iVar1 = param_1->unk70;
- iVar2 = param_1->unk70;
-
+ struct DungeonEntityData *iVar1;
+ struct DungeonEntityData *iVar2;
+
+ iVar1 = param_1->entityData;
+ iVar2 = param_1->entityData;
+
iVar1->isBoss = TRUE;
// BUG: Source of the Reviver Seed Boss Glitch
//
// Video to demonstration:
// https://www.youtube.com/watch?v=rHu7EehrZ68
- iVar1->bossHPBackup = iVar1->maxHP;
+ iVar1->originalHP = iVar1->maxHP;
if (newHP != 0) {
iVar1->maxHP = newHP;
iVar1->HP = newHP;
}
- gUnknown_203B418->unk66A = param_3;
- sub_808EC94(iVar2->unk8C,iVar2->isBoss);
+ gDungeonGlobalData->unk66A = param_3;
+ sub_808EC94(iVar2->IQSkillsSelected,iVar2->isBoss);
sub_807191C(param_1);
}
void sub_8086AC0(void)
{
if(!sub_8044B28())
- if(gUnknown_203B418->unk2 == 0)
+ if(gDungeonGlobalData->unk2 == 0)
sub_8097FF8();
}
@@ -71,7 +71,7 @@ u8 sub_8086AE4(s16 _index)
{
s32 pokeIndex = _index;
- if(gUnknown_203B418->unk65C == 0)
+ if(gDungeonGlobalData->unk65C == 0)
return 1;
else
return HasRecruitedMon(pokeIndex);
@@ -82,7 +82,7 @@ void sub_8086B14(void)
struct DungeonEntity * iVar1;
struct DungeonEntity * iVar2;
struct DungeonEntity * uVar3;
-
+
iVar1 = sub_8085480();
iVar2 = sub_8085680(4);
uVar3 = sub_8085680(3);
@@ -92,7 +92,7 @@ void sub_8086B14(void)
sub_8085930(4);
sub_80855E4(sub_8086A3C);
sub_8086A3C(uVar3);
- iVar2->unk70->unk15C = 1;
+ iVar2->entityData->unk15C = 1;
sub_8085860(iVar1->posWorldX,iVar1->posWorldY + -2);
CopySpeciesNametoBuffer(gUnknown_202E038,SPECIES_DIGLETT);
CopySpeciesNametoBuffer(gUnknown_202E038 + 0x50, SPECIES_SKARMORY);
@@ -103,7 +103,7 @@ void sub_8086B94(void)
struct DungeonEntity * iVar1;
struct DungeonEntity * iVar2;
struct DungeonEntity * uVar3;
-
+
iVar1 = sub_8085480();
iVar2 = sub_8085680(4);
uVar3 = sub_8085680(3);
@@ -119,6 +119,6 @@ void sub_8086BDC(char param_1, s32 param_2)
{
if ((((param_2 * 0x1000000) - 0x1000000U) >> 0x18 < 2) && (param_1 == 3)) {
sub_8097FA8(1);
- gUnknown_203B418->unk2 = 1;
+ gDungeonGlobalData->unk2 = 1;
}
}
diff --git a/src/debug_menu_mid.c b/src/debug_menu_mid.c
index a07b6c5..c210773 100644
--- a/src/debug_menu_mid.c
+++ b/src/debug_menu_mid.c
@@ -180,7 +180,7 @@ void sub_803A51C(void)
void sub_803A5A0(void)
{
struct ItemSlot auStack8;
-
+
switch(gUnknown_203B3F0->state) {
case 0:
sub_801C8C4(2,3,0,10);
diff --git a/src/friend_area_action_menu_1.c b/src/friend_area_action_menu_1.c
index a848fff..98427f8 100644
--- a/src/friend_area_action_menu_1.c
+++ b/src/friend_area_action_menu_1.c
@@ -53,7 +53,7 @@ void sub_8027AE4(void)
void sub_8027B28(void)
{
- switch(sub_801A6E8(1))
+ switch(sub_801A6E8(1))
{
case 3:
gUnknown_203B2BC->unkC = sub_801A8AC();
@@ -81,7 +81,7 @@ void sub_8027B28(void)
void sub_8027BD8(void)
{
s32 menuAction;
-
+
menuAction = 0;
sub_801A6E8(0);
if ((sub_8012FD8(&gUnknown_203B2BC->unk7C) == 0) && (sub_8013114(&gUnknown_203B2BC->unk7C,&menuAction), menuAction != 1)) {
@@ -93,7 +93,7 @@ void sub_8027BD8(void)
PlaySound(0x14d);
ShiftItemsDownFrom(gUnknown_203B2BC->unkC);
FillInventoryGaps();
- if (gUnknown_203B2BC->unk14.unk0 != 0) {
+ if (gUnknown_203B2BC->unk14.itemFlags != 0) {
sub_8091274(&gUnknown_203B2BC->unk14);
}
GivePokemonItem(gUnknown_203B2BC->unk8,&gUnknown_203B2BC->unk10);
diff --git a/src/friend_rescue_1.c b/src/friend_rescue_1.c
index 499ba92..325cf4e 100644
--- a/src/friend_rescue_1.c
+++ b/src/friend_rescue_1.c
@@ -101,7 +101,7 @@ extern u8 gUnknown_80E46C8[];
extern u8 gUnknown_80E4704[];
extern u8 gUnknown_80E4744[];
extern u8 gUnknown_80E4788[];
-extern u8 gUnknown_80E47D8[];
+extern u8 gUnknown_80E47D8[];
extern u8 gUnknown_80E4480[];
extern u8 gUnknown_80E482C[];
@@ -1057,7 +1057,7 @@ void sub_8034848(void)
MemoryFill8((u8 *)&gUnknown_203B33C->unk41C, 0 , 4);
gUnknown_203B33C->unk41C.itemIndex = ITEM_ID_NOTHING;
gUnknown_203B33C->unk41C.numItems = 1;
- gUnknown_203B33C->unk41C.unk0 = 0;
+ gUnknown_203B33C->unk41C.itemFlags = 0;
if(gUnknown_203B33C->status == 0)
{
@@ -1087,7 +1087,7 @@ void sub_80348C4(void)
MemoryFill8((u8 *)&gUnknown_203B33C->unk41C, 0 , 4);
gUnknown_203B33C->unk41C.itemIndex = ITEM_ID_NOTHING;
gUnknown_203B33C->unk41C.numItems = 1;
- gUnknown_203B33C->unk41C.unk0 = 0;
+ gUnknown_203B33C->unk41C.itemFlags = 0;
if(gUnknown_203B33C->status == 0)
{
@@ -1240,7 +1240,7 @@ void sub_8034B88(void)
{
gUnknown_203B33C->unk41C.itemIndex = ITEM_ID_NOTHING;
gUnknown_203B33C->unk41C.numItems = 1;
- gUnknown_203B33C->unk41C.unk0 = 0;
+ gUnknown_203B33C->unk41C.itemFlags = 0;
switch(sub_801CA08(1))
{
case 2:
diff --git a/src/items.c b/src/items.c
index 3ced8fe..f4f7170 100644
--- a/src/items.c
+++ b/src/items.c
@@ -64,10 +64,10 @@ struct TeamInventory *GetMoneyItemsInfo(void)
void InitializeMoneyItems(void)
{
s32 i;
-
+
for(i = 0; i < INVENTORY_SIZE; i++)
{
- gTeamInventory_203B460->teamItems[i].unk0 = 0;
+ gTeamInventory_203B460->teamItems[i].itemFlags = 0;
}
for(i = 0; i < 0xF0; i++)
@@ -87,11 +87,11 @@ s32 GetNumberOfFilledInventorySlots(void)
{
s32 i;
s32 count;
-
+
count = 0;
for(i = 0; i < INVENTORY_SIZE; i++)
{
- if ((gTeamInventory_203B460->teamItems[i].unk0 & 1) != 0) {
+ if ((gTeamInventory_203B460->teamItems[i].itemFlags & ITEM_FLAG_EXISTS) != 0) {
count++;
}
}
@@ -102,7 +102,7 @@ bool8 IsThrowableItem(u8 itemIndex)
{
if ((GetItemType(itemIndex) != ITEM_TYPE_THROWABLE) && (GetItemType(itemIndex) != ITEM_TYPE_ROCK))
return FALSE;
- else
+ else
return TRUE;
}
@@ -110,9 +110,9 @@ void xxx_init_itemslot_8090A8C(struct ItemSlot *slot, u8 itemIndex, u8 param_3)
{
u32 uVar3;
u32 uVar4;
-
+
if (itemIndex != ITEM_ID_NOTHING) {
- slot->unk0 = 1;
+ slot->itemFlags = ITEM_FLAG_EXISTS;
slot->itemIndex = itemIndex;
if (IsThrowableItem(itemIndex)) {
uVar3 = GetItemUnkThrow(itemIndex, 0);
@@ -121,15 +121,15 @@ void xxx_init_itemslot_8090A8C(struct ItemSlot *slot, u8 itemIndex, u8 param_3)
}
else if (GetItemType(itemIndex) == ITEM_TYPE_MONEY)
slot->numItems = 1;
- else
+ else
slot->numItems = 0;
if (param_3 != 0)
- slot->unk0 |= 8;
+ slot->itemFlags |= ITEM_FLAG_STICKY;
}
else {
- slot->unk0 = 0;
+ slot->itemFlags = 0;
slot->itemIndex = ITEM_ID_NOTHING;
slot->numItems = 0;
}
@@ -139,14 +139,14 @@ void xxx_init_helditem_8090B08(struct HeldItem *held, u8 itemIndex)
{
u32 uVar2;
u32 uVar3;
-
+
if (itemIndex != ITEM_ID_NOTHING) {
held->itemIndex = itemIndex;
if (IsThrowableItem(itemIndex)) {
uVar2 = GetItemUnkThrow(itemIndex,0);
uVar3 = GetItemUnkThrow(itemIndex,1);
held->numItems = RandomRange(uVar2, uVar3);
- }
+ }
else if (GetItemType(itemIndex) == ITEM_TYPE_MONEY)
held->numItems = 1;
else
@@ -164,7 +164,7 @@ void HeldItemToSlot(struct ItemSlot *slot, struct HeldItem *held)
if(held->itemIndex != ITEM_ID_NOTHING)
{
- slot->unk0 = 1;
+ slot->itemFlags = ITEM_FLAG_EXISTS;
slot->itemIndex = held->itemIndex;
is_throwable = IsThrowableItem(slot->itemIndex);
if(is_throwable != 0 || GetItemType(slot->itemIndex) == ITEM_TYPE_MONEY)
@@ -178,13 +178,13 @@ void HeldItemToSlot(struct ItemSlot *slot, struct HeldItem *held)
{
slot->itemIndex = ITEM_ID_NOTHING;
slot->numItems = 0;
- slot->unk0 = 0;
+ slot->itemFlags = 0;
}
}
void SlotToHeldItem(struct HeldItem *held,struct ItemSlot *slot)
{
- if ((slot->unk0 & 1) != 0) {
+ if ((slot->itemFlags & ITEM_FLAG_EXISTS) != 0) {
held->itemIndex = slot->itemIndex;
held->numItems = slot->numItems;
}
@@ -293,16 +293,16 @@ u8 *GetItemDescription(u8 itemIndex)
return gItemParametersData[itemIndex].descriptionPointer;
}
-u32 GetItemUnkFood(u8 itemIndex, u32 r1)
+u32 GetItemAIFlags(u8 itemIndex, u32 r1)
{
- return gItemParametersData[itemIndex].unkFood1[r1];
+ return gItemParametersData[itemIndex].aiFlags[r1];
}
void sub_8090DC4(void* param_1,u8 itemIndex, struct unkStruct_8090F58* param_3)
{
char acStack104 [80];
struct ItemSlot unkItem;
-
+
strncpy(acStack104,gItemParametersData[itemIndex].namePointer,0x50);
xxx_init_itemslot_8090A8C(&unkItem,itemIndex,0);
unkItem.numItems = 1;
@@ -347,18 +347,18 @@ void sub_8090E14(u8* ext_buffer, struct ItemSlot* slot, struct unkStruct_8090F58
strncpy(buffer, gItemParametersData[slot->itemIndex].namePointer, 80);
}
- if (slot->unk0 & 8) {
+ if (slot->itemFlags & ITEM_FLAG_STICKY) {
ExpandPlaceholdersBuffer(ext_buffer, gUnknown_8109784, buffer);
strncpy(buffer, ext_buffer, 80);
}
if (a3) {
- if (a3->unk4 && (slot->unk0 & 0x10)) {
+ if (a3->unk4 && (slot->itemFlags & ITEM_FLAG_SET)) {
ExpandPlaceholdersBuffer(ext_buffer, gUnknown_810978C, buffer);
strncpy(buffer, ext_buffer, 80);
}
if ((*(u32*)a3 == 1) || (*(u32*)a3 == 3)) {
- if (slot->unk0 & 2) {
+ if (slot->itemFlags & ITEM_FLAG_FOR_SALE) {
sub_8090F58(ext_buffer, buffer, slot, a3);
return;
}
@@ -379,7 +379,7 @@ void sub_8090F58(void* a1, u8 *a2, struct ItemSlot *slot, struct unkStruct_8090F
u32 unk0;
s32 value;
u8 buffer[40];
-
+
if (!a4) {
strncpy(a1, a2, 80);
return;
@@ -406,7 +406,7 @@ void sub_8090F58(void* a1, u8 *a2, struct ItemSlot *slot, struct unkStruct_8090F
}
}
- if (a4->unk6) {
+ if (a4->unk6) {
sub_8090FEC(value, buffer, 1);
ExpandPlaceholdersBuffer(a1, gUnknown_8109794, a2, a4->unk6, buffer);
}
@@ -416,7 +416,7 @@ void sub_8090F58(void* a1, u8 *a2, struct ItemSlot *slot, struct unkStruct_8090F
}
}
-s32 sub_8090FEC(s32 a1, u8* strbuf, u8 a3)
+s32 sub_8090FEC(s32 a1, u8* strbuf, u8 a3)
{
s32 i, count;
s32 cond = 0;
@@ -424,7 +424,7 @@ s32 sub_8090FEC(s32 a1, u8* strbuf, u8 a3)
count = 0;
for (i = 0; i < 5; i++) {
s32 div;
-
+
div = 0;
while (a1 >= gUnknown_81097B0[i]) {
a1 -= gUnknown_81097B0[i];
@@ -458,7 +458,7 @@ s32 sub_8090FEC(s32 a1, u8* strbuf, u8 a3)
return count;
}
-void FillInventoryGaps()
+void FillInventoryGaps()
{
// fill inventory gaps
s32 slot_checking = 0;
@@ -466,7 +466,7 @@ void FillInventoryGaps()
do {
while (slot_checking < INVENTORY_SIZE) {
- if (slot_checking[gTeamInventory_203B460->teamItems].unk0 & 1) {
+ if (slot_checking[gTeamInventory_203B460->teamItems].itemFlags & ITEM_FLAG_EXISTS) {
break;
}
// find next empty slot
@@ -498,22 +498,22 @@ void FillInventoryGaps()
#endif
slot->itemIndex = 0;
slot->numItems = 0;
- slot->unk0 = 0;
+ slot->itemFlags = 0;
}
}
-s32 FindItemInInventory(u8 itemIndex)
+s32 FindItemInInventory(u8 itemIndex)
{
s32 i;
for (i = 0; i < INVENTORY_SIZE; i++) {
- if ((gTeamInventory_203B460->teamItems[i].unk0 & 1) && (gTeamInventory_203B460->teamItems[i].itemIndex == itemIndex)) {
+ if ((gTeamInventory_203B460->teamItems[i].itemFlags & ITEM_FLAG_EXISTS) && (gTeamInventory_203B460->teamItems[i].itemIndex == itemIndex)) {
return i;
}
}
return -1;
}
-s32 GetItemCountInInventory(u8 _itemIndex)
+s32 GetItemCountInInventory(u8 _itemIndex)
{
#ifdef NONMATCHING
s32 count = 0;
@@ -533,7 +533,7 @@ s32 GetItemCountInInventory(u8 _itemIndex)
s32 i = 19;
do {
- register u32 unk0 asm("r1") = slot->unk0;
+ register u32 unk0 asm("r1") = slot->itemFlags;
u32 bottom_bit = one;
bottom_bit &= unk0;
if (bottom_bit && (slot->itemIndex == itemIndex)) {
@@ -545,11 +545,11 @@ s32 GetItemCountInInventory(u8 _itemIndex)
#endif
}
-s32 GetItemPossessionCount(u8 itemIndex)
+s32 GetItemPossessionCount(u8 itemIndex)
{
s32 item_count = GetItemCountInInventory(itemIndex);
s32 i = 0;
-
+
struct unkStruct_203B45C *_gRecruitedPokemonRef = gRecruitedPokemonRef;
for (i = 0; i < NUM_SPECIES; i++) {
struct PokemonStruct* pokemon = &_gRecruitedPokemonRef->pokemon[i];
@@ -563,20 +563,20 @@ s32 GetItemPossessionCount(u8 itemIndex)
return item_count;
}
-void ShiftItemsDownFrom(s32 start)
+void ShiftItemsDownFrom(s32 start)
{
s32 i, j;
for (i = start, j = start + 1; i < 19; i++, j++) {
gTeamInventory_203B460->teamItems[i] = gTeamInventory_203B460->teamItems[j];
}
gTeamInventory_203B460->teamItems[19].itemIndex = 0;
- gTeamInventory_203B460->teamItems[19].unk0 = 0;
+ gTeamInventory_203B460->teamItems[19].itemFlags = 0;
}
void ClearItemSlotAt(u32 index)
{
gTeamInventory_203B460->teamItems[index].itemIndex = ITEM_ID_NOTHING;
- gTeamInventory_203B460->teamItems[index].unk0 = 0;
+ gTeamInventory_203B460->teamItems[index].itemFlags = 0;
}
bool8 sub_809124C(u8 itemIndex, u8 param_3)
@@ -586,7 +586,7 @@ bool8 sub_809124C(u8 itemIndex, u8 param_3)
return AddItemToInventory(&temp);
}
-bool8 sub_8091274(struct HeldItem* slot)
+bool8 sub_8091274(struct HeldItem* slot)
{
struct ItemSlot temp;
@@ -594,14 +594,14 @@ bool8 sub_8091274(struct HeldItem* slot)
return AddItemToInventory(&temp);
}
-bool8 AddItemToInventory(const struct ItemSlot* slot)
+bool8 AddItemToInventory(const struct ItemSlot* slot)
{
s32 i;
// try to add item to inventory, return 1 if failed
for (i = 0; i < INVENTORY_SIZE; i++) {
UNUSED struct ItemSlot* current = &gTeamInventory_203B460->teamItems[i];
- if (!(i[gTeamInventory_203B460->teamItems].unk0 & 1)) {
+ if (!(i[gTeamInventory_203B460->teamItems].itemFlags & ITEM_FLAG_EXISTS)) {
gTeamInventory_203B460->teamItems[i] = *slot;
return FALSE;
}
@@ -609,7 +609,7 @@ bool8 AddItemToInventory(const struct ItemSlot* slot)
return TRUE;
}
-void ConvertMoneyItemToMoney()
+void ConvertMoneyItemToMoney()
{
s32 i = 0;
@@ -618,14 +618,14 @@ void ConvertMoneyItemToMoney()
UNUSED size_t offs = offsetof(struct TeamInventory, teamItems[i]);
struct ItemSlot* current_slot = &gTeamInventory_203B460->teamItems[i];
- if ((current_slot->unk0 & 1) && (current_slot->itemIndex == ITEM_ID_POKE)) {
+ if ((current_slot->itemFlags & ITEM_FLAG_EXISTS) && (current_slot->itemIndex == ITEM_ID_POKE)) {
u32 result;
result = GetMoneyValue(current_slot);
AddToTeamMoney(result);
current_slot->itemIndex = 0;
current_slot->numItems = 0;
- current_slot->unk0 = 0;
+ current_slot->itemFlags = 0;
}
} while (++i < INVENTORY_SIZE);
FillInventoryGaps();
@@ -635,9 +635,9 @@ void ConvertMoneyItemToMoney()
s32 lowest_index = -1;
UNUSED size_t offs = offsetof(struct TeamInventory, teamItems[i]);
- bool8 item_occupied = i[gTeamInventory_203B460->teamItems].unk0 & 1;
+ bool8 item_occupied = i[gTeamInventory_203B460->teamItems].itemFlags & ITEM_FLAG_EXISTS;
s32 next = i + 1;
-
+
if (item_occupied) {
s32 lowest_order = GetItemOrder(gTeamInventory_203B460->teamItems[i].itemIndex);
s32 j;
@@ -645,7 +645,7 @@ void ConvertMoneyItemToMoney()
// find next lowest
for (j = next; j < INVENTORY_SIZE; j++) {
UNUSED size_t offs = offsetof(struct TeamInventory, teamItems[j]);
- if ((j[gTeamInventory_203B460->teamItems].unk0 & 1) && (lowest_order > GetItemOrder(gTeamInventory_203B460->teamItems[j].itemIndex))) {
+ if ((j[gTeamInventory_203B460->teamItems].itemFlags & ITEM_FLAG_EXISTS) && (lowest_order > GetItemOrder(gTeamInventory_203B460->teamItems[j].itemIndex))) {
lowest_index = j;
lowest_order = GetItemOrder(gTeamInventory_203B460->teamItems[j].itemIndex);
}
@@ -654,7 +654,7 @@ void ConvertMoneyItemToMoney()
if (lowest_index >= 0) {
// swap the slots
struct ItemSlot current = gTeamInventory_203B460->teamItems[i];
- gTeamInventory_203B460->teamItems[i] = gTeamInventory_203B460->teamItems[lowest_index];
+ gTeamInventory_203B460->teamItems[i] = gTeamInventory_203B460->teamItems[lowest_index];
gTeamInventory_203B460->teamItems[lowest_index] = current;
}
}
@@ -678,12 +678,12 @@ void AddToTeamMoney(s32 amount)
gTeamInventory_203B460->teamMoney = clamped_money;
}
-u16 GetItemMove(u8 index)
+u16 GetItemMove(u8 index)
{
return gItemParametersData[index].move;
}
-u32 sub_80913E0(struct ItemSlot* slot, u32 a2, struct subStruct_203B240 ** a3)
+u32 sub_80913E0(struct ItemSlot* slot, u32 a2, struct subStruct_203B240 ** a3)
{
u8 buffer88[88]; // some struct
@@ -695,7 +695,7 @@ u32 sub_80913E0(struct ItemSlot* slot, u32 a2, struct subStruct_203B240 ** a3)
}
sub_80073B8(a2);
xxx_format_and_draw(16, 0, buffer88, a2, 0);
-
+
xxx_format_and_draw(8, 24, GetItemDescription(slot->itemIndex), a2, 0);
if (GetItemType(slot->itemIndex) == ITEM_TYPE_TM) {
u8* buffer8 = buffer88 + 0x50; // field in struct
@@ -719,7 +719,7 @@ u32 sub_80913E0(struct ItemSlot* slot, u32 a2, struct subStruct_203B240 ** a3)
return sub_8097DF0(GetItemDescription(slot->itemIndex), a3);
}
-bool8 CanSellItem(u32 id)
+bool8 CanSellItem(u32 id)
{
u8 id_;
id = (u8)id;
@@ -738,7 +738,7 @@ bool8 CanSellItem(u32 id)
return FALSE;
}
-bool8 IsNotMoneyOrUsedTMItem(u8 id)
+bool8 IsNotMoneyOrUsedTMItem(u8 id)
{
if (id == ITEM_ID_NOTHING) {
return FALSE;
@@ -752,7 +752,7 @@ bool8 IsNotMoneyOrUsedTMItem(u8 id)
return TRUE;
}
-bool8 IsNotSpecialItem(u8 id)
+bool8 IsNotSpecialItem(u8 id)
{
if (id == ITEM_ID_NOTHING) {
return FALSE;
@@ -775,7 +775,7 @@ bool8 IsNotSpecialItem(u8 id)
return TRUE;
}
-bool8 IsEdibleItem(u8 id)
+bool8 IsEdibleItem(u8 id)
{
if (!((GetItemType(id) == ITEM_TYPE_BERRY_SEED) || (GetItemType(id) == ITEM_TYPE_APPLE_GUMMI))) {
return FALSE;
@@ -783,7 +783,7 @@ bool8 IsEdibleItem(u8 id)
return TRUE;
}
-bool8 IsHMItem(u8 id)
+bool8 IsHMItem(u8 id)
{
if (id == ITEM_ID_CUT) {
return TRUE;
@@ -812,18 +812,18 @@ bool8 IsHMItem(u8 id)
return FALSE;
}
-u32 GetMoneyValue(struct ItemSlot* slot)
+u32 GetMoneyValue(struct ItemSlot* slot)
{
return gUnknown_810A3F0[slot->numItems];
}
-u32 GetMoneyValueHeld(struct HeldItem* slot)
+u32 GetMoneyValueHeld(struct HeldItem* slot)
{
// potentially different slot type (used for held item)
return gUnknown_810A3F0[slot->numItems];
}
-void GetGummiItemStatBoost(struct PokemonStruct* pokemon, u8 itemIndex, u8 a3, struct unkStruct_80915F4* a4)
+void GetGummiItemStatBoost(struct PokemonStruct* pokemon, u8 itemIndex, u8 a3, struct unkStruct_80915F4* a4)
{
// item stat buff?
s8 result;
@@ -917,7 +917,7 @@ void GetGummiItemStatBoost(struct PokemonStruct* pokemon, u8 itemIndex, u8 a3, s
}
}
-bool8 IsGummiItem(u8 itemIndex)
+bool8 IsGummiItem(u8 itemIndex)
{
if (itemIndex < ITEM_ID_WHITE_GUMMI) {
return FALSE;
@@ -928,19 +928,19 @@ bool8 IsGummiItem(u8 itemIndex)
return TRUE;
}
-bool8 HasGummiItem()
+bool8 HasGummiItem()
{
s32 i;
for (i = 0; i < INVENTORY_SIZE; i++) {
UNUSED size_t offs = offsetof(struct TeamInventory, teamItems[i]);
- if ((i[gTeamInventory_203B460->teamItems].unk0 & 1) && IsGummiItem(i[gTeamInventory_203B460->teamItems].itemIndex)) {
+ if ((i[gTeamInventory_203B460->teamItems].itemFlags & ITEM_FLAG_EXISTS) && IsGummiItem(i[gTeamInventory_203B460->teamItems].itemIndex)) {
return TRUE;
}
}
return FALSE;
}
-void MoveToStorage(struct ItemSlot* slot)
+void MoveToStorage(struct ItemSlot* slot)
{
if (IsThrowableItem(slot->itemIndex)) {
gTeamInventory_203B460->teamStorage[slot->itemIndex] += slot->numItems;
@@ -954,7 +954,7 @@ void MoveToStorage(struct ItemSlot* slot)
}
}
-s32 xxx_count_inv_unk230()
+s32 xxx_count_inv_unk230()
{
s32 i;
s32 counter = 0;
@@ -966,7 +966,7 @@ s32 xxx_count_inv_unk230()
return counter;
}
-void xxx_init_unk230_substruct(u8 i)
+void xxx_init_unk230_substruct(u8 i)
{
struct HeldItem* unk230;
@@ -975,7 +975,7 @@ void xxx_init_unk230_substruct(u8 i)
unk230->numItems = 0;
}
-struct HeldItem* xxx_get_inv_unk230_at_809185C(u8 i)
+struct HeldItem* xxx_get_inv_unk230_at_809185C(u8 i)
{
return &gTeamInventory_203B460->unk230[i];
}
@@ -1160,7 +1160,7 @@ bool8 xxx_insert_unk250_8091C1C(u8 itemIndex) {
return TRUE;
}
-s32 SaveTeamInventory(u8* unk0, u32 size)
+s32 SaveTeamInventory(u8* unk0, u32 size)
{
struct unkStruct_8094924 unk;
s32 i;
@@ -1184,7 +1184,7 @@ s32 SaveTeamInventory(u8* unk0, u32 size)
return unk.unk8;
}
-s32 RestoreTeamInventory(u8 *unk0, u32 size)
+s32 RestoreTeamInventory(u8 *unk0, u32 size)
{
struct unkStruct_8094924 unk;
s32 i;
@@ -1214,7 +1214,7 @@ void RestoreHeldItem(struct unkStruct_8094924 *a1, struct HeldItem *item)
RestoreIntegerBits(a1, &item->numItems, 7);
}
-void SaveHeldItem(struct unkStruct_8094924 *a1, struct HeldItem *item)
+void SaveHeldItem(struct unkStruct_8094924 *a1, struct HeldItem *item)
{
SaveIntegerBits(a1, &item->itemIndex, 8);
SaveIntegerBits(a1, &item->numItems, 7);
@@ -1222,24 +1222,24 @@ void SaveHeldItem(struct unkStruct_8094924 *a1, struct HeldItem *item)
void RestoreItemSlot(struct unkStruct_8094924 *a1, struct ItemSlot *slot)
{
- RestoreIntegerBits(a1, &slot->unk0, 8);
+ RestoreIntegerBits(a1, &slot->itemFlags, 8);
RestoreIntegerBits(a1, &slot->numItems, 7);
RestoreIntegerBits(a1, &slot->itemIndex, 8);
}
-void SaveItemSlot(struct unkStruct_8094924 *a1, struct ItemSlot *slot)
+void SaveItemSlot(struct unkStruct_8094924 *a1, struct ItemSlot *slot)
{
- SaveIntegerBits(a1, &slot->unk0, 8);
+ SaveIntegerBits(a1, &slot->itemFlags, 8);
SaveIntegerBits(a1, &slot->numItems, 7);
SaveIntegerBits(a1, &slot->itemIndex, 8);
}
-u32 sub_8091E50(u8 index)
+u32 sub_8091E50(u8 index)
{
return gUnknown_810AF50[index];
}
-u32 xxx_bit_lut_lookup_8091E50(u8 i0, u8 i1)
+u32 xxx_bit_lut_lookup_8091E50(u8 i0, u8 i1)
{
if (i0 > 0x3e)
return 0;
@@ -1266,7 +1266,7 @@ s32 sub_8091E94(s32 a1, s32 a2, s32 a3)
// struct of 12 + 0xf0 (NUMBER_OF_ITEM_IDS) hwords?
struct UnkStruct_8091E94 s1;
- u16 s2[12 + 0xf0];
+ u16 s2[12 + 0xf0];
s32 data_index;
// 30000: level up exp required?
@@ -1471,13 +1471,13 @@ void ClearAllItems_8091FB4() {
for (i = 0; i < INVENTORY_SIZE; i++) {
struct ItemSlot* slot = &gTeamInventory_203B460->teamItems[i];
- if (slot->unk0 & 1) {
- slot->unk0 &= 0xf7;
+ if (slot->itemFlags & ITEM_FLAG_EXISTS) {
+ slot->itemFlags &= 0xf7;
if (slot->itemIndex == ITEM_ID_POKE) {
AddToTeamMoney(GetMoneyValue(slot));
slot->itemIndex = 0;
slot->numItems = 0;
- slot->unk0 = 0;
+ slot->itemFlags = 0;
}
}
}
diff --git a/src/kecleon_items_1.c b/src/kecleon_items_1.c
index b4f1b44..6d73eb0 100644
--- a/src/kecleon_items_1.c
+++ b/src/kecleon_items_1.c
@@ -28,7 +28,7 @@ extern void DrawTeamMoneyBox(u32);
void sub_8019B08(void)
{
- switch(sub_801A6E8(1))
+ switch(sub_801A6E8(1))
{
case 0:
break;
@@ -59,7 +59,7 @@ void sub_8019B08(void)
void sub_8019BBC(void)
{
int menuAction;
-
+
menuAction = 0;
if (gUnknown_203B210->unk4) {
sub_8019EDC(0);
@@ -94,7 +94,7 @@ void sub_8019BBC(void)
void sub_8019C78(void)
{
int menuAction;
-
+
menuAction = 0;
sub_801A6E8(0);
if ((sub_8012FD8(&gUnknown_203B210->unk84) == '\0') && (sub_8013114(&gUnknown_203B210->unk84,&menuAction), menuAction != 1)) {
@@ -176,12 +176,12 @@ void sub_8019DAC(void)
s32 iVar3;
struct ItemSlot *pbVar4;
s32 iVar5;
-
+
gUnknown_203B210->unk14 = 0;
gUnknown_203B210->unk18 = 0;
for(iVar5 = 0; iVar5 < 0x14; iVar5++){
pbVar4 = &gTeamInventory_203B460->teamItems[iVar5];
- if (((pbVar4->unk0 & 1) != 0) && (CanSellItem(pbVar4->itemIndex))) {
+ if (((pbVar4->itemFlags & ITEM_FLAG_EXISTS) != 0) && (CanSellItem(pbVar4->itemIndex))) {
iVar3 = GetStackSellPrice(pbVar4);
gUnknown_203B210->unk18 += iVar3;
gUnknown_203B210->unk14++;
@@ -191,7 +191,7 @@ void sub_8019DAC(void)
void sub_8019E04(s32 param_1)
{
-
+
if (gUnknown_203B210->unk4) {
if (param_1 == 1)
gUnknown_203B210->unkE0 = 1;
diff --git a/src/pokemon_mid.c b/src/pokemon_mid.c
index e774836..0af12d0 100644
--- a/src/pokemon_mid.c
+++ b/src/pokemon_mid.c
@@ -54,7 +54,7 @@ extern const char gUnknown_8107684[];
extern struct unkStruct_203B45C *gRecruitedPokemonRef;
-bool8 sub_808D6E8()
+bool8 sub_808D6E8()
{
s32 i;
s32 count = 0;
@@ -253,12 +253,12 @@ void sub_808D930(u8 *buffer, s16 index)
char *unownString;
s32 unownIndex;
const char *preload;
-
+
if (GetBaseSpecies(index) == SPECIES_UNOWN) {
preload = gUnknown_8107630; // %s%c
unownString = GetMonSpecies(SPECIES_UNOWN);
unownIndex = GetUnownIndex(index);
- ExpandPlaceholdersBuffer(buffer,preload,unownString,gUnownLetters[unownIndex]); // ABCDEFGHIJKLMNOPQRSTUVWXYZ!?
+ ExpandPlaceholdersBuffer(buffer,preload,unownString,gUnownLetters[unownIndex]); // ABCDEFGHIJKLMNOPQRSTUVWXYZ!?
}
else {
ExpandPlaceholdersBuffer(buffer,gUnknown_8107638, gMonsterParameters[index].species); // %s
@@ -305,7 +305,7 @@ void sub_808DA34(u8 *buffer, struct PokemonStruct *pokemon)
sub_80922B4(buffer, pokemon->name, POKEMON_NAME_LENGTH);
}
-bool8 sub_808DA44(s32 a1_, u32 a2_)
+bool8 sub_808DA44(s32 a1_, u32 a2_)
{
// this is the dumbest thing ever, but just making a1 a s16 and
// a2 a u8 did weird stuff with shifting...
@@ -388,9 +388,9 @@ u16 GetBaseHP(s16 index)
return gMonsterParameters[index].base_hp;
}
-bool8 GetUnk33(s16 index)
+bool8 IsToolboxEnabled(s16 index)
{
- return gMonsterParameters[index].unk33;
+ return gMonsterParameters[index].toolboxEnabled;
}
u8 GetUnk12(s16 index)
@@ -472,7 +472,7 @@ u8 GetPokemonOverworldPalette(s16 index, u32 r1)
{
return 10;
}
- else
+ else
{
return gMonsterParameters[temp].overworld_palette;
}
@@ -547,7 +547,7 @@ void xxx_pokemonstruct_to_pokemon2_808DE50(struct PokemonStruct2 * a1, struct Po
for (i = 0; i < 10; i++) {
a1->name[i] = pokemon->name[i];
}
-
+
held = &pokemon->heldItem;
slot = &a1->itemSlot;
@@ -557,8 +557,8 @@ void xxx_pokemonstruct_to_pokemon2_808DE50(struct PokemonStruct2 * a1, struct Po
else {
slot->itemIndex = 0;
slot->numItems = 0;
- slot->unk0 = 0;
- }
+ slot->itemFlags = 0;
+ }
sub_80943A0(&somestruct_80943A0, 100);
a1->unk44 = somestruct_80943A0;
sub_80943A0(&somestruct2_80943A0, 100);
@@ -599,7 +599,7 @@ void xxx_pokemon2_to_pokemonstruct_808DF44(struct PokemonStruct* pokemon, struct
pokemon->name[i] = a2->name[i];
}
- if (a2->itemSlot.unk0 & 1) {
+ if (a2->itemSlot.itemFlags & ITEM_FLAG_EXISTS) {
SlotToHeldItem(&pokemon->heldItem, &a2->itemSlot);
}
else {
@@ -611,7 +611,7 @@ void sub_808DFDC(s32 a1, struct PokemonStruct2* a2)
{
// transfer item from unk to pokemon at index
struct PokemonStruct* pokemon = &gRecruitedPokemonRef->pokemon[a1];
- if (a2->itemSlot.unk0 & 1) {
+ if (a2->itemSlot.itemFlags & ITEM_FLAG_EXISTS) {
SlotToHeldItem(&pokemon->heldItem, &a2->itemSlot);
}
else {
@@ -675,7 +675,7 @@ s32 sub_808E0AC(u16* a1, s16 species, s32 a3, s32 a4)
u16 result; // struct?
s32 count;
register s32 _species asm("r2"); // weird regalloc
-
+
_species = (s16)species;
count = 0;
@@ -716,13 +716,13 @@ s32 sub_808E0AC(u16* a1, s16 species, s32 a3, s32 a4)
return count;
}
-bool8 sub_808E190(u16 a1, s16 _species)
+bool8 sub_808E190(u16 a1, s16 _species)
{
u16 result;
u16 result2;
s32 species = _species; // r4
u8* ptr;
-
+
if (species == SPECIES_DECOY) return 0;
if (species == SPECIES_NONE) return 0;
if (species == SPECIES_MUNCHLAX) return 0;
@@ -748,7 +748,7 @@ bool8 sub_808E190(u16 a1, s16 _species)
}
-s32 sub_808E218(struct unkStruct_808E218_arg* a1, struct PokemonStruct* pokemon)
+s32 sub_808E218(struct unkStruct_808E218_arg* a1, struct PokemonStruct* pokemon)
{
s32 i;
s32 count;
@@ -810,7 +810,7 @@ s32 sub_808E218(struct unkStruct_808E218_arg* a1, struct PokemonStruct* pokemon)
}
-s32 GetEvolutionSequence(struct PokemonStruct* pokemon, struct EvolveStage* a2)
+s32 GetEvolutionSequence(struct PokemonStruct* pokemon, struct EvolveStage* a2)
{
#ifdef NONMATCHING
s32 count;
@@ -872,7 +872,7 @@ s32 GetEvolutionSequence(struct PokemonStruct* pokemon, struct EvolveStage* a2)
#endif
}
-s32 sub_808E400(s32 _species, s16* _a2, s32 _a3, s32 _a4)
+s32 sub_808E400(s32 _species, s16* _a2, s32 _a3, s32 _a4)
{
// this is horrible
s32 i;
@@ -900,7 +900,7 @@ s32 sub_808E400(s32 _species, s16* _a2, s32 _a3, s32 _a4)
return count;
}
-void sub_808E490(struct unkPokeSubStruct_2C* a1, s16 species)
+void sub_808E490(struct unkPokeSubStruct_2C* a1, s16 species)
{
u16 buffer[0x10];
s32 i;
@@ -924,16 +924,16 @@ void sub_808E490(struct unkPokeSubStruct_2C* a1, s16 species)
}
}
-char* sub_808E4FC(s32 a1)
+char* sub_808E4FC(s32 a1)
{
- struct subStruct_203B240 *result[4];
+ struct subStruct_203B240 *result[4];
sub_8097DF0(gFormattedStatusNames[a1], result);
return result[0]->unk0;
}
-char* sub_808E51C(s32 a1)
+char* sub_808E51C(s32 a1)
{
- struct subStruct_203B240 *result[4];
+ struct subStruct_203B240 *result[4];
sub_8097DF0(gFormattedStatusNames[a1], result);
return result[0]->unk4;
}
diff --git a/src/thank_you_wonder_mail.c b/src/thank_you_wonder_mail.c
index 4e26b46..745d682 100644
--- a/src/thank_you_wonder_mail.c
+++ b/src/thank_you_wonder_mail.c
@@ -41,7 +41,7 @@ extern struct TeamInventory *gTeamInventory_203B460;
#define PROCESS_THANK_YOU_PASSWORD 0x27
#define THANK_YOU_PASSWORD_WRONG 0x28
-const struct ItemSlot gUnknown_80DED44 =
+const struct ItemSlot gUnknown_80DED44 =
{
1, 0, 0
};
@@ -50,7 +50,7 @@ extern char gUnknown_202E5D8[0x50];
extern char gAvailablePokemonNames[0x50];
-const struct UnkTextStruct2 gUnknown_80DED48 =
+const struct UnkTextStruct2 gUnknown_80DED48 =
{
0x00, 0x00, 0x00, 0x00,
0x03, 0x00, 0x00, 0x00,
@@ -60,7 +60,7 @@ const struct UnkTextStruct2 gUnknown_80DED48 =
NULL
};
-const struct UnkTextStruct2 gUnknown_80DED60 =
+const struct UnkTextStruct2 gUnknown_80DED60 =
{
0x00, 0x00, 0x00, 0x00,
0x03, 0x00, 0x00, 0x00,
@@ -83,7 +83,7 @@ extern const u8 SendItem_Text[];
extern const u8 DontSendItem_Text[];
extern const u8 SendWOItem_Text[];
-const struct MenuItem gUnknown_80DED78[3] =
+const struct MenuItem gUnknown_80DED78[3] =
{
{Confirm_80DED98, 0xB},
{Info_80DED90, 0xC},
@@ -94,7 +94,7 @@ ALIGNED(4) const u8 Info_80DED90[] = "Info";
ALIGNED(4) const u8 Confirm_80DED98[] = "Confirm";
// Unused
-const struct UnkTextStruct2 gUnknown_80DEDA0 =
+const struct UnkTextStruct2 gUnknown_80DEDA0 =
{
0x00, 0x00, 0x00, 0x00,
0x03, 0x00, 0x00, 0x00,
@@ -105,7 +105,7 @@ const struct UnkTextStruct2 gUnknown_80DEDA0 =
};
-const struct MenuItem gThankYouMailMainMenuItems[4] =
+const struct MenuItem gThankYouMailMainMenuItems[4] =
{
{SendThankYou_Text, 0x1},
{GetThankYou_Text, 0x2},
@@ -117,7 +117,7 @@ ALIGNED(4) const u8 Cancel_80DEDD8[] = "Cancel";
ALIGNED(4) const u8 GetThankYou_Text[] = "Get Thank-You Mail";
ALIGNED(4) const u8 SendThankYou_Text[] = "Send Thank-You Mail";
-const struct MenuItem gUnknown_80DEE08[4] =
+const struct MenuItem gUnknown_80DEE08[4] =
{
{GameLinkCable_Text, WONDER_MAIL_GAME_LINK},
{Password_Text, WONDER_MAIL_PASSWORD},
@@ -128,7 +128,7 @@ const struct MenuItem gUnknown_80DEE08[4] =
ALIGNED(4) const u8 Password_Text[] = "Password";
ALIGNED(4) const u8 GameLinkCable_Text[] = "Game Link cable";
-const struct MenuItem gUnknown_80DEE44[3] =
+const struct MenuItem gUnknown_80DEE44[3] =
{
{Yes_80DEE5C, 0x7},
{Cancel_80DEDD8, 0x0},
@@ -138,7 +138,7 @@ const struct MenuItem gUnknown_80DEE44[3] =
ALIGNED(4) const u8 Yes_80DEE5C[] = "Yes";
-const struct MenuItem gUnknown_80DEE60[3] =
+const struct MenuItem gUnknown_80DEE60[3] =
{
{Yes_80DEE5C, 0x7},
{No_80DEE78, 0x8},
@@ -147,7 +147,7 @@ const struct MenuItem gUnknown_80DEE60[3] =
ALIGNED(4) const u8 No_80DEE78[] = "No";
-const struct MenuItem gUnknown_80DEE7C[4] =
+const struct MenuItem gUnknown_80DEE7C[4] =
{
{SendItem_Text, 0x9},
{DontSendItem_Text, 0xA},
@@ -158,7 +158,7 @@ const struct MenuItem gUnknown_80DEE7C[4] =
ALIGNED(4) const u8 DontSendItem_Text[] = "Don~27t Send Item";
ALIGNED(4) const u8 SendItem_Text[] = "Send Item";
-const struct MenuItem gUnknown_80DEEBC[3] =
+const struct MenuItem gUnknown_80DEEBC[3] =
{
{SendWOItem_Text, 0xA},
{Cancel_80DEDD8, 0x0},
@@ -167,7 +167,7 @@ const struct MenuItem gUnknown_80DEEBC[3] =
ALIGNED(4) const u8 SendWOItem_Text[] = "Send w/o Item";
-const struct MenuItem gUnknown_80DEEE4[4] =
+const struct MenuItem gUnknown_80DEEE4[4] =
{
{Yes_80DEE5C, 0x7},
{No_80DEE78, 0x8},
@@ -594,7 +594,7 @@ u32 ThankYouMailPelipperCallback(void)
case 0x20:
ExitThankYouMailMenu2();
break;
- case THANK_YOU_MAIL_COMMS_CLEANUP:
+ case THANK_YOU_MAIL_COMMS_CLEANUP:
ExitThankYouMailMenu1();
break;
case CONFIRM_ITEM_TO_SEND:
@@ -715,9 +715,9 @@ void DisplayThankYouMailCommsOutcome(void)
MemoryFill8((u8 *)&gUnknown_203B2C4->unk41C, 0, sizeof(struct ItemSlot));
gUnknown_203B2C4->unk41C.itemIndex = 0;
gUnknown_203B2C4->unk41C.numItems = 1;
- gUnknown_203B2C4->unk41C.unk0 = 0;
+ gUnknown_203B2C4->unk41C.itemFlags = 0;
if (gUnknown_203B2C4->linkError == 0) {
- switch(gUnknown_203B2C4->unk40)
+ switch(gUnknown_203B2C4->unk40)
{
case 6:
switch(gUnknown_203B2C4->wonderMailMethod)
@@ -830,7 +830,7 @@ void sub_802A174(void)
if (sub_8012FD8(&gUnknown_203B2C4->unk30C) == 0) {
sub_8013114(&gUnknown_203B2C4->unk30C, &menuAction);
}
-
+
switch(menuAction)
{
case 0xB:
@@ -856,7 +856,7 @@ void sub_802A174(void)
}
void sub_802A230(void)
-{
+{
switch(sub_8030DA0())
{
case 2:
@@ -883,7 +883,7 @@ void sub_802A28C(void)
gUnknown_203B2C4->unk41C.itemIndex = 0;
gUnknown_203B2C4->unk41C.numItems = 1;
- gUnknown_203B2C4->unk41C.unk0 = 0;
+ gUnknown_203B2C4->unk41C.itemFlags = 0;
switch(sub_801CA08(1))
{
@@ -1033,7 +1033,7 @@ void HandleThankYouMailPasswordMenu(void)
switch(return_var)
{
case 3:
- switch(sub_8039068(0x20,gUnknown_203B2C4->passwordBuffer,&temp.unk0))
+ switch(sub_8039068(0x20,gUnknown_203B2C4->passwordBuffer,&temp.unk0))
{
case 0x11:
// Wrong password
diff --git a/src/trade_items_menu.c b/src/trade_items_menu.c
index e1c2241..d0c4598 100644
--- a/src/trade_items_menu.c
+++ b/src/trade_items_menu.c
@@ -51,8 +51,8 @@ extern void sub_8035CC0(struct UnkTextStruct2 *, u32);
extern void sub_801CCD8();
extern u32 sub_801B410();
extern void sub_801B450();
-extern void sub_801CB5C(u32);
-extern void sub_8035CF4(u32 *, u32, u32);
+extern void sub_801CB5C(u32);
+extern void sub_8035CF4(u32 *, u32, u32);
extern u32 sub_8013BBC(u32 *);
extern void sub_80141B4(u32 *, u32, u32, u32);
@@ -113,7 +113,7 @@ enum TradeItemsModes
s32 CreateTradeItemsMenu(void)
{
-
+
ResetUnusedInputStruct();
sub_800641C(0,1,1);
gTradeItemsMenu = MemoryAlloc(sizeof(struct TradeItemsMenu), 8);
@@ -127,7 +127,7 @@ s32 CreateTradeItemsMenu(void)
s32 UpdateTradeItemsMenu(void)
{
-
+
switch(gTradeItemsMenu->currMenu) {
case TRADE_ITEMS_MAIN_MENU:
TradeItem_MainMenu();
@@ -192,7 +192,7 @@ s32 UpdateTradeItemsMenu(void)
void TradeItem_MainMenu(void)
{
s32 menuAction;
-
+
if (sub_80144A4(&menuAction) == 0) {
switch(menuAction)
{
@@ -219,16 +219,16 @@ void TradeItem_MainMenu(void)
void sub_8036590(void)
{
s32 iVar1;
-
+
if (sub_80144A4(&iVar1) == 0)
SetTradeItemMenu(TRADE_ITEMS_SEND_ITEM_SELECTION);
}
void sub_80365AC(void)
-{
+{
gTradeItemsMenu->itemToSend.itemIndex = 0;
gTradeItemsMenu->itemToSend.numItems = 1;
- gTradeItemsMenu->itemToSend.unk0 = 0;
+ gTradeItemsMenu->itemToSend.itemFlags = 0;
switch(sub_801CA08(1)){
case 2:
// Cancel
@@ -257,7 +257,7 @@ void sub_80365AC(void)
void sub_8036674(void)
{
int menuAction;
-
+
menuAction = -1;
sub_801CA08(0);
if (sub_8012FD8(&gTradeItemsMenu->unk134) == '\0') {
@@ -309,7 +309,7 @@ void sub_8036728(void)
}
void sub_8036788(void)
-{
+{
sub_8012FD8(&gTradeItemsMenu->unk134);
sub_801CA08(0);
switch(sub_8013BBC(&gTradeItemsMenu->numItemsToSend)){
@@ -344,7 +344,7 @@ void TradeItem_SendItemConfirm(void)
int menuAction;
u16 load;
- if (sub_80144A4(&menuAction) == 0)
+ if (sub_80144A4(&menuAction) == 0)
{
switch(menuAction){
case 5:
@@ -447,7 +447,7 @@ void sub_8036950(void)
void TradeItem_AddItem(void)
{
- // Use temp var to get correct statements
+ // Use temp var to get correct statements
u16 load;
load = gTeamInventory_203B460->teamStorage[gTradeItemsMenu->sentItem.itemIdx.itemIndex];
load += gTradeItemsMenu->sentItem.numItems;
@@ -558,7 +558,7 @@ void sub_8036B28(void)
u32 load_2;
struct TradeSubStruct *temp;
struct TradeSubStruct *temp2;
-
+
switch(gTradeItemsMenu->currMenu) {
case 0:
if (sub_801CF14(0) != '\0') {
diff --git a/src/wonder_mail.c b/src/wonder_mail.c
index ed52bb2..29cd2bc 100644
--- a/src/wonder_mail.c
+++ b/src/wonder_mail.c
@@ -145,7 +145,7 @@ void sub_8028B1C(u32 r0)
}
void sub_8028BF0(void)
-{
+{
u32 temp;
if(sub_80144A4(&temp) != 0)
{
@@ -1199,4 +1199,3 @@ void sub_8029B34(void)
}
sub_8028B04(3);
}
-
diff --git a/sym_ewram2.txt b/sym_ewram2.txt
index 455c065..61444a8 100644
--- a/sym_ewram2.txt
+++ b/sym_ewram2.txt
@@ -545,7 +545,7 @@ gUnknown_203B410 = .; /* 203B410 */
gUnknown_203B414 = .; /* 203B414 */
. += 0x4;
-gUnknown_203B418 = .; /* 203B418 */
+gDungeonGlobalData = .; /* 203B418 */
. += 0x4;
gUnknown_203B41C = .; /* 203B41C */
diff --git a/tools/aif2pcm/.gitignore b/tools/aif2pcm/.gitignore
index e6f739c..3153179 100644
--- a/tools/aif2pcm/.gitignore
+++ b/tools/aif2pcm/.gitignore
@@ -1,2 +1,2 @@
-aif2pcm
-
+aif2pcm
+
diff --git a/tools/bin2c/.gitignore b/tools/bin2c/.gitignore
index 4ab7f6f..366f3d3 100644
--- a/tools/bin2c/.gitignore
+++ b/tools/bin2c/.gitignore
@@ -1 +1 @@
-bin2c
+bin2c
diff --git a/tools/br_ips/.gitignore b/tools/br_ips/.gitignore
index 8ed5798..f3fb144 100644
--- a/tools/br_ips/.gitignore
+++ b/tools/br_ips/.gitignore
@@ -1,2 +1,2 @@
-br_ips
-ips_patch
+br_ips
+ips_patch
diff --git a/tools/dungeonjson/.gitignore b/tools/dungeonjson/.gitignore
index 2980942..3a9416d 100644
--- a/tools/dungeonjson/.gitignore
+++ b/tools/dungeonjson/.gitignore
@@ -1 +1 @@
-dungeonjson
+dungeonjson
diff --git a/tools/dungeonjson/json11.cpp b/tools/dungeonjson/json11.cpp
index d66cb61..1da5302 100644
--- a/tools/dungeonjson/json11.cpp
+++ b/tools/dungeonjson/json11.cpp
@@ -1,786 +1,786 @@
-/* Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-#include "json11.h"
-#include <cassert>
-#include <cmath>
-#include <cstdlib>
-#include <cstdio>
-#include <limits>
-
-namespace json11 {
-
-static const int max_depth = 200;
-
-using std::string;
-using std::vector;
-using std::map;
-using std::make_shared;
-using std::initializer_list;
-using std::move;
-
-/* Helper for representing null - just a do-nothing struct, plus comparison
- * operators so the helpers in JsonValue work. We can't use nullptr_t because
- * it may not be orderable.
- */
-struct NullStruct {
- bool operator==(NullStruct) const { return true; }
- bool operator<(NullStruct) const { return false; }
-};
-
-/* * * * * * * * * * * * * * * * * * * *
- * Serialization
- */
-
-static void dump(NullStruct, string &out) {
- out += "null";
-}
-
-static void dump(double value, string &out) {
- if (std::isfinite(value)) {
- char buf[32];
- snprintf(buf, sizeof buf, "%.17g", value);
- out += buf;
- } else {
- out += "null";
- }
-}
-
-static void dump(int value, string &out) {
- char buf[32];
- snprintf(buf, sizeof buf, "%d", value);
- out += buf;
-}
-
-static void dump(bool value, string &out) {
- out += value ? "true" : "false";
-}
-
-static void dump(const string &value, string &out) {
- out += '"';
- for (size_t i = 0; i < value.length(); i++) {
- const char ch = value[i];
- if (ch == '\\') {
- out += "\\\\";
- } else if (ch == '"') {
- out += "\\\"";
- } else if (ch == '\b') {
- out += "\\b";
- } else if (ch == '\f') {
- out += "\\f";
- } else if (ch == '\n') {
- out += "\\n";
- } else if (ch == '\r') {
- out += "\\r";
- } else if (ch == '\t') {
- out += "\\t";
- } else if (static_cast<uint8_t>(ch) <= 0x1f) {
- char buf[8];
- snprintf(buf, sizeof buf, "\\u%04x", ch);
- out += buf;
- } else if (static_cast<uint8_t>(ch) == 0xe2 && static_cast<uint8_t>(value[i+1]) == 0x80
- && static_cast<uint8_t>(value[i+2]) == 0xa8) {
- out += "\\u2028";
- i += 2;
- } else if (static_cast<uint8_t>(ch) == 0xe2 && static_cast<uint8_t>(value[i+1]) == 0x80
- && static_cast<uint8_t>(value[i+2]) == 0xa9) {
- out += "\\u2029";
- i += 2;
- } else {
- out += ch;
- }
- }
- out += '"';
-}
-
-static void dump(const Json::array &values, string &out) {
- bool first = true;
- out += "[";
- for (const auto &value : values) {
- if (!first)
- out += ", ";
- value.dump(out);
- first = false;
- }
- out += "]";
-}
-
-static void dump(const Json::object &values, string &out) {
- bool first = true;
- out += "{";
- for (const auto &kv : values) {
- if (!first)
- out += ", ";
- dump(kv.first, out);
- out += ": ";
- kv.second.dump(out);
- first = false;
- }
- out += "}";
-}
-
-void Json::dump(string &out) const {
- m_ptr->dump(out);
-}
-
-/* * * * * * * * * * * * * * * * * * * *
- * Value wrappers
- */
-
-template <Json::Type tag, typename T>
-class Value : public JsonValue {
-protected:
-
- // Constructors
- explicit Value(const T &value) : m_value(value) {}
- explicit Value(T &&value) : m_value(move(value)) {}
-
- // Get type tag
- Json::Type type() const override {
- return tag;
- }
-
- // Comparisons
- bool equals(const JsonValue * other) const override {
- return m_value == static_cast<const Value<tag, T> *>(other)->m_value;
- }
- bool less(const JsonValue * other) const override {
- return m_value < static_cast<const Value<tag, T> *>(other)->m_value;
- }
-
- const T m_value;
- void dump(string &out) const override { json11::dump(m_value, out); }
-};
-
-class JsonDouble final : public Value<Json::NUMBER, double> {
- double number_value() const override { return m_value; }
- int int_value() const override { return static_cast<int>(m_value); }
- bool equals(const JsonValue * other) const override { return m_value == other->number_value(); }
- bool less(const JsonValue * other) const override { return m_value < other->number_value(); }
-public:
- explicit JsonDouble(double value) : Value(value) {}
-};
-
-class JsonInt final : public Value<Json::NUMBER, int> {
- double number_value() const override { return m_value; }
- int int_value() const override { return m_value; }
- bool equals(const JsonValue * other) const override { return m_value == other->number_value(); }
- bool less(const JsonValue * other) const override { return m_value < other->number_value(); }
-public:
- explicit JsonInt(int value) : Value(value) {}
-};
-
-class JsonBoolean final : public Value<Json::BOOL, bool> {
- bool bool_value() const override { return m_value; }
-public:
- explicit JsonBoolean(bool value) : Value(value) {}
-};
-
-class JsonString final : public Value<Json::STRING, string> {
- const string &string_value() const override { return m_value; }
-public:
- explicit JsonString(const string &value) : Value(value) {}
- explicit JsonString(string &&value) : Value(move(value)) {}
-};
-
-class JsonArray final : public Value<Json::ARRAY, Json::array> {
- const Json::array &array_items() const override { return m_value; }
- const Json & operator[](size_t i) const override;
-public:
- explicit JsonArray(const Json::array &value) : Value(value) {}
- explicit JsonArray(Json::array &&value) : Value(move(value)) {}
-};
-
-class JsonObject final : public Value<Json::OBJECT, Json::object> {
- const Json::object &object_items() const override { return m_value; }
- const Json & operator[](const string &key) const override;
-public:
- explicit JsonObject(const Json::object &value) : Value(value) {}
- explicit JsonObject(Json::object &&value) : Value(move(value)) {}
-};
-
-class JsonNull final : public Value<Json::NUL, NullStruct> {
-public:
- JsonNull() : Value({}) {}
-};
-
-/* * * * * * * * * * * * * * * * * * * *
- * Static globals - static-init-safe
- */
-struct Statics {
- const std::shared_ptr<JsonValue> null = make_shared<JsonNull>();
- const std::shared_ptr<JsonValue> t = make_shared<JsonBoolean>(true);
- const std::shared_ptr<JsonValue> f = make_shared<JsonBoolean>(false);
- const string empty_string;
- const vector<Json> empty_vector;
- const map<string, Json> empty_map;
- Statics() {}
-};
-
-static const Statics & statics() {
- static const Statics s {};
- return s;
-}
-
-static const Json & static_null() {
- // This has to be separate, not in Statics, because Json() accesses statics().null.
- static const Json json_null;
- return json_null;
-}
-
-/* * * * * * * * * * * * * * * * * * * *
- * Constructors
- */
-
-Json::Json() noexcept : m_ptr(statics().null) {}
-Json::Json(std::nullptr_t) noexcept : m_ptr(statics().null) {}
-Json::Json(double value) : m_ptr(make_shared<JsonDouble>(value)) {}
-Json::Json(int value) : m_ptr(make_shared<JsonInt>(value)) {}
-Json::Json(bool value) : m_ptr(value ? statics().t : statics().f) {}
-Json::Json(const string &value) : m_ptr(make_shared<JsonString>(value)) {}
-Json::Json(string &&value) : m_ptr(make_shared<JsonString>(move(value))) {}
-Json::Json(const char * value) : m_ptr(make_shared<JsonString>(value)) {}
-Json::Json(const Json::array &values) : m_ptr(make_shared<JsonArray>(values)) {}
-Json::Json(Json::array &&values) : m_ptr(make_shared<JsonArray>(move(values))) {}
-Json::Json(const Json::object &values) : m_ptr(make_shared<JsonObject>(values)) {}
-Json::Json(Json::object &&values) : m_ptr(make_shared<JsonObject>(move(values))) {}
-
-/* * * * * * * * * * * * * * * * * * * *
- * Accessors
- */
-
-Json::Type Json::type() const { return m_ptr->type(); }
-double Json::number_value() const { return m_ptr->number_value(); }
-int Json::int_value() const { return m_ptr->int_value(); }
-bool Json::bool_value() const { return m_ptr->bool_value(); }
-const string & Json::string_value() const { return m_ptr->string_value(); }
-const vector<Json> & Json::array_items() const { return m_ptr->array_items(); }
-const map<string, Json> & Json::object_items() const { return m_ptr->object_items(); }
-const Json & Json::operator[] (size_t i) const { return (*m_ptr)[i]; }
-const Json & Json::operator[] (const string &key) const { return (*m_ptr)[key]; }
-
-double JsonValue::number_value() const { return 0; }
-int JsonValue::int_value() const { return 0; }
-bool JsonValue::bool_value() const { return false; }
-const string & JsonValue::string_value() const { return statics().empty_string; }
-const vector<Json> & JsonValue::array_items() const { return statics().empty_vector; }
-const map<string, Json> & JsonValue::object_items() const { return statics().empty_map; }
-const Json & JsonValue::operator[] (size_t) const { return static_null(); }
-const Json & JsonValue::operator[] (const string &) const { return static_null(); }
-
-const Json & JsonObject::operator[] (const string &key) const {
- auto iter = m_value.find(key);
- return (iter == m_value.end()) ? static_null() : iter->second;
-}
-const Json & JsonArray::operator[] (size_t i) const {
- if (i >= m_value.size()) return static_null();
- else return m_value[i];
-}
-
-/* * * * * * * * * * * * * * * * * * * *
- * Comparison
- */
-
-bool Json::operator== (const Json &other) const {
- if (m_ptr == other.m_ptr)
- return true;
- if (m_ptr->type() != other.m_ptr->type())
- return false;
-
- return m_ptr->equals(other.m_ptr.get());
-}
-
-bool Json::operator< (const Json &other) const {
- if (m_ptr == other.m_ptr)
- return false;
- if (m_ptr->type() != other.m_ptr->type())
- return m_ptr->type() < other.m_ptr->type();
-
- return m_ptr->less(other.m_ptr.get());
-}
-
-/* * * * * * * * * * * * * * * * * * * *
- * Parsing
- */
-
-/* esc(c)
- *
- * Format char c suitable for printing in an error message.
- */
-static inline string esc(char c) {
- char buf[12];
- if (static_cast<uint8_t>(c) >= 0x20 && static_cast<uint8_t>(c) <= 0x7f) {
- snprintf(buf, sizeof buf, "'%c' (%d)", c, c);
- } else {
- snprintf(buf, sizeof buf, "(%d)", c);
- }
- return string(buf);
-}
-
-static inline bool in_range(long x, long lower, long upper) {
- return (x >= lower && x <= upper);
-}
-
-namespace {
-/* JsonParser
- *
- * Object that tracks all state of an in-progress parse.
- */
-struct JsonParser final {
-
- /* State
- */
- const string &str;
- size_t i;
- string &err;
- bool failed;
- const JsonParse strategy;
-
- /* fail(msg, err_ret = Json())
- *
- * Mark this parse as failed.
- */
- Json fail(string &&msg) {
- return fail(move(msg), Json());
- }
-
- template <typename T>
- T fail(string &&msg, const T err_ret) {
- if (!failed)
- err = std::move(msg);
- failed = true;
- return err_ret;
- }
-
- /* consume_whitespace()
- *
- * Advance until the current character is non-whitespace.
- */
- void consume_whitespace() {
- while (str[i] == ' ' || str[i] == '\r' || str[i] == '\n' || str[i] == '\t')
- i++;
- }
-
- /* consume_comment()
- *
- * Advance comments (c-style inline and multiline).
- */
- bool consume_comment() {
- bool comment_found = false;
- if (str[i] == '/') {
- i++;
- if (i == str.size())
- return fail("unexpected end of input after start of comment", false);
- if (str[i] == '/') { // inline comment
- i++;
- // advance until next line, or end of input
- while (i < str.size() && str[i] != '\n') {
- i++;
- }
- comment_found = true;
- }
- else if (str[i] == '*') { // multiline comment
- i++;
- if (i > str.size()-2)
- return fail("unexpected end of input inside multi-line comment", false);
- // advance until closing tokens
- while (!(str[i] == '*' && str[i+1] == '/')) {
- i++;
- if (i > str.size()-2)
- return fail(
- "unexpected end of input inside multi-line comment", false);
- }
- i += 2;
- comment_found = true;
- }
- else
- return fail("malformed comment", false);
- }
- return comment_found;
- }
-
- /* consume_garbage()
- *
- * Advance until the current character is non-whitespace and non-comment.
- */
- void consume_garbage() {
- consume_whitespace();
- if(strategy == JsonParse::COMMENTS) {
- bool comment_found = false;
- do {
- comment_found = consume_comment();
- if (failed) return;
- consume_whitespace();
- }
- while(comment_found);
- }
- }
-
- /* get_next_token()
- *
- * Return the next non-whitespace character. If the end of the input is reached,
- * flag an error and return 0.
- */
- char get_next_token() {
- consume_garbage();
- if (failed) return static_cast<char>(0);
- if (i == str.size())
- return fail("unexpected end of input", static_cast<char>(0));
-
- return str[i++];
- }
-
- /* encode_utf8(pt, out)
- *
- * Encode pt as UTF-8 and add it to out.
- */
- void encode_utf8(long pt, string & out) {
- if (pt < 0)
- return;
-
- if (pt < 0x80) {
- out += static_cast<char>(pt);
- } else if (pt < 0x800) {
- out += static_cast<char>((pt >> 6) | 0xC0);
- out += static_cast<char>((pt & 0x3F) | 0x80);
- } else if (pt < 0x10000) {
- out += static_cast<char>((pt >> 12) | 0xE0);
- out += static_cast<char>(((pt >> 6) & 0x3F) | 0x80);
- out += static_cast<char>((pt & 0x3F) | 0x80);
- } else {
- out += static_cast<char>((pt >> 18) | 0xF0);
- out += static_cast<char>(((pt >> 12) & 0x3F) | 0x80);
- out += static_cast<char>(((pt >> 6) & 0x3F) | 0x80);
- out += static_cast<char>((pt & 0x3F) | 0x80);
- }
- }
-
- /* parse_string()
- *
- * Parse a string, starting at the current position.
- */
- string parse_string() {
- string out;
- long last_escaped_codepoint = -1;
- while (true) {
- if (i == str.size())
- return fail("unexpected end of input in string", "");
-
- char ch = str[i++];
-
- if (ch == '"') {
- encode_utf8(last_escaped_codepoint, out);
- return out;
- }
-
- if (in_range(ch, 0, 0x1f))
- return fail("unescaped " + esc(ch) + " in string", "");
-
- // The usual case: non-escaped characters
- if (ch != '\\') {
- encode_utf8(last_escaped_codepoint, out);
- last_escaped_codepoint = -1;
- out += ch;
- continue;
- }
-
- // Handle escapes
- if (i == str.size())
- return fail("unexpected end of input in string", "");
-
- ch = str[i++];
-
- if (ch == 'u') {
- // Extract 4-byte escape sequence
- string esc = str.substr(i, 4);
- // Explicitly check length of the substring. The following loop
- // relies on std::string returning the terminating NUL when
- // accessing str[length]. Checking here reduces brittleness.
- if (esc.length() < 4) {
- return fail("bad \\u escape: " + esc, "");
- }
- for (size_t j = 0; j < 4; j++) {
- if (!in_range(esc[j], 'a', 'f') && !in_range(esc[j], 'A', 'F')
- && !in_range(esc[j], '0', '9'))
- return fail("bad \\u escape: " + esc, "");
- }
-
- long codepoint = strtol(esc.data(), nullptr, 16);
-
- // JSON specifies that characters outside the BMP shall be encoded as a pair
- // of 4-hex-digit \u escapes encoding their surrogate pair components. Check
- // whether we're in the middle of such a beast: the previous codepoint was an
- // escaped lead (high) surrogate, and this is a trail (low) surrogate.
- if (in_range(last_escaped_codepoint, 0xD800, 0xDBFF)
- && in_range(codepoint, 0xDC00, 0xDFFF)) {
- // Reassemble the two surrogate pairs into one astral-plane character, per
- // the UTF-16 algorithm.
- encode_utf8((((last_escaped_codepoint - 0xD800) << 10)
- | (codepoint - 0xDC00)) + 0x10000, out);
- last_escaped_codepoint = -1;
- } else {
- encode_utf8(last_escaped_codepoint, out);
- last_escaped_codepoint = codepoint;
- }
-
- i += 4;
- continue;
- }
-
- encode_utf8(last_escaped_codepoint, out);
- last_escaped_codepoint = -1;
-
- if (ch == 'b') {
- out += '\b';
- } else if (ch == 'f') {
- out += '\f';
- } else if (ch == 'n') {
- out += '\n';
- } else if (ch == 'r') {
- out += '\r';
- } else if (ch == 't') {
- out += '\t';
- } else if (ch == '"' || ch == '\\' || ch == '/') {
- out += ch;
- } else {
- return fail("invalid escape character " + esc(ch), "");
- }
- }
- }
-
- /* parse_number()
- *
- * Parse a double.
- */
- Json parse_number() {
- size_t start_pos = i;
-
- if (str[i] == '-')
- i++;
-
- // Integer part
- if (str[i] == '0') {
- i++;
- if (in_range(str[i], '0', '9'))
- return fail("leading 0s not permitted in numbers");
- } else if (in_range(str[i], '1', '9')) {
- i++;
- while (in_range(str[i], '0', '9'))
- i++;
- } else {
- return fail("invalid " + esc(str[i]) + " in number");
- }
-
- if (str[i] != '.' && str[i] != 'e' && str[i] != 'E'
- && (i - start_pos) <= static_cast<size_t>(std::numeric_limits<int>::digits10)) {
- return std::atoi(str.c_str() + start_pos);
- }
-
- // Decimal part
- if (str[i] == '.') {
- i++;
- if (!in_range(str[i], '0', '9'))
- return fail("at least one digit required in fractional part");
-
- while (in_range(str[i], '0', '9'))
- i++;
- }
-
- // Exponent part
- if (str[i] == 'e' || str[i] == 'E') {
- i++;
-
- if (str[i] == '+' || str[i] == '-')
- i++;
-
- if (!in_range(str[i], '0', '9'))
- return fail("at least one digit required in exponent");
-
- while (in_range(str[i], '0', '9'))
- i++;
- }
-
- return std::strtod(str.c_str() + start_pos, nullptr);
- }
-
- /* expect(str, res)
- *
- * Expect that 'str' starts at the character that was just read. If it does, advance
- * the input and return res. If not, flag an error.
- */
- Json expect(const string &expected, Json res) {
- assert(i != 0);
- i--;
- if (str.compare(i, expected.length(), expected) == 0) {
- i += expected.length();
- return res;
- } else {
- return fail("parse error: expected " + expected + ", got " + str.substr(i, expected.length()));
- }
- }
-
- /* parse_json()
- *
- * Parse a JSON object.
- */
- Json parse_json(int depth) {
- if (depth > max_depth) {
- return fail("exceeded maximum nesting depth");
- }
-
- char ch = get_next_token();
- if (failed)
- return Json();
-
- if (ch == '-' || (ch >= '0' && ch <= '9')) {
- i--;
- return parse_number();
- }
-
- if (ch == 't')
- return expect("true", true);
-
- if (ch == 'f')
- return expect("false", false);
-
- if (ch == 'n')
- return expect("null", Json());
-
- if (ch == '"')
- return parse_string();
-
- if (ch == '{') {
- map<string, Json> data;
- ch = get_next_token();
- if (ch == '}')
- return data;
-
- while (1) {
- if (ch != '"')
- return fail("expected '\"' in object, got " + esc(ch));
-
- string key = parse_string();
- if (failed)
- return Json();
-
- ch = get_next_token();
- if (ch != ':')
- return fail("expected ':' in object, got " + esc(ch));
-
- data[std::move(key)] = parse_json(depth + 1);
- if (failed)
- return Json();
-
- ch = get_next_token();
- if (ch == '}')
- break;
- if (ch != ',')
- return fail("expected ',' in object, got " + esc(ch));
-
- ch = get_next_token();
- }
- return data;
- }
-
- if (ch == '[') {
- vector<Json> data;
- ch = get_next_token();
- if (ch == ']')
- return data;
-
- while (1) {
- i--;
- data.push_back(parse_json(depth + 1));
- if (failed)
- return Json();
-
- ch = get_next_token();
- if (ch == ']')
- break;
- if (ch != ',')
- return fail("expected ',' in list, got " + esc(ch));
-
- ch = get_next_token();
- (void)ch;
- }
- return data;
- }
-
- return fail("expected value, got " + esc(ch));
- }
-};
-}//namespace {
-
-Json Json::parse(const string &in, string &err, JsonParse strategy) {
- JsonParser parser { in, 0, err, false, strategy };
- Json result = parser.parse_json(0);
-
- // Check for any trailing garbage
- parser.consume_garbage();
- if (parser.failed)
- return Json();
- if (parser.i != in.size())
- return parser.fail("unexpected trailing " + esc(in[parser.i]));
-
- return result;
-}
-
-// Documented in json11.hpp
-vector<Json> Json::parse_multi(const string &in,
- std::string::size_type &parser_stop_pos,
- string &err,
- JsonParse strategy) {
- JsonParser parser { in, 0, err, false, strategy };
- parser_stop_pos = 0;
- vector<Json> json_vec;
- while (parser.i != in.size() && !parser.failed) {
- json_vec.push_back(parser.parse_json(0));
- if (parser.failed)
- break;
-
- // Check for another object
- parser.consume_garbage();
- if (parser.failed)
- break;
- parser_stop_pos = parser.i;
- }
- return json_vec;
-}
-
-/* * * * * * * * * * * * * * * * * * * *
- * Shape-checking
- */
-
-bool Json::has_shape(const shape & types, string & err) const {
- if (!is_object()) {
- err = "expected JSON object, got " + dump();
- return false;
- }
-
- for (auto & item : types) {
- if ((*this)[item.first].type() != item.second) {
- err = "bad type for " + item.first + " in " + dump();
- return false;
- }
- }
-
- return true;
-}
-
-} // namespace json11
+/* Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "json11.h"
+#include <cassert>
+#include <cmath>
+#include <cstdlib>
+#include <cstdio>
+#include <limits>
+
+namespace json11 {
+
+static const int max_depth = 200;
+
+using std::string;
+using std::vector;
+using std::map;
+using std::make_shared;
+using std::initializer_list;
+using std::move;
+
+/* Helper for representing null - just a do-nothing struct, plus comparison
+ * operators so the helpers in JsonValue work. We can't use nullptr_t because
+ * it may not be orderable.
+ */
+struct NullStruct {
+ bool operator==(NullStruct) const { return true; }
+ bool operator<(NullStruct) const { return false; }
+};
+
+/* * * * * * * * * * * * * * * * * * * *
+ * Serialization
+ */
+
+static void dump(NullStruct, string &out) {
+ out += "null";
+}
+
+static void dump(double value, string &out) {
+ if (std::isfinite(value)) {
+ char buf[32];
+ snprintf(buf, sizeof buf, "%.17g", value);
+ out += buf;
+ } else {
+ out += "null";
+ }
+}
+
+static void dump(int value, string &out) {
+ char buf[32];
+ snprintf(buf, sizeof buf, "%d", value);
+ out += buf;
+}
+
+static void dump(bool value, string &out) {
+ out += value ? "true" : "false";
+}
+
+static void dump(const string &value, string &out) {
+ out += '"';
+ for (size_t i = 0; i < value.length(); i++) {
+ const char ch = value[i];
+ if (ch == '\\') {
+ out += "\\\\";
+ } else if (ch == '"') {
+ out += "\\\"";
+ } else if (ch == '\b') {
+ out += "\\b";
+ } else if (ch == '\f') {
+ out += "\\f";
+ } else if (ch == '\n') {
+ out += "\\n";
+ } else if (ch == '\r') {
+ out += "\\r";
+ } else if (ch == '\t') {
+ out += "\\t";
+ } else if (static_cast<uint8_t>(ch) <= 0x1f) {
+ char buf[8];
+ snprintf(buf, sizeof buf, "\\u%04x", ch);
+ out += buf;
+ } else if (static_cast<uint8_t>(ch) == 0xe2 && static_cast<uint8_t>(value[i+1]) == 0x80
+ && static_cast<uint8_t>(value[i+2]) == 0xa8) {
+ out += "\\u2028";
+ i += 2;
+ } else if (static_cast<uint8_t>(ch) == 0xe2 && static_cast<uint8_t>(value[i+1]) == 0x80
+ && static_cast<uint8_t>(value[i+2]) == 0xa9) {
+ out += "\\u2029";
+ i += 2;
+ } else {
+ out += ch;
+ }
+ }
+ out += '"';
+}
+
+static void dump(const Json::array &values, string &out) {
+ bool first = true;
+ out += "[";
+ for (const auto &value : values) {
+ if (!first)
+ out += ", ";
+ value.dump(out);
+ first = false;
+ }
+ out += "]";
+}
+
+static void dump(const Json::object &values, string &out) {
+ bool first = true;
+ out += "{";
+ for (const auto &kv : values) {
+ if (!first)
+ out += ", ";
+ dump(kv.first, out);
+ out += ": ";
+ kv.second.dump(out);
+ first = false;
+ }
+ out += "}";
+}
+
+void Json::dump(string &out) const {
+ m_ptr->dump(out);
+}
+
+/* * * * * * * * * * * * * * * * * * * *
+ * Value wrappers
+ */
+
+template <Json::Type tag, typename T>
+class Value : public JsonValue {
+protected:
+
+ // Constructors
+ explicit Value(const T &value) : m_value(value) {}
+ explicit Value(T &&value) : m_value(move(value)) {}
+
+ // Get type tag
+ Json::Type type() const override {
+ return tag;
+ }
+
+ // Comparisons
+ bool equals(const JsonValue * other) const override {
+ return m_value == static_cast<const Value<tag, T> *>(other)->m_value;
+ }
+ bool less(const JsonValue * other) const override {
+ return m_value < static_cast<const Value<tag, T> *>(other)->m_value;
+ }
+
+ const T m_value;
+ void dump(string &out) const override { json11::dump(m_value, out); }
+};
+
+class JsonDouble final : public Value<Json::NUMBER, double> {
+ double number_value() const override { return m_value; }
+ int int_value() const override { return static_cast<int>(m_value); }
+ bool equals(const JsonValue * other) const override { return m_value == other->number_value(); }
+ bool less(const JsonValue * other) const override { return m_value < other->number_value(); }
+public:
+ explicit JsonDouble(double value) : Value(value) {}
+};
+
+class JsonInt final : public Value<Json::NUMBER, int> {
+ double number_value() const override { return m_value; }
+ int int_value() const override { return m_value; }
+ bool equals(const JsonValue * other) const override { return m_value == other->number_value(); }
+ bool less(const JsonValue * other) const override { return m_value < other->number_value(); }
+public:
+ explicit JsonInt(int value) : Value(value) {}
+};
+
+class JsonBoolean final : public Value<Json::BOOL, bool> {
+ bool bool_value() const override { return m_value; }
+public:
+ explicit JsonBoolean(bool value) : Value(value) {}
+};
+
+class JsonString final : public Value<Json::STRING, string> {
+ const string &string_value() const override { return m_value; }
+public:
+ explicit JsonString(const string &value) : Value(value) {}
+ explicit JsonString(string &&value) : Value(move(value)) {}
+};
+
+class JsonArray final : public Value<Json::ARRAY, Json::array> {
+ const Json::array &array_items() const override { return m_value; }
+ const Json & operator[](size_t i) const override;
+public:
+ explicit JsonArray(const Json::array &value) : Value(value) {}
+ explicit JsonArray(Json::array &&value) : Value(move(value)) {}
+};
+
+class JsonObject final : public Value<Json::OBJECT, Json::object> {
+ const Json::object &object_items() const override { return m_value; }
+ const Json & operator[](const string &key) const override;
+public:
+ explicit JsonObject(const Json::object &value) : Value(value) {}
+ explicit JsonObject(Json::object &&value) : Value(move(value)) {}
+};
+
+class JsonNull final : public Value<Json::NUL, NullStruct> {
+public:
+ JsonNull() : Value({}) {}
+};
+
+/* * * * * * * * * * * * * * * * * * * *
+ * Static globals - static-init-safe
+ */
+struct Statics {
+ const std::shared_ptr<JsonValue> null = make_shared<JsonNull>();
+ const std::shared_ptr<JsonValue> t = make_shared<JsonBoolean>(true);
+ const std::shared_ptr<JsonValue> f = make_shared<JsonBoolean>(false);
+ const string empty_string;
+ const vector<Json> empty_vector;
+ const map<string, Json> empty_map;
+ Statics() {}
+};
+
+static const Statics & statics() {
+ static const Statics s {};
+ return s;
+}
+
+static const Json & static_null() {
+ // This has to be separate, not in Statics, because Json() accesses statics().null.
+ static const Json json_null;
+ return json_null;
+}
+
+/* * * * * * * * * * * * * * * * * * * *
+ * Constructors
+ */
+
+Json::Json() noexcept : m_ptr(statics().null) {}
+Json::Json(std::nullptr_t) noexcept : m_ptr(statics().null) {}
+Json::Json(double value) : m_ptr(make_shared<JsonDouble>(value)) {}
+Json::Json(int value) : m_ptr(make_shared<JsonInt>(value)) {}
+Json::Json(bool value) : m_ptr(value ? statics().t : statics().f) {}
+Json::Json(const string &value) : m_ptr(make_shared<JsonString>(value)) {}
+Json::Json(string &&value) : m_ptr(make_shared<JsonString>(move(value))) {}
+Json::Json(const char * value) : m_ptr(make_shared<JsonString>(value)) {}
+Json::Json(const Json::array &values) : m_ptr(make_shared<JsonArray>(values)) {}
+Json::Json(Json::array &&values) : m_ptr(make_shared<JsonArray>(move(values))) {}
+Json::Json(const Json::object &values) : m_ptr(make_shared<JsonObject>(values)) {}
+Json::Json(Json::object &&values) : m_ptr(make_shared<JsonObject>(move(values))) {}
+
+/* * * * * * * * * * * * * * * * * * * *
+ * Accessors
+ */
+
+Json::Type Json::type() const { return m_ptr->type(); }
+double Json::number_value() const { return m_ptr->number_value(); }
+int Json::int_value() const { return m_ptr->int_value(); }
+bool Json::bool_value() const { return m_ptr->bool_value(); }
+const string & Json::string_value() const { return m_ptr->string_value(); }
+const vector<Json> & Json::array_items() const { return m_ptr->array_items(); }
+const map<string, Json> & Json::object_items() const { return m_ptr->object_items(); }
+const Json & Json::operator[] (size_t i) const { return (*m_ptr)[i]; }
+const Json & Json::operator[] (const string &key) const { return (*m_ptr)[key]; }
+
+double JsonValue::number_value() const { return 0; }
+int JsonValue::int_value() const { return 0; }
+bool JsonValue::bool_value() const { return false; }
+const string & JsonValue::string_value() const { return statics().empty_string; }
+const vector<Json> & JsonValue::array_items() const { return statics().empty_vector; }
+const map<string, Json> & JsonValue::object_items() const { return statics().empty_map; }
+const Json & JsonValue::operator[] (size_t) const { return static_null(); }
+const Json & JsonValue::operator[] (const string &) const { return static_null(); }
+
+const Json & JsonObject::operator[] (const string &key) const {
+ auto iter = m_value.find(key);
+ return (iter == m_value.end()) ? static_null() : iter->second;
+}
+const Json & JsonArray::operator[] (size_t i) const {
+ if (i >= m_value.size()) return static_null();
+ else return m_value[i];
+}
+
+/* * * * * * * * * * * * * * * * * * * *
+ * Comparison
+ */
+
+bool Json::operator== (const Json &other) const {
+ if (m_ptr == other.m_ptr)
+ return true;
+ if (m_ptr->type() != other.m_ptr->type())
+ return false;
+
+ return m_ptr->equals(other.m_ptr.get());
+}
+
+bool Json::operator< (const Json &other) const {
+ if (m_ptr == other.m_ptr)
+ return false;
+ if (m_ptr->type() != other.m_ptr->type())
+ return m_ptr->type() < other.m_ptr->type();
+
+ return m_ptr->less(other.m_ptr.get());
+}
+
+/* * * * * * * * * * * * * * * * * * * *
+ * Parsing
+ */
+
+/* esc(c)
+ *
+ * Format char c suitable for printing in an error message.
+ */
+static inline string esc(char c) {
+ char buf[12];
+ if (static_cast<uint8_t>(c) >= 0x20 && static_cast<uint8_t>(c) <= 0x7f) {
+ snprintf(buf, sizeof buf, "'%c' (%d)", c, c);
+ } else {
+ snprintf(buf, sizeof buf, "(%d)", c);
+ }
+ return string(buf);
+}
+
+static inline bool in_range(long x, long lower, long upper) {
+ return (x >= lower && x <= upper);
+}
+
+namespace {
+/* JsonParser
+ *
+ * Object that tracks all state of an in-progress parse.
+ */
+struct JsonParser final {
+
+ /* State
+ */
+ const string &str;
+ size_t i;
+ string &err;
+ bool failed;
+ const JsonParse strategy;
+
+ /* fail(msg, err_ret = Json())
+ *
+ * Mark this parse as failed.
+ */
+ Json fail(string &&msg) {
+ return fail(move(msg), Json());
+ }
+
+ template <typename T>
+ T fail(string &&msg, const T err_ret) {
+ if (!failed)
+ err = std::move(msg);
+ failed = true;
+ return err_ret;
+ }
+
+ /* consume_whitespace()
+ *
+ * Advance until the current character is non-whitespace.
+ */
+ void consume_whitespace() {
+ while (str[i] == ' ' || str[i] == '\r' || str[i] == '\n' || str[i] == '\t')
+ i++;
+ }
+
+ /* consume_comment()
+ *
+ * Advance comments (c-style inline and multiline).
+ */
+ bool consume_comment() {
+ bool comment_found = false;
+ if (str[i] == '/') {
+ i++;
+ if (i == str.size())
+ return fail("unexpected end of input after start of comment", false);
+ if (str[i] == '/') { // inline comment
+ i++;
+ // advance until next line, or end of input
+ while (i < str.size() && str[i] != '\n') {
+ i++;
+ }
+ comment_found = true;
+ }
+ else if (str[i] == '*') { // multiline comment
+ i++;
+ if (i > str.size()-2)
+ return fail("unexpected end of input inside multi-line comment", false);
+ // advance until closing tokens
+ while (!(str[i] == '*' && str[i+1] == '/')) {
+ i++;
+ if (i > str.size()-2)
+ return fail(
+ "unexpected end of input inside multi-line comment", false);
+ }
+ i += 2;
+ comment_found = true;
+ }
+ else
+ return fail("malformed comment", false);
+ }
+ return comment_found;
+ }
+
+ /* consume_garbage()
+ *
+ * Advance until the current character is non-whitespace and non-comment.
+ */
+ void consume_garbage() {
+ consume_whitespace();
+ if(strategy == JsonParse::COMMENTS) {
+ bool comment_found = false;
+ do {
+ comment_found = consume_comment();
+ if (failed) return;
+ consume_whitespace();
+ }
+ while(comment_found);
+ }
+ }
+
+ /* get_next_token()
+ *
+ * Return the next non-whitespace character. If the end of the input is reached,
+ * flag an error and return 0.
+ */
+ char get_next_token() {
+ consume_garbage();
+ if (failed) return static_cast<char>(0);
+ if (i == str.size())
+ return fail("unexpected end of input", static_cast<char>(0));
+
+ return str[i++];
+ }
+
+ /* encode_utf8(pt, out)
+ *
+ * Encode pt as UTF-8 and add it to out.
+ */
+ void encode_utf8(long pt, string & out) {
+ if (pt < 0)
+ return;
+
+ if (pt < 0x80) {
+ out += static_cast<char>(pt);
+ } else if (pt < 0x800) {
+ out += static_cast<char>((pt >> 6) | 0xC0);
+ out += static_cast<char>((pt & 0x3F) | 0x80);
+ } else if (pt < 0x10000) {
+ out += static_cast<char>((pt >> 12) | 0xE0);
+ out += static_cast<char>(((pt >> 6) & 0x3F) | 0x80);
+ out += static_cast<char>((pt & 0x3F) | 0x80);
+ } else {
+ out += static_cast<char>((pt >> 18) | 0xF0);
+ out += static_cast<char>(((pt >> 12) & 0x3F) | 0x80);
+ out += static_cast<char>(((pt >> 6) & 0x3F) | 0x80);
+ out += static_cast<char>((pt & 0x3F) | 0x80);
+ }
+ }
+
+ /* parse_string()
+ *
+ * Parse a string, starting at the current position.
+ */
+ string parse_string() {
+ string out;
+ long last_escaped_codepoint = -1;
+ while (true) {
+ if (i == str.size())
+ return fail("unexpected end of input in string", "");
+
+ char ch = str[i++];
+
+ if (ch == '"') {
+ encode_utf8(last_escaped_codepoint, out);
+ return out;
+ }
+
+ if (in_range(ch, 0, 0x1f))
+ return fail("unescaped " + esc(ch) + " in string", "");
+
+ // The usual case: non-escaped characters
+ if (ch != '\\') {
+ encode_utf8(last_escaped_codepoint, out);
+ last_escaped_codepoint = -1;
+ out += ch;
+ continue;
+ }
+
+ // Handle escapes
+ if (i == str.size())
+ return fail("unexpected end of input in string", "");
+
+ ch = str[i++];
+
+ if (ch == 'u') {
+ // Extract 4-byte escape sequence
+ string esc = str.substr(i, 4);
+ // Explicitly check length of the substring. The following loop
+ // relies on std::string returning the terminating NUL when
+ // accessing str[length]. Checking here reduces brittleness.
+ if (esc.length() < 4) {
+ return fail("bad \\u escape: " + esc, "");
+ }
+ for (size_t j = 0; j < 4; j++) {
+ if (!in_range(esc[j], 'a', 'f') && !in_range(esc[j], 'A', 'F')
+ && !in_range(esc[j], '0', '9'))
+ return fail("bad \\u escape: " + esc, "");
+ }
+
+ long codepoint = strtol(esc.data(), nullptr, 16);
+
+ // JSON specifies that characters outside the BMP shall be encoded as a pair
+ // of 4-hex-digit \u escapes encoding their surrogate pair components. Check
+ // whether we're in the middle of such a beast: the previous codepoint was an
+ // escaped lead (high) surrogate, and this is a trail (low) surrogate.
+ if (in_range(last_escaped_codepoint, 0xD800, 0xDBFF)
+ && in_range(codepoint, 0xDC00, 0xDFFF)) {
+ // Reassemble the two surrogate pairs into one astral-plane character, per
+ // the UTF-16 algorithm.
+ encode_utf8((((last_escaped_codepoint - 0xD800) << 10)
+ | (codepoint - 0xDC00)) + 0x10000, out);
+ last_escaped_codepoint = -1;
+ } else {
+ encode_utf8(last_escaped_codepoint, out);
+ last_escaped_codepoint = codepoint;
+ }
+
+ i += 4;
+ continue;
+ }
+
+ encode_utf8(last_escaped_codepoint, out);
+ last_escaped_codepoint = -1;
+
+ if (ch == 'b') {
+ out += '\b';
+ } else if (ch == 'f') {
+ out += '\f';
+ } else if (ch == 'n') {
+ out += '\n';
+ } else if (ch == 'r') {
+ out += '\r';
+ } else if (ch == 't') {
+ out += '\t';
+ } else if (ch == '"' || ch == '\\' || ch == '/') {
+ out += ch;
+ } else {
+ return fail("invalid escape character " + esc(ch), "");
+ }
+ }
+ }
+
+ /* parse_number()
+ *
+ * Parse a double.
+ */
+ Json parse_number() {
+ size_t start_pos = i;
+
+ if (str[i] == '-')
+ i++;
+
+ // Integer part
+ if (str[i] == '0') {
+ i++;
+ if (in_range(str[i], '0', '9'))
+ return fail("leading 0s not permitted in numbers");
+ } else if (in_range(str[i], '1', '9')) {
+ i++;
+ while (in_range(str[i], '0', '9'))
+ i++;
+ } else {
+ return fail("invalid " + esc(str[i]) + " in number");
+ }
+
+ if (str[i] != '.' && str[i] != 'e' && str[i] != 'E'
+ && (i - start_pos) <= static_cast<size_t>(std::numeric_limits<int>::digits10)) {
+ return std::atoi(str.c_str() + start_pos);
+ }
+
+ // Decimal part
+ if (str[i] == '.') {
+ i++;
+ if (!in_range(str[i], '0', '9'))
+ return fail("at least one digit required in fractional part");
+
+ while (in_range(str[i], '0', '9'))
+ i++;
+ }
+
+ // Exponent part
+ if (str[i] == 'e' || str[i] == 'E') {
+ i++;
+
+ if (str[i] == '+' || str[i] == '-')
+ i++;
+
+ if (!in_range(str[i], '0', '9'))
+ return fail("at least one digit required in exponent");
+
+ while (in_range(str[i], '0', '9'))
+ i++;
+ }
+
+ return std::strtod(str.c_str() + start_pos, nullptr);
+ }
+
+ /* expect(str, res)
+ *
+ * Expect that 'str' starts at the character that was just read. If it does, advance
+ * the input and return res. If not, flag an error.
+ */
+ Json expect(const string &expected, Json res) {
+ assert(i != 0);
+ i--;
+ if (str.compare(i, expected.length(), expected) == 0) {
+ i += expected.length();
+ return res;
+ } else {
+ return fail("parse error: expected " + expected + ", got " + str.substr(i, expected.length()));
+ }
+ }
+
+ /* parse_json()
+ *
+ * Parse a JSON object.
+ */
+ Json parse_json(int depth) {
+ if (depth > max_depth) {
+ return fail("exceeded maximum nesting depth");
+ }
+
+ char ch = get_next_token();
+ if (failed)
+ return Json();
+
+ if (ch == '-' || (ch >= '0' && ch <= '9')) {
+ i--;
+ return parse_number();
+ }
+
+ if (ch == 't')
+ return expect("true", true);
+
+ if (ch == 'f')
+ return expect("false", false);
+
+ if (ch == 'n')
+ return expect("null", Json());
+
+ if (ch == '"')
+ return parse_string();
+
+ if (ch == '{') {
+ map<string, Json> data;
+ ch = get_next_token();
+ if (ch == '}')
+ return data;
+
+ while (1) {
+ if (ch != '"')
+ return fail("expected '\"' in object, got " + esc(ch));
+
+ string key = parse_string();
+ if (failed)
+ return Json();
+
+ ch = get_next_token();
+ if (ch != ':')
+ return fail("expected ':' in object, got " + esc(ch));
+
+ data[std::move(key)] = parse_json(depth + 1);
+ if (failed)
+ return Json();
+
+ ch = get_next_token();
+ if (ch == '}')
+ break;
+ if (ch != ',')
+ return fail("expected ',' in object, got " + esc(ch));
+
+ ch = get_next_token();
+ }
+ return data;
+ }
+
+ if (ch == '[') {
+ vector<Json> data;
+ ch = get_next_token();
+ if (ch == ']')
+ return data;
+
+ while (1) {
+ i--;
+ data.push_back(parse_json(depth + 1));
+ if (failed)
+ return Json();
+
+ ch = get_next_token();
+ if (ch == ']')
+ break;
+ if (ch != ',')
+ return fail("expected ',' in list, got " + esc(ch));
+
+ ch = get_next_token();
+ (void)ch;
+ }
+ return data;
+ }
+
+ return fail("expected value, got " + esc(ch));
+ }
+};
+}//namespace {
+
+Json Json::parse(const string &in, string &err, JsonParse strategy) {
+ JsonParser parser { in, 0, err, false, strategy };
+ Json result = parser.parse_json(0);
+
+ // Check for any trailing garbage
+ parser.consume_garbage();
+ if (parser.failed)
+ return Json();
+ if (parser.i != in.size())
+ return parser.fail("unexpected trailing " + esc(in[parser.i]));
+
+ return result;
+}
+
+// Documented in json11.hpp
+vector<Json> Json::parse_multi(const string &in,
+ std::string::size_type &parser_stop_pos,
+ string &err,
+ JsonParse strategy) {
+ JsonParser parser { in, 0, err, false, strategy };
+ parser_stop_pos = 0;
+ vector<Json> json_vec;
+ while (parser.i != in.size() && !parser.failed) {
+ json_vec.push_back(parser.parse_json(0));
+ if (parser.failed)
+ break;
+
+ // Check for another object
+ parser.consume_garbage();
+ if (parser.failed)
+ break;
+ parser_stop_pos = parser.i;
+ }
+ return json_vec;
+}
+
+/* * * * * * * * * * * * * * * * * * * *
+ * Shape-checking
+ */
+
+bool Json::has_shape(const shape & types, string & err) const {
+ if (!is_object()) {
+ err = "expected JSON object, got " + dump();
+ return false;
+ }
+
+ for (auto & item : types) {
+ if ((*this)[item.first].type() != item.second) {
+ err = "bad type for " + item.first + " in " + dump();
+ return false;
+ }
+ }
+
+ return true;
+}
+
+} // namespace json11
diff --git a/tools/gbafix/.gitignore b/tools/gbafix/.gitignore
index 0bf7356..3cebf8a 100644
--- a/tools/gbafix/.gitignore
+++ b/tools/gbafix/.gitignore
@@ -1,2 +1,2 @@
-gbafix
-README
+gbafix
+README
diff --git a/tools/gbagfx/.gitignore b/tools/gbagfx/.gitignore
index 12a06ea..dbbb3f0 100644
--- a/tools/gbagfx/.gitignore
+++ b/tools/gbagfx/.gitignore
@@ -1 +1 @@
-gbagfx
+gbagfx
diff --git a/tools/jsonproc/.gitignore b/tools/jsonproc/.gitignore
index ea58d57..a613cf2 100644
--- a/tools/jsonproc/.gitignore
+++ b/tools/jsonproc/.gitignore
@@ -1 +1 @@
-jsonproc
+jsonproc
diff --git a/tools/jsonproc/inja.hpp b/tools/jsonproc/inja.hpp
index 7f24e06..d5bf5bc 100644
--- a/tools/jsonproc/inja.hpp
+++ b/tools/jsonproc/inja.hpp
@@ -1,3529 +1,3529 @@
-// MIT License
-
-// Copyright (c) 2018 lbersch
-
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-
-// ---
-
-
-// Copyright (c) 2009-2018 FIRST
-// All rights reserved.
-
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above copyright
-// notice, this list of conditions and the following disclaimer in the
-// documentation and/or other materials provided with the distribution.
-// * Neither the name of the FIRST nor the
-// names of its contributors may be used to endorse or promote products
-// derived from this software without specific prior written permission.
-
-// THIS SOFTWARE IS PROVIDED BY FIRST AND CONTRIBUTORS``AS IS'' AND ANY
-// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-// WARRANTIES OF MERCHANTABILITY NONINFRINGEMENT AND FITNESS FOR A PARTICULAR
-// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL FIRST OR CONTRIBUTORS BE LIABLE FOR
-// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#ifndef PANTOR_INJA_HPP
-#define PANTOR_INJA_HPP
-
-#include <functional>
-#include <iostream>
-#include <map>
-#include <memory>
-#include <sstream>
-#include <string>
-#include <vector>
-
-#include <nlohmann/json.hpp>
-
-// #include "environment.hpp"
-#ifndef PANTOR_INJA_ENVIRONMENT_HPP
-#define PANTOR_INJA_ENVIRONMENT_HPP
-
-#include <memory>
-#include <fstream>
-#include <sstream>
-#include <string>
-
-#include <nlohmann/json.hpp>
-
-// #include "config.hpp"
-#ifndef PANTOR_INJA_CONFIG_HPP
-#define PANTOR_INJA_CONFIG_HPP
-
-#include <functional>
-#include <string>
-
-// #include "string_view.hpp"
-// Copyright 2017-2019 by Martin Moene
-//
-// string-view lite, a C++17-like string_view for C++98 and later.
-// For more information see https://github.com/martinmoene/string-view-lite
-//
-// Distributed under the Boost Software License, Version 1.0.
-// (See accompanying file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-
-
-
-#ifndef NONSTD_SV_LITE_H_INCLUDED
-#define NONSTD_SV_LITE_H_INCLUDED
-
-#define string_view_lite_MAJOR 1
-#define string_view_lite_MINOR 1
-#define string_view_lite_PATCH 0
-
-#define string_view_lite_VERSION nssv_STRINGIFY(string_view_lite_MAJOR) "." nssv_STRINGIFY(string_view_lite_MINOR) "." nssv_STRINGIFY(string_view_lite_PATCH)
-
-#define nssv_STRINGIFY( x ) nssv_STRINGIFY_( x )
-#define nssv_STRINGIFY_( x ) #x
-
-// string-view lite configuration:
-
-#define nssv_STRING_VIEW_DEFAULT 0
-#define nssv_STRING_VIEW_NONSTD 1
-#define nssv_STRING_VIEW_STD 2
-
-#if !defined( nssv_CONFIG_SELECT_STRING_VIEW )
-# define nssv_CONFIG_SELECT_STRING_VIEW ( nssv_HAVE_STD_STRING_VIEW ? nssv_STRING_VIEW_STD : nssv_STRING_VIEW_NONSTD )
-#endif
-
-#if defined( nssv_CONFIG_SELECT_STD_STRING_VIEW ) || defined( nssv_CONFIG_SELECT_NONSTD_STRING_VIEW )
-# error nssv_CONFIG_SELECT_STD_STRING_VIEW and nssv_CONFIG_SELECT_NONSTD_STRING_VIEW are deprecated and removed, please use nssv_CONFIG_SELECT_STRING_VIEW=nssv_STRING_VIEW_...
-#endif
-
-#ifndef nssv_CONFIG_STD_SV_OPERATOR
-# define nssv_CONFIG_STD_SV_OPERATOR 0
-#endif
-
-#ifndef nssv_CONFIG_USR_SV_OPERATOR
-# define nssv_CONFIG_USR_SV_OPERATOR 1
-#endif
-
-#ifdef nssv_CONFIG_CONVERSION_STD_STRING
-# define nssv_CONFIG_CONVERSION_STD_STRING_CLASS_METHODS nssv_CONFIG_CONVERSION_STD_STRING
-# define nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS nssv_CONFIG_CONVERSION_STD_STRING
-#endif
-
-#ifndef nssv_CONFIG_CONVERSION_STD_STRING_CLASS_METHODS
-# define nssv_CONFIG_CONVERSION_STD_STRING_CLASS_METHODS 1
-#endif
-
-#ifndef nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS
-# define nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS 1
-#endif
-
-// Control presence of exception handling (try and auto discover):
-
-#ifndef nssv_CONFIG_NO_EXCEPTIONS
-# if defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)
-# define nssv_CONFIG_NO_EXCEPTIONS 0
-# else
-# define nssv_CONFIG_NO_EXCEPTIONS 1
-# endif
-#endif
-
-// C++ language version detection (C++20 is speculative):
-// Note: VC14.0/1900 (VS2015) lacks too much from C++14.
-
-#ifndef nssv_CPLUSPLUS
-# if defined(_MSVC_LANG ) && !defined(__clang__)
-# define nssv_CPLUSPLUS (_MSC_VER == 1900 ? 201103L : _MSVC_LANG )
-# else
-# define nssv_CPLUSPLUS __cplusplus
-# endif
-#endif
-
-#define nssv_CPP98_OR_GREATER ( nssv_CPLUSPLUS >= 199711L )
-#define nssv_CPP11_OR_GREATER ( nssv_CPLUSPLUS >= 201103L )
-#define nssv_CPP11_OR_GREATER_ ( nssv_CPLUSPLUS >= 201103L )
-#define nssv_CPP14_OR_GREATER ( nssv_CPLUSPLUS >= 201402L )
-#define nssv_CPP17_OR_GREATER ( nssv_CPLUSPLUS >= 201703L )
-#define nssv_CPP20_OR_GREATER ( nssv_CPLUSPLUS >= 202000L )
-
-// use C++17 std::string_view if available and requested:
-
-#if nssv_CPP17_OR_GREATER && defined(__has_include )
-# if __has_include( <string_view> )
-# define nssv_HAVE_STD_STRING_VIEW 1
-# else
-# define nssv_HAVE_STD_STRING_VIEW 0
-# endif
-#else
-# define nssv_HAVE_STD_STRING_VIEW 0
-#endif
-
-#define nssv_USES_STD_STRING_VIEW ( (nssv_CONFIG_SELECT_STRING_VIEW == nssv_STRING_VIEW_STD) || ((nssv_CONFIG_SELECT_STRING_VIEW == nssv_STRING_VIEW_DEFAULT) && nssv_HAVE_STD_STRING_VIEW) )
-
-#define nssv_HAVE_STARTS_WITH ( nssv_CPP20_OR_GREATER || !nssv_USES_STD_STRING_VIEW )
-#define nssv_HAVE_ENDS_WITH nssv_HAVE_STARTS_WITH
-
-//
-// Use C++17 std::string_view:
-//
-
-#if nssv_USES_STD_STRING_VIEW
-
-#include <string_view>
-
-// Extensions for std::string:
-
-#if nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS
-
-namespace nonstd {
-
-template< class CharT, class Traits, class Allocator = std::allocator<CharT> >
-std::basic_string<CharT, Traits, Allocator>
-to_string( std::basic_string_view<CharT, Traits> v, Allocator const & a = Allocator() )
-{
- return std::basic_string<CharT,Traits, Allocator>( v.begin(), v.end(), a );
-}
-
-template< class CharT, class Traits, class Allocator >
-std::basic_string_view<CharT, Traits>
-to_string_view( std::basic_string<CharT, Traits, Allocator> const & s )
-{
- return std::basic_string_view<CharT, Traits>( s.data(), s.size() );
-}
-
-// Literal operators sv and _sv:
-
-#if nssv_CONFIG_STD_SV_OPERATOR
-
-using namespace std::literals::string_view_literals;
-
-#endif
-
-#if nssv_CONFIG_USR_SV_OPERATOR
-
-inline namespace literals {
-inline namespace string_view_literals {
-
-
-constexpr std::string_view operator "" _sv( const char* str, size_t len ) noexcept // (1)
-{
- return std::string_view{ str, len };
-}
-
-constexpr std::u16string_view operator "" _sv( const char16_t* str, size_t len ) noexcept // (2)
-{
- return std::u16string_view{ str, len };
-}
-
-constexpr std::u32string_view operator "" _sv( const char32_t* str, size_t len ) noexcept // (3)
-{
- return std::u32string_view{ str, len };
-}
-
-constexpr std::wstring_view operator "" _sv( const wchar_t* str, size_t len ) noexcept // (4)
-{
- return std::wstring_view{ str, len };
-}
-
-}} // namespace literals::string_view_literals
-
-#endif // nssv_CONFIG_USR_SV_OPERATOR
-
-} // namespace nonstd
-
-#endif // nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS
-
-namespace nonstd {
-
-using std::string_view;
-using std::wstring_view;
-using std::u16string_view;
-using std::u32string_view;
-using std::basic_string_view;
-
-// literal "sv" and "_sv", see above
-
-using std::operator==;
-using std::operator!=;
-using std::operator<;
-using std::operator<=;
-using std::operator>;
-using std::operator>=;
-
-using std::operator<<;
-
-} // namespace nonstd
-
-#else // nssv_HAVE_STD_STRING_VIEW
-
-//
-// Before C++17: use string_view lite:
-//
-
-// Compiler versions:
-//
-// MSVC++ 6.0 _MSC_VER == 1200 (Visual Studio 6.0)
-// MSVC++ 7.0 _MSC_VER == 1300 (Visual Studio .NET 2002)
-// MSVC++ 7.1 _MSC_VER == 1310 (Visual Studio .NET 2003)
-// MSVC++ 8.0 _MSC_VER == 1400 (Visual Studio 2005)
-// MSVC++ 9.0 _MSC_VER == 1500 (Visual Studio 2008)
-// MSVC++ 10.0 _MSC_VER == 1600 (Visual Studio 2010)
-// MSVC++ 11.0 _MSC_VER == 1700 (Visual Studio 2012)
-// MSVC++ 12.0 _MSC_VER == 1800 (Visual Studio 2013)
-// MSVC++ 14.0 _MSC_VER == 1900 (Visual Studio 2015)
-// MSVC++ 14.1 _MSC_VER >= 1910 (Visual Studio 2017)
-
-#if defined(_MSC_VER ) && !defined(__clang__)
-# define nssv_COMPILER_MSVC_VER (_MSC_VER )
-# define nssv_COMPILER_MSVC_VERSION (_MSC_VER / 10 - 10 * ( 5 + (_MSC_VER < 1900 ) ) )
-#else
-# define nssv_COMPILER_MSVC_VER 0
-# define nssv_COMPILER_MSVC_VERSION 0
-#endif
-
-#define nssv_COMPILER_VERSION( major, minor, patch ) (10 * ( 10 * major + minor) + patch)
-
-#if defined(__clang__)
-# define nssv_COMPILER_CLANG_VERSION nssv_COMPILER_VERSION(__clang_major__, __clang_minor__, __clang_patchlevel__)
-#else
-# define nssv_COMPILER_CLANG_VERSION 0
-#endif
-
-#if defined(__GNUC__) && !defined(__clang__)
-# define nssv_COMPILER_GNUC_VERSION nssv_COMPILER_VERSION(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
-#else
-# define nssv_COMPILER_GNUC_VERSION 0
-#endif
-
-// half-open range [lo..hi):
-#define nssv_BETWEEN( v, lo, hi ) ( (lo) <= (v) && (v) < (hi) )
-
-// Presence of language and library features:
-
-#ifdef _HAS_CPP0X
-# define nssv_HAS_CPP0X _HAS_CPP0X
-#else
-# define nssv_HAS_CPP0X 0
-#endif
-
-// Unless defined otherwise below, consider VC14 as C++11 for variant-lite:
-
-#if nssv_COMPILER_MSVC_VER >= 1900
-# undef nssv_CPP11_OR_GREATER
-# define nssv_CPP11_OR_GREATER 1
-#endif
-
-#define nssv_CPP11_90 (nssv_CPP11_OR_GREATER_ || nssv_COMPILER_MSVC_VER >= 1500)
-#define nssv_CPP11_100 (nssv_CPP11_OR_GREATER_ || nssv_COMPILER_MSVC_VER >= 1600)
-#define nssv_CPP11_110 (nssv_CPP11_OR_GREATER_ || nssv_COMPILER_MSVC_VER >= 1700)
-#define nssv_CPP11_120 (nssv_CPP11_OR_GREATER_ || nssv_COMPILER_MSVC_VER >= 1800)
-#define nssv_CPP11_140 (nssv_CPP11_OR_GREATER_ || nssv_COMPILER_MSVC_VER >= 1900)
-#define nssv_CPP11_141 (nssv_CPP11_OR_GREATER_ || nssv_COMPILER_MSVC_VER >= 1910)
-
-#define nssv_CPP14_000 (nssv_CPP14_OR_GREATER)
-#define nssv_CPP17_000 (nssv_CPP17_OR_GREATER)
-
-// Presence of C++11 language features:
-
-#define nssv_HAVE_CONSTEXPR_11 nssv_CPP11_140
-#define nssv_HAVE_EXPLICIT_CONVERSION nssv_CPP11_140
-#define nssv_HAVE_INLINE_NAMESPACE nssv_CPP11_140
-#define nssv_HAVE_NOEXCEPT nssv_CPP11_140
-#define nssv_HAVE_NULLPTR nssv_CPP11_100
-#define nssv_HAVE_REF_QUALIFIER nssv_CPP11_140
-#define nssv_HAVE_UNICODE_LITERALS nssv_CPP11_140
-#define nssv_HAVE_USER_DEFINED_LITERALS nssv_CPP11_140
-#define nssv_HAVE_WCHAR16_T nssv_CPP11_100
-#define nssv_HAVE_WCHAR32_T nssv_CPP11_100
-
-#if ! ( ( nssv_CPP11 && nssv_COMPILER_CLANG_VERSION ) || nssv_BETWEEN( nssv_COMPILER_CLANG_VERSION, 300, 400 ) )
-# define nssv_HAVE_STD_DEFINED_LITERALS nssv_CPP11_140
-#endif
-
-// Presence of C++14 language features:
-
-#define nssv_HAVE_CONSTEXPR_14 nssv_CPP14_000
-
-// Presence of C++17 language features:
-
-#define nssv_HAVE_NODISCARD nssv_CPP17_000
-
-// Presence of C++ library features:
-
-#define nssv_HAVE_STD_HASH nssv_CPP11_120
-
-// C++ feature usage:
-
-#if nssv_HAVE_CONSTEXPR_11
-# define nssv_constexpr constexpr
-#else
-# define nssv_constexpr /*constexpr*/
-#endif
-
-#if nssv_HAVE_CONSTEXPR_14
-# define nssv_constexpr14 constexpr
-#else
-# define nssv_constexpr14 /*constexpr*/
-#endif
-
-#if nssv_HAVE_EXPLICIT_CONVERSION
-# define nssv_explicit explicit
-#else
-# define nssv_explicit /*explicit*/
-#endif
-
-#if nssv_HAVE_INLINE_NAMESPACE
-# define nssv_inline_ns inline
-#else
-# define nssv_inline_ns /*inline*/
-#endif
-
-#if nssv_HAVE_NOEXCEPT
-# define nssv_noexcept noexcept
-#else
-# define nssv_noexcept /*noexcept*/
-#endif
-
-//#if nssv_HAVE_REF_QUALIFIER
-//# define nssv_ref_qual &
-//# define nssv_refref_qual &&
-//#else
-//# define nssv_ref_qual /*&*/
-//# define nssv_refref_qual /*&&*/
-//#endif
-
-#if nssv_HAVE_NULLPTR
-# define nssv_nullptr nullptr
-#else
-# define nssv_nullptr NULL
-#endif
-
-#if nssv_HAVE_NODISCARD
-# define nssv_nodiscard [[nodiscard]]
-#else
-# define nssv_nodiscard /*[[nodiscard]]*/
-#endif
-
-// Additional includes:
-
-#include <algorithm>
-#include <cassert>
-#include <iterator>
-#include <limits>
-#include <ostream>
-#include <string> // std::char_traits<>
-
-#if ! nssv_CONFIG_NO_EXCEPTIONS
-# include <stdexcept>
-#endif
-
-#if nssv_CPP11_OR_GREATER
-# include <type_traits>
-#endif
-
-// Clang, GNUC, MSVC warning suppression macros:
-
-#if defined(__clang__)
-# pragma clang diagnostic ignored "-Wreserved-user-defined-literal"
-# pragma clang diagnostic push
-# pragma clang diagnostic ignored "-Wuser-defined-literals"
-#elif defined(__GNUC__)
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Wliteral-suffix"
-#endif // __clang__
-
-#if nssv_COMPILER_MSVC_VERSION >= 140
-# define nssv_SUPPRESS_MSGSL_WARNING(expr) [[gsl::suppress(expr)]]
-# define nssv_SUPPRESS_MSVC_WARNING(code, descr) __pragma(warning(suppress: code) )
-# define nssv_DISABLE_MSVC_WARNINGS(codes) __pragma(warning(push)) __pragma(warning(disable: codes))
-#else
-# define nssv_SUPPRESS_MSGSL_WARNING(expr)
-# define nssv_SUPPRESS_MSVC_WARNING(code, descr)
-# define nssv_DISABLE_MSVC_WARNINGS(codes)
-#endif
-
-#if defined(__clang__)
-# define nssv_RESTORE_WARNINGS() _Pragma("clang diagnostic pop")
-#elif defined(__GNUC__)
-# define nssv_RESTORE_WARNINGS() _Pragma("GCC diagnostic pop")
-#elif nssv_COMPILER_MSVC_VERSION >= 140
-# define nssv_RESTORE_WARNINGS() __pragma(warning(pop ))
-#else
-# define nssv_RESTORE_WARNINGS()
-#endif
-
-// Suppress the following MSVC (GSL) warnings:
-// - C4455, non-gsl : 'operator ""sv': literal suffix identifiers that do not
-// start with an underscore are reserved
-// - C26472, gsl::t.1 : don't use a static_cast for arithmetic conversions;
-// use brace initialization, gsl::narrow_cast or gsl::narow
-// - C26481: gsl::b.1 : don't use pointer arithmetic. Use span instead
-
-nssv_DISABLE_MSVC_WARNINGS( 4455 26481 26472 )
-//nssv_DISABLE_CLANG_WARNINGS( "-Wuser-defined-literals" )
-//nssv_DISABLE_GNUC_WARNINGS( -Wliteral-suffix )
-
-namespace nonstd { namespace sv_lite {
-
-template
-<
- class CharT,
- class Traits = std::char_traits<CharT>
->
-class basic_string_view;
-
-//
-// basic_string_view:
-//
-
-template
-<
- class CharT,
- class Traits /* = std::char_traits<CharT> */
->
-class basic_string_view
-{
-public:
- // Member types:
-
- typedef Traits traits_type;
- typedef CharT value_type;
-
- typedef CharT * pointer;
- typedef CharT const * const_pointer;
- typedef CharT & reference;
- typedef CharT const & const_reference;
-
- typedef const_pointer iterator;
- typedef const_pointer const_iterator;
- typedef std::reverse_iterator< const_iterator > reverse_iterator;
- typedef std::reverse_iterator< const_iterator > const_reverse_iterator;
-
- typedef std::size_t size_type;
- typedef std::ptrdiff_t difference_type;
-
- // 24.4.2.1 Construction and assignment:
-
- nssv_constexpr basic_string_view() nssv_noexcept
- : data_( nssv_nullptr )
- , size_( 0 )
- {}
-
-#if nssv_CPP11_OR_GREATER
- nssv_constexpr basic_string_view( basic_string_view const & other ) nssv_noexcept = default;
-#else
- nssv_constexpr basic_string_view( basic_string_view const & other ) nssv_noexcept
- : data_( other.data_)
- , size_( other.size_)
- {}
-#endif
-
- nssv_constexpr basic_string_view( CharT const * s, size_type count )
- : data_( s )
- , size_( count )
- {}
-
- nssv_constexpr basic_string_view( CharT const * s)
- : data_( s )
- , size_( Traits::length(s) )
- {}
-
- // Assignment:
-
-#if nssv_CPP11_OR_GREATER
- nssv_constexpr14 basic_string_view & operator=( basic_string_view const & other ) nssv_noexcept = default;
-#else
- nssv_constexpr14 basic_string_view & operator=( basic_string_view const & other ) nssv_noexcept
- {
- data_ = other.data_;
- size_ = other.size_;
- return *this;
- }
-#endif
-
- // 24.4.2.2 Iterator support:
-
- nssv_constexpr const_iterator begin() const nssv_noexcept { return data_; }
- nssv_constexpr const_iterator end() const nssv_noexcept { return data_ + size_; }
-
- nssv_constexpr const_iterator cbegin() const nssv_noexcept { return begin(); }
- nssv_constexpr const_iterator cend() const nssv_noexcept { return end(); }
-
- nssv_constexpr const_reverse_iterator rbegin() const nssv_noexcept { return const_reverse_iterator( end() ); }
- nssv_constexpr const_reverse_iterator rend() const nssv_noexcept { return const_reverse_iterator( begin() ); }
-
- nssv_constexpr const_reverse_iterator crbegin() const nssv_noexcept { return rbegin(); }
- nssv_constexpr const_reverse_iterator crend() const nssv_noexcept { return rend(); }
-
- // 24.4.2.3 Capacity:
-
- nssv_constexpr size_type size() const nssv_noexcept { return size_; }
- nssv_constexpr size_type length() const nssv_noexcept { return size_; }
- nssv_constexpr size_type max_size() const nssv_noexcept { return (std::numeric_limits< size_type >::max)(); }
-
- // since C++20
- nssv_nodiscard nssv_constexpr bool empty() const nssv_noexcept
- {
- return 0 == size_;
- }
-
- // 24.4.2.4 Element access:
-
- nssv_constexpr const_reference operator[]( size_type pos ) const
- {
- return data_at( pos );
- }
-
- nssv_constexpr14 const_reference at( size_type pos ) const
- {
-#if nssv_CONFIG_NO_EXCEPTIONS
- assert( pos < size() );
-#else
- if ( pos >= size() )
- {
- throw std::out_of_range("nonst::string_view::at()");
- }
-#endif
- return data_at( pos );
- }
-
- nssv_constexpr const_reference front() const { return data_at( 0 ); }
- nssv_constexpr const_reference back() const { return data_at( size() - 1 ); }
-
- nssv_constexpr const_pointer data() const nssv_noexcept { return data_; }
-
- // 24.4.2.5 Modifiers:
-
- nssv_constexpr14 void remove_prefix( size_type n )
- {
- assert( n <= size() );
- data_ += n;
- size_ -= n;
- }
-
- nssv_constexpr14 void remove_suffix( size_type n )
- {
- assert( n <= size() );
- size_ -= n;
- }
-
- nssv_constexpr14 void swap( basic_string_view & other ) nssv_noexcept
- {
- using std::swap;
- swap( data_, other.data_ );
- swap( size_, other.size_ );
- }
-
- // 24.4.2.6 String operations:
-
- size_type copy( CharT * dest, size_type n, size_type pos = 0 ) const
- {
-#if nssv_CONFIG_NO_EXCEPTIONS
- assert( pos <= size() );
-#else
- if ( pos > size() )
- {
- throw std::out_of_range("nonst::string_view::copy()");
- }
-#endif
- const size_type rlen = (std::min)( n, size() - pos );
-
- (void) Traits::copy( dest, data() + pos, rlen );
-
- return rlen;
- }
-
- nssv_constexpr14 basic_string_view substr( size_type pos = 0, size_type n = npos ) const
- {
-#if nssv_CONFIG_NO_EXCEPTIONS
- assert( pos <= size() );
-#else
- if ( pos > size() )
- {
- throw std::out_of_range("nonst::string_view::substr()");
- }
-#endif
- return basic_string_view( data() + pos, (std::min)( n, size() - pos ) );
- }
-
- // compare(), 6x:
-
- nssv_constexpr14 int compare( basic_string_view other ) const nssv_noexcept // (1)
- {
- if ( const int result = Traits::compare( data(), other.data(), (std::min)( size(), other.size() ) ) )
- return result;
-
- return size() == other.size() ? 0 : size() < other.size() ? -1 : 1;
- }
-
- nssv_constexpr int compare( size_type pos1, size_type n1, basic_string_view other ) const // (2)
- {
- return substr( pos1, n1 ).compare( other );
- }
-
- nssv_constexpr int compare( size_type pos1, size_type n1, basic_string_view other, size_type pos2, size_type n2 ) const // (3)
- {
- return substr( pos1, n1 ).compare( other.substr( pos2, n2 ) );
- }
-
- nssv_constexpr int compare( CharT const * s ) const // (4)
- {
- return compare( basic_string_view( s ) );
- }
-
- nssv_constexpr int compare( size_type pos1, size_type n1, CharT const * s ) const // (5)
- {
- return substr( pos1, n1 ).compare( basic_string_view( s ) );
- }
-
- nssv_constexpr int compare( size_type pos1, size_type n1, CharT const * s, size_type n2 ) const // (6)
- {
- return substr( pos1, n1 ).compare( basic_string_view( s, n2 ) );
- }
-
- // 24.4.2.7 Searching:
-
- // starts_with(), 3x, since C++20:
-
- nssv_constexpr bool starts_with( basic_string_view v ) const nssv_noexcept // (1)
- {
- return size() >= v.size() && compare( 0, v.size(), v ) == 0;
- }
-
- nssv_constexpr bool starts_with( CharT c ) const nssv_noexcept // (2)
- {
- return starts_with( basic_string_view( &c, 1 ) );
- }
-
- nssv_constexpr bool starts_with( CharT const * s ) const // (3)
- {
- return starts_with( basic_string_view( s ) );
- }
-
- // ends_with(), 3x, since C++20:
-
- nssv_constexpr bool ends_with( basic_string_view v ) const nssv_noexcept // (1)
- {
- return size() >= v.size() && compare( size() - v.size(), npos, v ) == 0;
- }
-
- nssv_constexpr bool ends_with( CharT c ) const nssv_noexcept // (2)
- {
- return ends_with( basic_string_view( &c, 1 ) );
- }
-
- nssv_constexpr bool ends_with( CharT const * s ) const // (3)
- {
- return ends_with( basic_string_view( s ) );
- }
-
- // find(), 4x:
-
- nssv_constexpr14 size_type find( basic_string_view v, size_type pos = 0 ) const nssv_noexcept // (1)
- {
- return assert( v.size() == 0 || v.data() != nssv_nullptr )
- , pos >= size()
- ? npos
- : to_pos( std::search( cbegin() + pos, cend(), v.cbegin(), v.cend(), Traits::eq ) );
- }
-
- nssv_constexpr14 size_type find( CharT c, size_type pos = 0 ) const nssv_noexcept // (2)
- {
- return find( basic_string_view( &c, 1 ), pos );
- }
-
- nssv_constexpr14 size_type find( CharT const * s, size_type pos, size_type n ) const // (3)
- {
- return find( basic_string_view( s, n ), pos );
- }
-
- nssv_constexpr14 size_type find( CharT const * s, size_type pos = 0 ) const // (4)
- {
- return find( basic_string_view( s ), pos );
- }
-
- // rfind(), 4x:
-
- nssv_constexpr14 size_type rfind( basic_string_view v, size_type pos = npos ) const nssv_noexcept // (1)
- {
- if ( size() < v.size() )
- return npos;
-
- if ( v.empty() )
- return (std::min)( size(), pos );
-
- const_iterator last = cbegin() + (std::min)( size() - v.size(), pos ) + v.size();
- const_iterator result = std::find_end( cbegin(), last, v.cbegin(), v.cend(), Traits::eq );
-
- return result != last ? size_type( result - cbegin() ) : npos;
- }
-
- nssv_constexpr14 size_type rfind( CharT c, size_type pos = npos ) const nssv_noexcept // (2)
- {
- return rfind( basic_string_view( &c, 1 ), pos );
- }
-
- nssv_constexpr14 size_type rfind( CharT const * s, size_type pos, size_type n ) const // (3)
- {
- return rfind( basic_string_view( s, n ), pos );
- }
-
- nssv_constexpr14 size_type rfind( CharT const * s, size_type pos = npos ) const // (4)
- {
- return rfind( basic_string_view( s ), pos );
- }
-
- // find_first_of(), 4x:
-
- nssv_constexpr size_type find_first_of( basic_string_view v, size_type pos = 0 ) const nssv_noexcept // (1)
- {
- return pos >= size()
- ? npos
- : to_pos( std::find_first_of( cbegin() + pos, cend(), v.cbegin(), v.cend(), Traits::eq ) );
- }
-
- nssv_constexpr size_type find_first_of( CharT c, size_type pos = 0 ) const nssv_noexcept // (2)
- {
- return find_first_of( basic_string_view( &c, 1 ), pos );
- }
-
- nssv_constexpr size_type find_first_of( CharT const * s, size_type pos, size_type n ) const // (3)
- {
- return find_first_of( basic_string_view( s, n ), pos );
- }
-
- nssv_constexpr size_type find_first_of( CharT const * s, size_type pos = 0 ) const // (4)
- {
- return find_first_of( basic_string_view( s ), pos );
- }
-
- // find_last_of(), 4x:
-
- nssv_constexpr size_type find_last_of( basic_string_view v, size_type pos = npos ) const nssv_noexcept // (1)
- {
- return empty()
- ? npos
- : pos >= size()
- ? find_last_of( v, size() - 1 )
- : to_pos( std::find_first_of( const_reverse_iterator( cbegin() + pos + 1 ), crend(), v.cbegin(), v.cend(), Traits::eq ) );
- }
-
- nssv_constexpr size_type find_last_of( CharT c, size_type pos = npos ) const nssv_noexcept // (2)
- {
- return find_last_of( basic_string_view( &c, 1 ), pos );
- }
-
- nssv_constexpr size_type find_last_of( CharT const * s, size_type pos, size_type count ) const // (3)
- {
- return find_last_of( basic_string_view( s, count ), pos );
- }
-
- nssv_constexpr size_type find_last_of( CharT const * s, size_type pos = npos ) const // (4)
- {
- return find_last_of( basic_string_view( s ), pos );
- }
-
- // find_first_not_of(), 4x:
-
- nssv_constexpr size_type find_first_not_of( basic_string_view v, size_type pos = 0 ) const nssv_noexcept // (1)
- {
- return pos >= size()
- ? npos
- : to_pos( std::find_if( cbegin() + pos, cend(), not_in_view( v ) ) );
- }
-
- nssv_constexpr size_type find_first_not_of( CharT c, size_type pos = 0 ) const nssv_noexcept // (2)
- {
- return find_first_not_of( basic_string_view( &c, 1 ), pos );
- }
-
- nssv_constexpr size_type find_first_not_of( CharT const * s, size_type pos, size_type count ) const // (3)
- {
- return find_first_not_of( basic_string_view( s, count ), pos );
- }
-
- nssv_constexpr size_type find_first_not_of( CharT const * s, size_type pos = 0 ) const // (4)
- {
- return find_first_not_of( basic_string_view( s ), pos );
- }
-
- // find_last_not_of(), 4x:
-
- nssv_constexpr size_type find_last_not_of( basic_string_view v, size_type pos = npos ) const nssv_noexcept // (1)
- {
- return empty()
- ? npos
- : pos >= size()
- ? find_last_not_of( v, size() - 1 )
- : to_pos( std::find_if( const_reverse_iterator( cbegin() + pos + 1 ), crend(), not_in_view( v ) ) );
- }
-
- nssv_constexpr size_type find_last_not_of( CharT c, size_type pos = npos ) const nssv_noexcept // (2)
- {
- return find_last_not_of( basic_string_view( &c, 1 ), pos );
- }
-
- nssv_constexpr size_type find_last_not_of( CharT const * s, size_type pos, size_type count ) const // (3)
- {
- return find_last_not_of( basic_string_view( s, count ), pos );
- }
-
- nssv_constexpr size_type find_last_not_of( CharT const * s, size_type pos = npos ) const // (4)
- {
- return find_last_not_of( basic_string_view( s ), pos );
- }
-
- // Constants:
-
-#if nssv_CPP17_OR_GREATER
- static nssv_constexpr size_type npos = size_type(-1);
-#elif nssv_CPP11_OR_GREATER
- enum : size_type { npos = size_type(-1) };
-#else
- enum { npos = size_type(-1) };
-#endif
-
-private:
- struct not_in_view
- {
- const basic_string_view v;
-
- nssv_constexpr not_in_view( basic_string_view v ) : v( v ) {}
-
- nssv_constexpr bool operator()( CharT c ) const
- {
- return npos == v.find_first_of( c );
- }
- };
-
- nssv_constexpr size_type to_pos( const_iterator it ) const
- {
- return it == cend() ? npos : size_type( it - cbegin() );
- }
-
- nssv_constexpr size_type to_pos( const_reverse_iterator it ) const
- {
- return it == crend() ? npos : size_type( crend() - it - 1 );
- }
-
- nssv_constexpr const_reference data_at( size_type pos ) const
- {
-#if nssv_BETWEEN( nssv_COMPILER_GNUC_VERSION, 1, 500 )
- return data_[pos];
-#else
- return assert( pos < size() ), data_[pos];
-#endif
- }
-
-private:
- const_pointer data_;
- size_type size_;
-
-public:
-#if nssv_CONFIG_CONVERSION_STD_STRING_CLASS_METHODS
-
- template< class Allocator >
- basic_string_view( std::basic_string<CharT, Traits, Allocator> const & s ) nssv_noexcept
- : data_( s.data() )
- , size_( s.size() )
- {}
-
-#if nssv_HAVE_EXPLICIT_CONVERSION
-
- template< class Allocator >
- explicit operator std::basic_string<CharT, Traits, Allocator>() const
- {
- return to_string( Allocator() );
- }
-
-#endif // nssv_HAVE_EXPLICIT_CONVERSION
-
-#if nssv_CPP11_OR_GREATER
-
- template< class Allocator = std::allocator<CharT> >
- std::basic_string<CharT, Traits, Allocator>
- to_string( Allocator const & a = Allocator() ) const
- {
- return std::basic_string<CharT, Traits, Allocator>( begin(), end(), a );
- }
-
-#else
-
- std::basic_string<CharT, Traits>
- to_string() const
- {
- return std::basic_string<CharT, Traits>( begin(), end() );
- }
-
- template< class Allocator >
- std::basic_string<CharT, Traits, Allocator>
- to_string( Allocator const & a ) const
- {
- return std::basic_string<CharT, Traits, Allocator>( begin(), end(), a );
- }
-
-#endif // nssv_CPP11_OR_GREATER
-
-#endif // nssv_CONFIG_CONVERSION_STD_STRING_CLASS_METHODS
-};
-
-//
-// Non-member functions:
-//
-
-// 24.4.3 Non-member comparison functions:
-// lexicographically compare two string views (function template):
-
-template< class CharT, class Traits >
-nssv_constexpr bool operator== (
- basic_string_view <CharT, Traits> lhs,
- basic_string_view <CharT, Traits> rhs ) nssv_noexcept
-{ return lhs.compare( rhs ) == 0 ; }
-
-template< class CharT, class Traits >
-nssv_constexpr bool operator!= (
- basic_string_view <CharT, Traits> lhs,
- basic_string_view <CharT, Traits> rhs ) nssv_noexcept
-{ return lhs.compare( rhs ) != 0 ; }
-
-template< class CharT, class Traits >
-nssv_constexpr bool operator< (
- basic_string_view <CharT, Traits> lhs,
- basic_string_view <CharT, Traits> rhs ) nssv_noexcept
-{ return lhs.compare( rhs ) < 0 ; }
-
-template< class CharT, class Traits >
-nssv_constexpr bool operator<= (
- basic_string_view <CharT, Traits> lhs,
- basic_string_view <CharT, Traits> rhs ) nssv_noexcept
-{ return lhs.compare( rhs ) <= 0 ; }
-
-template< class CharT, class Traits >
-nssv_constexpr bool operator> (
- basic_string_view <CharT, Traits> lhs,
- basic_string_view <CharT, Traits> rhs ) nssv_noexcept
-{ return lhs.compare( rhs ) > 0 ; }
-
-template< class CharT, class Traits >
-nssv_constexpr bool operator>= (
- basic_string_view <CharT, Traits> lhs,
- basic_string_view <CharT, Traits> rhs ) nssv_noexcept
-{ return lhs.compare( rhs ) >= 0 ; }
-
-// Let S be basic_string_view<CharT, Traits>, and sv be an instance of S.
-// Implementations shall provide sufficient additional overloads marked
-// constexpr and noexcept so that an object t with an implicit conversion
-// to S can be compared according to Table 67.
-
-#if nssv_CPP11_OR_GREATER && ! nssv_BETWEEN( nssv_COMPILER_MSVC_VERSION, 100, 141 )
-
-#define nssv_BASIC_STRING_VIEW_I(T,U) typename std::decay< basic_string_view<T,U> >::type
-
-#if nssv_BETWEEN( nssv_COMPILER_MSVC_VERSION, 140, 150 )
-# define nssv_MSVC_ORDER(x) , int=x
-#else
-# define nssv_MSVC_ORDER(x) /*, int=x*/
-#endif
-
-// ==
-
-template< class CharT, class Traits nssv_MSVC_ORDER(1) >
-nssv_constexpr bool operator==(
- basic_string_view <CharT, Traits> lhs,
- nssv_BASIC_STRING_VIEW_I(CharT, Traits) rhs ) nssv_noexcept
-{ return lhs.compare( rhs ) == 0; }
-
-template< class CharT, class Traits nssv_MSVC_ORDER(2) >
-nssv_constexpr bool operator==(
- nssv_BASIC_STRING_VIEW_I(CharT, Traits) lhs,
- basic_string_view <CharT, Traits> rhs ) nssv_noexcept
-{ return lhs.size() == rhs.size() && lhs.compare( rhs ) == 0; }
-
-// !=
-
-template< class CharT, class Traits nssv_MSVC_ORDER(1) >
-nssv_constexpr bool operator!= (
- basic_string_view < CharT, Traits > lhs,
- nssv_BASIC_STRING_VIEW_I( CharT, Traits ) rhs ) nssv_noexcept
-{ return lhs.size() != rhs.size() || lhs.compare( rhs ) != 0 ; }
-
-template< class CharT, class Traits nssv_MSVC_ORDER(2) >
-nssv_constexpr bool operator!= (
- nssv_BASIC_STRING_VIEW_I( CharT, Traits ) lhs,
- basic_string_view < CharT, Traits > rhs ) nssv_noexcept
-{ return lhs.compare( rhs ) != 0 ; }
-
-// <
-
-template< class CharT, class Traits nssv_MSVC_ORDER(1) >
-nssv_constexpr bool operator< (
- basic_string_view < CharT, Traits > lhs,
- nssv_BASIC_STRING_VIEW_I( CharT, Traits ) rhs ) nssv_noexcept
-{ return lhs.compare( rhs ) < 0 ; }
-
-template< class CharT, class Traits nssv_MSVC_ORDER(2) >
-nssv_constexpr bool operator< (
- nssv_BASIC_STRING_VIEW_I( CharT, Traits ) lhs,
- basic_string_view < CharT, Traits > rhs ) nssv_noexcept
-{ return lhs.compare( rhs ) < 0 ; }
-
-// <=
-
-template< class CharT, class Traits nssv_MSVC_ORDER(1) >
-nssv_constexpr bool operator<= (
- basic_string_view < CharT, Traits > lhs,
- nssv_BASIC_STRING_VIEW_I( CharT, Traits ) rhs ) nssv_noexcept
-{ return lhs.compare( rhs ) <= 0 ; }
-
-template< class CharT, class Traits nssv_MSVC_ORDER(2) >
-nssv_constexpr bool operator<= (
- nssv_BASIC_STRING_VIEW_I( CharT, Traits ) lhs,
- basic_string_view < CharT, Traits > rhs ) nssv_noexcept
-{ return lhs.compare( rhs ) <= 0 ; }
-
-// >
-
-template< class CharT, class Traits nssv_MSVC_ORDER(1) >
-nssv_constexpr bool operator> (
- basic_string_view < CharT, Traits > lhs,
- nssv_BASIC_STRING_VIEW_I( CharT, Traits ) rhs ) nssv_noexcept
-{ return lhs.compare( rhs ) > 0 ; }
-
-template< class CharT, class Traits nssv_MSVC_ORDER(2) >
-nssv_constexpr bool operator> (
- nssv_BASIC_STRING_VIEW_I( CharT, Traits ) lhs,
- basic_string_view < CharT, Traits > rhs ) nssv_noexcept
-{ return lhs.compare( rhs ) > 0 ; }
-
-// >=
-
-template< class CharT, class Traits nssv_MSVC_ORDER(1) >
-nssv_constexpr bool operator>= (
- basic_string_view < CharT, Traits > lhs,
- nssv_BASIC_STRING_VIEW_I( CharT, Traits ) rhs ) nssv_noexcept
-{ return lhs.compare( rhs ) >= 0 ; }
-
-template< class CharT, class Traits nssv_MSVC_ORDER(2) >
-nssv_constexpr bool operator>= (
- nssv_BASIC_STRING_VIEW_I( CharT, Traits ) lhs,
- basic_string_view < CharT, Traits > rhs ) nssv_noexcept
-{ return lhs.compare( rhs ) >= 0 ; }
-
-#undef nssv_MSVC_ORDER
-#undef nssv_BASIC_STRING_VIEW_I
-
-#endif // nssv_CPP11_OR_GREATER
-
-// 24.4.4 Inserters and extractors:
-
-namespace detail {
-
-template< class Stream >
-void write_padding( Stream & os, std::streamsize n )
-{
- for ( std::streamsize i = 0; i < n; ++i )
- os.rdbuf()->sputc( os.fill() );
-}
-
-template< class Stream, class View >
-Stream & write_to_stream( Stream & os, View const & sv )
-{
- typename Stream::sentry sentry( os );
-
- if ( !os )
- return os;
-
- const std::streamsize length = static_cast<std::streamsize>( sv.length() );
-
- // Whether, and how, to pad:
- const bool pad = ( length < os.width() );
- const bool left_pad = pad && ( os.flags() & std::ios_base::adjustfield ) == std::ios_base::right;
-
- if ( left_pad )
- write_padding( os, os.width() - length );
-
- // Write span characters:
- os.rdbuf()->sputn( sv.begin(), length );
-
- if ( pad && !left_pad )
- write_padding( os, os.width() - length );
-
- // Reset output stream width:
- os.width( 0 );
-
- return os;
-}
-
-} // namespace detail
-
-template< class CharT, class Traits >
-std::basic_ostream<CharT, Traits> &
-operator<<(
- std::basic_ostream<CharT, Traits>& os,
- basic_string_view <CharT, Traits> sv )
-{
- return detail::write_to_stream( os, sv );
-}
-
-// Several typedefs for common character types are provided:
-
-typedef basic_string_view<char> string_view;
-typedef basic_string_view<wchar_t> wstring_view;
-#if nssv_HAVE_WCHAR16_T
-typedef basic_string_view<char16_t> u16string_view;
-typedef basic_string_view<char32_t> u32string_view;
-#endif
-
-}} // namespace nonstd::sv_lite
-
-//
-// 24.4.6 Suffix for basic_string_view literals:
-//
-
-#if nssv_HAVE_USER_DEFINED_LITERALS
-
-namespace nonstd {
-nssv_inline_ns namespace literals {
-nssv_inline_ns namespace string_view_literals {
-
-#if nssv_CONFIG_STD_SV_OPERATOR && nssv_HAVE_STD_DEFINED_LITERALS
-
-nssv_constexpr nonstd::sv_lite::string_view operator "" sv( const char* str, size_t len ) nssv_noexcept // (1)
-{
- return nonstd::sv_lite::string_view{ str, len };
-}
-
-nssv_constexpr nonstd::sv_lite::u16string_view operator "" sv( const char16_t* str, size_t len ) nssv_noexcept // (2)
-{
- return nonstd::sv_lite::u16string_view{ str, len };
-}
-
-nssv_constexpr nonstd::sv_lite::u32string_view operator "" sv( const char32_t* str, size_t len ) nssv_noexcept // (3)
-{
- return nonstd::sv_lite::u32string_view{ str, len };
-}
-
-nssv_constexpr nonstd::sv_lite::wstring_view operator "" sv( const wchar_t* str, size_t len ) nssv_noexcept // (4)
-{
- return nonstd::sv_lite::wstring_view{ str, len };
-}
-
-#endif // nssv_CONFIG_STD_SV_OPERATOR && nssv_HAVE_STD_DEFINED_LITERALS
-
-#if nssv_CONFIG_USR_SV_OPERATOR
-
-nssv_constexpr nonstd::sv_lite::string_view operator "" _sv( const char* str, size_t len ) nssv_noexcept // (1)
-{
- return nonstd::sv_lite::string_view{ str, len };
-}
-
-nssv_constexpr nonstd::sv_lite::u16string_view operator "" _sv( const char16_t* str, size_t len ) nssv_noexcept // (2)
-{
- return nonstd::sv_lite::u16string_view{ str, len };
-}
-
-nssv_constexpr nonstd::sv_lite::u32string_view operator "" _sv( const char32_t* str, size_t len ) nssv_noexcept // (3)
-{
- return nonstd::sv_lite::u32string_view{ str, len };
-}
-
-nssv_constexpr nonstd::sv_lite::wstring_view operator "" _sv( const wchar_t* str, size_t len ) nssv_noexcept // (4)
-{
- return nonstd::sv_lite::wstring_view{ str, len };
-}
-
-#endif // nssv_CONFIG_USR_SV_OPERATOR
-
-}}} // namespace nonstd::literals::string_view_literals
-
-#endif
-
-//
-// Extensions for std::string:
-//
-
-#if nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS
-
-namespace nonstd {
-namespace sv_lite {
-
-// Exclude MSVC 14 (19.00): it yields ambiguous to_string():
-
-#if nssv_CPP11_OR_GREATER && nssv_COMPILER_MSVC_VERSION != 140
-
-template< class CharT, class Traits, class Allocator = std::allocator<CharT> >
-std::basic_string<CharT, Traits, Allocator>
-to_string( basic_string_view<CharT, Traits> v, Allocator const & a = Allocator() )
-{
- return std::basic_string<CharT,Traits, Allocator>( v.begin(), v.end(), a );
-}
-
-#else
-
-template< class CharT, class Traits >
-std::basic_string<CharT, Traits>
-to_string( basic_string_view<CharT, Traits> v )
-{
- return std::basic_string<CharT, Traits>( v.begin(), v.end() );
-}
-
-template< class CharT, class Traits, class Allocator >
-std::basic_string<CharT, Traits, Allocator>
-to_string( basic_string_view<CharT, Traits> v, Allocator const & a )
-{
- return std::basic_string<CharT, Traits, Allocator>( v.begin(), v.end(), a );
-}
-
-#endif // nssv_CPP11_OR_GREATER
-
-template< class CharT, class Traits, class Allocator >
-basic_string_view<CharT, Traits>
-to_string_view( std::basic_string<CharT, Traits, Allocator> const & s )
-{
- return basic_string_view<CharT, Traits>( s.data(), s.size() );
-}
-
-}} // namespace nonstd::sv_lite
-
-#endif // nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS
-
-//
-// make types and algorithms available in namespace nonstd:
-//
-
-namespace nonstd {
-
-using sv_lite::basic_string_view;
-using sv_lite::string_view;
-using sv_lite::wstring_view;
-
-#if nssv_HAVE_WCHAR16_T
-using sv_lite::u16string_view;
-#endif
-#if nssv_HAVE_WCHAR32_T
-using sv_lite::u32string_view;
-#endif
-
-// literal "sv"
-
-using sv_lite::operator==;
-using sv_lite::operator!=;
-using sv_lite::operator<;
-using sv_lite::operator<=;
-using sv_lite::operator>;
-using sv_lite::operator>=;
-
-using sv_lite::operator<<;
-
-#if nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS
-using sv_lite::to_string;
-using sv_lite::to_string_view;
-#endif
-
-} // namespace nonstd
-
-// 24.4.5 Hash support (C++11):
-
-// Note: The hash value of a string view object is equal to the hash value of
-// the corresponding string object.
-
-#if nssv_HAVE_STD_HASH
-
-#include <functional>
-
-namespace std {
-
-template<>
-struct hash< nonstd::string_view >
-{
-public:
- std::size_t operator()( nonstd::string_view v ) const nssv_noexcept
- {
- return std::hash<std::string>()( std::string( v.data(), v.size() ) );
- }
-};
-
-template<>
-struct hash< nonstd::wstring_view >
-{
-public:
- std::size_t operator()( nonstd::wstring_view v ) const nssv_noexcept
- {
- return std::hash<std::wstring>()( std::wstring( v.data(), v.size() ) );
- }
-};
-
-template<>
-struct hash< nonstd::u16string_view >
-{
-public:
- std::size_t operator()( nonstd::u16string_view v ) const nssv_noexcept
- {
- return std::hash<std::u16string>()( std::u16string( v.data(), v.size() ) );
- }
-};
-
-template<>
-struct hash< nonstd::u32string_view >
-{
-public:
- std::size_t operator()( nonstd::u32string_view v ) const nssv_noexcept
- {
- return std::hash<std::u32string>()( std::u32string( v.data(), v.size() ) );
- }
-};
-
-} // namespace std
-
-#endif // nssv_HAVE_STD_HASH
-
-nssv_RESTORE_WARNINGS()
-
-#endif // nssv_HAVE_STD_STRING_VIEW
-#endif // NONSTD_SV_LITE_H_INCLUDED
-
-
-
-namespace inja {
-
-enum class ElementNotation {
- Dot,
- Pointer
-};
-
-/*!
- * \brief Class for lexer configuration.
- */
-struct LexerConfig {
- std::string statement_open {"{%"};
- std::string statement_close {"%}"};
- std::string line_statement {"##"};
- std::string expression_open {"{{"};
- std::string expression_close {"}}"};
- std::string comment_open {"{#"};
- std::string comment_close {"#}"};
- std::string open_chars {"#{"};
-
- bool trim_blocks {false};
- bool lstrip_blocks {false};
-
- void update_open_chars() {
- open_chars = "";
- if (open_chars.find(line_statement[0]) == std::string::npos) {
- open_chars += line_statement[0];
- }
- if (open_chars.find(statement_open[0]) == std::string::npos) {
- open_chars += statement_open[0];
- }
- if (open_chars.find(expression_open[0]) == std::string::npos) {
- open_chars += expression_open[0];
- }
- if (open_chars.find(comment_open[0]) == std::string::npos) {
- open_chars += comment_open[0];
- }
- }
-};
-
-/*!
- * \brief Class for parser configuration.
- */
-struct ParserConfig {
- ElementNotation notation {ElementNotation::Dot};
-};
-
-}
-
-#endif // PANTOR_INJA_CONFIG_HPP
-
-// #include "function_storage.hpp"
-#ifndef PANTOR_INJA_FUNCTION_STORAGE_HPP
-#define PANTOR_INJA_FUNCTION_STORAGE_HPP
-
-#include <vector>
-
-// #include "bytecode.hpp"
-#ifndef PANTOR_INJA_BYTECODE_HPP
-#define PANTOR_INJA_BYTECODE_HPP
-
-#include <string>
-#include <utility>
-
-#include <nlohmann/json.hpp>
-
-// #include "string_view.hpp"
-
-
-
-namespace inja {
-
-using json = nlohmann::json;
-
-
-struct Bytecode {
- enum class Op : uint8_t {
- Nop,
- // print StringRef (always immediate)
- PrintText,
- // print value
- PrintValue,
- // push value onto stack (always immediate)
- Push,
-
- // builtin functions
- // result is pushed to stack
- // args specify number of arguments
- // all functions can take their "last" argument either immediate
- // or popped off stack (e.g. if immediate, it's like the immediate was
- // just pushed to the stack)
- Not,
- And,
- Or,
- In,
- Equal,
- Greater,
- GreaterEqual,
- Less,
- LessEqual,
- At,
- Different,
- DivisibleBy,
- Even,
- First,
- Float,
- Int,
- Last,
- Length,
- Lower,
- Max,
- Min,
- Odd,
- Range,
- Result,
- Round,
- Sort,
- Upper,
- Exists,
- ExistsInObject,
- IsBoolean,
- IsNumber,
- IsInteger,
- IsFloat,
- IsObject,
- IsArray,
- IsString,
- Default,
-
- // include another template
- // value is the template name
- Include,
-
- // callback function
- // str is the function name (this means it cannot be a lookup)
- // args specify number of arguments
- // as with builtin functions, "last" argument can be immediate
- Callback,
-
- // unconditional jump
- // args is the index of the bytecode to jump to.
- Jump,
-
- // conditional jump
- // value popped off stack is checked for truthyness
- // if false, args is the index of the bytecode to jump to.
- // if true, no action is taken (falls through)
- ConditionalJump,
-
- // start loop
- // value popped off stack is what is iterated over
- // args is index of bytecode after end loop (jumped to if iterable is
- // empty)
- // immediate value is key name (for maps)
- // str is value name
- StartLoop,
-
- // end a loop
- // args is index of the first bytecode in the loop body
- EndLoop,
- };
-
- enum Flag {
- // location of value for value-taking ops (mask)
- ValueMask = 0x03,
- // pop value off stack
- ValuePop = 0x00,
- // value is immediate rather than on stack
- ValueImmediate = 0x01,
- // lookup immediate str (dot notation)
- ValueLookupDot = 0x02,
- // lookup immediate str (json pointer notation)
- ValueLookupPointer = 0x03,
- };
-
- Op op {Op::Nop};
- uint32_t args: 30;
- uint32_t flags: 2;
-
- json value;
- std::string str;
-
- Bytecode(): args(0), flags(0) {}
- explicit Bytecode(Op op, unsigned int args = 0): op(op), args(args), flags(0) {}
- explicit Bytecode(Op op, nonstd::string_view str, unsigned int flags): op(op), args(0), flags(flags), str(str) {}
- explicit Bytecode(Op op, json&& value, unsigned int flags): op(op), args(0), flags(flags), value(std::move(value)) {}
-};
-
-} // namespace inja
-
-#endif // PANTOR_INJA_BYTECODE_HPP
-
-// #include "string_view.hpp"
-
-
-
-namespace inja {
-
-using namespace nlohmann;
-
-using Arguments = std::vector<const json*>;
-using CallbackFunction = std::function<json(Arguments& args)>;
-
-/*!
- * \brief Class for builtin functions and user-defined callbacks.
- */
-class FunctionStorage {
- public:
- void add_builtin(nonstd::string_view name, unsigned int num_args, Bytecode::Op op) {
- auto& data = get_or_new(name, num_args);
- data.op = op;
- }
-
- void add_callback(nonstd::string_view name, unsigned int num_args, const CallbackFunction& function) {
- auto& data = get_or_new(name, num_args);
- data.function = function;
- }
-
- Bytecode::Op find_builtin(nonstd::string_view name, unsigned int num_args) const {
- if (auto ptr = get(name, num_args)) {
- return ptr->op;
- }
- return Bytecode::Op::Nop;
- }
-
- CallbackFunction find_callback(nonstd::string_view name, unsigned int num_args) const {
- if (auto ptr = get(name, num_args)) {
- return ptr->function;
- }
- return nullptr;
- }
-
- private:
- struct FunctionData {
- unsigned int num_args {0};
- Bytecode::Op op {Bytecode::Op::Nop}; // for builtins
- CallbackFunction function; // for callbacks
- };
-
- FunctionData& get_or_new(nonstd::string_view name, unsigned int num_args) {
- auto &vec = m_map[static_cast<std::string>(name)];
- for (auto &i: vec) {
- if (i.num_args == num_args) return i;
- }
- vec.emplace_back();
- vec.back().num_args = num_args;
- return vec.back();
- }
-
- const FunctionData* get(nonstd::string_view name, unsigned int num_args) const {
- auto it = m_map.find(static_cast<std::string>(name));
- if (it == m_map.end()) return nullptr;
- for (auto &&i: it->second) {
- if (i.num_args == num_args) return &i;
- }
- return nullptr;
- }
-
- std::map<std::string, std::vector<FunctionData>> m_map;
-};
-
-}
-
-#endif // PANTOR_INJA_FUNCTION_STORAGE_HPP
-
-// #include "parser.hpp"
-#ifndef PANTOR_INJA_PARSER_HPP
-#define PANTOR_INJA_PARSER_HPP
-
-#include <limits>
-#include <string>
-#include <utility>
-#include <vector>
-
-// #include "bytecode.hpp"
-
-// #include "config.hpp"
-
-// #include "function_storage.hpp"
-
-// #include "lexer.hpp"
-#ifndef PANTOR_INJA_LEXER_HPP
-#define PANTOR_INJA_LEXER_HPP
-
-#include <cctype>
-#include <locale>
-
-// #include "config.hpp"
-
-// #include "token.hpp"
-#ifndef PANTOR_INJA_TOKEN_HPP
-#define PANTOR_INJA_TOKEN_HPP
-
-#include <string>
-
-// #include "string_view.hpp"
-
-
-
-namespace inja {
-
-/*!
- * \brief Helper-class for the inja Parser.
- */
-struct Token {
- enum class Kind {
- Text,
- ExpressionOpen, // {{
- ExpressionClose, // }}
- LineStatementOpen, // ##
- LineStatementClose, // \n
- StatementOpen, // {%
- StatementClose, // %}
- CommentOpen, // {#
- CommentClose, // #}
- Id, // this, this.foo
- Number, // 1, 2, -1, 5.2, -5.3
- String, // "this"
- Comma, // ,
- Colon, // :
- LeftParen, // (
- RightParen, // )
- LeftBracket, // [
- RightBracket, // ]
- LeftBrace, // {
- RightBrace, // }
- Equal, // ==
- GreaterThan, // >
- GreaterEqual, // >=
- LessThan, // <
- LessEqual, // <=
- NotEqual, // !=
- Unknown,
- Eof
- } kind {Kind::Unknown};
-
- nonstd::string_view text;
-
- constexpr Token() = default;
- constexpr Token(Kind kind, nonstd::string_view text): kind(kind), text(text) {}
-
- std::string describe() const {
- switch (kind) {
- case Kind::Text:
- return "<text>";
- case Kind::LineStatementClose:
- return "<eol>";
- case Kind::Eof:
- return "<eof>";
- default:
- return static_cast<std::string>(text);
- }
- }
-};
-
-}
-
-#endif // PANTOR_INJA_TOKEN_HPP
-
-// #include "utils.hpp"
-#ifndef PANTOR_INJA_UTILS_HPP
-#define PANTOR_INJA_UTILS_HPP
-
-#include <algorithm>
-#include <fstream>
-#include <stdexcept>
-#include <string>
-#include <utility>
-
-// #include "string_view.hpp"
-
-
-
-namespace inja {
-
-inline void inja_throw(const std::string& type, const std::string& message) {
- throw std::runtime_error("[inja.exception." + type + "] " + message);
-}
-
-inline std::ifstream open_file_or_throw(const std::string& path) {
- std::ifstream file;
- file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
- try {
- file.open(path);
- } catch(const std::ios_base::failure& e) {
- inja_throw("file_error", "failed accessing file at '" + path + "'");
- }
- return file;
-}
-
-namespace string_view {
- inline nonstd::string_view slice(nonstd::string_view view, size_t start, size_t end) {
- start = std::min(start, view.size());
- end = std::min(std::max(start, end), view.size());
- return view.substr(start, end - start); // StringRef(Data + Start, End - Start);
- }
-
- inline std::pair<nonstd::string_view, nonstd::string_view> split(nonstd::string_view view, char Separator) {
- size_t idx = view.find(Separator);
- if (idx == nonstd::string_view::npos) {
- return std::make_pair(view, nonstd::string_view());
- }
- return std::make_pair(slice(view, 0, idx), slice(view, idx + 1, nonstd::string_view::npos));
- }
-
- inline bool starts_with(nonstd::string_view view, nonstd::string_view prefix) {
- return (view.size() >= prefix.size() && view.compare(0, prefix.size(), prefix) == 0);
- }
-} // namespace string
-
-} // namespace inja
-
-#endif // PANTOR_INJA_UTILS_HPP
-
-
-
-namespace inja {
-
-/*!
- * \brief Class for lexing an inja Template.
- */
-class Lexer {
- enum class State {
- Text,
- ExpressionStart,
- ExpressionBody,
- LineStart,
- LineBody,
- StatementStart,
- StatementBody,
- CommentStart,
- CommentBody
- } m_state;
-
- const LexerConfig& m_config;
- nonstd::string_view m_in;
- size_t m_tok_start;
- size_t m_pos;
-
- public:
- explicit Lexer(const LexerConfig& config) : m_config(config) {}
-
- void start(nonstd::string_view in) {
- m_in = in;
- m_tok_start = 0;
- m_pos = 0;
- m_state = State::Text;
- }
-
- Token scan() {
- m_tok_start = m_pos;
-
- again:
- if (m_tok_start >= m_in.size()) return make_token(Token::Kind::Eof);
-
- switch (m_state) {
- default:
- case State::Text: {
- // fast-scan to first open character
- size_t open_start = m_in.substr(m_pos).find_first_of(m_config.open_chars);
- if (open_start == nonstd::string_view::npos) {
- // didn't find open, return remaining text as text token
- m_pos = m_in.size();
- return make_token(Token::Kind::Text);
- }
- m_pos += open_start;
-
- // try to match one of the opening sequences, and get the close
- nonstd::string_view open_str = m_in.substr(m_pos);
- bool must_lstrip = false;
- if (inja::string_view::starts_with(open_str, m_config.expression_open)) {
- m_state = State::ExpressionStart;
- } else if (inja::string_view::starts_with(open_str, m_config.statement_open)) {
- m_state = State::StatementStart;
- must_lstrip = m_config.lstrip_blocks;
- } else if (inja::string_view::starts_with(open_str, m_config.comment_open)) {
- m_state = State::CommentStart;
- must_lstrip = m_config.lstrip_blocks;
- } else if ((m_pos == 0 || m_in[m_pos - 1] == '\n') &&
- inja::string_view::starts_with(open_str, m_config.line_statement)) {
- m_state = State::LineStart;
- } else {
- m_pos += 1; // wasn't actually an opening sequence
- goto again;
- }
-
- nonstd::string_view text = string_view::slice(m_in, m_tok_start, m_pos);
- if (must_lstrip)
- text = clear_final_line_if_whitespace(text);
-
- if (text.empty()) goto again; // don't generate empty token
- return Token(Token::Kind::Text, text);
- }
- case State::ExpressionStart: {
- m_state = State::ExpressionBody;
- m_pos += m_config.expression_open.size();
- return make_token(Token::Kind::ExpressionOpen);
- }
- case State::LineStart: {
- m_state = State::LineBody;
- m_pos += m_config.line_statement.size();
- return make_token(Token::Kind::LineStatementOpen);
- }
- case State::StatementStart: {
- m_state = State::StatementBody;
- m_pos += m_config.statement_open.size();
- return make_token(Token::Kind::StatementOpen);
- }
- case State::CommentStart: {
- m_state = State::CommentBody;
- m_pos += m_config.comment_open.size();
- return make_token(Token::Kind::CommentOpen);
- }
- case State::ExpressionBody:
- return scan_body(m_config.expression_close, Token::Kind::ExpressionClose);
- case State::LineBody:
- return scan_body("\n", Token::Kind::LineStatementClose);
- case State::StatementBody:
- return scan_body(m_config.statement_close, Token::Kind::StatementClose, m_config.trim_blocks);
- case State::CommentBody: {
- // fast-scan to comment close
- size_t end = m_in.substr(m_pos).find(m_config.comment_close);
- if (end == nonstd::string_view::npos) {
- m_pos = m_in.size();
- return make_token(Token::Kind::Eof);
- }
- // return the entire comment in the close token
- m_state = State::Text;
- m_pos += end + m_config.comment_close.size();
- Token tok = make_token(Token::Kind::CommentClose);
- if (m_config.trim_blocks)
- skip_newline();
- return tok;
- }
- }
- }
-
- const LexerConfig& get_config() const { return m_config; }
-
- private:
- Token scan_body(nonstd::string_view close, Token::Kind closeKind, bool trim = false) {
- again:
- // skip whitespace (except for \n as it might be a close)
- if (m_tok_start >= m_in.size()) return make_token(Token::Kind::Eof);
- char ch = m_in[m_tok_start];
- if (ch == ' ' || ch == '\t' || ch == '\r') {
- m_tok_start += 1;
- goto again;
- }
-
- // check for close
- if (inja::string_view::starts_with(m_in.substr(m_tok_start), close)) {
- m_state = State::Text;
- m_pos = m_tok_start + close.size();
- Token tok = make_token(closeKind);
- if (trim)
- skip_newline();
- return tok;
- }
-
- // skip \n
- if (ch == '\n') {
- m_tok_start += 1;
- goto again;
- }
-
- m_pos = m_tok_start + 1;
- if (std::isalpha(ch)) return scan_id();
- switch (ch) {
- case ',':
- return make_token(Token::Kind::Comma);
- case ':':
- return make_token(Token::Kind::Colon);
- case '(':
- return make_token(Token::Kind::LeftParen);
- case ')':
- return make_token(Token::Kind::RightParen);
- case '[':
- return make_token(Token::Kind::LeftBracket);
- case ']':
- return make_token(Token::Kind::RightBracket);
- case '{':
- return make_token(Token::Kind::LeftBrace);
- case '}':
- return make_token(Token::Kind::RightBrace);
- case '>':
- if (m_pos < m_in.size() && m_in[m_pos] == '=') {
- m_pos += 1;
- return make_token(Token::Kind::GreaterEqual);
- }
- return make_token(Token::Kind::GreaterThan);
- case '<':
- if (m_pos < m_in.size() && m_in[m_pos] == '=') {
- m_pos += 1;
- return make_token(Token::Kind::LessEqual);
- }
- return make_token(Token::Kind::LessThan);
- case '=':
- if (m_pos < m_in.size() && m_in[m_pos] == '=') {
- m_pos += 1;
- return make_token(Token::Kind::Equal);
- }
- return make_token(Token::Kind::Unknown);
- case '!':
- if (m_pos < m_in.size() && m_in[m_pos] == '=') {
- m_pos += 1;
- return make_token(Token::Kind::NotEqual);
- }
- return make_token(Token::Kind::Unknown);
- case '\"':
- return scan_string();
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- case '-':
- return scan_number();
- case '_':
- return scan_id();
- default:
- return make_token(Token::Kind::Unknown);
- }
- }
-
- Token scan_id() {
- for (;;) {
- if (m_pos >= m_in.size()) {
- break;
- }
- char ch = m_in[m_pos];
- if (!std::isalnum(ch) && ch != '.' && ch != '/' && ch != '_' && ch != '-') {
- break;
- }
- m_pos += 1;
- }
- return make_token(Token::Kind::Id);
- }
-
- Token scan_number() {
- for (;;) {
- if (m_pos >= m_in.size()) {
- break;
- }
- char ch = m_in[m_pos];
- // be very permissive in lexer (we'll catch errors when conversion happens)
- if (!std::isdigit(ch) && ch != '.' && ch != 'e' && ch != 'E' && ch != '+' && ch != '-') {
- break;
- }
- m_pos += 1;
- }
- return make_token(Token::Kind::Number);
- }
-
- Token scan_string() {
- bool escape {false};
- for (;;) {
- if (m_pos >= m_in.size()) break;
- char ch = m_in[m_pos++];
- if (ch == '\\') {
- escape = true;
- } else if (!escape && ch == m_in[m_tok_start]) {
- break;
- } else {
- escape = false;
- }
- }
- return make_token(Token::Kind::String);
- }
-
- Token make_token(Token::Kind kind) const {
- return Token(kind, string_view::slice(m_in, m_tok_start, m_pos));
- }
-
- void skip_newline() {
- if (m_pos < m_in.size()) {
- char ch = m_in[m_pos];
- if (ch == '\n')
- m_pos += 1;
- else if (ch == '\r') {
- m_pos += 1;
- if (m_pos < m_in.size() && m_in[m_pos] == '\n')
- m_pos += 1;
- }
- }
- }
-
- static nonstd::string_view clear_final_line_if_whitespace(nonstd::string_view text)
- {
- nonstd::string_view result = text;
- while (!result.empty()) {
- char ch = result.back();
- if (ch == ' ' || ch == '\t')
- result.remove_suffix(1);
- else if (ch == '\n' || ch == '\r')
- break;
- else
- return text;
- }
- return result;
- }
-};
-
-}
-
-#endif // PANTOR_INJA_LEXER_HPP
-
-// #include "template.hpp"
-#ifndef PANTOR_INJA_TEMPLATE_HPP
-#define PANTOR_INJA_TEMPLATE_HPP
-
-#include <map>
-#include <string>
-#include <vector>
-
-// #include "bytecode.hpp"
-
-
-
-namespace inja {
-
-/*!
- * \brief The main inja Template.
- */
-struct Template {
- std::vector<Bytecode> bytecodes;
- std::string content;
-};
-
-using TemplateStorage = std::map<std::string, Template>;
-
-}
-
-#endif // PANTOR_INJA_TEMPLATE_HPP
-
-// #include "token.hpp"
-
-// #include "utils.hpp"
-
-
-#include <nlohmann/json.hpp>
-
-
-namespace inja {
-
-class ParserStatic {
- ParserStatic() {
- functions.add_builtin("at", 2, Bytecode::Op::At);
- functions.add_builtin("default", 2, Bytecode::Op::Default);
- functions.add_builtin("divisibleBy", 2, Bytecode::Op::DivisibleBy);
- functions.add_builtin("even", 1, Bytecode::Op::Even);
- functions.add_builtin("first", 1, Bytecode::Op::First);
- functions.add_builtin("float", 1, Bytecode::Op::Float);
- functions.add_builtin("int", 1, Bytecode::Op::Int);
- functions.add_builtin("last", 1, Bytecode::Op::Last);
- functions.add_builtin("length", 1, Bytecode::Op::Length);
- functions.add_builtin("lower", 1, Bytecode::Op::Lower);
- functions.add_builtin("max", 1, Bytecode::Op::Max);
- functions.add_builtin("min", 1, Bytecode::Op::Min);
- functions.add_builtin("odd", 1, Bytecode::Op::Odd);
- functions.add_builtin("range", 1, Bytecode::Op::Range);
- functions.add_builtin("round", 2, Bytecode::Op::Round);
- functions.add_builtin("sort", 1, Bytecode::Op::Sort);
- functions.add_builtin("upper", 1, Bytecode::Op::Upper);
- functions.add_builtin("exists", 1, Bytecode::Op::Exists);
- functions.add_builtin("existsIn", 2, Bytecode::Op::ExistsInObject);
- functions.add_builtin("isBoolean", 1, Bytecode::Op::IsBoolean);
- functions.add_builtin("isNumber", 1, Bytecode::Op::IsNumber);
- functions.add_builtin("isInteger", 1, Bytecode::Op::IsInteger);
- functions.add_builtin("isFloat", 1, Bytecode::Op::IsFloat);
- functions.add_builtin("isObject", 1, Bytecode::Op::IsObject);
- functions.add_builtin("isArray", 1, Bytecode::Op::IsArray);
- functions.add_builtin("isString", 1, Bytecode::Op::IsString);
- }
-
- public:
- ParserStatic(const ParserStatic&) = delete;
- ParserStatic& operator=(const ParserStatic&) = delete;
-
- static const ParserStatic& get_instance() {
- static ParserStatic inst;
- return inst;
- }
-
- FunctionStorage functions;
-};
-
-/*!
- * \brief Class for parsing an inja Template.
- */
-class Parser {
- public:
- explicit Parser(const ParserConfig& parser_config, const LexerConfig& lexer_config, TemplateStorage& included_templates): m_config(parser_config), m_lexer(lexer_config), m_included_templates(included_templates), m_static(ParserStatic::get_instance()) { }
-
- bool parse_expression(Template& tmpl) {
- if (!parse_expression_and(tmpl)) return false;
- if (m_tok.kind != Token::Kind::Id || m_tok.text != static_cast<decltype(m_tok.text)>("or")) return true;
- get_next_token();
- if (!parse_expression_and(tmpl)) return false;
- append_function(tmpl, Bytecode::Op::Or, 2);
- return true;
- }
-
- bool parse_expression_and(Template& tmpl) {
- if (!parse_expression_not(tmpl)) return false;
- if (m_tok.kind != Token::Kind::Id || m_tok.text != static_cast<decltype(m_tok.text)>("and")) return true;
- get_next_token();
- if (!parse_expression_not(tmpl)) return false;
- append_function(tmpl, Bytecode::Op::And, 2);
- return true;
- }
-
- bool parse_expression_not(Template& tmpl) {
- if (m_tok.kind == Token::Kind::Id && m_tok.text == static_cast<decltype(m_tok.text)>("not")) {
- get_next_token();
- if (!parse_expression_not(tmpl)) return false;
- append_function(tmpl, Bytecode::Op::Not, 1);
- return true;
- } else {
- return parse_expression_comparison(tmpl);
- }
- }
-
- bool parse_expression_comparison(Template& tmpl) {
- if (!parse_expression_datum(tmpl)) return false;
- Bytecode::Op op;
- switch (m_tok.kind) {
- case Token::Kind::Id:
- if (m_tok.text == static_cast<decltype(m_tok.text)>("in"))
- op = Bytecode::Op::In;
- else
- return true;
- break;
- case Token::Kind::Equal:
- op = Bytecode::Op::Equal;
- break;
- case Token::Kind::GreaterThan:
- op = Bytecode::Op::Greater;
- break;
- case Token::Kind::LessThan:
- op = Bytecode::Op::Less;
- break;
- case Token::Kind::LessEqual:
- op = Bytecode::Op::LessEqual;
- break;
- case Token::Kind::GreaterEqual:
- op = Bytecode::Op::GreaterEqual;
- break;
- case Token::Kind::NotEqual:
- op = Bytecode::Op::Different;
- break;
- default:
- return true;
- }
- get_next_token();
- if (!parse_expression_datum(tmpl)) return false;
- append_function(tmpl, op, 2);
- return true;
- }
-
- bool parse_expression_datum(Template& tmpl) {
- nonstd::string_view json_first;
- size_t bracket_level = 0;
- size_t brace_level = 0;
-
- for (;;) {
- switch (m_tok.kind) {
- case Token::Kind::LeftParen: {
- get_next_token();
- if (!parse_expression(tmpl)) return false;
- if (m_tok.kind != Token::Kind::RightParen) {
- inja_throw("parser_error", "unmatched '('");
- }
- get_next_token();
- return true;
- }
- case Token::Kind::Id:
- get_peek_token();
- if (m_peek_tok.kind == Token::Kind::LeftParen) {
- // function call, parse arguments
- Token func_token = m_tok;
- get_next_token(); // id
- get_next_token(); // leftParen
- unsigned int num_args = 0;
- if (m_tok.kind == Token::Kind::RightParen) {
- // no args
- get_next_token();
- } else {
- for (;;) {
- if (!parse_expression(tmpl)) {
- inja_throw("parser_error", "expected expression, got '" + m_tok.describe() + "'");
- }
- num_args += 1;
- if (m_tok.kind == Token::Kind::RightParen) {
- get_next_token();
- break;
- }
- if (m_tok.kind != Token::Kind::Comma) {
- inja_throw("parser_error", "expected ')' or ',', got '" + m_tok.describe() + "'");
- }
- get_next_token();
- }
- }
-
- auto op = m_static.functions.find_builtin(func_token.text, num_args);
-
- if (op != Bytecode::Op::Nop) {
- // swap arguments for default(); see comment in RenderTo()
- if (op == Bytecode::Op::Default)
- std::swap(tmpl.bytecodes.back(), *(tmpl.bytecodes.rbegin() + 1));
- append_function(tmpl, op, num_args);
- return true;
- } else {
- append_callback(tmpl, func_token.text, num_args);
- return true;
- }
- } else if (m_tok.text == static_cast<decltype(m_tok.text)>("true") ||
- m_tok.text == static_cast<decltype(m_tok.text)>("false") ||
- m_tok.text == static_cast<decltype(m_tok.text)>("null")) {
- // true, false, null are json literals
- if (brace_level == 0 && bracket_level == 0) {
- json_first = m_tok.text;
- goto returnJson;
- }
- break;
- } else {
- // normal literal (json read)
- tmpl.bytecodes.emplace_back(
- Bytecode::Op::Push, m_tok.text,
- m_config.notation == ElementNotation::Pointer ? Bytecode::Flag::ValueLookupPointer : Bytecode::Flag::ValueLookupDot);
- get_next_token();
- return true;
- }
- // json passthrough
- case Token::Kind::Number:
- case Token::Kind::String:
- if (brace_level == 0 && bracket_level == 0) {
- json_first = m_tok.text;
- goto returnJson;
- }
- break;
- case Token::Kind::Comma:
- case Token::Kind::Colon:
- if (brace_level == 0 && bracket_level == 0) {
- inja_throw("parser_error", "unexpected token '" + m_tok.describe() + "'");
- }
- break;
- case Token::Kind::LeftBracket:
- if (brace_level == 0 && bracket_level == 0) {
- json_first = m_tok.text;
- }
- bracket_level += 1;
- break;
- case Token::Kind::LeftBrace:
- if (brace_level == 0 && bracket_level == 0) {
- json_first = m_tok.text;
- }
- brace_level += 1;
- break;
- case Token::Kind::RightBracket:
- if (bracket_level == 0) {
- inja_throw("parser_error", "unexpected ']'");
- }
- --bracket_level;
- if (brace_level == 0 && bracket_level == 0) goto returnJson;
- break;
- case Token::Kind::RightBrace:
- if (brace_level == 0) {
- inja_throw("parser_error", "unexpected '}'");
- }
- --brace_level;
- if (brace_level == 0 && bracket_level == 0) goto returnJson;
- break;
- default:
- if (brace_level != 0) {
- inja_throw("parser_error", "unmatched '{'");
- }
- if (bracket_level != 0) {
- inja_throw("parser_error", "unmatched '['");
- }
- return false;
- }
-
- get_next_token();
- }
-
- returnJson:
- // bridge across all intermediate tokens
- nonstd::string_view json_text(json_first.data(), m_tok.text.data() - json_first.data() + m_tok.text.size());
- tmpl.bytecodes.emplace_back(Bytecode::Op::Push, json::parse(json_text), Bytecode::Flag::ValueImmediate);
- get_next_token();
- return true;
- }
-
- bool parse_statement(Template& tmpl, nonstd::string_view path) {
- if (m_tok.kind != Token::Kind::Id) return false;
-
- if (m_tok.text == static_cast<decltype(m_tok.text)>("if")) {
- get_next_token();
-
- // evaluate expression
- if (!parse_expression(tmpl)) return false;
-
- // start a new if block on if stack
- m_if_stack.emplace_back(tmpl.bytecodes.size());
-
- // conditional jump; destination will be filled in by else or endif
- tmpl.bytecodes.emplace_back(Bytecode::Op::ConditionalJump);
- } else if (m_tok.text == static_cast<decltype(m_tok.text)>("endif")) {
- if (m_if_stack.empty()) {
- inja_throw("parser_error", "endif without matching if");
- }
- auto& if_data = m_if_stack.back();
- get_next_token();
-
- // previous conditional jump jumps here
- if (if_data.prev_cond_jump != std::numeric_limits<unsigned int>::max()) {
- tmpl.bytecodes[if_data.prev_cond_jump].args = tmpl.bytecodes.size();
- }
-
- // update all previous unconditional jumps to here
- for (unsigned int i: if_data.uncond_jumps) {
- tmpl.bytecodes[i].args = tmpl.bytecodes.size();
- }
-
- // pop if stack
- m_if_stack.pop_back();
- } else if (m_tok.text == static_cast<decltype(m_tok.text)>("else")) {
- if (m_if_stack.empty())
- inja_throw("parser_error", "else without matching if");
- auto& if_data = m_if_stack.back();
- get_next_token();
-
- // end previous block with unconditional jump to endif; destination will be
- // filled in by endif
- if_data.uncond_jumps.push_back(tmpl.bytecodes.size());
- tmpl.bytecodes.emplace_back(Bytecode::Op::Jump);
-
- // previous conditional jump jumps here
- tmpl.bytecodes[if_data.prev_cond_jump].args = tmpl.bytecodes.size();
- if_data.prev_cond_jump = std::numeric_limits<unsigned int>::max();
-
- // chained else if
- if (m_tok.kind == Token::Kind::Id && m_tok.text == static_cast<decltype(m_tok.text)>("if")) {
- get_next_token();
-
- // evaluate expression
- if (!parse_expression(tmpl)) return false;
-
- // update "previous jump"
- if_data.prev_cond_jump = tmpl.bytecodes.size();
-
- // conditional jump; destination will be filled in by else or endif
- tmpl.bytecodes.emplace_back(Bytecode::Op::ConditionalJump);
- }
- } else if (m_tok.text == static_cast<decltype(m_tok.text)>("for")) {
- get_next_token();
-
- // options: for a in arr; for a, b in obj
- if (m_tok.kind != Token::Kind::Id)
- inja_throw("parser_error", "expected id, got '" + m_tok.describe() + "'");
- Token value_token = m_tok;
- get_next_token();
-
- Token key_token;
- if (m_tok.kind == Token::Kind::Comma) {
- get_next_token();
- if (m_tok.kind != Token::Kind::Id)
- inja_throw("parser_error", "expected id, got '" + m_tok.describe() + "'");
- key_token = std::move(value_token);
- value_token = m_tok;
- get_next_token();
- }
-
- if (m_tok.kind != Token::Kind::Id || m_tok.text != static_cast<decltype(m_tok.text)>("in"))
- inja_throw("parser_error",
- "expected 'in', got '" + m_tok.describe() + "'");
- get_next_token();
-
- if (!parse_expression(tmpl)) return false;
-
- m_loop_stack.push_back(tmpl.bytecodes.size());
-
- tmpl.bytecodes.emplace_back(Bytecode::Op::StartLoop);
- if (!key_token.text.empty()) {
- tmpl.bytecodes.back().value = key_token.text;
- }
- tmpl.bytecodes.back().str = static_cast<std::string>(value_token.text);
- } else if (m_tok.text == static_cast<decltype(m_tok.text)>("endfor")) {
- get_next_token();
- if (m_loop_stack.empty()) {
- inja_throw("parser_error", "endfor without matching for");
- }
-
- // update loop with EndLoop index (for empty case)
- tmpl.bytecodes[m_loop_stack.back()].args = tmpl.bytecodes.size();
-
- tmpl.bytecodes.emplace_back(Bytecode::Op::EndLoop);
- tmpl.bytecodes.back().args = m_loop_stack.back() + 1; // loop body
- m_loop_stack.pop_back();
- } else if (m_tok.text == static_cast<decltype(m_tok.text)>("include")) {
- get_next_token();
-
- if (m_tok.kind != Token::Kind::String) {
- inja_throw("parser_error", "expected string, got '" + m_tok.describe() + "'");
- }
-
- // build the relative path
- json json_name = json::parse(m_tok.text);
- std::string pathname = static_cast<std::string>(path);
- pathname += json_name.get_ref<const std::string&>();
- if (pathname.compare(0, 2, "./") == 0) {
- pathname.erase(0, 2);
- }
- // sys::path::remove_dots(pathname, true, sys::path::Style::posix);
-
- if (m_included_templates.find(pathname) == m_included_templates.end()) {
- Template include_template = parse_template(pathname);
- m_included_templates.emplace(pathname, include_template);
- }
-
- // generate a reference bytecode
- tmpl.bytecodes.emplace_back(Bytecode::Op::Include, json(pathname), Bytecode::Flag::ValueImmediate);
-
- get_next_token();
- } else {
- return false;
- }
- return true;
- }
-
- void append_function(Template& tmpl, Bytecode::Op op, unsigned int num_args) {
- // we can merge with back-to-back push
- if (!tmpl.bytecodes.empty()) {
- Bytecode& last = tmpl.bytecodes.back();
- if (last.op == Bytecode::Op::Push) {
- last.op = op;
- last.args = num_args;
- return;
- }
- }
-
- // otherwise just add it to the end
- tmpl.bytecodes.emplace_back(op, num_args);
- }
-
- void append_callback(Template& tmpl, nonstd::string_view name, unsigned int num_args) {
- // we can merge with back-to-back push value (not lookup)
- if (!tmpl.bytecodes.empty()) {
- Bytecode& last = tmpl.bytecodes.back();
- if (last.op == Bytecode::Op::Push &&
- (last.flags & Bytecode::Flag::ValueMask) == Bytecode::Flag::ValueImmediate) {
- last.op = Bytecode::Op::Callback;
- last.args = num_args;
- last.str = static_cast<std::string>(name);
- return;
- }
- }
-
- // otherwise just add it to the end
- tmpl.bytecodes.emplace_back(Bytecode::Op::Callback, num_args);
- tmpl.bytecodes.back().str = static_cast<std::string>(name);
- }
-
- void parse_into(Template& tmpl, nonstd::string_view path) {
- m_lexer.start(tmpl.content);
-
- for (;;) {
- get_next_token();
- switch (m_tok.kind) {
- case Token::Kind::Eof:
- if (!m_if_stack.empty()) inja_throw("parser_error", "unmatched if");
- if (!m_loop_stack.empty()) inja_throw("parser_error", "unmatched for");
- return;
- case Token::Kind::Text:
- tmpl.bytecodes.emplace_back(Bytecode::Op::PrintText, m_tok.text, 0u);
- break;
- case Token::Kind::StatementOpen:
- get_next_token();
- if (!parse_statement(tmpl, path)) {
- inja_throw("parser_error", "expected statement, got '" + m_tok.describe() + "'");
- }
- if (m_tok.kind != Token::Kind::StatementClose) {
- inja_throw("parser_error", "expected statement close, got '" + m_tok.describe() + "'");
- }
- break;
- case Token::Kind::LineStatementOpen:
- get_next_token();
- parse_statement(tmpl, path);
- if (m_tok.kind != Token::Kind::LineStatementClose &&
- m_tok.kind != Token::Kind::Eof) {
- inja_throw("parser_error", "expected line statement close, got '" + m_tok.describe() + "'");
- }
- break;
- case Token::Kind::ExpressionOpen:
- get_next_token();
- if (!parse_expression(tmpl)) {
- inja_throw("parser_error", "expected expression, got '" + m_tok.describe() + "'");
- }
- append_function(tmpl, Bytecode::Op::PrintValue, 1);
- if (m_tok.kind != Token::Kind::ExpressionClose) {
- inja_throw("parser_error", "expected expression close, got '" + m_tok.describe() + "'");
- }
- break;
- case Token::Kind::CommentOpen:
- get_next_token();
- if (m_tok.kind != Token::Kind::CommentClose) {
- inja_throw("parser_error", "expected comment close, got '" + m_tok.describe() + "'");
- }
- break;
- default:
- inja_throw("parser_error", "unexpected token '" + m_tok.describe() + "'");
- break;
- }
- }
- }
-
- Template parse(nonstd::string_view input, nonstd::string_view path) {
- Template result;
- result.content = static_cast<std::string>(input);
- parse_into(result, path);
- return result;
- }
-
- Template parse(nonstd::string_view input) {
- return parse(input, "./");
- }
-
- Template parse_template(nonstd::string_view filename) {
- Template result;
- result.content = load_file(filename);
-
- nonstd::string_view path = filename.substr(0, filename.find_last_of("/\\") + 1);
- // StringRef path = sys::path::parent_path(filename);
- Parser(m_config, m_lexer.get_config(), m_included_templates).parse_into(result, path);
- return result;
- }
-
- std::string load_file(nonstd::string_view filename) {
- std::ifstream file = open_file_or_throw(static_cast<std::string>(filename));
- std::string text((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
- return text;
- }
-
- private:
- const ParserConfig& m_config;
- Lexer m_lexer;
- Token m_tok;
- Token m_peek_tok;
- bool m_have_peek_tok {false};
- TemplateStorage& m_included_templates;
- const ParserStatic& m_static;
-
- struct IfData {
- unsigned int prev_cond_jump;
- std::vector<unsigned int> uncond_jumps;
-
- explicit IfData(unsigned int condJump): prev_cond_jump(condJump) {}
- };
-
- std::vector<IfData> m_if_stack;
- std::vector<unsigned int> m_loop_stack;
-
- void get_next_token() {
- if (m_have_peek_tok) {
- m_tok = m_peek_tok;
- m_have_peek_tok = false;
- } else {
- m_tok = m_lexer.scan();
- }
- }
-
- void get_peek_token() {
- if (!m_have_peek_tok) {
- m_peek_tok = m_lexer.scan();
- m_have_peek_tok = true;
- }
- }
-};
-
-} // namespace inja
-
-#endif // PANTOR_INJA_PARSER_HPP
-
-// #include "polyfill.hpp"
-#ifndef PANTOR_INJA_POLYFILL_HPP
-#define PANTOR_INJA_POLYFILL_HPP
-
-
-#if __cplusplus < 201402L
-
-#include <cstddef>
-#include <memory>
-#include <type_traits>
-#include <utility>
-
-
-namespace stdinja {
- template<class T> struct _Unique_if {
- typedef std::unique_ptr<T> _Single_object;
- };
-
- template<class T> struct _Unique_if<T[]> {
- typedef std::unique_ptr<T[]> _Unknown_bound;
- };
-
- template<class T, size_t N> struct _Unique_if<T[N]> {
- typedef void _Known_bound;
- };
-
- template<class T, class... Args>
- typename _Unique_if<T>::_Single_object
- make_unique(Args&&... args) {
- return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
- }
-
- template<class T>
- typename _Unique_if<T>::_Unknown_bound
- make_unique(size_t n) {
- typedef typename std::remove_extent<T>::type U;
- return std::unique_ptr<T>(new U[n]());
- }
-
- template<class T, class... Args>
- typename _Unique_if<T>::_Known_bound
- make_unique(Args&&...) = delete;
-}
-
-#else
-
-namespace stdinja = std;
-
-#endif // memory */
-
-
-#endif // PANTOR_INJA_POLYFILL_HPP
-
-// #include "renderer.hpp"
-#ifndef PANTOR_INJA_RENDERER_HPP
-#define PANTOR_INJA_RENDERER_HPP
-
-#include <algorithm>
-#include <numeric>
-#include <string>
-#include <utility>
-#include <vector>
-
-#include <nlohmann/json.hpp>
-
-// #include "bytecode.hpp"
-
-// #include "template.hpp"
-
-// #include "utils.hpp"
-
-
-
-namespace inja {
-
-inline nonstd::string_view convert_dot_to_json_pointer(nonstd::string_view dot, std::string& out) {
- out.clear();
- do {
- nonstd::string_view part;
- std::tie(part, dot) = string_view::split(dot, '.');
- out.push_back('/');
- out.append(part.begin(), part.end());
- } while (!dot.empty());
- return nonstd::string_view(out.data(), out.size());
-}
-
-/*!
- * \brief Class for rendering a Template with data.
- */
-class Renderer {
- std::vector<const json*>& get_args(const Bytecode& bc) {
- m_tmp_args.clear();
-
- bool has_imm = ((bc.flags & Bytecode::Flag::ValueMask) != Bytecode::Flag::ValuePop);
-
- // get args from stack
- unsigned int pop_args = bc.args;
- if (has_imm) {
- pop_args -= 1;
- }
-
- for (auto i = std::prev(m_stack.end(), pop_args); i != m_stack.end(); i++) {
- m_tmp_args.push_back(&(*i));
- }
-
- // get immediate arg
- if (has_imm) {
- m_tmp_args.push_back(get_imm(bc));
- }
-
- return m_tmp_args;
- }
-
- void pop_args(const Bytecode& bc) {
- unsigned int popArgs = bc.args;
- if ((bc.flags & Bytecode::Flag::ValueMask) != Bytecode::Flag::ValuePop) {
- popArgs -= 1;
- }
- for (unsigned int i = 0; i < popArgs; ++i) {
- m_stack.pop_back();
- }
- }
-
- const json* get_imm(const Bytecode& bc) {
- std::string ptr_buffer;
- nonstd::string_view ptr;
- switch (bc.flags & Bytecode::Flag::ValueMask) {
- case Bytecode::Flag::ValuePop:
- return nullptr;
- case Bytecode::Flag::ValueImmediate:
- return &bc.value;
- case Bytecode::Flag::ValueLookupDot:
- ptr = convert_dot_to_json_pointer(bc.str, ptr_buffer);
- break;
- case Bytecode::Flag::ValueLookupPointer:
- ptr_buffer += '/';
- ptr_buffer += bc.str;
- ptr = ptr_buffer;
- break;
- }
- try {
- return &m_data->at(json::json_pointer(ptr.data()));
- } catch (std::exception&) {
- // try to evaluate as a no-argument callback
- if (auto callback = m_callbacks.find_callback(bc.str, 0)) {
- std::vector<const json*> arguments {};
- m_tmp_val = callback(arguments);
- return &m_tmp_val;
- }
- inja_throw("render_error", "variable '" + static_cast<std::string>(bc.str) + "' not found");
- return nullptr;
- }
- }
-
- bool truthy(const json& var) const {
- if (var.empty()) {
- return false;
- } else if (var.is_number()) {
- return (var != 0);
- } else if (var.is_string()) {
- return !var.empty();
- }
-
- try {
- return var.get<bool>();
- } catch (json::type_error& e) {
- inja_throw("json_error", e.what());
- throw;
- }
- }
-
- void update_loop_data() {
- LoopLevel& level = m_loop_stack.back();
-
- if (level.loop_type == LoopLevel::Type::Array) {
- level.data[static_cast<std::string>(level.value_name)] = level.values.at(level.index); // *level.it;
- auto& loopData = level.data["loop"];
- loopData["index"] = level.index;
- loopData["index1"] = level.index + 1;
- loopData["is_first"] = (level.index == 0);
- loopData["is_last"] = (level.index == level.size - 1);
- } else {
- level.data[static_cast<std::string>(level.key_name)] = level.map_it->first;
- level.data[static_cast<std::string>(level.value_name)] = *level.map_it->second;
- }
- }
-
- const TemplateStorage& m_included_templates;
- const FunctionStorage& m_callbacks;
-
- std::vector<json> m_stack;
-
-
- struct LoopLevel {
- enum class Type { Map, Array };
-
- Type loop_type;
- nonstd::string_view key_name; // variable name for keys
- nonstd::string_view value_name; // variable name for values
- json data; // data with loop info added
-
- json values; // values to iterate over
-
- // loop over list
- size_t index; // current list index
- size_t size; // length of list
-
- // loop over map
- using KeyValue = std::pair<nonstd::string_view, json*>;
- using MapValues = std::vector<KeyValue>;
- MapValues map_values; // values to iterate over
- MapValues::iterator map_it; // iterator over values
-
- };
-
- std::vector<LoopLevel> m_loop_stack;
- const json* m_data;
-
- std::vector<const json*> m_tmp_args;
- json m_tmp_val;
-
-
- public:
- Renderer(const TemplateStorage& included_templates, const FunctionStorage& callbacks): m_included_templates(included_templates), m_callbacks(callbacks) {
- m_stack.reserve(16);
- m_tmp_args.reserve(4);
- m_loop_stack.reserve(16);
- }
-
- void render_to(std::ostream& os, const Template& tmpl, const json& data) {
- m_data = &data;
-
- for (size_t i = 0; i < tmpl.bytecodes.size(); ++i) {
- const auto& bc = tmpl.bytecodes[i];
-
- switch (bc.op) {
- case Bytecode::Op::Nop: {
- break;
- }
- case Bytecode::Op::PrintText: {
- os << bc.str;
- break;
- }
- case Bytecode::Op::PrintValue: {
- const json& val = *get_args(bc)[0];
- if (val.is_string()) {
- os << val.get_ref<const std::string&>();
- } else {
- os << val.dump();
- }
- pop_args(bc);
- break;
- }
- case Bytecode::Op::Push: {
- m_stack.emplace_back(*get_imm(bc));
- break;
- }
- case Bytecode::Op::Upper: {
- auto result = get_args(bc)[0]->get<std::string>();
- std::transform(result.begin(), result.end(), result.begin(), ::toupper);
- pop_args(bc);
- m_stack.emplace_back(std::move(result));
- break;
- }
- case Bytecode::Op::Lower: {
- auto result = get_args(bc)[0]->get<std::string>();
- std::transform(result.begin(), result.end(), result.begin(), ::tolower);
- pop_args(bc);
- m_stack.emplace_back(std::move(result));
- break;
- }
- case Bytecode::Op::Range: {
- int number = get_args(bc)[0]->get<int>();
- std::vector<int> result(number);
- std::iota(std::begin(result), std::end(result), 0);
- pop_args(bc);
- m_stack.emplace_back(std::move(result));
- break;
- }
- case Bytecode::Op::Length: {
- const json& val = *get_args(bc)[0];
-
- int result;
- if (val.is_string()) {
- result = val.get_ref<const std::string&>().length();
- } else {
- result = val.size();
- }
-
- pop_args(bc);
- m_stack.emplace_back(result);
- break;
- }
- case Bytecode::Op::Sort: {
- auto result = get_args(bc)[0]->get<std::vector<json>>();
- std::sort(result.begin(), result.end());
- pop_args(bc);
- m_stack.emplace_back(std::move(result));
- break;
- }
- case Bytecode::Op::At: {
- auto args = get_args(bc);
- auto result = args[0]->at(args[1]->get<int>());
- pop_args(bc);
- m_stack.emplace_back(result);
- break;
- }
- case Bytecode::Op::First: {
- auto result = get_args(bc)[0]->front();
- pop_args(bc);
- m_stack.emplace_back(result);
- break;
- }
- case Bytecode::Op::Last: {
- auto result = get_args(bc)[0]->back();
- pop_args(bc);
- m_stack.emplace_back(result);
- break;
- }
- case Bytecode::Op::Round: {
- auto args = get_args(bc);
- double number = args[0]->get<double>();
- int precision = args[1]->get<int>();
- pop_args(bc);
- m_stack.emplace_back(std::round(number * std::pow(10.0, precision)) / std::pow(10.0, precision));
- break;
- }
- case Bytecode::Op::DivisibleBy: {
- auto args = get_args(bc);
- int number = args[0]->get<int>();
- int divisor = args[1]->get<int>();
- pop_args(bc);
- m_stack.emplace_back((divisor != 0) && (number % divisor == 0));
- break;
- }
- case Bytecode::Op::Odd: {
- int number = get_args(bc)[0]->get<int>();
- pop_args(bc);
- m_stack.emplace_back(number % 2 != 0);
- break;
- }
- case Bytecode::Op::Even: {
- int number = get_args(bc)[0]->get<int>();
- pop_args(bc);
- m_stack.emplace_back(number % 2 == 0);
- break;
- }
- case Bytecode::Op::Max: {
- auto args = get_args(bc);
- auto result = *std::max_element(args[0]->begin(), args[0]->end());
- pop_args(bc);
- m_stack.emplace_back(std::move(result));
- break;
- }
- case Bytecode::Op::Min: {
- auto args = get_args(bc);
- auto result = *std::min_element(args[0]->begin(), args[0]->end());
- pop_args(bc);
- m_stack.emplace_back(std::move(result));
- break;
- }
- case Bytecode::Op::Not: {
- bool result = !truthy(*get_args(bc)[0]);
- pop_args(bc);
- m_stack.emplace_back(result);
- break;
- }
- case Bytecode::Op::And: {
- auto args = get_args(bc);
- bool result = truthy(*args[0]) && truthy(*args[1]);
- pop_args(bc);
- m_stack.emplace_back(result);
- break;
- }
- case Bytecode::Op::Or: {
- auto args = get_args(bc);
- bool result = truthy(*args[0]) || truthy(*args[1]);
- pop_args(bc);
- m_stack.emplace_back(result);
- break;
- }
- case Bytecode::Op::In: {
- auto args = get_args(bc);
- bool result = std::find(args[1]->begin(), args[1]->end(), *args[0]) !=
- args[1]->end();
- pop_args(bc);
- m_stack.emplace_back(result);
- break;
- }
- case Bytecode::Op::Equal: {
- auto args = get_args(bc);
- bool result = (*args[0] == *args[1]);
- pop_args(bc);
- m_stack.emplace_back(result);
- break;
- }
- case Bytecode::Op::Greater: {
- auto args = get_args(bc);
- bool result = (*args[0] > *args[1]);
- pop_args(bc);
- m_stack.emplace_back(result);
- break;
- }
- case Bytecode::Op::Less: {
- auto args = get_args(bc);
- bool result = (*args[0] < *args[1]);
- pop_args(bc);
- m_stack.emplace_back(result);
- break;
- }
- case Bytecode::Op::GreaterEqual: {
- auto args = get_args(bc);
- bool result = (*args[0] >= *args[1]);
- pop_args(bc);
- m_stack.emplace_back(result);
- break;
- }
- case Bytecode::Op::LessEqual: {
- auto args = get_args(bc);
- bool result = (*args[0] <= *args[1]);
- pop_args(bc);
- m_stack.emplace_back(result);
- break;
- }
- case Bytecode::Op::Different: {
- auto args = get_args(bc);
- bool result = (*args[0] != *args[1]);
- pop_args(bc);
- m_stack.emplace_back(result);
- break;
- }
- case Bytecode::Op::Float: {
- double result =
- std::stod(get_args(bc)[0]->get_ref<const std::string&>());
- pop_args(bc);
- m_stack.emplace_back(result);
- break;
- }
- case Bytecode::Op::Int: {
- int result = std::stoi(get_args(bc)[0]->get_ref<const std::string&>());
- pop_args(bc);
- m_stack.emplace_back(result);
- break;
- }
- case Bytecode::Op::Exists: {
- auto&& name = get_args(bc)[0]->get_ref<const std::string&>();
- bool result = (data.find(name) != data.end());
- pop_args(bc);
- m_stack.emplace_back(result);
- break;
- }
- case Bytecode::Op::ExistsInObject: {
- auto args = get_args(bc);
- auto&& name = args[1]->get_ref<const std::string&>();
- bool result = (args[0]->find(name) != args[0]->end());
- pop_args(bc);
- m_stack.emplace_back(result);
- break;
- }
- case Bytecode::Op::IsBoolean: {
- bool result = get_args(bc)[0]->is_boolean();
- pop_args(bc);
- m_stack.emplace_back(result);
- break;
- }
- case Bytecode::Op::IsNumber: {
- bool result = get_args(bc)[0]->is_number();
- pop_args(bc);
- m_stack.emplace_back(result);
- break;
- }
- case Bytecode::Op::IsInteger: {
- bool result = get_args(bc)[0]->is_number_integer();
- pop_args(bc);
- m_stack.emplace_back(result);
- break;
- }
- case Bytecode::Op::IsFloat: {
- bool result = get_args(bc)[0]->is_number_float();
- pop_args(bc);
- m_stack.emplace_back(result);
- break;
- }
- case Bytecode::Op::IsObject: {
- bool result = get_args(bc)[0]->is_object();
- pop_args(bc);
- m_stack.emplace_back(result);
- break;
- }
- case Bytecode::Op::IsArray: {
- bool result = get_args(bc)[0]->is_array();
- pop_args(bc);
- m_stack.emplace_back(result);
- break;
- }
- case Bytecode::Op::IsString: {
- bool result = get_args(bc)[0]->is_string();
- pop_args(bc);
- m_stack.emplace_back(result);
- break;
- }
- case Bytecode::Op::Default: {
- // default needs to be a bit "magic"; we can't evaluate the first
- // argument during the push operation, so we swap the arguments during
- // the parse phase so the second argument is pushed on the stack and
- // the first argument is in the immediate
- try {
- const json* imm = get_imm(bc);
- // if no exception was raised, replace the stack value with it
- m_stack.back() = *imm;
- } catch (std::exception&) {
- // couldn't read immediate, just leave the stack as is
- }
- break;
- }
- case Bytecode::Op::Include:
- Renderer(m_included_templates, m_callbacks).render_to(os, m_included_templates.find(get_imm(bc)->get_ref<const std::string&>())->second, *m_data);
- break;
- case Bytecode::Op::Callback: {
- auto callback = m_callbacks.find_callback(bc.str, bc.args);
- if (!callback) {
- inja_throw("render_error", "function '" + static_cast<std::string>(bc.str) + "' (" + std::to_string(static_cast<unsigned int>(bc.args)) + ") not found");
- }
- json result = callback(get_args(bc));
- pop_args(bc);
- m_stack.emplace_back(std::move(result));
- break;
- }
- case Bytecode::Op::Jump: {
- i = bc.args - 1; // -1 due to ++i in loop
- break;
- }
- case Bytecode::Op::ConditionalJump: {
- if (!truthy(m_stack.back())) {
- i = bc.args - 1; // -1 due to ++i in loop
- }
- m_stack.pop_back();
- break;
- }
- case Bytecode::Op::StartLoop: {
- // jump past loop body if empty
- if (m_stack.back().empty()) {
- m_stack.pop_back();
- i = bc.args; // ++i in loop will take it past EndLoop
- break;
- }
-
- m_loop_stack.emplace_back();
- LoopLevel& level = m_loop_stack.back();
- level.value_name = bc.str;
- level.values = std::move(m_stack.back());
- level.data = (*m_data);
- m_stack.pop_back();
-
- if (bc.value.is_string()) {
- // map iterator
- if (!level.values.is_object()) {
- m_loop_stack.pop_back();
- inja_throw("render_error", "for key, value requires object");
- }
- level.loop_type = LoopLevel::Type::Map;
- level.key_name = bc.value.get_ref<const std::string&>();
-
- // sort by key
- for (auto it = level.values.begin(), end = level.values.end(); it != end; ++it) {
- level.map_values.emplace_back(it.key(), &it.value());
- }
- std::sort(level.map_values.begin(), level.map_values.end(), [](const LoopLevel::KeyValue& a, const LoopLevel::KeyValue& b) { return a.first < b.first; });
- level.map_it = level.map_values.begin();
- } else {
- if (!level.values.is_array()) {
- m_loop_stack.pop_back();
- inja_throw("render_error", "type must be array");
- }
-
- // list iterator
- level.loop_type = LoopLevel::Type::Array;
- level.index = 0;
- level.size = level.values.size();
- }
-
- // provide parent access in nested loop
- auto parent_loop_it = level.data.find("loop");
- if (parent_loop_it != level.data.end()) {
- json loop_copy = *parent_loop_it;
- (*parent_loop_it)["parent"] = std::move(loop_copy);
- }
-
- // set "current" data to loop data
- m_data = &level.data;
- update_loop_data();
- break;
- }
- case Bytecode::Op::EndLoop: {
- if (m_loop_stack.empty()) {
- inja_throw("render_error", "unexpected state in renderer");
- }
- LoopLevel& level = m_loop_stack.back();
-
- bool done;
- if (level.loop_type == LoopLevel::Type::Array) {
- level.index += 1;
- done = (level.index == level.values.size());
- } else {
- level.map_it += 1;
- done = (level.map_it == level.map_values.end());
- }
-
- if (done) {
- m_loop_stack.pop_back();
- // set "current" data to outer loop data or main data as appropriate
- if (!m_loop_stack.empty()) {
- m_data = &m_loop_stack.back().data;
- } else {
- m_data = &data;
- }
- break;
- }
-
- update_loop_data();
-
- // jump back to start of loop
- i = bc.args - 1; // -1 due to ++i in loop
- break;
- }
- default: {
- inja_throw("render_error", "unknown op in renderer: " + std::to_string(static_cast<unsigned int>(bc.op)));
- }
- }
- }
- }
-};
-
-} // namespace inja
-
-#endif // PANTOR_INJA_RENDERER_HPP
-
-// #include "string_view.hpp"
-
-// #include "template.hpp"
-
-// #include "utils.hpp"
-
-
-
-namespace inja {
-
-using namespace nlohmann;
-
-/*!
- * \brief Class for changing the configuration.
- */
-class Environment {
- class Impl {
- public:
- std::string input_path;
- std::string output_path;
-
- LexerConfig lexer_config;
- ParserConfig parser_config;
-
- FunctionStorage callbacks;
- TemplateStorage included_templates;
- };
-
- std::unique_ptr<Impl> m_impl;
-
- public:
- Environment(): Environment("") { }
-
- explicit Environment(const std::string& global_path): m_impl(stdinja::make_unique<Impl>()) {
- m_impl->input_path = global_path;
- m_impl->output_path = global_path;
- }
-
- explicit Environment(const std::string& input_path, const std::string& output_path): m_impl(stdinja::make_unique<Impl>()) {
- m_impl->input_path = input_path;
- m_impl->output_path = output_path;
- }
-
- /// Sets the opener and closer for template statements
- void set_statement(const std::string& open, const std::string& close) {
- m_impl->lexer_config.statement_open = open;
- m_impl->lexer_config.statement_close = close;
- m_impl->lexer_config.update_open_chars();
- }
-
- /// Sets the opener for template line statements
- void set_line_statement(const std::string& open) {
- m_impl->lexer_config.line_statement = open;
- m_impl->lexer_config.update_open_chars();
- }
-
- /// Sets the opener and closer for template expressions
- void set_expression(const std::string& open, const std::string& close) {
- m_impl->lexer_config.expression_open = open;
- m_impl->lexer_config.expression_close = close;
- m_impl->lexer_config.update_open_chars();
- }
-
- /// Sets the opener and closer for template comments
- void set_comment(const std::string& open, const std::string& close) {
- m_impl->lexer_config.comment_open = open;
- m_impl->lexer_config.comment_close = close;
- m_impl->lexer_config.update_open_chars();
- }
-
- /// Sets whether to remove the first newline after a block
- void set_trim_blocks(bool trim_blocks) {
- m_impl->lexer_config.trim_blocks = trim_blocks;
- }
-
- /// Sets whether to strip the spaces and tabs from the start of a line to a block
- void set_lstrip_blocks(bool lstrip_blocks) {
- m_impl->lexer_config.lstrip_blocks = lstrip_blocks;
- }
-
- /// Sets the element notation syntax
- void set_element_notation(ElementNotation notation) {
- m_impl->parser_config.notation = notation;
- }
-
-
- Template parse(nonstd::string_view input) {
- Parser parser(m_impl->parser_config, m_impl->lexer_config, m_impl->included_templates);
- return parser.parse(input);
- }
-
- Template parse_template(const std::string& filename) {
- Parser parser(m_impl->parser_config, m_impl->lexer_config, m_impl->included_templates);
- return parser.parse_template(m_impl->input_path + static_cast<std::string>(filename));
- }
-
- std::string render(nonstd::string_view input, const json& data) {
- return render(parse(input), data);
- }
-
- std::string render(const Template& tmpl, const json& data) {
- std::stringstream os;
- render_to(os, tmpl, data);
- return os.str();
- }
-
- std::string render_file(const std::string& filename, const json& data) {
- return render(parse_template(filename), data);
- }
-
- std::string render_file_with_json_file(const std::string& filename, const std::string& filename_data) {
- const json data = load_json(filename_data);
- return render_file(filename, data);
- }
-
- void write(const std::string& filename, const json& data, const std::string& filename_out) {
- std::ofstream file(m_impl->output_path + filename_out);
- file << render_file(filename, data);
- file.close();
- }
-
- void write(const Template& temp, const json& data, const std::string& filename_out) {
- std::ofstream file(m_impl->output_path + filename_out);
- file << render(temp, data);
- file.close();
- }
-
- void write_with_json_file(const std::string& filename, const std::string& filename_data, const std::string& filename_out) {
- const json data = load_json(filename_data);
- write(filename, data, filename_out);
- }
-
- void write_with_json_file(const Template& temp, const std::string& filename_data, const std::string& filename_out) {
- const json data = load_json(filename_data);
- write(temp, data, filename_out);
- }
-
- std::ostream& render_to(std::ostream& os, const Template& tmpl, const json& data) {
- Renderer(m_impl->included_templates, m_impl->callbacks).render_to(os, tmpl, data);
- return os;
- }
-
- std::string load_file(const std::string& filename) {
- Parser parser(m_impl->parser_config, m_impl->lexer_config, m_impl->included_templates);
- return parser.load_file(m_impl->input_path + filename);
- }
-
- json load_json(const std::string& filename) {
- std::ifstream file = open_file_or_throw(m_impl->input_path + filename);
- json j;
- file >> j;
- return j;
- }
-
- void add_callback(const std::string& name, unsigned int numArgs, const CallbackFunction& callback) {
- m_impl->callbacks.add_callback(name, numArgs, callback);
- }
-
- /** Includes a template with a given name into the environment.
- * Then, a template can be rendered in another template using the
- * include "<name>" syntax.
- */
- void include_template(const std::string& name, const Template& tmpl) {
- m_impl->included_templates[name] = tmpl;
- }
-};
-
-/*!
-@brief render with default settings to a string
-*/
-inline std::string render(nonstd::string_view input, const json& data) {
- return Environment().render(input, data);
-}
-
-/*!
-@brief render with default settings to the given output stream
-*/
-inline void render_to(std::ostream& os, nonstd::string_view input, const json& data) {
- Environment env;
- env.render_to(os, env.parse(input), data);
-}
-
-}
-
-#endif // PANTOR_INJA_ENVIRONMENT_HPP
-
-// #include "string_view.hpp"
-
-// #include "template.hpp"
-
-// #include "parser.hpp"
-
-// #include "renderer.hpp"
-
-
-
-#endif // PANTOR_INJA_HPP
+// MIT License
+
+// Copyright (c) 2018 lbersch
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+
+// ---
+
+
+// Copyright (c) 2009-2018 FIRST
+// All rights reserved.
+
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of the FIRST nor the
+// names of its contributors may be used to endorse or promote products
+// derived from this software without specific prior written permission.
+
+// THIS SOFTWARE IS PROVIDED BY FIRST AND CONTRIBUTORS``AS IS'' AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+// WARRANTIES OF MERCHANTABILITY NONINFRINGEMENT AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL FIRST OR CONTRIBUTORS BE LIABLE FOR
+// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef PANTOR_INJA_HPP
+#define PANTOR_INJA_HPP
+
+#include <functional>
+#include <iostream>
+#include <map>
+#include <memory>
+#include <sstream>
+#include <string>
+#include <vector>
+
+#include <nlohmann/json.hpp>
+
+// #include "environment.hpp"
+#ifndef PANTOR_INJA_ENVIRONMENT_HPP
+#define PANTOR_INJA_ENVIRONMENT_HPP
+
+#include <memory>
+#include <fstream>
+#include <sstream>
+#include <string>
+
+#include <nlohmann/json.hpp>
+
+// #include "config.hpp"
+#ifndef PANTOR_INJA_CONFIG_HPP
+#define PANTOR_INJA_CONFIG_HPP
+
+#include <functional>
+#include <string>
+
+// #include "string_view.hpp"
+// Copyright 2017-2019 by Martin Moene
+//
+// string-view lite, a C++17-like string_view for C++98 and later.
+// For more information see https://github.com/martinmoene/string-view-lite
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+
+
+#ifndef NONSTD_SV_LITE_H_INCLUDED
+#define NONSTD_SV_LITE_H_INCLUDED
+
+#define string_view_lite_MAJOR 1
+#define string_view_lite_MINOR 1
+#define string_view_lite_PATCH 0
+
+#define string_view_lite_VERSION nssv_STRINGIFY(string_view_lite_MAJOR) "." nssv_STRINGIFY(string_view_lite_MINOR) "." nssv_STRINGIFY(string_view_lite_PATCH)
+
+#define nssv_STRINGIFY( x ) nssv_STRINGIFY_( x )
+#define nssv_STRINGIFY_( x ) #x
+
+// string-view lite configuration:
+
+#define nssv_STRING_VIEW_DEFAULT 0
+#define nssv_STRING_VIEW_NONSTD 1
+#define nssv_STRING_VIEW_STD 2
+
+#if !defined( nssv_CONFIG_SELECT_STRING_VIEW )
+# define nssv_CONFIG_SELECT_STRING_VIEW ( nssv_HAVE_STD_STRING_VIEW ? nssv_STRING_VIEW_STD : nssv_STRING_VIEW_NONSTD )
+#endif
+
+#if defined( nssv_CONFIG_SELECT_STD_STRING_VIEW ) || defined( nssv_CONFIG_SELECT_NONSTD_STRING_VIEW )
+# error nssv_CONFIG_SELECT_STD_STRING_VIEW and nssv_CONFIG_SELECT_NONSTD_STRING_VIEW are deprecated and removed, please use nssv_CONFIG_SELECT_STRING_VIEW=nssv_STRING_VIEW_...
+#endif
+
+#ifndef nssv_CONFIG_STD_SV_OPERATOR
+# define nssv_CONFIG_STD_SV_OPERATOR 0
+#endif
+
+#ifndef nssv_CONFIG_USR_SV_OPERATOR
+# define nssv_CONFIG_USR_SV_OPERATOR 1
+#endif
+
+#ifdef nssv_CONFIG_CONVERSION_STD_STRING
+# define nssv_CONFIG_CONVERSION_STD_STRING_CLASS_METHODS nssv_CONFIG_CONVERSION_STD_STRING
+# define nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS nssv_CONFIG_CONVERSION_STD_STRING
+#endif
+
+#ifndef nssv_CONFIG_CONVERSION_STD_STRING_CLASS_METHODS
+# define nssv_CONFIG_CONVERSION_STD_STRING_CLASS_METHODS 1
+#endif
+
+#ifndef nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS
+# define nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS 1
+#endif
+
+// Control presence of exception handling (try and auto discover):
+
+#ifndef nssv_CONFIG_NO_EXCEPTIONS
+# if defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)
+# define nssv_CONFIG_NO_EXCEPTIONS 0
+# else
+# define nssv_CONFIG_NO_EXCEPTIONS 1
+# endif
+#endif
+
+// C++ language version detection (C++20 is speculative):
+// Note: VC14.0/1900 (VS2015) lacks too much from C++14.
+
+#ifndef nssv_CPLUSPLUS
+# if defined(_MSVC_LANG ) && !defined(__clang__)
+# define nssv_CPLUSPLUS (_MSC_VER == 1900 ? 201103L : _MSVC_LANG )
+# else
+# define nssv_CPLUSPLUS __cplusplus
+# endif
+#endif
+
+#define nssv_CPP98_OR_GREATER ( nssv_CPLUSPLUS >= 199711L )
+#define nssv_CPP11_OR_GREATER ( nssv_CPLUSPLUS >= 201103L )
+#define nssv_CPP11_OR_GREATER_ ( nssv_CPLUSPLUS >= 201103L )
+#define nssv_CPP14_OR_GREATER ( nssv_CPLUSPLUS >= 201402L )
+#define nssv_CPP17_OR_GREATER ( nssv_CPLUSPLUS >= 201703L )
+#define nssv_CPP20_OR_GREATER ( nssv_CPLUSPLUS >= 202000L )
+
+// use C++17 std::string_view if available and requested:
+
+#if nssv_CPP17_OR_GREATER && defined(__has_include )
+# if __has_include( <string_view> )
+# define nssv_HAVE_STD_STRING_VIEW 1
+# else
+# define nssv_HAVE_STD_STRING_VIEW 0
+# endif
+#else
+# define nssv_HAVE_STD_STRING_VIEW 0
+#endif
+
+#define nssv_USES_STD_STRING_VIEW ( (nssv_CONFIG_SELECT_STRING_VIEW == nssv_STRING_VIEW_STD) || ((nssv_CONFIG_SELECT_STRING_VIEW == nssv_STRING_VIEW_DEFAULT) && nssv_HAVE_STD_STRING_VIEW) )
+
+#define nssv_HAVE_STARTS_WITH ( nssv_CPP20_OR_GREATER || !nssv_USES_STD_STRING_VIEW )
+#define nssv_HAVE_ENDS_WITH nssv_HAVE_STARTS_WITH
+
+//
+// Use C++17 std::string_view:
+//
+
+#if nssv_USES_STD_STRING_VIEW
+
+#include <string_view>
+
+// Extensions for std::string:
+
+#if nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS
+
+namespace nonstd {
+
+template< class CharT, class Traits, class Allocator = std::allocator<CharT> >
+std::basic_string<CharT, Traits, Allocator>
+to_string( std::basic_string_view<CharT, Traits> v, Allocator const & a = Allocator() )
+{
+ return std::basic_string<CharT,Traits, Allocator>( v.begin(), v.end(), a );
+}
+
+template< class CharT, class Traits, class Allocator >
+std::basic_string_view<CharT, Traits>
+to_string_view( std::basic_string<CharT, Traits, Allocator> const & s )
+{
+ return std::basic_string_view<CharT, Traits>( s.data(), s.size() );
+}
+
+// Literal operators sv and _sv:
+
+#if nssv_CONFIG_STD_SV_OPERATOR
+
+using namespace std::literals::string_view_literals;
+
+#endif
+
+#if nssv_CONFIG_USR_SV_OPERATOR
+
+inline namespace literals {
+inline namespace string_view_literals {
+
+
+constexpr std::string_view operator "" _sv( const char* str, size_t len ) noexcept // (1)
+{
+ return std::string_view{ str, len };
+}
+
+constexpr std::u16string_view operator "" _sv( const char16_t* str, size_t len ) noexcept // (2)
+{
+ return std::u16string_view{ str, len };
+}
+
+constexpr std::u32string_view operator "" _sv( const char32_t* str, size_t len ) noexcept // (3)
+{
+ return std::u32string_view{ str, len };
+}
+
+constexpr std::wstring_view operator "" _sv( const wchar_t* str, size_t len ) noexcept // (4)
+{
+ return std::wstring_view{ str, len };
+}
+
+}} // namespace literals::string_view_literals
+
+#endif // nssv_CONFIG_USR_SV_OPERATOR
+
+} // namespace nonstd
+
+#endif // nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS
+
+namespace nonstd {
+
+using std::string_view;
+using std::wstring_view;
+using std::u16string_view;
+using std::u32string_view;
+using std::basic_string_view;
+
+// literal "sv" and "_sv", see above
+
+using std::operator==;
+using std::operator!=;
+using std::operator<;
+using std::operator<=;
+using std::operator>;
+using std::operator>=;
+
+using std::operator<<;
+
+} // namespace nonstd
+
+#else // nssv_HAVE_STD_STRING_VIEW
+
+//
+// Before C++17: use string_view lite:
+//
+
+// Compiler versions:
+//
+// MSVC++ 6.0 _MSC_VER == 1200 (Visual Studio 6.0)
+// MSVC++ 7.0 _MSC_VER == 1300 (Visual Studio .NET 2002)
+// MSVC++ 7.1 _MSC_VER == 1310 (Visual Studio .NET 2003)
+// MSVC++ 8.0 _MSC_VER == 1400 (Visual Studio 2005)
+// MSVC++ 9.0 _MSC_VER == 1500 (Visual Studio 2008)
+// MSVC++ 10.0 _MSC_VER == 1600 (Visual Studio 2010)
+// MSVC++ 11.0 _MSC_VER == 1700 (Visual Studio 2012)
+// MSVC++ 12.0 _MSC_VER == 1800 (Visual Studio 2013)
+// MSVC++ 14.0 _MSC_VER == 1900 (Visual Studio 2015)
+// MSVC++ 14.1 _MSC_VER >= 1910 (Visual Studio 2017)
+
+#if defined(_MSC_VER ) && !defined(__clang__)
+# define nssv_COMPILER_MSVC_VER (_MSC_VER )
+# define nssv_COMPILER_MSVC_VERSION (_MSC_VER / 10 - 10 * ( 5 + (_MSC_VER < 1900 ) ) )
+#else
+# define nssv_COMPILER_MSVC_VER 0
+# define nssv_COMPILER_MSVC_VERSION 0
+#endif
+
+#define nssv_COMPILER_VERSION( major, minor, patch ) (10 * ( 10 * major + minor) + patch)
+
+#if defined(__clang__)
+# define nssv_COMPILER_CLANG_VERSION nssv_COMPILER_VERSION(__clang_major__, __clang_minor__, __clang_patchlevel__)
+#else
+# define nssv_COMPILER_CLANG_VERSION 0
+#endif
+
+#if defined(__GNUC__) && !defined(__clang__)
+# define nssv_COMPILER_GNUC_VERSION nssv_COMPILER_VERSION(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
+#else
+# define nssv_COMPILER_GNUC_VERSION 0
+#endif
+
+// half-open range [lo..hi):
+#define nssv_BETWEEN( v, lo, hi ) ( (lo) <= (v) && (v) < (hi) )
+
+// Presence of language and library features:
+
+#ifdef _HAS_CPP0X
+# define nssv_HAS_CPP0X _HAS_CPP0X
+#else
+# define nssv_HAS_CPP0X 0
+#endif
+
+// Unless defined otherwise below, consider VC14 as C++11 for variant-lite:
+
+#if nssv_COMPILER_MSVC_VER >= 1900
+# undef nssv_CPP11_OR_GREATER
+# define nssv_CPP11_OR_GREATER 1
+#endif
+
+#define nssv_CPP11_90 (nssv_CPP11_OR_GREATER_ || nssv_COMPILER_MSVC_VER >= 1500)
+#define nssv_CPP11_100 (nssv_CPP11_OR_GREATER_ || nssv_COMPILER_MSVC_VER >= 1600)
+#define nssv_CPP11_110 (nssv_CPP11_OR_GREATER_ || nssv_COMPILER_MSVC_VER >= 1700)
+#define nssv_CPP11_120 (nssv_CPP11_OR_GREATER_ || nssv_COMPILER_MSVC_VER >= 1800)
+#define nssv_CPP11_140 (nssv_CPP11_OR_GREATER_ || nssv_COMPILER_MSVC_VER >= 1900)
+#define nssv_CPP11_141 (nssv_CPP11_OR_GREATER_ || nssv_COMPILER_MSVC_VER >= 1910)
+
+#define nssv_CPP14_000 (nssv_CPP14_OR_GREATER)
+#define nssv_CPP17_000 (nssv_CPP17_OR_GREATER)
+
+// Presence of C++11 language features:
+
+#define nssv_HAVE_CONSTEXPR_11 nssv_CPP11_140
+#define nssv_HAVE_EXPLICIT_CONVERSION nssv_CPP11_140
+#define nssv_HAVE_INLINE_NAMESPACE nssv_CPP11_140
+#define nssv_HAVE_NOEXCEPT nssv_CPP11_140
+#define nssv_HAVE_NULLPTR nssv_CPP11_100
+#define nssv_HAVE_REF_QUALIFIER nssv_CPP11_140
+#define nssv_HAVE_UNICODE_LITERALS nssv_CPP11_140
+#define nssv_HAVE_USER_DEFINED_LITERALS nssv_CPP11_140
+#define nssv_HAVE_WCHAR16_T nssv_CPP11_100
+#define nssv_HAVE_WCHAR32_T nssv_CPP11_100
+
+#if ! ( ( nssv_CPP11 && nssv_COMPILER_CLANG_VERSION ) || nssv_BETWEEN( nssv_COMPILER_CLANG_VERSION, 300, 400 ) )
+# define nssv_HAVE_STD_DEFINED_LITERALS nssv_CPP11_140
+#endif
+
+// Presence of C++14 language features:
+
+#define nssv_HAVE_CONSTEXPR_14 nssv_CPP14_000
+
+// Presence of C++17 language features:
+
+#define nssv_HAVE_NODISCARD nssv_CPP17_000
+
+// Presence of C++ library features:
+
+#define nssv_HAVE_STD_HASH nssv_CPP11_120
+
+// C++ feature usage:
+
+#if nssv_HAVE_CONSTEXPR_11
+# define nssv_constexpr constexpr
+#else
+# define nssv_constexpr /*constexpr*/
+#endif
+
+#if nssv_HAVE_CONSTEXPR_14
+# define nssv_constexpr14 constexpr
+#else
+# define nssv_constexpr14 /*constexpr*/
+#endif
+
+#if nssv_HAVE_EXPLICIT_CONVERSION
+# define nssv_explicit explicit
+#else
+# define nssv_explicit /*explicit*/
+#endif
+
+#if nssv_HAVE_INLINE_NAMESPACE
+# define nssv_inline_ns inline
+#else
+# define nssv_inline_ns /*inline*/
+#endif
+
+#if nssv_HAVE_NOEXCEPT
+# define nssv_noexcept noexcept
+#else
+# define nssv_noexcept /*noexcept*/
+#endif
+
+//#if nssv_HAVE_REF_QUALIFIER
+//# define nssv_ref_qual &
+//# define nssv_refref_qual &&
+//#else
+//# define nssv_ref_qual /*&*/
+//# define nssv_refref_qual /*&&*/
+//#endif
+
+#if nssv_HAVE_NULLPTR
+# define nssv_nullptr nullptr
+#else
+# define nssv_nullptr NULL
+#endif
+
+#if nssv_HAVE_NODISCARD
+# define nssv_nodiscard [[nodiscard]]
+#else
+# define nssv_nodiscard /*[[nodiscard]]*/
+#endif
+
+// Additional includes:
+
+#include <algorithm>
+#include <cassert>
+#include <iterator>
+#include <limits>
+#include <ostream>
+#include <string> // std::char_traits<>
+
+#if ! nssv_CONFIG_NO_EXCEPTIONS
+# include <stdexcept>
+#endif
+
+#if nssv_CPP11_OR_GREATER
+# include <type_traits>
+#endif
+
+// Clang, GNUC, MSVC warning suppression macros:
+
+#if defined(__clang__)
+# pragma clang diagnostic ignored "-Wreserved-user-defined-literal"
+# pragma clang diagnostic push
+# pragma clang diagnostic ignored "-Wuser-defined-literals"
+#elif defined(__GNUC__)
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wliteral-suffix"
+#endif // __clang__
+
+#if nssv_COMPILER_MSVC_VERSION >= 140
+# define nssv_SUPPRESS_MSGSL_WARNING(expr) [[gsl::suppress(expr)]]
+# define nssv_SUPPRESS_MSVC_WARNING(code, descr) __pragma(warning(suppress: code) )
+# define nssv_DISABLE_MSVC_WARNINGS(codes) __pragma(warning(push)) __pragma(warning(disable: codes))
+#else
+# define nssv_SUPPRESS_MSGSL_WARNING(expr)
+# define nssv_SUPPRESS_MSVC_WARNING(code, descr)
+# define nssv_DISABLE_MSVC_WARNINGS(codes)
+#endif
+
+#if defined(__clang__)
+# define nssv_RESTORE_WARNINGS() _Pragma("clang diagnostic pop")
+#elif defined(__GNUC__)
+# define nssv_RESTORE_WARNINGS() _Pragma("GCC diagnostic pop")
+#elif nssv_COMPILER_MSVC_VERSION >= 140
+# define nssv_RESTORE_WARNINGS() __pragma(warning(pop ))
+#else
+# define nssv_RESTORE_WARNINGS()
+#endif
+
+// Suppress the following MSVC (GSL) warnings:
+// - C4455, non-gsl : 'operator ""sv': literal suffix identifiers that do not
+// start with an underscore are reserved
+// - C26472, gsl::t.1 : don't use a static_cast for arithmetic conversions;
+// use brace initialization, gsl::narrow_cast or gsl::narow
+// - C26481: gsl::b.1 : don't use pointer arithmetic. Use span instead
+
+nssv_DISABLE_MSVC_WARNINGS( 4455 26481 26472 )
+//nssv_DISABLE_CLANG_WARNINGS( "-Wuser-defined-literals" )
+//nssv_DISABLE_GNUC_WARNINGS( -Wliteral-suffix )
+
+namespace nonstd { namespace sv_lite {
+
+template
+<
+ class CharT,
+ class Traits = std::char_traits<CharT>
+>
+class basic_string_view;
+
+//
+// basic_string_view:
+//
+
+template
+<
+ class CharT,
+ class Traits /* = std::char_traits<CharT> */
+>
+class basic_string_view
+{
+public:
+ // Member types:
+
+ typedef Traits traits_type;
+ typedef CharT value_type;
+
+ typedef CharT * pointer;
+ typedef CharT const * const_pointer;
+ typedef CharT & reference;
+ typedef CharT const & const_reference;
+
+ typedef const_pointer iterator;
+ typedef const_pointer const_iterator;
+ typedef std::reverse_iterator< const_iterator > reverse_iterator;
+ typedef std::reverse_iterator< const_iterator > const_reverse_iterator;
+
+ typedef std::size_t size_type;
+ typedef std::ptrdiff_t difference_type;
+
+ // 24.4.2.1 Construction and assignment:
+
+ nssv_constexpr basic_string_view() nssv_noexcept
+ : data_( nssv_nullptr )
+ , size_( 0 )
+ {}
+
+#if nssv_CPP11_OR_GREATER
+ nssv_constexpr basic_string_view( basic_string_view const & other ) nssv_noexcept = default;
+#else
+ nssv_constexpr basic_string_view( basic_string_view const & other ) nssv_noexcept
+ : data_( other.data_)
+ , size_( other.size_)
+ {}
+#endif
+
+ nssv_constexpr basic_string_view( CharT const * s, size_type count )
+ : data_( s )
+ , size_( count )
+ {}
+
+ nssv_constexpr basic_string_view( CharT const * s)
+ : data_( s )
+ , size_( Traits::length(s) )
+ {}
+
+ // Assignment:
+
+#if nssv_CPP11_OR_GREATER
+ nssv_constexpr14 basic_string_view & operator=( basic_string_view const & other ) nssv_noexcept = default;
+#else
+ nssv_constexpr14 basic_string_view & operator=( basic_string_view const & other ) nssv_noexcept
+ {
+ data_ = other.data_;
+ size_ = other.size_;
+ return *this;
+ }
+#endif
+
+ // 24.4.2.2 Iterator support:
+
+ nssv_constexpr const_iterator begin() const nssv_noexcept { return data_; }
+ nssv_constexpr const_iterator end() const nssv_noexcept { return data_ + size_; }
+
+ nssv_constexpr const_iterator cbegin() const nssv_noexcept { return begin(); }
+ nssv_constexpr const_iterator cend() const nssv_noexcept { return end(); }
+
+ nssv_constexpr const_reverse_iterator rbegin() const nssv_noexcept { return const_reverse_iterator( end() ); }
+ nssv_constexpr const_reverse_iterator rend() const nssv_noexcept { return const_reverse_iterator( begin() ); }
+
+ nssv_constexpr const_reverse_iterator crbegin() const nssv_noexcept { return rbegin(); }
+ nssv_constexpr const_reverse_iterator crend() const nssv_noexcept { return rend(); }
+
+ // 24.4.2.3 Capacity:
+
+ nssv_constexpr size_type size() const nssv_noexcept { return size_; }
+ nssv_constexpr size_type length() const nssv_noexcept { return size_; }
+ nssv_constexpr size_type max_size() const nssv_noexcept { return (std::numeric_limits< size_type >::max)(); }
+
+ // since C++20
+ nssv_nodiscard nssv_constexpr bool empty() const nssv_noexcept
+ {
+ return 0 == size_;
+ }
+
+ // 24.4.2.4 Element access:
+
+ nssv_constexpr const_reference operator[]( size_type pos ) const
+ {
+ return data_at( pos );
+ }
+
+ nssv_constexpr14 const_reference at( size_type pos ) const
+ {
+#if nssv_CONFIG_NO_EXCEPTIONS
+ assert( pos < size() );
+#else
+ if ( pos >= size() )
+ {
+ throw std::out_of_range("nonst::string_view::at()");
+ }
+#endif
+ return data_at( pos );
+ }
+
+ nssv_constexpr const_reference front() const { return data_at( 0 ); }
+ nssv_constexpr const_reference back() const { return data_at( size() - 1 ); }
+
+ nssv_constexpr const_pointer data() const nssv_noexcept { return data_; }
+
+ // 24.4.2.5 Modifiers:
+
+ nssv_constexpr14 void remove_prefix( size_type n )
+ {
+ assert( n <= size() );
+ data_ += n;
+ size_ -= n;
+ }
+
+ nssv_constexpr14 void remove_suffix( size_type n )
+ {
+ assert( n <= size() );
+ size_ -= n;
+ }
+
+ nssv_constexpr14 void swap( basic_string_view & other ) nssv_noexcept
+ {
+ using std::swap;
+ swap( data_, other.data_ );
+ swap( size_, other.size_ );
+ }
+
+ // 24.4.2.6 String operations:
+
+ size_type copy( CharT * dest, size_type n, size_type pos = 0 ) const
+ {
+#if nssv_CONFIG_NO_EXCEPTIONS
+ assert( pos <= size() );
+#else
+ if ( pos > size() )
+ {
+ throw std::out_of_range("nonst::string_view::copy()");
+ }
+#endif
+ const size_type rlen = (std::min)( n, size() - pos );
+
+ (void) Traits::copy( dest, data() + pos, rlen );
+
+ return rlen;
+ }
+
+ nssv_constexpr14 basic_string_view substr( size_type pos = 0, size_type n = npos ) const
+ {
+#if nssv_CONFIG_NO_EXCEPTIONS
+ assert( pos <= size() );
+#else
+ if ( pos > size() )
+ {
+ throw std::out_of_range("nonst::string_view::substr()");
+ }
+#endif
+ return basic_string_view( data() + pos, (std::min)( n, size() - pos ) );
+ }
+
+ // compare(), 6x:
+
+ nssv_constexpr14 int compare( basic_string_view other ) const nssv_noexcept // (1)
+ {
+ if ( const int result = Traits::compare( data(), other.data(), (std::min)( size(), other.size() ) ) )
+ return result;
+
+ return size() == other.size() ? 0 : size() < other.size() ? -1 : 1;
+ }
+
+ nssv_constexpr int compare( size_type pos1, size_type n1, basic_string_view other ) const // (2)
+ {
+ return substr( pos1, n1 ).compare( other );
+ }
+
+ nssv_constexpr int compare( size_type pos1, size_type n1, basic_string_view other, size_type pos2, size_type n2 ) const // (3)
+ {
+ return substr( pos1, n1 ).compare( other.substr( pos2, n2 ) );
+ }
+
+ nssv_constexpr int compare( CharT const * s ) const // (4)
+ {
+ return compare( basic_string_view( s ) );
+ }
+
+ nssv_constexpr int compare( size_type pos1, size_type n1, CharT const * s ) const // (5)
+ {
+ return substr( pos1, n1 ).compare( basic_string_view( s ) );
+ }
+
+ nssv_constexpr int compare( size_type pos1, size_type n1, CharT const * s, size_type n2 ) const // (6)
+ {
+ return substr( pos1, n1 ).compare( basic_string_view( s, n2 ) );
+ }
+
+ // 24.4.2.7 Searching:
+
+ // starts_with(), 3x, since C++20:
+
+ nssv_constexpr bool starts_with( basic_string_view v ) const nssv_noexcept // (1)
+ {
+ return size() >= v.size() && compare( 0, v.size(), v ) == 0;
+ }
+
+ nssv_constexpr bool starts_with( CharT c ) const nssv_noexcept // (2)
+ {
+ return starts_with( basic_string_view( &c, 1 ) );
+ }
+
+ nssv_constexpr bool starts_with( CharT const * s ) const // (3)
+ {
+ return starts_with( basic_string_view( s ) );
+ }
+
+ // ends_with(), 3x, since C++20:
+
+ nssv_constexpr bool ends_with( basic_string_view v ) const nssv_noexcept // (1)
+ {
+ return size() >= v.size() && compare( size() - v.size(), npos, v ) == 0;
+ }
+
+ nssv_constexpr bool ends_with( CharT c ) const nssv_noexcept // (2)
+ {
+ return ends_with( basic_string_view( &c, 1 ) );
+ }
+
+ nssv_constexpr bool ends_with( CharT const * s ) const // (3)
+ {
+ return ends_with( basic_string_view( s ) );
+ }
+
+ // find(), 4x:
+
+ nssv_constexpr14 size_type find( basic_string_view v, size_type pos = 0 ) const nssv_noexcept // (1)
+ {
+ return assert( v.size() == 0 || v.data() != nssv_nullptr )
+ , pos >= size()
+ ? npos
+ : to_pos( std::search( cbegin() + pos, cend(), v.cbegin(), v.cend(), Traits::eq ) );
+ }
+
+ nssv_constexpr14 size_type find( CharT c, size_type pos = 0 ) const nssv_noexcept // (2)
+ {
+ return find( basic_string_view( &c, 1 ), pos );
+ }
+
+ nssv_constexpr14 size_type find( CharT const * s, size_type pos, size_type n ) const // (3)
+ {
+ return find( basic_string_view( s, n ), pos );
+ }
+
+ nssv_constexpr14 size_type find( CharT const * s, size_type pos = 0 ) const // (4)
+ {
+ return find( basic_string_view( s ), pos );
+ }
+
+ // rfind(), 4x:
+
+ nssv_constexpr14 size_type rfind( basic_string_view v, size_type pos = npos ) const nssv_noexcept // (1)
+ {
+ if ( size() < v.size() )
+ return npos;
+
+ if ( v.empty() )
+ return (std::min)( size(), pos );
+
+ const_iterator last = cbegin() + (std::min)( size() - v.size(), pos ) + v.size();
+ const_iterator result = std::find_end( cbegin(), last, v.cbegin(), v.cend(), Traits::eq );
+
+ return result != last ? size_type( result - cbegin() ) : npos;
+ }
+
+ nssv_constexpr14 size_type rfind( CharT c, size_type pos = npos ) const nssv_noexcept // (2)
+ {
+ return rfind( basic_string_view( &c, 1 ), pos );
+ }
+
+ nssv_constexpr14 size_type rfind( CharT const * s, size_type pos, size_type n ) const // (3)
+ {
+ return rfind( basic_string_view( s, n ), pos );
+ }
+
+ nssv_constexpr14 size_type rfind( CharT const * s, size_type pos = npos ) const // (4)
+ {
+ return rfind( basic_string_view( s ), pos );
+ }
+
+ // find_first_of(), 4x:
+
+ nssv_constexpr size_type find_first_of( basic_string_view v, size_type pos = 0 ) const nssv_noexcept // (1)
+ {
+ return pos >= size()
+ ? npos
+ : to_pos( std::find_first_of( cbegin() + pos, cend(), v.cbegin(), v.cend(), Traits::eq ) );
+ }
+
+ nssv_constexpr size_type find_first_of( CharT c, size_type pos = 0 ) const nssv_noexcept // (2)
+ {
+ return find_first_of( basic_string_view( &c, 1 ), pos );
+ }
+
+ nssv_constexpr size_type find_first_of( CharT const * s, size_type pos, size_type n ) const // (3)
+ {
+ return find_first_of( basic_string_view( s, n ), pos );
+ }
+
+ nssv_constexpr size_type find_first_of( CharT const * s, size_type pos = 0 ) const // (4)
+ {
+ return find_first_of( basic_string_view( s ), pos );
+ }
+
+ // find_last_of(), 4x:
+
+ nssv_constexpr size_type find_last_of( basic_string_view v, size_type pos = npos ) const nssv_noexcept // (1)
+ {
+ return empty()
+ ? npos
+ : pos >= size()
+ ? find_last_of( v, size() - 1 )
+ : to_pos( std::find_first_of( const_reverse_iterator( cbegin() + pos + 1 ), crend(), v.cbegin(), v.cend(), Traits::eq ) );
+ }
+
+ nssv_constexpr size_type find_last_of( CharT c, size_type pos = npos ) const nssv_noexcept // (2)
+ {
+ return find_last_of( basic_string_view( &c, 1 ), pos );
+ }
+
+ nssv_constexpr size_type find_last_of( CharT const * s, size_type pos, size_type count ) const // (3)
+ {
+ return find_last_of( basic_string_view( s, count ), pos );
+ }
+
+ nssv_constexpr size_type find_last_of( CharT const * s, size_type pos = npos ) const // (4)
+ {
+ return find_last_of( basic_string_view( s ), pos );
+ }
+
+ // find_first_not_of(), 4x:
+
+ nssv_constexpr size_type find_first_not_of( basic_string_view v, size_type pos = 0 ) const nssv_noexcept // (1)
+ {
+ return pos >= size()
+ ? npos
+ : to_pos( std::find_if( cbegin() + pos, cend(), not_in_view( v ) ) );
+ }
+
+ nssv_constexpr size_type find_first_not_of( CharT c, size_type pos = 0 ) const nssv_noexcept // (2)
+ {
+ return find_first_not_of( basic_string_view( &c, 1 ), pos );
+ }
+
+ nssv_constexpr size_type find_first_not_of( CharT const * s, size_type pos, size_type count ) const // (3)
+ {
+ return find_first_not_of( basic_string_view( s, count ), pos );
+ }
+
+ nssv_constexpr size_type find_first_not_of( CharT const * s, size_type pos = 0 ) const // (4)
+ {
+ return find_first_not_of( basic_string_view( s ), pos );
+ }
+
+ // find_last_not_of(), 4x:
+
+ nssv_constexpr size_type find_last_not_of( basic_string_view v, size_type pos = npos ) const nssv_noexcept // (1)
+ {
+ return empty()
+ ? npos
+ : pos >= size()
+ ? find_last_not_of( v, size() - 1 )
+ : to_pos( std::find_if( const_reverse_iterator( cbegin() + pos + 1 ), crend(), not_in_view( v ) ) );
+ }
+
+ nssv_constexpr size_type find_last_not_of( CharT c, size_type pos = npos ) const nssv_noexcept // (2)
+ {
+ return find_last_not_of( basic_string_view( &c, 1 ), pos );
+ }
+
+ nssv_constexpr size_type find_last_not_of( CharT const * s, size_type pos, size_type count ) const // (3)
+ {
+ return find_last_not_of( basic_string_view( s, count ), pos );
+ }
+
+ nssv_constexpr size_type find_last_not_of( CharT const * s, size_type pos = npos ) const // (4)
+ {
+ return find_last_not_of( basic_string_view( s ), pos );
+ }
+
+ // Constants:
+
+#if nssv_CPP17_OR_GREATER
+ static nssv_constexpr size_type npos = size_type(-1);
+#elif nssv_CPP11_OR_GREATER
+ enum : size_type { npos = size_type(-1) };
+#else
+ enum { npos = size_type(-1) };
+#endif
+
+private:
+ struct not_in_view
+ {
+ const basic_string_view v;
+
+ nssv_constexpr not_in_view( basic_string_view v ) : v( v ) {}
+
+ nssv_constexpr bool operator()( CharT c ) const
+ {
+ return npos == v.find_first_of( c );
+ }
+ };
+
+ nssv_constexpr size_type to_pos( const_iterator it ) const
+ {
+ return it == cend() ? npos : size_type( it - cbegin() );
+ }
+
+ nssv_constexpr size_type to_pos( const_reverse_iterator it ) const
+ {
+ return it == crend() ? npos : size_type( crend() - it - 1 );
+ }
+
+ nssv_constexpr const_reference data_at( size_type pos ) const
+ {
+#if nssv_BETWEEN( nssv_COMPILER_GNUC_VERSION, 1, 500 )
+ return data_[pos];
+#else
+ return assert( pos < size() ), data_[pos];
+#endif
+ }
+
+private:
+ const_pointer data_;
+ size_type size_;
+
+public:
+#if nssv_CONFIG_CONVERSION_STD_STRING_CLASS_METHODS
+
+ template< class Allocator >
+ basic_string_view( std::basic_string<CharT, Traits, Allocator> const & s ) nssv_noexcept
+ : data_( s.data() )
+ , size_( s.size() )
+ {}
+
+#if nssv_HAVE_EXPLICIT_CONVERSION
+
+ template< class Allocator >
+ explicit operator std::basic_string<CharT, Traits, Allocator>() const
+ {
+ return to_string( Allocator() );
+ }
+
+#endif // nssv_HAVE_EXPLICIT_CONVERSION
+
+#if nssv_CPP11_OR_GREATER
+
+ template< class Allocator = std::allocator<CharT> >
+ std::basic_string<CharT, Traits, Allocator>
+ to_string( Allocator const & a = Allocator() ) const
+ {
+ return std::basic_string<CharT, Traits, Allocator>( begin(), end(), a );
+ }
+
+#else
+
+ std::basic_string<CharT, Traits>
+ to_string() const
+ {
+ return std::basic_string<CharT, Traits>( begin(), end() );
+ }
+
+ template< class Allocator >
+ std::basic_string<CharT, Traits, Allocator>
+ to_string( Allocator const & a ) const
+ {
+ return std::basic_string<CharT, Traits, Allocator>( begin(), end(), a );
+ }
+
+#endif // nssv_CPP11_OR_GREATER
+
+#endif // nssv_CONFIG_CONVERSION_STD_STRING_CLASS_METHODS
+};
+
+//
+// Non-member functions:
+//
+
+// 24.4.3 Non-member comparison functions:
+// lexicographically compare two string views (function template):
+
+template< class CharT, class Traits >
+nssv_constexpr bool operator== (
+ basic_string_view <CharT, Traits> lhs,
+ basic_string_view <CharT, Traits> rhs ) nssv_noexcept
+{ return lhs.compare( rhs ) == 0 ; }
+
+template< class CharT, class Traits >
+nssv_constexpr bool operator!= (
+ basic_string_view <CharT, Traits> lhs,
+ basic_string_view <CharT, Traits> rhs ) nssv_noexcept
+{ return lhs.compare( rhs ) != 0 ; }
+
+template< class CharT, class Traits >
+nssv_constexpr bool operator< (
+ basic_string_view <CharT, Traits> lhs,
+ basic_string_view <CharT, Traits> rhs ) nssv_noexcept
+{ return lhs.compare( rhs ) < 0 ; }
+
+template< class CharT, class Traits >
+nssv_constexpr bool operator<= (
+ basic_string_view <CharT, Traits> lhs,
+ basic_string_view <CharT, Traits> rhs ) nssv_noexcept
+{ return lhs.compare( rhs ) <= 0 ; }
+
+template< class CharT, class Traits >
+nssv_constexpr bool operator> (
+ basic_string_view <CharT, Traits> lhs,
+ basic_string_view <CharT, Traits> rhs ) nssv_noexcept
+{ return lhs.compare( rhs ) > 0 ; }
+
+template< class CharT, class Traits >
+nssv_constexpr bool operator>= (
+ basic_string_view <CharT, Traits> lhs,
+ basic_string_view <CharT, Traits> rhs ) nssv_noexcept
+{ return lhs.compare( rhs ) >= 0 ; }
+
+// Let S be basic_string_view<CharT, Traits>, and sv be an instance of S.
+// Implementations shall provide sufficient additional overloads marked
+// constexpr and noexcept so that an object t with an implicit conversion
+// to S can be compared according to Table 67.
+
+#if nssv_CPP11_OR_GREATER && ! nssv_BETWEEN( nssv_COMPILER_MSVC_VERSION, 100, 141 )
+
+#define nssv_BASIC_STRING_VIEW_I(T,U) typename std::decay< basic_string_view<T,U> >::type
+
+#if nssv_BETWEEN( nssv_COMPILER_MSVC_VERSION, 140, 150 )
+# define nssv_MSVC_ORDER(x) , int=x
+#else
+# define nssv_MSVC_ORDER(x) /*, int=x*/
+#endif
+
+// ==
+
+template< class CharT, class Traits nssv_MSVC_ORDER(1) >
+nssv_constexpr bool operator==(
+ basic_string_view <CharT, Traits> lhs,
+ nssv_BASIC_STRING_VIEW_I(CharT, Traits) rhs ) nssv_noexcept
+{ return lhs.compare( rhs ) == 0; }
+
+template< class CharT, class Traits nssv_MSVC_ORDER(2) >
+nssv_constexpr bool operator==(
+ nssv_BASIC_STRING_VIEW_I(CharT, Traits) lhs,
+ basic_string_view <CharT, Traits> rhs ) nssv_noexcept
+{ return lhs.size() == rhs.size() && lhs.compare( rhs ) == 0; }
+
+// !=
+
+template< class CharT, class Traits nssv_MSVC_ORDER(1) >
+nssv_constexpr bool operator!= (
+ basic_string_view < CharT, Traits > lhs,
+ nssv_BASIC_STRING_VIEW_I( CharT, Traits ) rhs ) nssv_noexcept
+{ return lhs.size() != rhs.size() || lhs.compare( rhs ) != 0 ; }
+
+template< class CharT, class Traits nssv_MSVC_ORDER(2) >
+nssv_constexpr bool operator!= (
+ nssv_BASIC_STRING_VIEW_I( CharT, Traits ) lhs,
+ basic_string_view < CharT, Traits > rhs ) nssv_noexcept
+{ return lhs.compare( rhs ) != 0 ; }
+
+// <
+
+template< class CharT, class Traits nssv_MSVC_ORDER(1) >
+nssv_constexpr bool operator< (
+ basic_string_view < CharT, Traits > lhs,
+ nssv_BASIC_STRING_VIEW_I( CharT, Traits ) rhs ) nssv_noexcept
+{ return lhs.compare( rhs ) < 0 ; }
+
+template< class CharT, class Traits nssv_MSVC_ORDER(2) >
+nssv_constexpr bool operator< (
+ nssv_BASIC_STRING_VIEW_I( CharT, Traits ) lhs,
+ basic_string_view < CharT, Traits > rhs ) nssv_noexcept
+{ return lhs.compare( rhs ) < 0 ; }
+
+// <=
+
+template< class CharT, class Traits nssv_MSVC_ORDER(1) >
+nssv_constexpr bool operator<= (
+ basic_string_view < CharT, Traits > lhs,
+ nssv_BASIC_STRING_VIEW_I( CharT, Traits ) rhs ) nssv_noexcept
+{ return lhs.compare( rhs ) <= 0 ; }
+
+template< class CharT, class Traits nssv_MSVC_ORDER(2) >
+nssv_constexpr bool operator<= (
+ nssv_BASIC_STRING_VIEW_I( CharT, Traits ) lhs,
+ basic_string_view < CharT, Traits > rhs ) nssv_noexcept
+{ return lhs.compare( rhs ) <= 0 ; }
+
+// >
+
+template< class CharT, class Traits nssv_MSVC_ORDER(1) >
+nssv_constexpr bool operator> (
+ basic_string_view < CharT, Traits > lhs,
+ nssv_BASIC_STRING_VIEW_I( CharT, Traits ) rhs ) nssv_noexcept
+{ return lhs.compare( rhs ) > 0 ; }
+
+template< class CharT, class Traits nssv_MSVC_ORDER(2) >
+nssv_constexpr bool operator> (
+ nssv_BASIC_STRING_VIEW_I( CharT, Traits ) lhs,
+ basic_string_view < CharT, Traits > rhs ) nssv_noexcept
+{ return lhs.compare( rhs ) > 0 ; }
+
+// >=
+
+template< class CharT, class Traits nssv_MSVC_ORDER(1) >
+nssv_constexpr bool operator>= (
+ basic_string_view < CharT, Traits > lhs,
+ nssv_BASIC_STRING_VIEW_I( CharT, Traits ) rhs ) nssv_noexcept
+{ return lhs.compare( rhs ) >= 0 ; }
+
+template< class CharT, class Traits nssv_MSVC_ORDER(2) >
+nssv_constexpr bool operator>= (
+ nssv_BASIC_STRING_VIEW_I( CharT, Traits ) lhs,
+ basic_string_view < CharT, Traits > rhs ) nssv_noexcept
+{ return lhs.compare( rhs ) >= 0 ; }
+
+#undef nssv_MSVC_ORDER
+#undef nssv_BASIC_STRING_VIEW_I
+
+#endif // nssv_CPP11_OR_GREATER
+
+// 24.4.4 Inserters and extractors:
+
+namespace detail {
+
+template< class Stream >
+void write_padding( Stream & os, std::streamsize n )
+{
+ for ( std::streamsize i = 0; i < n; ++i )
+ os.rdbuf()->sputc( os.fill() );
+}
+
+template< class Stream, class View >
+Stream & write_to_stream( Stream & os, View const & sv )
+{
+ typename Stream::sentry sentry( os );
+
+ if ( !os )
+ return os;
+
+ const std::streamsize length = static_cast<std::streamsize>( sv.length() );
+
+ // Whether, and how, to pad:
+ const bool pad = ( length < os.width() );
+ const bool left_pad = pad && ( os.flags() & std::ios_base::adjustfield ) == std::ios_base::right;
+
+ if ( left_pad )
+ write_padding( os, os.width() - length );
+
+ // Write span characters:
+ os.rdbuf()->sputn( sv.begin(), length );
+
+ if ( pad && !left_pad )
+ write_padding( os, os.width() - length );
+
+ // Reset output stream width:
+ os.width( 0 );
+
+ return os;
+}
+
+} // namespace detail
+
+template< class CharT, class Traits >
+std::basic_ostream<CharT, Traits> &
+operator<<(
+ std::basic_ostream<CharT, Traits>& os,
+ basic_string_view <CharT, Traits> sv )
+{
+ return detail::write_to_stream( os, sv );
+}
+
+// Several typedefs for common character types are provided:
+
+typedef basic_string_view<char> string_view;
+typedef basic_string_view<wchar_t> wstring_view;
+#if nssv_HAVE_WCHAR16_T
+typedef basic_string_view<char16_t> u16string_view;
+typedef basic_string_view<char32_t> u32string_view;
+#endif
+
+}} // namespace nonstd::sv_lite
+
+//
+// 24.4.6 Suffix for basic_string_view literals:
+//
+
+#if nssv_HAVE_USER_DEFINED_LITERALS
+
+namespace nonstd {
+nssv_inline_ns namespace literals {
+nssv_inline_ns namespace string_view_literals {
+
+#if nssv_CONFIG_STD_SV_OPERATOR && nssv_HAVE_STD_DEFINED_LITERALS
+
+nssv_constexpr nonstd::sv_lite::string_view operator "" sv( const char* str, size_t len ) nssv_noexcept // (1)
+{
+ return nonstd::sv_lite::string_view{ str, len };
+}
+
+nssv_constexpr nonstd::sv_lite::u16string_view operator "" sv( const char16_t* str, size_t len ) nssv_noexcept // (2)
+{
+ return nonstd::sv_lite::u16string_view{ str, len };
+}
+
+nssv_constexpr nonstd::sv_lite::u32string_view operator "" sv( const char32_t* str, size_t len ) nssv_noexcept // (3)
+{
+ return nonstd::sv_lite::u32string_view{ str, len };
+}
+
+nssv_constexpr nonstd::sv_lite::wstring_view operator "" sv( const wchar_t* str, size_t len ) nssv_noexcept // (4)
+{
+ return nonstd::sv_lite::wstring_view{ str, len };
+}
+
+#endif // nssv_CONFIG_STD_SV_OPERATOR && nssv_HAVE_STD_DEFINED_LITERALS
+
+#if nssv_CONFIG_USR_SV_OPERATOR
+
+nssv_constexpr nonstd::sv_lite::string_view operator "" _sv( const char* str, size_t len ) nssv_noexcept // (1)
+{
+ return nonstd::sv_lite::string_view{ str, len };
+}
+
+nssv_constexpr nonstd::sv_lite::u16string_view operator "" _sv( const char16_t* str, size_t len ) nssv_noexcept // (2)
+{
+ return nonstd::sv_lite::u16string_view{ str, len };
+}
+
+nssv_constexpr nonstd::sv_lite::u32string_view operator "" _sv( const char32_t* str, size_t len ) nssv_noexcept // (3)
+{
+ return nonstd::sv_lite::u32string_view{ str, len };
+}
+
+nssv_constexpr nonstd::sv_lite::wstring_view operator "" _sv( const wchar_t* str, size_t len ) nssv_noexcept // (4)
+{
+ return nonstd::sv_lite::wstring_view{ str, len };
+}
+
+#endif // nssv_CONFIG_USR_SV_OPERATOR
+
+}}} // namespace nonstd::literals::string_view_literals
+
+#endif
+
+//
+// Extensions for std::string:
+//
+
+#if nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS
+
+namespace nonstd {
+namespace sv_lite {
+
+// Exclude MSVC 14 (19.00): it yields ambiguous to_string():
+
+#if nssv_CPP11_OR_GREATER && nssv_COMPILER_MSVC_VERSION != 140
+
+template< class CharT, class Traits, class Allocator = std::allocator<CharT> >
+std::basic_string<CharT, Traits, Allocator>
+to_string( basic_string_view<CharT, Traits> v, Allocator const & a = Allocator() )
+{
+ return std::basic_string<CharT,Traits, Allocator>( v.begin(), v.end(), a );
+}
+
+#else
+
+template< class CharT, class Traits >
+std::basic_string<CharT, Traits>
+to_string( basic_string_view<CharT, Traits> v )
+{
+ return std::basic_string<CharT, Traits>( v.begin(), v.end() );
+}
+
+template< class CharT, class Traits, class Allocator >
+std::basic_string<CharT, Traits, Allocator>
+to_string( basic_string_view<CharT, Traits> v, Allocator const & a )
+{
+ return std::basic_string<CharT, Traits, Allocator>( v.begin(), v.end(), a );
+}
+
+#endif // nssv_CPP11_OR_GREATER
+
+template< class CharT, class Traits, class Allocator >
+basic_string_view<CharT, Traits>
+to_string_view( std::basic_string<CharT, Traits, Allocator> const & s )
+{
+ return basic_string_view<CharT, Traits>( s.data(), s.size() );
+}
+
+}} // namespace nonstd::sv_lite
+
+#endif // nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS
+
+//
+// make types and algorithms available in namespace nonstd:
+//
+
+namespace nonstd {
+
+using sv_lite::basic_string_view;
+using sv_lite::string_view;
+using sv_lite::wstring_view;
+
+#if nssv_HAVE_WCHAR16_T
+using sv_lite::u16string_view;
+#endif
+#if nssv_HAVE_WCHAR32_T
+using sv_lite::u32string_view;
+#endif
+
+// literal "sv"
+
+using sv_lite::operator==;
+using sv_lite::operator!=;
+using sv_lite::operator<;
+using sv_lite::operator<=;
+using sv_lite::operator>;
+using sv_lite::operator>=;
+
+using sv_lite::operator<<;
+
+#if nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS
+using sv_lite::to_string;
+using sv_lite::to_string_view;
+#endif
+
+} // namespace nonstd
+
+// 24.4.5 Hash support (C++11):
+
+// Note: The hash value of a string view object is equal to the hash value of
+// the corresponding string object.
+
+#if nssv_HAVE_STD_HASH
+
+#include <functional>
+
+namespace std {
+
+template<>
+struct hash< nonstd::string_view >
+{
+public:
+ std::size_t operator()( nonstd::string_view v ) const nssv_noexcept
+ {
+ return std::hash<std::string>()( std::string( v.data(), v.size() ) );
+ }
+};
+
+template<>
+struct hash< nonstd::wstring_view >
+{
+public:
+ std::size_t operator()( nonstd::wstring_view v ) const nssv_noexcept
+ {
+ return std::hash<std::wstring>()( std::wstring( v.data(), v.size() ) );
+ }
+};
+
+template<>
+struct hash< nonstd::u16string_view >
+{
+public:
+ std::size_t operator()( nonstd::u16string_view v ) const nssv_noexcept
+ {
+ return std::hash<std::u16string>()( std::u16string( v.data(), v.size() ) );
+ }
+};
+
+template<>
+struct hash< nonstd::u32string_view >
+{
+public:
+ std::size_t operator()( nonstd::u32string_view v ) const nssv_noexcept
+ {
+ return std::hash<std::u32string>()( std::u32string( v.data(), v.size() ) );
+ }
+};
+
+} // namespace std
+
+#endif // nssv_HAVE_STD_HASH
+
+nssv_RESTORE_WARNINGS()
+
+#endif // nssv_HAVE_STD_STRING_VIEW
+#endif // NONSTD_SV_LITE_H_INCLUDED
+
+
+
+namespace inja {
+
+enum class ElementNotation {
+ Dot,
+ Pointer
+};
+
+/*!
+ * \brief Class for lexer configuration.
+ */
+struct LexerConfig {
+ std::string statement_open {"{%"};
+ std::string statement_close {"%}"};
+ std::string line_statement {"##"};
+ std::string expression_open {"{{"};
+ std::string expression_close {"}}"};
+ std::string comment_open {"{#"};
+ std::string comment_close {"#}"};
+ std::string open_chars {"#{"};
+
+ bool trim_blocks {false};
+ bool lstrip_blocks {false};
+
+ void update_open_chars() {
+ open_chars = "";
+ if (open_chars.find(line_statement[0]) == std::string::npos) {
+ open_chars += line_statement[0];
+ }
+ if (open_chars.find(statement_open[0]) == std::string::npos) {
+ open_chars += statement_open[0];
+ }
+ if (open_chars.find(expression_open[0]) == std::string::npos) {
+ open_chars += expression_open[0];
+ }
+ if (open_chars.find(comment_open[0]) == std::string::npos) {
+ open_chars += comment_open[0];
+ }
+ }
+};
+
+/*!
+ * \brief Class for parser configuration.
+ */
+struct ParserConfig {
+ ElementNotation notation {ElementNotation::Dot};
+};
+
+}
+
+#endif // PANTOR_INJA_CONFIG_HPP
+
+// #include "function_storage.hpp"
+#ifndef PANTOR_INJA_FUNCTION_STORAGE_HPP
+#define PANTOR_INJA_FUNCTION_STORAGE_HPP
+
+#include <vector>
+
+// #include "bytecode.hpp"
+#ifndef PANTOR_INJA_BYTECODE_HPP
+#define PANTOR_INJA_BYTECODE_HPP
+
+#include <string>
+#include <utility>
+
+#include <nlohmann/json.hpp>
+
+// #include "string_view.hpp"
+
+
+
+namespace inja {
+
+using json = nlohmann::json;
+
+
+struct Bytecode {
+ enum class Op : uint8_t {
+ Nop,
+ // print StringRef (always immediate)
+ PrintText,
+ // print value
+ PrintValue,
+ // push value onto stack (always immediate)
+ Push,
+
+ // builtin functions
+ // result is pushed to stack
+ // args specify number of arguments
+ // all functions can take their "last" argument either immediate
+ // or popped off stack (e.g. if immediate, it's like the immediate was
+ // just pushed to the stack)
+ Not,
+ And,
+ Or,
+ In,
+ Equal,
+ Greater,
+ GreaterEqual,
+ Less,
+ LessEqual,
+ At,
+ Different,
+ DivisibleBy,
+ Even,
+ First,
+ Float,
+ Int,
+ Last,
+ Length,
+ Lower,
+ Max,
+ Min,
+ Odd,
+ Range,
+ Result,
+ Round,
+ Sort,
+ Upper,
+ Exists,
+ ExistsInObject,
+ IsBoolean,
+ IsNumber,
+ IsInteger,
+ IsFloat,
+ IsObject,
+ IsArray,
+ IsString,
+ Default,
+
+ // include another template
+ // value is the template name
+ Include,
+
+ // callback function
+ // str is the function name (this means it cannot be a lookup)
+ // args specify number of arguments
+ // as with builtin functions, "last" argument can be immediate
+ Callback,
+
+ // unconditional jump
+ // args is the index of the bytecode to jump to.
+ Jump,
+
+ // conditional jump
+ // value popped off stack is checked for truthyness
+ // if false, args is the index of the bytecode to jump to.
+ // if true, no action is taken (falls through)
+ ConditionalJump,
+
+ // start loop
+ // value popped off stack is what is iterated over
+ // args is index of bytecode after end loop (jumped to if iterable is
+ // empty)
+ // immediate value is key name (for maps)
+ // str is value name
+ StartLoop,
+
+ // end a loop
+ // args is index of the first bytecode in the loop body
+ EndLoop,
+ };
+
+ enum Flag {
+ // location of value for value-taking ops (mask)
+ ValueMask = 0x03,
+ // pop value off stack
+ ValuePop = 0x00,
+ // value is immediate rather than on stack
+ ValueImmediate = 0x01,
+ // lookup immediate str (dot notation)
+ ValueLookupDot = 0x02,
+ // lookup immediate str (json pointer notation)
+ ValueLookupPointer = 0x03,
+ };
+
+ Op op {Op::Nop};
+ uint32_t args: 30;
+ uint32_t flags: 2;
+
+ json value;
+ std::string str;
+
+ Bytecode(): args(0), flags(0) {}
+ explicit Bytecode(Op op, unsigned int args = 0): op(op), args(args), flags(0) {}
+ explicit Bytecode(Op op, nonstd::string_view str, unsigned int flags): op(op), args(0), flags(flags), str(str) {}
+ explicit Bytecode(Op op, json&& value, unsigned int flags): op(op), args(0), flags(flags), value(std::move(value)) {}
+};
+
+} // namespace inja
+
+#endif // PANTOR_INJA_BYTECODE_HPP
+
+// #include "string_view.hpp"
+
+
+
+namespace inja {
+
+using namespace nlohmann;
+
+using Arguments = std::vector<const json*>;
+using CallbackFunction = std::function<json(Arguments& args)>;
+
+/*!
+ * \brief Class for builtin functions and user-defined callbacks.
+ */
+class FunctionStorage {
+ public:
+ void add_builtin(nonstd::string_view name, unsigned int num_args, Bytecode::Op op) {
+ auto& data = get_or_new(name, num_args);
+ data.op = op;
+ }
+
+ void add_callback(nonstd::string_view name, unsigned int num_args, const CallbackFunction& function) {
+ auto& data = get_or_new(name, num_args);
+ data.function = function;
+ }
+
+ Bytecode::Op find_builtin(nonstd::string_view name, unsigned int num_args) const {
+ if (auto ptr = get(name, num_args)) {
+ return ptr->op;
+ }
+ return Bytecode::Op::Nop;
+ }
+
+ CallbackFunction find_callback(nonstd::string_view name, unsigned int num_args) const {
+ if (auto ptr = get(name, num_args)) {
+ return ptr->function;
+ }
+ return nullptr;
+ }
+
+ private:
+ struct FunctionData {
+ unsigned int num_args {0};
+ Bytecode::Op op {Bytecode::Op::Nop}; // for builtins
+ CallbackFunction function; // for callbacks
+ };
+
+ FunctionData& get_or_new(nonstd::string_view name, unsigned int num_args) {
+ auto &vec = m_map[static_cast<std::string>(name)];
+ for (auto &i: vec) {
+ if (i.num_args == num_args) return i;
+ }
+ vec.emplace_back();
+ vec.back().num_args = num_args;
+ return vec.back();
+ }
+
+ const FunctionData* get(nonstd::string_view name, unsigned int num_args) const {
+ auto it = m_map.find(static_cast<std::string>(name));
+ if (it == m_map.end()) return nullptr;
+ for (auto &&i: it->second) {
+ if (i.num_args == num_args) return &i;
+ }
+ return nullptr;
+ }
+
+ std::map<std::string, std::vector<FunctionData>> m_map;
+};
+
+}
+
+#endif // PANTOR_INJA_FUNCTION_STORAGE_HPP
+
+// #include "parser.hpp"
+#ifndef PANTOR_INJA_PARSER_HPP
+#define PANTOR_INJA_PARSER_HPP
+
+#include <limits>
+#include <string>
+#include <utility>
+#include <vector>
+
+// #include "bytecode.hpp"
+
+// #include "config.hpp"
+
+// #include "function_storage.hpp"
+
+// #include "lexer.hpp"
+#ifndef PANTOR_INJA_LEXER_HPP
+#define PANTOR_INJA_LEXER_HPP
+
+#include <cctype>
+#include <locale>
+
+// #include "config.hpp"
+
+// #include "token.hpp"
+#ifndef PANTOR_INJA_TOKEN_HPP
+#define PANTOR_INJA_TOKEN_HPP
+
+#include <string>
+
+// #include "string_view.hpp"
+
+
+
+namespace inja {
+
+/*!
+ * \brief Helper-class for the inja Parser.
+ */
+struct Token {
+ enum class Kind {
+ Text,
+ ExpressionOpen, // {{
+ ExpressionClose, // }}
+ LineStatementOpen, // ##
+ LineStatementClose, // \n
+ StatementOpen, // {%
+ StatementClose, // %}
+ CommentOpen, // {#
+ CommentClose, // #}
+ Id, // this, this.foo
+ Number, // 1, 2, -1, 5.2, -5.3
+ String, // "this"
+ Comma, // ,
+ Colon, // :
+ LeftParen, // (
+ RightParen, // )
+ LeftBracket, // [
+ RightBracket, // ]
+ LeftBrace, // {
+ RightBrace, // }
+ Equal, // ==
+ GreaterThan, // >
+ GreaterEqual, // >=
+ LessThan, // <
+ LessEqual, // <=
+ NotEqual, // !=
+ Unknown,
+ Eof
+ } kind {Kind::Unknown};
+
+ nonstd::string_view text;
+
+ constexpr Token() = default;
+ constexpr Token(Kind kind, nonstd::string_view text): kind(kind), text(text) {}
+
+ std::string describe() const {
+ switch (kind) {
+ case Kind::Text:
+ return "<text>";
+ case Kind::LineStatementClose:
+ return "<eol>";
+ case Kind::Eof:
+ return "<eof>";
+ default:
+ return static_cast<std::string>(text);
+ }
+ }
+};
+
+}
+
+#endif // PANTOR_INJA_TOKEN_HPP
+
+// #include "utils.hpp"
+#ifndef PANTOR_INJA_UTILS_HPP
+#define PANTOR_INJA_UTILS_HPP
+
+#include <algorithm>
+#include <fstream>
+#include <stdexcept>
+#include <string>
+#include <utility>
+
+// #include "string_view.hpp"
+
+
+
+namespace inja {
+
+inline void inja_throw(const std::string& type, const std::string& message) {
+ throw std::runtime_error("[inja.exception." + type + "] " + message);
+}
+
+inline std::ifstream open_file_or_throw(const std::string& path) {
+ std::ifstream file;
+ file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
+ try {
+ file.open(path);
+ } catch(const std::ios_base::failure& e) {
+ inja_throw("file_error", "failed accessing file at '" + path + "'");
+ }
+ return file;
+}
+
+namespace string_view {
+ inline nonstd::string_view slice(nonstd::string_view view, size_t start, size_t end) {
+ start = std::min(start, view.size());
+ end = std::min(std::max(start, end), view.size());
+ return view.substr(start, end - start); // StringRef(Data + Start, End - Start);
+ }
+
+ inline std::pair<nonstd::string_view, nonstd::string_view> split(nonstd::string_view view, char Separator) {
+ size_t idx = view.find(Separator);
+ if (idx == nonstd::string_view::npos) {
+ return std::make_pair(view, nonstd::string_view());
+ }
+ return std::make_pair(slice(view, 0, idx), slice(view, idx + 1, nonstd::string_view::npos));
+ }
+
+ inline bool starts_with(nonstd::string_view view, nonstd::string_view prefix) {
+ return (view.size() >= prefix.size() && view.compare(0, prefix.size(), prefix) == 0);
+ }
+} // namespace string
+
+} // namespace inja
+
+#endif // PANTOR_INJA_UTILS_HPP
+
+
+
+namespace inja {
+
+/*!
+ * \brief Class for lexing an inja Template.
+ */
+class Lexer {
+ enum class State {
+ Text,
+ ExpressionStart,
+ ExpressionBody,
+ LineStart,
+ LineBody,
+ StatementStart,
+ StatementBody,
+ CommentStart,
+ CommentBody
+ } m_state;
+
+ const LexerConfig& m_config;
+ nonstd::string_view m_in;
+ size_t m_tok_start;
+ size_t m_pos;
+
+ public:
+ explicit Lexer(const LexerConfig& config) : m_config(config) {}
+
+ void start(nonstd::string_view in) {
+ m_in = in;
+ m_tok_start = 0;
+ m_pos = 0;
+ m_state = State::Text;
+ }
+
+ Token scan() {
+ m_tok_start = m_pos;
+
+ again:
+ if (m_tok_start >= m_in.size()) return make_token(Token::Kind::Eof);
+
+ switch (m_state) {
+ default:
+ case State::Text: {
+ // fast-scan to first open character
+ size_t open_start = m_in.substr(m_pos).find_first_of(m_config.open_chars);
+ if (open_start == nonstd::string_view::npos) {
+ // didn't find open, return remaining text as text token
+ m_pos = m_in.size();
+ return make_token(Token::Kind::Text);
+ }
+ m_pos += open_start;
+
+ // try to match one of the opening sequences, and get the close
+ nonstd::string_view open_str = m_in.substr(m_pos);
+ bool must_lstrip = false;
+ if (inja::string_view::starts_with(open_str, m_config.expression_open)) {
+ m_state = State::ExpressionStart;
+ } else if (inja::string_view::starts_with(open_str, m_config.statement_open)) {
+ m_state = State::StatementStart;
+ must_lstrip = m_config.lstrip_blocks;
+ } else if (inja::string_view::starts_with(open_str, m_config.comment_open)) {
+ m_state = State::CommentStart;
+ must_lstrip = m_config.lstrip_blocks;
+ } else if ((m_pos == 0 || m_in[m_pos - 1] == '\n') &&
+ inja::string_view::starts_with(open_str, m_config.line_statement)) {
+ m_state = State::LineStart;
+ } else {
+ m_pos += 1; // wasn't actually an opening sequence
+ goto again;
+ }
+
+ nonstd::string_view text = string_view::slice(m_in, m_tok_start, m_pos);
+ if (must_lstrip)
+ text = clear_final_line_if_whitespace(text);
+
+ if (text.empty()) goto again; // don't generate empty token
+ return Token(Token::Kind::Text, text);
+ }
+ case State::ExpressionStart: {
+ m_state = State::ExpressionBody;
+ m_pos += m_config.expression_open.size();
+ return make_token(Token::Kind::ExpressionOpen);
+ }
+ case State::LineStart: {
+ m_state = State::LineBody;
+ m_pos += m_config.line_statement.size();
+ return make_token(Token::Kind::LineStatementOpen);
+ }
+ case State::StatementStart: {
+ m_state = State::StatementBody;
+ m_pos += m_config.statement_open.size();
+ return make_token(Token::Kind::StatementOpen);
+ }
+ case State::CommentStart: {
+ m_state = State::CommentBody;
+ m_pos += m_config.comment_open.size();
+ return make_token(Token::Kind::CommentOpen);
+ }
+ case State::ExpressionBody:
+ return scan_body(m_config.expression_close, Token::Kind::ExpressionClose);
+ case State::LineBody:
+ return scan_body("\n", Token::Kind::LineStatementClose);
+ case State::StatementBody:
+ return scan_body(m_config.statement_close, Token::Kind::StatementClose, m_config.trim_blocks);
+ case State::CommentBody: {
+ // fast-scan to comment close
+ size_t end = m_in.substr(m_pos).find(m_config.comment_close);
+ if (end == nonstd::string_view::npos) {
+ m_pos = m_in.size();
+ return make_token(Token::Kind::Eof);
+ }
+ // return the entire comment in the close token
+ m_state = State::Text;
+ m_pos += end + m_config.comment_close.size();
+ Token tok = make_token(Token::Kind::CommentClose);
+ if (m_config.trim_blocks)
+ skip_newline();
+ return tok;
+ }
+ }
+ }
+
+ const LexerConfig& get_config() const { return m_config; }
+
+ private:
+ Token scan_body(nonstd::string_view close, Token::Kind closeKind, bool trim = false) {
+ again:
+ // skip whitespace (except for \n as it might be a close)
+ if (m_tok_start >= m_in.size()) return make_token(Token::Kind::Eof);
+ char ch = m_in[m_tok_start];
+ if (ch == ' ' || ch == '\t' || ch == '\r') {
+ m_tok_start += 1;
+ goto again;
+ }
+
+ // check for close
+ if (inja::string_view::starts_with(m_in.substr(m_tok_start), close)) {
+ m_state = State::Text;
+ m_pos = m_tok_start + close.size();
+ Token tok = make_token(closeKind);
+ if (trim)
+ skip_newline();
+ return tok;
+ }
+
+ // skip \n
+ if (ch == '\n') {
+ m_tok_start += 1;
+ goto again;
+ }
+
+ m_pos = m_tok_start + 1;
+ if (std::isalpha(ch)) return scan_id();
+ switch (ch) {
+ case ',':
+ return make_token(Token::Kind::Comma);
+ case ':':
+ return make_token(Token::Kind::Colon);
+ case '(':
+ return make_token(Token::Kind::LeftParen);
+ case ')':
+ return make_token(Token::Kind::RightParen);
+ case '[':
+ return make_token(Token::Kind::LeftBracket);
+ case ']':
+ return make_token(Token::Kind::RightBracket);
+ case '{':
+ return make_token(Token::Kind::LeftBrace);
+ case '}':
+ return make_token(Token::Kind::RightBrace);
+ case '>':
+ if (m_pos < m_in.size() && m_in[m_pos] == '=') {
+ m_pos += 1;
+ return make_token(Token::Kind::GreaterEqual);
+ }
+ return make_token(Token::Kind::GreaterThan);
+ case '<':
+ if (m_pos < m_in.size() && m_in[m_pos] == '=') {
+ m_pos += 1;
+ return make_token(Token::Kind::LessEqual);
+ }
+ return make_token(Token::Kind::LessThan);
+ case '=':
+ if (m_pos < m_in.size() && m_in[m_pos] == '=') {
+ m_pos += 1;
+ return make_token(Token::Kind::Equal);
+ }
+ return make_token(Token::Kind::Unknown);
+ case '!':
+ if (m_pos < m_in.size() && m_in[m_pos] == '=') {
+ m_pos += 1;
+ return make_token(Token::Kind::NotEqual);
+ }
+ return make_token(Token::Kind::Unknown);
+ case '\"':
+ return scan_string();
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ case '-':
+ return scan_number();
+ case '_':
+ return scan_id();
+ default:
+ return make_token(Token::Kind::Unknown);
+ }
+ }
+
+ Token scan_id() {
+ for (;;) {
+ if (m_pos >= m_in.size()) {
+ break;
+ }
+ char ch = m_in[m_pos];
+ if (!std::isalnum(ch) && ch != '.' && ch != '/' && ch != '_' && ch != '-') {
+ break;
+ }
+ m_pos += 1;
+ }
+ return make_token(Token::Kind::Id);
+ }
+
+ Token scan_number() {
+ for (;;) {
+ if (m_pos >= m_in.size()) {
+ break;
+ }
+ char ch = m_in[m_pos];
+ // be very permissive in lexer (we'll catch errors when conversion happens)
+ if (!std::isdigit(ch) && ch != '.' && ch != 'e' && ch != 'E' && ch != '+' && ch != '-') {
+ break;
+ }
+ m_pos += 1;
+ }
+ return make_token(Token::Kind::Number);
+ }
+
+ Token scan_string() {
+ bool escape {false};
+ for (;;) {
+ if (m_pos >= m_in.size()) break;
+ char ch = m_in[m_pos++];
+ if (ch == '\\') {
+ escape = true;
+ } else if (!escape && ch == m_in[m_tok_start]) {
+ break;
+ } else {
+ escape = false;
+ }
+ }
+ return make_token(Token::Kind::String);
+ }
+
+ Token make_token(Token::Kind kind) const {
+ return Token(kind, string_view::slice(m_in, m_tok_start, m_pos));
+ }
+
+ void skip_newline() {
+ if (m_pos < m_in.size()) {
+ char ch = m_in[m_pos];
+ if (ch == '\n')
+ m_pos += 1;
+ else if (ch == '\r') {
+ m_pos += 1;
+ if (m_pos < m_in.size() && m_in[m_pos] == '\n')
+ m_pos += 1;
+ }
+ }
+ }
+
+ static nonstd::string_view clear_final_line_if_whitespace(nonstd::string_view text)
+ {
+ nonstd::string_view result = text;
+ while (!result.empty()) {
+ char ch = result.back();
+ if (ch == ' ' || ch == '\t')
+ result.remove_suffix(1);
+ else if (ch == '\n' || ch == '\r')
+ break;
+ else
+ return text;
+ }
+ return result;
+ }
+};
+
+}
+
+#endif // PANTOR_INJA_LEXER_HPP
+
+// #include "template.hpp"
+#ifndef PANTOR_INJA_TEMPLATE_HPP
+#define PANTOR_INJA_TEMPLATE_HPP
+
+#include <map>
+#include <string>
+#include <vector>
+
+// #include "bytecode.hpp"
+
+
+
+namespace inja {
+
+/*!
+ * \brief The main inja Template.
+ */
+struct Template {
+ std::vector<Bytecode> bytecodes;
+ std::string content;
+};
+
+using TemplateStorage = std::map<std::string, Template>;
+
+}
+
+#endif // PANTOR_INJA_TEMPLATE_HPP
+
+// #include "token.hpp"
+
+// #include "utils.hpp"
+
+
+#include <nlohmann/json.hpp>
+
+
+namespace inja {
+
+class ParserStatic {
+ ParserStatic() {
+ functions.add_builtin("at", 2, Bytecode::Op::At);
+ functions.add_builtin("default", 2, Bytecode::Op::Default);
+ functions.add_builtin("divisibleBy", 2, Bytecode::Op::DivisibleBy);
+ functions.add_builtin("even", 1, Bytecode::Op::Even);
+ functions.add_builtin("first", 1, Bytecode::Op::First);
+ functions.add_builtin("float", 1, Bytecode::Op::Float);
+ functions.add_builtin("int", 1, Bytecode::Op::Int);
+ functions.add_builtin("last", 1, Bytecode::Op::Last);
+ functions.add_builtin("length", 1, Bytecode::Op::Length);
+ functions.add_builtin("lower", 1, Bytecode::Op::Lower);
+ functions.add_builtin("max", 1, Bytecode::Op::Max);
+ functions.add_builtin("min", 1, Bytecode::Op::Min);
+ functions.add_builtin("odd", 1, Bytecode::Op::Odd);
+ functions.add_builtin("range", 1, Bytecode::Op::Range);
+ functions.add_builtin("round", 2, Bytecode::Op::Round);
+ functions.add_builtin("sort", 1, Bytecode::Op::Sort);
+ functions.add_builtin("upper", 1, Bytecode::Op::Upper);
+ functions.add_builtin("exists", 1, Bytecode::Op::Exists);
+ functions.add_builtin("existsIn", 2, Bytecode::Op::ExistsInObject);
+ functions.add_builtin("isBoolean", 1, Bytecode::Op::IsBoolean);
+ functions.add_builtin("isNumber", 1, Bytecode::Op::IsNumber);
+ functions.add_builtin("isInteger", 1, Bytecode::Op::IsInteger);
+ functions.add_builtin("isFloat", 1, Bytecode::Op::IsFloat);
+ functions.add_builtin("isObject", 1, Bytecode::Op::IsObject);
+ functions.add_builtin("isArray", 1, Bytecode::Op::IsArray);
+ functions.add_builtin("isString", 1, Bytecode::Op::IsString);
+ }
+
+ public:
+ ParserStatic(const ParserStatic&) = delete;
+ ParserStatic& operator=(const ParserStatic&) = delete;
+
+ static const ParserStatic& get_instance() {
+ static ParserStatic inst;
+ return inst;
+ }
+
+ FunctionStorage functions;
+};
+
+/*!
+ * \brief Class for parsing an inja Template.
+ */
+class Parser {
+ public:
+ explicit Parser(const ParserConfig& parser_config, const LexerConfig& lexer_config, TemplateStorage& included_templates): m_config(parser_config), m_lexer(lexer_config), m_included_templates(included_templates), m_static(ParserStatic::get_instance()) { }
+
+ bool parse_expression(Template& tmpl) {
+ if (!parse_expression_and(tmpl)) return false;
+ if (m_tok.kind != Token::Kind::Id || m_tok.text != static_cast<decltype(m_tok.text)>("or")) return true;
+ get_next_token();
+ if (!parse_expression_and(tmpl)) return false;
+ append_function(tmpl, Bytecode::Op::Or, 2);
+ return true;
+ }
+
+ bool parse_expression_and(Template& tmpl) {
+ if (!parse_expression_not(tmpl)) return false;
+ if (m_tok.kind != Token::Kind::Id || m_tok.text != static_cast<decltype(m_tok.text)>("and")) return true;
+ get_next_token();
+ if (!parse_expression_not(tmpl)) return false;
+ append_function(tmpl, Bytecode::Op::And, 2);
+ return true;
+ }
+
+ bool parse_expression_not(Template& tmpl) {
+ if (m_tok.kind == Token::Kind::Id && m_tok.text == static_cast<decltype(m_tok.text)>("not")) {
+ get_next_token();
+ if (!parse_expression_not(tmpl)) return false;
+ append_function(tmpl, Bytecode::Op::Not, 1);
+ return true;
+ } else {
+ return parse_expression_comparison(tmpl);
+ }
+ }
+
+ bool parse_expression_comparison(Template& tmpl) {
+ if (!parse_expression_datum(tmpl)) return false;
+ Bytecode::Op op;
+ switch (m_tok.kind) {
+ case Token::Kind::Id:
+ if (m_tok.text == static_cast<decltype(m_tok.text)>("in"))
+ op = Bytecode::Op::In;
+ else
+ return true;
+ break;
+ case Token::Kind::Equal:
+ op = Bytecode::Op::Equal;
+ break;
+ case Token::Kind::GreaterThan:
+ op = Bytecode::Op::Greater;
+ break;
+ case Token::Kind::LessThan:
+ op = Bytecode::Op::Less;
+ break;
+ case Token::Kind::LessEqual:
+ op = Bytecode::Op::LessEqual;
+ break;
+ case Token::Kind::GreaterEqual:
+ op = Bytecode::Op::GreaterEqual;
+ break;
+ case Token::Kind::NotEqual:
+ op = Bytecode::Op::Different;
+ break;
+ default:
+ return true;
+ }
+ get_next_token();
+ if (!parse_expression_datum(tmpl)) return false;
+ append_function(tmpl, op, 2);
+ return true;
+ }
+
+ bool parse_expression_datum(Template& tmpl) {
+ nonstd::string_view json_first;
+ size_t bracket_level = 0;
+ size_t brace_level = 0;
+
+ for (;;) {
+ switch (m_tok.kind) {
+ case Token::Kind::LeftParen: {
+ get_next_token();
+ if (!parse_expression(tmpl)) return false;
+ if (m_tok.kind != Token::Kind::RightParen) {
+ inja_throw("parser_error", "unmatched '('");
+ }
+ get_next_token();
+ return true;
+ }
+ case Token::Kind::Id:
+ get_peek_token();
+ if (m_peek_tok.kind == Token::Kind::LeftParen) {
+ // function call, parse arguments
+ Token func_token = m_tok;
+ get_next_token(); // id
+ get_next_token(); // leftParen
+ unsigned int num_args = 0;
+ if (m_tok.kind == Token::Kind::RightParen) {
+ // no args
+ get_next_token();
+ } else {
+ for (;;) {
+ if (!parse_expression(tmpl)) {
+ inja_throw("parser_error", "expected expression, got '" + m_tok.describe() + "'");
+ }
+ num_args += 1;
+ if (m_tok.kind == Token::Kind::RightParen) {
+ get_next_token();
+ break;
+ }
+ if (m_tok.kind != Token::Kind::Comma) {
+ inja_throw("parser_error", "expected ')' or ',', got '" + m_tok.describe() + "'");
+ }
+ get_next_token();
+ }
+ }
+
+ auto op = m_static.functions.find_builtin(func_token.text, num_args);
+
+ if (op != Bytecode::Op::Nop) {
+ // swap arguments for default(); see comment in RenderTo()
+ if (op == Bytecode::Op::Default)
+ std::swap(tmpl.bytecodes.back(), *(tmpl.bytecodes.rbegin() + 1));
+ append_function(tmpl, op, num_args);
+ return true;
+ } else {
+ append_callback(tmpl, func_token.text, num_args);
+ return true;
+ }
+ } else if (m_tok.text == static_cast<decltype(m_tok.text)>("true") ||
+ m_tok.text == static_cast<decltype(m_tok.text)>("false") ||
+ m_tok.text == static_cast<decltype(m_tok.text)>("null")) {
+ // true, false, null are json literals
+ if (brace_level == 0 && bracket_level == 0) {
+ json_first = m_tok.text;
+ goto returnJson;
+ }
+ break;
+ } else {
+ // normal literal (json read)
+ tmpl.bytecodes.emplace_back(
+ Bytecode::Op::Push, m_tok.text,
+ m_config.notation == ElementNotation::Pointer ? Bytecode::Flag::ValueLookupPointer : Bytecode::Flag::ValueLookupDot);
+ get_next_token();
+ return true;
+ }
+ // json passthrough
+ case Token::Kind::Number:
+ case Token::Kind::String:
+ if (brace_level == 0 && bracket_level == 0) {
+ json_first = m_tok.text;
+ goto returnJson;
+ }
+ break;
+ case Token::Kind::Comma:
+ case Token::Kind::Colon:
+ if (brace_level == 0 && bracket_level == 0) {
+ inja_throw("parser_error", "unexpected token '" + m_tok.describe() + "'");
+ }
+ break;
+ case Token::Kind::LeftBracket:
+ if (brace_level == 0 && bracket_level == 0) {
+ json_first = m_tok.text;
+ }
+ bracket_level += 1;
+ break;
+ case Token::Kind::LeftBrace:
+ if (brace_level == 0 && bracket_level == 0) {
+ json_first = m_tok.text;
+ }
+ brace_level += 1;
+ break;
+ case Token::Kind::RightBracket:
+ if (bracket_level == 0) {
+ inja_throw("parser_error", "unexpected ']'");
+ }
+ --bracket_level;
+ if (brace_level == 0 && bracket_level == 0) goto returnJson;
+ break;
+ case Token::Kind::RightBrace:
+ if (brace_level == 0) {
+ inja_throw("parser_error", "unexpected '}'");
+ }
+ --brace_level;
+ if (brace_level == 0 && bracket_level == 0) goto returnJson;
+ break;
+ default:
+ if (brace_level != 0) {
+ inja_throw("parser_error", "unmatched '{'");
+ }
+ if (bracket_level != 0) {
+ inja_throw("parser_error", "unmatched '['");
+ }
+ return false;
+ }
+
+ get_next_token();
+ }
+
+ returnJson:
+ // bridge across all intermediate tokens
+ nonstd::string_view json_text(json_first.data(), m_tok.text.data() - json_first.data() + m_tok.text.size());
+ tmpl.bytecodes.emplace_back(Bytecode::Op::Push, json::parse(json_text), Bytecode::Flag::ValueImmediate);
+ get_next_token();
+ return true;
+ }
+
+ bool parse_statement(Template& tmpl, nonstd::string_view path) {
+ if (m_tok.kind != Token::Kind::Id) return false;
+
+ if (m_tok.text == static_cast<decltype(m_tok.text)>("if")) {
+ get_next_token();
+
+ // evaluate expression
+ if (!parse_expression(tmpl)) return false;
+
+ // start a new if block on if stack
+ m_if_stack.emplace_back(tmpl.bytecodes.size());
+
+ // conditional jump; destination will be filled in by else or endif
+ tmpl.bytecodes.emplace_back(Bytecode::Op::ConditionalJump);
+ } else if (m_tok.text == static_cast<decltype(m_tok.text)>("endif")) {
+ if (m_if_stack.empty()) {
+ inja_throw("parser_error", "endif without matching if");
+ }
+ auto& if_data = m_if_stack.back();
+ get_next_token();
+
+ // previous conditional jump jumps here
+ if (if_data.prev_cond_jump != std::numeric_limits<unsigned int>::max()) {
+ tmpl.bytecodes[if_data.prev_cond_jump].args = tmpl.bytecodes.size();
+ }
+
+ // update all previous unconditional jumps to here
+ for (unsigned int i: if_data.uncond_jumps) {
+ tmpl.bytecodes[i].args = tmpl.bytecodes.size();
+ }
+
+ // pop if stack
+ m_if_stack.pop_back();
+ } else if (m_tok.text == static_cast<decltype(m_tok.text)>("else")) {
+ if (m_if_stack.empty())
+ inja_throw("parser_error", "else without matching if");
+ auto& if_data = m_if_stack.back();
+ get_next_token();
+
+ // end previous block with unconditional jump to endif; destination will be
+ // filled in by endif
+ if_data.uncond_jumps.push_back(tmpl.bytecodes.size());
+ tmpl.bytecodes.emplace_back(Bytecode::Op::Jump);
+
+ // previous conditional jump jumps here
+ tmpl.bytecodes[if_data.prev_cond_jump].args = tmpl.bytecodes.size();
+ if_data.prev_cond_jump = std::numeric_limits<unsigned int>::max();
+
+ // chained else if
+ if (m_tok.kind == Token::Kind::Id && m_tok.text == static_cast<decltype(m_tok.text)>("if")) {
+ get_next_token();
+
+ // evaluate expression
+ if (!parse_expression(tmpl)) return false;
+
+ // update "previous jump"
+ if_data.prev_cond_jump = tmpl.bytecodes.size();
+
+ // conditional jump; destination will be filled in by else or endif
+ tmpl.bytecodes.emplace_back(Bytecode::Op::ConditionalJump);
+ }
+ } else if (m_tok.text == static_cast<decltype(m_tok.text)>("for")) {
+ get_next_token();
+
+ // options: for a in arr; for a, b in obj
+ if (m_tok.kind != Token::Kind::Id)
+ inja_throw("parser_error", "expected id, got '" + m_tok.describe() + "'");
+ Token value_token = m_tok;
+ get_next_token();
+
+ Token key_token;
+ if (m_tok.kind == Token::Kind::Comma) {
+ get_next_token();
+ if (m_tok.kind != Token::Kind::Id)
+ inja_throw("parser_error", "expected id, got '" + m_tok.describe() + "'");
+ key_token = std::move(value_token);
+ value_token = m_tok;
+ get_next_token();
+ }
+
+ if (m_tok.kind != Token::Kind::Id || m_tok.text != static_cast<decltype(m_tok.text)>("in"))
+ inja_throw("parser_error",
+ "expected 'in', got '" + m_tok.describe() + "'");
+ get_next_token();
+
+ if (!parse_expression(tmpl)) return false;
+
+ m_loop_stack.push_back(tmpl.bytecodes.size());
+
+ tmpl.bytecodes.emplace_back(Bytecode::Op::StartLoop);
+ if (!key_token.text.empty()) {
+ tmpl.bytecodes.back().value = key_token.text;
+ }
+ tmpl.bytecodes.back().str = static_cast<std::string>(value_token.text);
+ } else if (m_tok.text == static_cast<decltype(m_tok.text)>("endfor")) {
+ get_next_token();
+ if (m_loop_stack.empty()) {
+ inja_throw("parser_error", "endfor without matching for");
+ }
+
+ // update loop with EndLoop index (for empty case)
+ tmpl.bytecodes[m_loop_stack.back()].args = tmpl.bytecodes.size();
+
+ tmpl.bytecodes.emplace_back(Bytecode::Op::EndLoop);
+ tmpl.bytecodes.back().args = m_loop_stack.back() + 1; // loop body
+ m_loop_stack.pop_back();
+ } else if (m_tok.text == static_cast<decltype(m_tok.text)>("include")) {
+ get_next_token();
+
+ if (m_tok.kind != Token::Kind::String) {
+ inja_throw("parser_error", "expected string, got '" + m_tok.describe() + "'");
+ }
+
+ // build the relative path
+ json json_name = json::parse(m_tok.text);
+ std::string pathname = static_cast<std::string>(path);
+ pathname += json_name.get_ref<const std::string&>();
+ if (pathname.compare(0, 2, "./") == 0) {
+ pathname.erase(0, 2);
+ }
+ // sys::path::remove_dots(pathname, true, sys::path::Style::posix);
+
+ if (m_included_templates.find(pathname) == m_included_templates.end()) {
+ Template include_template = parse_template(pathname);
+ m_included_templates.emplace(pathname, include_template);
+ }
+
+ // generate a reference bytecode
+ tmpl.bytecodes.emplace_back(Bytecode::Op::Include, json(pathname), Bytecode::Flag::ValueImmediate);
+
+ get_next_token();
+ } else {
+ return false;
+ }
+ return true;
+ }
+
+ void append_function(Template& tmpl, Bytecode::Op op, unsigned int num_args) {
+ // we can merge with back-to-back push
+ if (!tmpl.bytecodes.empty()) {
+ Bytecode& last = tmpl.bytecodes.back();
+ if (last.op == Bytecode::Op::Push) {
+ last.op = op;
+ last.args = num_args;
+ return;
+ }
+ }
+
+ // otherwise just add it to the end
+ tmpl.bytecodes.emplace_back(op, num_args);
+ }
+
+ void append_callback(Template& tmpl, nonstd::string_view name, unsigned int num_args) {
+ // we can merge with back-to-back push value (not lookup)
+ if (!tmpl.bytecodes.empty()) {
+ Bytecode& last = tmpl.bytecodes.back();
+ if (last.op == Bytecode::Op::Push &&
+ (last.flags & Bytecode::Flag::ValueMask) == Bytecode::Flag::ValueImmediate) {
+ last.op = Bytecode::Op::Callback;
+ last.args = num_args;
+ last.str = static_cast<std::string>(name);
+ return;
+ }
+ }
+
+ // otherwise just add it to the end
+ tmpl.bytecodes.emplace_back(Bytecode::Op::Callback, num_args);
+ tmpl.bytecodes.back().str = static_cast<std::string>(name);
+ }
+
+ void parse_into(Template& tmpl, nonstd::string_view path) {
+ m_lexer.start(tmpl.content);
+
+ for (;;) {
+ get_next_token();
+ switch (m_tok.kind) {
+ case Token::Kind::Eof:
+ if (!m_if_stack.empty()) inja_throw("parser_error", "unmatched if");
+ if (!m_loop_stack.empty()) inja_throw("parser_error", "unmatched for");
+ return;
+ case Token::Kind::Text:
+ tmpl.bytecodes.emplace_back(Bytecode::Op::PrintText, m_tok.text, 0u);
+ break;
+ case Token::Kind::StatementOpen:
+ get_next_token();
+ if (!parse_statement(tmpl, path)) {
+ inja_throw("parser_error", "expected statement, got '" + m_tok.describe() + "'");
+ }
+ if (m_tok.kind != Token::Kind::StatementClose) {
+ inja_throw("parser_error", "expected statement close, got '" + m_tok.describe() + "'");
+ }
+ break;
+ case Token::Kind::LineStatementOpen:
+ get_next_token();
+ parse_statement(tmpl, path);
+ if (m_tok.kind != Token::Kind::LineStatementClose &&
+ m_tok.kind != Token::Kind::Eof) {
+ inja_throw("parser_error", "expected line statement close, got '" + m_tok.describe() + "'");
+ }
+ break;
+ case Token::Kind::ExpressionOpen:
+ get_next_token();
+ if (!parse_expression(tmpl)) {
+ inja_throw("parser_error", "expected expression, got '" + m_tok.describe() + "'");
+ }
+ append_function(tmpl, Bytecode::Op::PrintValue, 1);
+ if (m_tok.kind != Token::Kind::ExpressionClose) {
+ inja_throw("parser_error", "expected expression close, got '" + m_tok.describe() + "'");
+ }
+ break;
+ case Token::Kind::CommentOpen:
+ get_next_token();
+ if (m_tok.kind != Token::Kind::CommentClose) {
+ inja_throw("parser_error", "expected comment close, got '" + m_tok.describe() + "'");
+ }
+ break;
+ default:
+ inja_throw("parser_error", "unexpected token '" + m_tok.describe() + "'");
+ break;
+ }
+ }
+ }
+
+ Template parse(nonstd::string_view input, nonstd::string_view path) {
+ Template result;
+ result.content = static_cast<std::string>(input);
+ parse_into(result, path);
+ return result;
+ }
+
+ Template parse(nonstd::string_view input) {
+ return parse(input, "./");
+ }
+
+ Template parse_template(nonstd::string_view filename) {
+ Template result;
+ result.content = load_file(filename);
+
+ nonstd::string_view path = filename.substr(0, filename.find_last_of("/\\") + 1);
+ // StringRef path = sys::path::parent_path(filename);
+ Parser(m_config, m_lexer.get_config(), m_included_templates).parse_into(result, path);
+ return result;
+ }
+
+ std::string load_file(nonstd::string_view filename) {
+ std::ifstream file = open_file_or_throw(static_cast<std::string>(filename));
+ std::string text((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
+ return text;
+ }
+
+ private:
+ const ParserConfig& m_config;
+ Lexer m_lexer;
+ Token m_tok;
+ Token m_peek_tok;
+ bool m_have_peek_tok {false};
+ TemplateStorage& m_included_templates;
+ const ParserStatic& m_static;
+
+ struct IfData {
+ unsigned int prev_cond_jump;
+ std::vector<unsigned int> uncond_jumps;
+
+ explicit IfData(unsigned int condJump): prev_cond_jump(condJump) {}
+ };
+
+ std::vector<IfData> m_if_stack;
+ std::vector<unsigned int> m_loop_stack;
+
+ void get_next_token() {
+ if (m_have_peek_tok) {
+ m_tok = m_peek_tok;
+ m_have_peek_tok = false;
+ } else {
+ m_tok = m_lexer.scan();
+ }
+ }
+
+ void get_peek_token() {
+ if (!m_have_peek_tok) {
+ m_peek_tok = m_lexer.scan();
+ m_have_peek_tok = true;
+ }
+ }
+};
+
+} // namespace inja
+
+#endif // PANTOR_INJA_PARSER_HPP
+
+// #include "polyfill.hpp"
+#ifndef PANTOR_INJA_POLYFILL_HPP
+#define PANTOR_INJA_POLYFILL_HPP
+
+
+#if __cplusplus < 201402L
+
+#include <cstddef>
+#include <memory>
+#include <type_traits>
+#include <utility>
+
+
+namespace stdinja {
+ template<class T> struct _Unique_if {
+ typedef std::unique_ptr<T> _Single_object;
+ };
+
+ template<class T> struct _Unique_if<T[]> {
+ typedef std::unique_ptr<T[]> _Unknown_bound;
+ };
+
+ template<class T, size_t N> struct _Unique_if<T[N]> {
+ typedef void _Known_bound;
+ };
+
+ template<class T, class... Args>
+ typename _Unique_if<T>::_Single_object
+ make_unique(Args&&... args) {
+ return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
+ }
+
+ template<class T>
+ typename _Unique_if<T>::_Unknown_bound
+ make_unique(size_t n) {
+ typedef typename std::remove_extent<T>::type U;
+ return std::unique_ptr<T>(new U[n]());
+ }
+
+ template<class T, class... Args>
+ typename _Unique_if<T>::_Known_bound
+ make_unique(Args&&...) = delete;
+}
+
+#else
+
+namespace stdinja = std;
+
+#endif // memory */
+
+
+#endif // PANTOR_INJA_POLYFILL_HPP
+
+// #include "renderer.hpp"
+#ifndef PANTOR_INJA_RENDERER_HPP
+#define PANTOR_INJA_RENDERER_HPP
+
+#include <algorithm>
+#include <numeric>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include <nlohmann/json.hpp>
+
+// #include "bytecode.hpp"
+
+// #include "template.hpp"
+
+// #include "utils.hpp"
+
+
+
+namespace inja {
+
+inline nonstd::string_view convert_dot_to_json_pointer(nonstd::string_view dot, std::string& out) {
+ out.clear();
+ do {
+ nonstd::string_view part;
+ std::tie(part, dot) = string_view::split(dot, '.');
+ out.push_back('/');
+ out.append(part.begin(), part.end());
+ } while (!dot.empty());
+ return nonstd::string_view(out.data(), out.size());
+}
+
+/*!
+ * \brief Class for rendering a Template with data.
+ */
+class Renderer {
+ std::vector<const json*>& get_args(const Bytecode& bc) {
+ m_tmp_args.clear();
+
+ bool has_imm = ((bc.flags & Bytecode::Flag::ValueMask) != Bytecode::Flag::ValuePop);
+
+ // get args from stack
+ unsigned int pop_args = bc.args;
+ if (has_imm) {
+ pop_args -= 1;
+ }
+
+ for (auto i = std::prev(m_stack.end(), pop_args); i != m_stack.end(); i++) {
+ m_tmp_args.push_back(&(*i));
+ }
+
+ // get immediate arg
+ if (has_imm) {
+ m_tmp_args.push_back(get_imm(bc));
+ }
+
+ return m_tmp_args;
+ }
+
+ void pop_args(const Bytecode& bc) {
+ unsigned int popArgs = bc.args;
+ if ((bc.flags & Bytecode::Flag::ValueMask) != Bytecode::Flag::ValuePop) {
+ popArgs -= 1;
+ }
+ for (unsigned int i = 0; i < popArgs; ++i) {
+ m_stack.pop_back();
+ }
+ }
+
+ const json* get_imm(const Bytecode& bc) {
+ std::string ptr_buffer;
+ nonstd::string_view ptr;
+ switch (bc.flags & Bytecode::Flag::ValueMask) {
+ case Bytecode::Flag::ValuePop:
+ return nullptr;
+ case Bytecode::Flag::ValueImmediate:
+ return &bc.value;
+ case Bytecode::Flag::ValueLookupDot:
+ ptr = convert_dot_to_json_pointer(bc.str, ptr_buffer);
+ break;
+ case Bytecode::Flag::ValueLookupPointer:
+ ptr_buffer += '/';
+ ptr_buffer += bc.str;
+ ptr = ptr_buffer;
+ break;
+ }
+ try {
+ return &m_data->at(json::json_pointer(ptr.data()));
+ } catch (std::exception&) {
+ // try to evaluate as a no-argument callback
+ if (auto callback = m_callbacks.find_callback(bc.str, 0)) {
+ std::vector<const json*> arguments {};
+ m_tmp_val = callback(arguments);
+ return &m_tmp_val;
+ }
+ inja_throw("render_error", "variable '" + static_cast<std::string>(bc.str) + "' not found");
+ return nullptr;
+ }
+ }
+
+ bool truthy(const json& var) const {
+ if (var.empty()) {
+ return false;
+ } else if (var.is_number()) {
+ return (var != 0);
+ } else if (var.is_string()) {
+ return !var.empty();
+ }
+
+ try {
+ return var.get<bool>();
+ } catch (json::type_error& e) {
+ inja_throw("json_error", e.what());
+ throw;
+ }
+ }
+
+ void update_loop_data() {
+ LoopLevel& level = m_loop_stack.back();
+
+ if (level.loop_type == LoopLevel::Type::Array) {
+ level.data[static_cast<std::string>(level.value_name)] = level.values.at(level.index); // *level.it;
+ auto& loopData = level.data["loop"];
+ loopData["index"] = level.index;
+ loopData["index1"] = level.index + 1;
+ loopData["is_first"] = (level.index == 0);
+ loopData["is_last"] = (level.index == level.size - 1);
+ } else {
+ level.data[static_cast<std::string>(level.key_name)] = level.map_it->first;
+ level.data[static_cast<std::string>(level.value_name)] = *level.map_it->second;
+ }
+ }
+
+ const TemplateStorage& m_included_templates;
+ const FunctionStorage& m_callbacks;
+
+ std::vector<json> m_stack;
+
+
+ struct LoopLevel {
+ enum class Type { Map, Array };
+
+ Type loop_type;
+ nonstd::string_view key_name; // variable name for keys
+ nonstd::string_view value_name; // variable name for values
+ json data; // data with loop info added
+
+ json values; // values to iterate over
+
+ // loop over list
+ size_t index; // current list index
+ size_t size; // length of list
+
+ // loop over map
+ using KeyValue = std::pair<nonstd::string_view, json*>;
+ using MapValues = std::vector<KeyValue>;
+ MapValues map_values; // values to iterate over
+ MapValues::iterator map_it; // iterator over values
+
+ };
+
+ std::vector<LoopLevel> m_loop_stack;
+ const json* m_data;
+
+ std::vector<const json*> m_tmp_args;
+ json m_tmp_val;
+
+
+ public:
+ Renderer(const TemplateStorage& included_templates, const FunctionStorage& callbacks): m_included_templates(included_templates), m_callbacks(callbacks) {
+ m_stack.reserve(16);
+ m_tmp_args.reserve(4);
+ m_loop_stack.reserve(16);
+ }
+
+ void render_to(std::ostream& os, const Template& tmpl, const json& data) {
+ m_data = &data;
+
+ for (size_t i = 0; i < tmpl.bytecodes.size(); ++i) {
+ const auto& bc = tmpl.bytecodes[i];
+
+ switch (bc.op) {
+ case Bytecode::Op::Nop: {
+ break;
+ }
+ case Bytecode::Op::PrintText: {
+ os << bc.str;
+ break;
+ }
+ case Bytecode::Op::PrintValue: {
+ const json& val = *get_args(bc)[0];
+ if (val.is_string()) {
+ os << val.get_ref<const std::string&>();
+ } else {
+ os << val.dump();
+ }
+ pop_args(bc);
+ break;
+ }
+ case Bytecode::Op::Push: {
+ m_stack.emplace_back(*get_imm(bc));
+ break;
+ }
+ case Bytecode::Op::Upper: {
+ auto result = get_args(bc)[0]->get<std::string>();
+ std::transform(result.begin(), result.end(), result.begin(), ::toupper);
+ pop_args(bc);
+ m_stack.emplace_back(std::move(result));
+ break;
+ }
+ case Bytecode::Op::Lower: {
+ auto result = get_args(bc)[0]->get<std::string>();
+ std::transform(result.begin(), result.end(), result.begin(), ::tolower);
+ pop_args(bc);
+ m_stack.emplace_back(std::move(result));
+ break;
+ }
+ case Bytecode::Op::Range: {
+ int number = get_args(bc)[0]->get<int>();
+ std::vector<int> result(number);
+ std::iota(std::begin(result), std::end(result), 0);
+ pop_args(bc);
+ m_stack.emplace_back(std::move(result));
+ break;
+ }
+ case Bytecode::Op::Length: {
+ const json& val = *get_args(bc)[0];
+
+ int result;
+ if (val.is_string()) {
+ result = val.get_ref<const std::string&>().length();
+ } else {
+ result = val.size();
+ }
+
+ pop_args(bc);
+ m_stack.emplace_back(result);
+ break;
+ }
+ case Bytecode::Op::Sort: {
+ auto result = get_args(bc)[0]->get<std::vector<json>>();
+ std::sort(result.begin(), result.end());
+ pop_args(bc);
+ m_stack.emplace_back(std::move(result));
+ break;
+ }
+ case Bytecode::Op::At: {
+ auto args = get_args(bc);
+ auto result = args[0]->at(args[1]->get<int>());
+ pop_args(bc);
+ m_stack.emplace_back(result);
+ break;
+ }
+ case Bytecode::Op::First: {
+ auto result = get_args(bc)[0]->front();
+ pop_args(bc);
+ m_stack.emplace_back(result);
+ break;
+ }
+ case Bytecode::Op::Last: {
+ auto result = get_args(bc)[0]->back();
+ pop_args(bc);
+ m_stack.emplace_back(result);
+ break;
+ }
+ case Bytecode::Op::Round: {
+ auto args = get_args(bc);
+ double number = args[0]->get<double>();
+ int precision = args[1]->get<int>();
+ pop_args(bc);
+ m_stack.emplace_back(std::round(number * std::pow(10.0, precision)) / std::pow(10.0, precision));
+ break;
+ }
+ case Bytecode::Op::DivisibleBy: {
+ auto args = get_args(bc);
+ int number = args[0]->get<int>();
+ int divisor = args[1]->get<int>();
+ pop_args(bc);
+ m_stack.emplace_back((divisor != 0) && (number % divisor == 0));
+ break;
+ }
+ case Bytecode::Op::Odd: {
+ int number = get_args(bc)[0]->get<int>();
+ pop_args(bc);
+ m_stack.emplace_back(number % 2 != 0);
+ break;
+ }
+ case Bytecode::Op::Even: {
+ int number = get_args(bc)[0]->get<int>();
+ pop_args(bc);
+ m_stack.emplace_back(number % 2 == 0);
+ break;
+ }
+ case Bytecode::Op::Max: {
+ auto args = get_args(bc);
+ auto result = *std::max_element(args[0]->begin(), args[0]->end());
+ pop_args(bc);
+ m_stack.emplace_back(std::move(result));
+ break;
+ }
+ case Bytecode::Op::Min: {
+ auto args = get_args(bc);
+ auto result = *std::min_element(args[0]->begin(), args[0]->end());
+ pop_args(bc);
+ m_stack.emplace_back(std::move(result));
+ break;
+ }
+ case Bytecode::Op::Not: {
+ bool result = !truthy(*get_args(bc)[0]);
+ pop_args(bc);
+ m_stack.emplace_back(result);
+ break;
+ }
+ case Bytecode::Op::And: {
+ auto args = get_args(bc);
+ bool result = truthy(*args[0]) && truthy(*args[1]);
+ pop_args(bc);
+ m_stack.emplace_back(result);
+ break;
+ }
+ case Bytecode::Op::Or: {
+ auto args = get_args(bc);
+ bool result = truthy(*args[0]) || truthy(*args[1]);
+ pop_args(bc);
+ m_stack.emplace_back(result);
+ break;
+ }
+ case Bytecode::Op::In: {
+ auto args = get_args(bc);
+ bool result = std::find(args[1]->begin(), args[1]->end(), *args[0]) !=
+ args[1]->end();
+ pop_args(bc);
+ m_stack.emplace_back(result);
+ break;
+ }
+ case Bytecode::Op::Equal: {
+ auto args = get_args(bc);
+ bool result = (*args[0] == *args[1]);
+ pop_args(bc);
+ m_stack.emplace_back(result);
+ break;
+ }
+ case Bytecode::Op::Greater: {
+ auto args = get_args(bc);
+ bool result = (*args[0] > *args[1]);
+ pop_args(bc);
+ m_stack.emplace_back(result);
+ break;
+ }
+ case Bytecode::Op::Less: {
+ auto args = get_args(bc);
+ bool result = (*args[0] < *args[1]);
+ pop_args(bc);
+ m_stack.emplace_back(result);
+ break;
+ }
+ case Bytecode::Op::GreaterEqual: {
+ auto args = get_args(bc);
+ bool result = (*args[0] >= *args[1]);
+ pop_args(bc);
+ m_stack.emplace_back(result);
+ break;
+ }
+ case Bytecode::Op::LessEqual: {
+ auto args = get_args(bc);
+ bool result = (*args[0] <= *args[1]);
+ pop_args(bc);
+ m_stack.emplace_back(result);
+ break;
+ }
+ case Bytecode::Op::Different: {
+ auto args = get_args(bc);
+ bool result = (*args[0] != *args[1]);
+ pop_args(bc);
+ m_stack.emplace_back(result);
+ break;
+ }
+ case Bytecode::Op::Float: {
+ double result =
+ std::stod(get_args(bc)[0]->get_ref<const std::string&>());
+ pop_args(bc);
+ m_stack.emplace_back(result);
+ break;
+ }
+ case Bytecode::Op::Int: {
+ int result = std::stoi(get_args(bc)[0]->get_ref<const std::string&>());
+ pop_args(bc);
+ m_stack.emplace_back(result);
+ break;
+ }
+ case Bytecode::Op::Exists: {
+ auto&& name = get_args(bc)[0]->get_ref<const std::string&>();
+ bool result = (data.find(name) != data.end());
+ pop_args(bc);
+ m_stack.emplace_back(result);
+ break;
+ }
+ case Bytecode::Op::ExistsInObject: {
+ auto args = get_args(bc);
+ auto&& name = args[1]->get_ref<const std::string&>();
+ bool result = (args[0]->find(name) != args[0]->end());
+ pop_args(bc);
+ m_stack.emplace_back(result);
+ break;
+ }
+ case Bytecode::Op::IsBoolean: {
+ bool result = get_args(bc)[0]->is_boolean();
+ pop_args(bc);
+ m_stack.emplace_back(result);
+ break;
+ }
+ case Bytecode::Op::IsNumber: {
+ bool result = get_args(bc)[0]->is_number();
+ pop_args(bc);
+ m_stack.emplace_back(result);
+ break;
+ }
+ case Bytecode::Op::IsInteger: {
+ bool result = get_args(bc)[0]->is_number_integer();
+ pop_args(bc);
+ m_stack.emplace_back(result);
+ break;
+ }
+ case Bytecode::Op::IsFloat: {
+ bool result = get_args(bc)[0]->is_number_float();
+ pop_args(bc);
+ m_stack.emplace_back(result);
+ break;
+ }
+ case Bytecode::Op::IsObject: {
+ bool result = get_args(bc)[0]->is_object();
+ pop_args(bc);
+ m_stack.emplace_back(result);
+ break;
+ }
+ case Bytecode::Op::IsArray: {
+ bool result = get_args(bc)[0]->is_array();
+ pop_args(bc);
+ m_stack.emplace_back(result);
+ break;
+ }
+ case Bytecode::Op::IsString: {
+ bool result = get_args(bc)[0]->is_string();
+ pop_args(bc);
+ m_stack.emplace_back(result);
+ break;
+ }
+ case Bytecode::Op::Default: {
+ // default needs to be a bit "magic"; we can't evaluate the first
+ // argument during the push operation, so we swap the arguments during
+ // the parse phase so the second argument is pushed on the stack and
+ // the first argument is in the immediate
+ try {
+ const json* imm = get_imm(bc);
+ // if no exception was raised, replace the stack value with it
+ m_stack.back() = *imm;
+ } catch (std::exception&) {
+ // couldn't read immediate, just leave the stack as is
+ }
+ break;
+ }
+ case Bytecode::Op::Include:
+ Renderer(m_included_templates, m_callbacks).render_to(os, m_included_templates.find(get_imm(bc)->get_ref<const std::string&>())->second, *m_data);
+ break;
+ case Bytecode::Op::Callback: {
+ auto callback = m_callbacks.find_callback(bc.str, bc.args);
+ if (!callback) {
+ inja_throw("render_error", "function '" + static_cast<std::string>(bc.str) + "' (" + std::to_string(static_cast<unsigned int>(bc.args)) + ") not found");
+ }
+ json result = callback(get_args(bc));
+ pop_args(bc);
+ m_stack.emplace_back(std::move(result));
+ break;
+ }
+ case Bytecode::Op::Jump: {
+ i = bc.args - 1; // -1 due to ++i in loop
+ break;
+ }
+ case Bytecode::Op::ConditionalJump: {
+ if (!truthy(m_stack.back())) {
+ i = bc.args - 1; // -1 due to ++i in loop
+ }
+ m_stack.pop_back();
+ break;
+ }
+ case Bytecode::Op::StartLoop: {
+ // jump past loop body if empty
+ if (m_stack.back().empty()) {
+ m_stack.pop_back();
+ i = bc.args; // ++i in loop will take it past EndLoop
+ break;
+ }
+
+ m_loop_stack.emplace_back();
+ LoopLevel& level = m_loop_stack.back();
+ level.value_name = bc.str;
+ level.values = std::move(m_stack.back());
+ level.data = (*m_data);
+ m_stack.pop_back();
+
+ if (bc.value.is_string()) {
+ // map iterator
+ if (!level.values.is_object()) {
+ m_loop_stack.pop_back();
+ inja_throw("render_error", "for key, value requires object");
+ }
+ level.loop_type = LoopLevel::Type::Map;
+ level.key_name = bc.value.get_ref<const std::string&>();
+
+ // sort by key
+ for (auto it = level.values.begin(), end = level.values.end(); it != end; ++it) {
+ level.map_values.emplace_back(it.key(), &it.value());
+ }
+ std::sort(level.map_values.begin(), level.map_values.end(), [](const LoopLevel::KeyValue& a, const LoopLevel::KeyValue& b) { return a.first < b.first; });
+ level.map_it = level.map_values.begin();
+ } else {
+ if (!level.values.is_array()) {
+ m_loop_stack.pop_back();
+ inja_throw("render_error", "type must be array");
+ }
+
+ // list iterator
+ level.loop_type = LoopLevel::Type::Array;
+ level.index = 0;
+ level.size = level.values.size();
+ }
+
+ // provide parent access in nested loop
+ auto parent_loop_it = level.data.find("loop");
+ if (parent_loop_it != level.data.end()) {
+ json loop_copy = *parent_loop_it;
+ (*parent_loop_it)["parent"] = std::move(loop_copy);
+ }
+
+ // set "current" data to loop data
+ m_data = &level.data;
+ update_loop_data();
+ break;
+ }
+ case Bytecode::Op::EndLoop: {
+ if (m_loop_stack.empty()) {
+ inja_throw("render_error", "unexpected state in renderer");
+ }
+ LoopLevel& level = m_loop_stack.back();
+
+ bool done;
+ if (level.loop_type == LoopLevel::Type::Array) {
+ level.index += 1;
+ done = (level.index == level.values.size());
+ } else {
+ level.map_it += 1;
+ done = (level.map_it == level.map_values.end());
+ }
+
+ if (done) {
+ m_loop_stack.pop_back();
+ // set "current" data to outer loop data or main data as appropriate
+ if (!m_loop_stack.empty()) {
+ m_data = &m_loop_stack.back().data;
+ } else {
+ m_data = &data;
+ }
+ break;
+ }
+
+ update_loop_data();
+
+ // jump back to start of loop
+ i = bc.args - 1; // -1 due to ++i in loop
+ break;
+ }
+ default: {
+ inja_throw("render_error", "unknown op in renderer: " + std::to_string(static_cast<unsigned int>(bc.op)));
+ }
+ }
+ }
+ }
+};
+
+} // namespace inja
+
+#endif // PANTOR_INJA_RENDERER_HPP
+
+// #include "string_view.hpp"
+
+// #include "template.hpp"
+
+// #include "utils.hpp"
+
+
+
+namespace inja {
+
+using namespace nlohmann;
+
+/*!
+ * \brief Class for changing the configuration.
+ */
+class Environment {
+ class Impl {
+ public:
+ std::string input_path;
+ std::string output_path;
+
+ LexerConfig lexer_config;
+ ParserConfig parser_config;
+
+ FunctionStorage callbacks;
+ TemplateStorage included_templates;
+ };
+
+ std::unique_ptr<Impl> m_impl;
+
+ public:
+ Environment(): Environment("") { }
+
+ explicit Environment(const std::string& global_path): m_impl(stdinja::make_unique<Impl>()) {
+ m_impl->input_path = global_path;
+ m_impl->output_path = global_path;
+ }
+
+ explicit Environment(const std::string& input_path, const std::string& output_path): m_impl(stdinja::make_unique<Impl>()) {
+ m_impl->input_path = input_path;
+ m_impl->output_path = output_path;
+ }
+
+ /// Sets the opener and closer for template statements
+ void set_statement(const std::string& open, const std::string& close) {
+ m_impl->lexer_config.statement_open = open;
+ m_impl->lexer_config.statement_close = close;
+ m_impl->lexer_config.update_open_chars();
+ }
+
+ /// Sets the opener for template line statements
+ void set_line_statement(const std::string& open) {
+ m_impl->lexer_config.line_statement = open;
+ m_impl->lexer_config.update_open_chars();
+ }
+
+ /// Sets the opener and closer for template expressions
+ void set_expression(const std::string& open, const std::string& close) {
+ m_impl->lexer_config.expression_open = open;
+ m_impl->lexer_config.expression_close = close;
+ m_impl->lexer_config.update_open_chars();
+ }
+
+ /// Sets the opener and closer for template comments
+ void set_comment(const std::string& open, const std::string& close) {
+ m_impl->lexer_config.comment_open = open;
+ m_impl->lexer_config.comment_close = close;
+ m_impl->lexer_config.update_open_chars();
+ }
+
+ /// Sets whether to remove the first newline after a block
+ void set_trim_blocks(bool trim_blocks) {
+ m_impl->lexer_config.trim_blocks = trim_blocks;
+ }
+
+ /// Sets whether to strip the spaces and tabs from the start of a line to a block
+ void set_lstrip_blocks(bool lstrip_blocks) {
+ m_impl->lexer_config.lstrip_blocks = lstrip_blocks;
+ }
+
+ /// Sets the element notation syntax
+ void set_element_notation(ElementNotation notation) {
+ m_impl->parser_config.notation = notation;
+ }
+
+
+ Template parse(nonstd::string_view input) {
+ Parser parser(m_impl->parser_config, m_impl->lexer_config, m_impl->included_templates);
+ return parser.parse(input);
+ }
+
+ Template parse_template(const std::string& filename) {
+ Parser parser(m_impl->parser_config, m_impl->lexer_config, m_impl->included_templates);
+ return parser.parse_template(m_impl->input_path + static_cast<std::string>(filename));
+ }
+
+ std::string render(nonstd::string_view input, const json& data) {
+ return render(parse(input), data);
+ }
+
+ std::string render(const Template& tmpl, const json& data) {
+ std::stringstream os;
+ render_to(os, tmpl, data);
+ return os.str();
+ }
+
+ std::string render_file(const std::string& filename, const json& data) {
+ return render(parse_template(filename), data);
+ }
+
+ std::string render_file_with_json_file(const std::string& filename, const std::string& filename_data) {
+ const json data = load_json(filename_data);
+ return render_file(filename, data);
+ }
+
+ void write(const std::string& filename, const json& data, const std::string& filename_out) {
+ std::ofstream file(m_impl->output_path + filename_out);
+ file << render_file(filename, data);
+ file.close();
+ }
+
+ void write(const Template& temp, const json& data, const std::string& filename_out) {
+ std::ofstream file(m_impl->output_path + filename_out);
+ file << render(temp, data);
+ file.close();
+ }
+
+ void write_with_json_file(const std::string& filename, const std::string& filename_data, const std::string& filename_out) {
+ const json data = load_json(filename_data);
+ write(filename, data, filename_out);
+ }
+
+ void write_with_json_file(const Template& temp, const std::string& filename_data, const std::string& filename_out) {
+ const json data = load_json(filename_data);
+ write(temp, data, filename_out);
+ }
+
+ std::ostream& render_to(std::ostream& os, const Template& tmpl, const json& data) {
+ Renderer(m_impl->included_templates, m_impl->callbacks).render_to(os, tmpl, data);
+ return os;
+ }
+
+ std::string load_file(const std::string& filename) {
+ Parser parser(m_impl->parser_config, m_impl->lexer_config, m_impl->included_templates);
+ return parser.load_file(m_impl->input_path + filename);
+ }
+
+ json load_json(const std::string& filename) {
+ std::ifstream file = open_file_or_throw(m_impl->input_path + filename);
+ json j;
+ file >> j;
+ return j;
+ }
+
+ void add_callback(const std::string& name, unsigned int numArgs, const CallbackFunction& callback) {
+ m_impl->callbacks.add_callback(name, numArgs, callback);
+ }
+
+ /** Includes a template with a given name into the environment.
+ * Then, a template can be rendered in another template using the
+ * include "<name>" syntax.
+ */
+ void include_template(const std::string& name, const Template& tmpl) {
+ m_impl->included_templates[name] = tmpl;
+ }
+};
+
+/*!
+@brief render with default settings to a string
+*/
+inline std::string render(nonstd::string_view input, const json& data) {
+ return Environment().render(input, data);
+}
+
+/*!
+@brief render with default settings to the given output stream
+*/
+inline void render_to(std::ostream& os, nonstd::string_view input, const json& data) {
+ Environment env;
+ env.render_to(os, env.parse(input), data);
+}
+
+}
+
+#endif // PANTOR_INJA_ENVIRONMENT_HPP
+
+// #include "string_view.hpp"
+
+// #include "template.hpp"
+
+// #include "parser.hpp"
+
+// #include "renderer.hpp"
+
+
+
+#endif // PANTOR_INJA_HPP
diff --git a/tools/jsonproc/jsonproc.cpp b/tools/jsonproc/jsonproc.cpp
index 5372194..2ba5fd0 100644
--- a/tools/jsonproc/jsonproc.cpp
+++ b/tools/jsonproc/jsonproc.cpp
@@ -1,109 +1,109 @@
-// jsonproc.cpp
-
-#include "jsonproc.h"
-
-#include <map>
-
-#include <string>
-using std::string; using std::to_string;
-
-#include <inja.hpp>
-using namespace inja;
-using json = nlohmann::json;
-
-std::map<string, string> customVars;
-
-void set_custom_var(string key, string value)
-{
- customVars[key] = value;
-}
-
-string get_custom_var(string key)
-{
- return customVars[key];
-}
-
-int main(int argc, char *argv[])
-{
- if (argc != 4)
- FATAL_ERROR("USAGE: jsonproc <json-filepath> <template-filepath> <output-filepath>\n");
-
- string jsonfilepath = argv[1];
- string templateFilepath = argv[2];
- string outputFilepath = argv[3];
-
- Environment env;
-
- // Add custom command callbacks.
- env.add_callback("doNotModifyHeader", 0, [jsonfilepath, templateFilepath](Arguments& args) {
- return "//\n// DO NOT MODIFY THIS FILE! It is auto-generated from " + jsonfilepath +" and Inja template " + templateFilepath + "\n//\n";
- });
-
- env.add_callback("subtract", 2, [](Arguments& args) {
- int minuend = args.at(0)->get<int>();
- int subtrahend = args.at(1)->get<int>();
-
- return minuend - subtrahend;
- });
-
- env.add_callback("setVar", 2, [=](Arguments& args) {
- string key = args.at(0)->get<string>();
- string value = args.at(1)->get<string>();
- set_custom_var(key, value);
- return "";
- });
-
- env.add_callback("setVarInt", 2, [=](Arguments& args) {
- string key = args.at(0)->get<string>();
- string value = to_string(args.at(1)->get<int>());
- set_custom_var(key, value);
- return "";
- });
-
- env.add_callback("getVar", 1, [=](Arguments& args) {
- string key = args.at(0)->get<string>();
- return get_custom_var(key);
- });
-
- env.add_callback("concat", 2, [](Arguments& args) {
- string first = args.at(0)->get<string>();
- string second = args.at(1)->get<string>();
- return first + second;
- });
-
- env.add_callback("removePrefix", 2, [](Arguments& args) {
- string rawValue = args.at(0)->get<string>();
- string prefix = args.at(1)->get<string>();
- string::size_type i = rawValue.find(prefix);
- if (i != 0)
- return rawValue;
-
- return rawValue.erase(0, prefix.length());
- });
-
- env.add_callback("removeSuffix", 2, [](Arguments& args) {
- string rawValue = args.at(0)->get<string>();
- string suffix = args.at(1)->get<string>();
- string::size_type i = rawValue.rfind(suffix);
- if (i == string::npos)
- return rawValue;
-
- return rawValue.substr(0, i);
- });
-
- // single argument is a json object
- env.add_callback("isEmpty", 1, [](Arguments& args) {
- return args.at(0)->empty();
- });
-
- try
- {
- env.write_with_json_file(templateFilepath, jsonfilepath, outputFilepath);
- }
- catch (const std::exception& e)
- {
- FATAL_ERROR("JSONPROC_ERROR: %s\n", e.what());
- }
-
- return 0;
-}
+// jsonproc.cpp
+
+#include "jsonproc.h"
+
+#include <map>
+
+#include <string>
+using std::string; using std::to_string;
+
+#include <inja.hpp>
+using namespace inja;
+using json = nlohmann::json;
+
+std::map<string, string> customVars;
+
+void set_custom_var(string key, string value)
+{
+ customVars[key] = value;
+}
+
+string get_custom_var(string key)
+{
+ return customVars[key];
+}
+
+int main(int argc, char *argv[])
+{
+ if (argc != 4)
+ FATAL_ERROR("USAGE: jsonproc <json-filepath> <template-filepath> <output-filepath>\n");
+
+ string jsonfilepath = argv[1];
+ string templateFilepath = argv[2];
+ string outputFilepath = argv[3];
+
+ Environment env;
+
+ // Add custom command callbacks.
+ env.add_callback("doNotModifyHeader", 0, [jsonfilepath, templateFilepath](Arguments& args) {
+ return "//\n// DO NOT MODIFY THIS FILE! It is auto-generated from " + jsonfilepath +" and Inja template " + templateFilepath + "\n//\n";
+ });
+
+ env.add_callback("subtract", 2, [](Arguments& args) {
+ int minuend = args.at(0)->get<int>();
+ int subtrahend = args.at(1)->get<int>();
+
+ return minuend - subtrahend;
+ });
+
+ env.add_callback("setVar", 2, [=](Arguments& args) {
+ string key = args.at(0)->get<string>();
+ string value = args.at(1)->get<string>();
+ set_custom_var(key, value);
+ return "";
+ });
+
+ env.add_callback("setVarInt", 2, [=](Arguments& args) {
+ string key = args.at(0)->get<string>();
+ string value = to_string(args.at(1)->get<int>());
+ set_custom_var(key, value);
+ return "";
+ });
+
+ env.add_callback("getVar", 1, [=](Arguments& args) {
+ string key = args.at(0)->get<string>();
+ return get_custom_var(key);
+ });
+
+ env.add_callback("concat", 2, [](Arguments& args) {
+ string first = args.at(0)->get<string>();
+ string second = args.at(1)->get<string>();
+ return first + second;
+ });
+
+ env.add_callback("removePrefix", 2, [](Arguments& args) {
+ string rawValue = args.at(0)->get<string>();
+ string prefix = args.at(1)->get<string>();
+ string::size_type i = rawValue.find(prefix);
+ if (i != 0)
+ return rawValue;
+
+ return rawValue.erase(0, prefix.length());
+ });
+
+ env.add_callback("removeSuffix", 2, [](Arguments& args) {
+ string rawValue = args.at(0)->get<string>();
+ string suffix = args.at(1)->get<string>();
+ string::size_type i = rawValue.rfind(suffix);
+ if (i == string::npos)
+ return rawValue;
+
+ return rawValue.substr(0, i);
+ });
+
+ // single argument is a json object
+ env.add_callback("isEmpty", 1, [](Arguments& args) {
+ return args.at(0)->empty();
+ });
+
+ try
+ {
+ env.write_with_json_file(templateFilepath, jsonfilepath, outputFilepath);
+ }
+ catch (const std::exception& e)
+ {
+ FATAL_ERROR("JSONPROC_ERROR: %s\n", e.what());
+ }
+
+ return 0;
+}
diff --git a/tools/jsonproc/nlohmann/json.hpp b/tools/jsonproc/nlohmann/json.hpp
index b9000e7..5003a4f 100644
--- a/tools/jsonproc/nlohmann/json.hpp
+++ b/tools/jsonproc/nlohmann/json.hpp
@@ -1,20842 +1,20842 @@
-/*
- __ _____ _____ _____
- __| | __| | | | JSON for Modern C++
-| | |__ | | | | | | version 3.6.1
-|_____|_____|_____|_|___| https://github.com/nlohmann/json
-
-Licensed under the MIT License <http://opensource.org/licenses/MIT>.
-SPDX-License-Identifier: MIT
-Copyright (c) 2013-2019 Niels Lohmann <http://nlohmann.me>.
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-*/
-
-#ifndef INCLUDE_NLOHMANN_JSON_HPP_
-#define INCLUDE_NLOHMANN_JSON_HPP_
-
-#define NLOHMANN_JSON_VERSION_MAJOR 3
-#define NLOHMANN_JSON_VERSION_MINOR 6
-#define NLOHMANN_JSON_VERSION_PATCH 1
-
-#include <algorithm> // all_of, find, for_each
-#include <cassert> // assert
-#include <ciso646> // and, not, or
-#include <cstddef> // nullptr_t, ptrdiff_t, size_t
-#include <functional> // hash, less
-#include <initializer_list> // initializer_list
-#include <iosfwd> // istream, ostream
-#include <iterator> // random_access_iterator_tag
-#include <memory> // unique_ptr
-#include <numeric> // accumulate
-#include <string> // string, stoi, to_string
-#include <utility> // declval, forward, move, pair, swap
-#include <vector> // vector
-
-// #include <nlohmann/adl_serializer.hpp>
-
-
-#include <utility>
-
-// #include <nlohmann/detail/conversions/from_json.hpp>
-
-
-#include <algorithm> // transform
-#include <array> // array
-#include <ciso646> // and, not
-#include <forward_list> // forward_list
-#include <iterator> // inserter, front_inserter, end
-#include <map> // map
-#include <string> // string
-#include <tuple> // tuple, make_tuple
-#include <type_traits> // is_arithmetic, is_same, is_enum, underlying_type, is_convertible
-#include <unordered_map> // unordered_map
-#include <utility> // pair, declval
-#include <valarray> // valarray
-
-// #include <nlohmann/detail/exceptions.hpp>
-
-
-#include <exception> // exception
-#include <stdexcept> // runtime_error
-#include <string> // to_string
-
-// #include <nlohmann/detail/input/position_t.hpp>
-
-
-#include <cstddef> // size_t
-
-namespace nlohmann
-{
-namespace detail
-{
-/// struct to capture the start position of the current token
-struct position_t
-{
- /// the total number of characters read
- std::size_t chars_read_total = 0;
- /// the number of characters read in the current line
- std::size_t chars_read_current_line = 0;
- /// the number of lines read
- std::size_t lines_read = 0;
-
- /// conversion to size_t to preserve SAX interface
- constexpr operator size_t() const
- {
- return chars_read_total;
- }
-};
-
-} // namespace detail
-} // namespace nlohmann
-
-
-namespace nlohmann
-{
-namespace detail
-{
-////////////////
-// exceptions //
-////////////////
-
-/*!
-@brief general exception of the @ref basic_json class
-
-This class is an extension of `std::exception` objects with a member @a id for
-exception ids. It is used as the base class for all exceptions thrown by the
-@ref basic_json class. This class can hence be used as "wildcard" to catch
-exceptions.
-
-Subclasses:
-- @ref parse_error for exceptions indicating a parse error
-- @ref invalid_iterator for exceptions indicating errors with iterators
-- @ref type_error for exceptions indicating executing a member function with
- a wrong type
-- @ref out_of_range for exceptions indicating access out of the defined range
-- @ref other_error for exceptions indicating other library errors
-
-@internal
-@note To have nothrow-copy-constructible exceptions, we internally use
- `std::runtime_error` which can cope with arbitrary-length error messages.
- Intermediate strings are built with static functions and then passed to
- the actual constructor.
-@endinternal
-
-@liveexample{The following code shows how arbitrary library exceptions can be
-caught.,exception}
-
-@since version 3.0.0
-*/
-class exception : public std::exception
-{
- public:
- /// returns the explanatory string
- const char* what() const noexcept override
- {
- return m.what();
- }
-
- /// the id of the exception
- const int id;
-
- protected:
- exception(int id_, const char* what_arg) : id(id_), m(what_arg) {}
-
- static std::string name(const std::string& ename, int id_)
- {
- return "[json.exception." + ename + "." + std::to_string(id_) + "] ";
- }
-
- private:
- /// an exception object as storage for error messages
- std::runtime_error m;
-};
-
-/*!
-@brief exception indicating a parse error
-
-This exception is thrown by the library when a parse error occurs. Parse errors
-can occur during the deserialization of JSON text, CBOR, MessagePack, as well
-as when using JSON Patch.
-
-Member @a byte holds the byte index of the last read character in the input
-file.
-
-Exceptions have ids 1xx.
-
-name / id | example message | description
------------------------------- | --------------- | -------------------------
-json.exception.parse_error.101 | parse error at 2: unexpected end of input; expected string literal | This error indicates a syntax error while deserializing a JSON text. The error message describes that an unexpected token (character) was encountered, and the member @a byte indicates the error position.
-json.exception.parse_error.102 | parse error at 14: missing or wrong low surrogate | JSON uses the `\uxxxx` format to describe Unicode characters. Code points above above 0xFFFF are split into two `\uxxxx` entries ("surrogate pairs"). This error indicates that the surrogate pair is incomplete or contains an invalid code point.
-json.exception.parse_error.103 | parse error: code points above 0x10FFFF are invalid | Unicode supports code points up to 0x10FFFF. Code points above 0x10FFFF are invalid.
-json.exception.parse_error.104 | parse error: JSON patch must be an array of objects | [RFC 6902](https://tools.ietf.org/html/rfc6902) requires a JSON Patch document to be a JSON document that represents an array of objects.
-json.exception.parse_error.105 | parse error: operation must have string member 'op' | An operation of a JSON Patch document must contain exactly one "op" member, whose value indicates the operation to perform. Its value must be one of "add", "remove", "replace", "move", "copy", or "test"; other values are errors.
-json.exception.parse_error.106 | parse error: array index '01' must not begin with '0' | An array index in a JSON Pointer ([RFC 6901](https://tools.ietf.org/html/rfc6901)) may be `0` or any number without a leading `0`.
-json.exception.parse_error.107 | parse error: JSON pointer must be empty or begin with '/' - was: 'foo' | A JSON Pointer must be a Unicode string containing a sequence of zero or more reference tokens, each prefixed by a `/` character.
-json.exception.parse_error.108 | parse error: escape character '~' must be followed with '0' or '1' | In a JSON Pointer, only `~0` and `~1` are valid escape sequences.
-json.exception.parse_error.109 | parse error: array index 'one' is not a number | A JSON Pointer array index must be a number.
-json.exception.parse_error.110 | parse error at 1: cannot read 2 bytes from vector | When parsing CBOR or MessagePack, the byte vector ends before the complete value has been read.
-json.exception.parse_error.112 | parse error at 1: error reading CBOR; last byte: 0xF8 | Not all types of CBOR or MessagePack are supported. This exception occurs if an unsupported byte was read.
-json.exception.parse_error.113 | parse error at 2: expected a CBOR string; last byte: 0x98 | While parsing a map key, a value that is not a string has been read.
-json.exception.parse_error.114 | parse error: Unsupported BSON record type 0x0F | The parsing of the corresponding BSON record type is not implemented (yet).
-
-@note For an input with n bytes, 1 is the index of the first character and n+1
- is the index of the terminating null byte or the end of file. This also
- holds true when reading a byte vector (CBOR or MessagePack).
-
-@liveexample{The following code shows how a `parse_error` exception can be
-caught.,parse_error}
-
-@sa - @ref exception for the base class of the library exceptions
-@sa - @ref invalid_iterator for exceptions indicating errors with iterators
-@sa - @ref type_error for exceptions indicating executing a member function with
- a wrong type
-@sa - @ref out_of_range for exceptions indicating access out of the defined range
-@sa - @ref other_error for exceptions indicating other library errors
-
-@since version 3.0.0
-*/
-class parse_error : public exception
-{
- public:
- /*!
- @brief create a parse error exception
- @param[in] id_ the id of the exception
- @param[in] pos the position where the error occurred (or with
- chars_read_total=0 if the position cannot be
- determined)
- @param[in] what_arg the explanatory string
- @return parse_error object
- */
- static parse_error create(int id_, const position_t& pos, const std::string& what_arg)
- {
- std::string w = exception::name("parse_error", id_) + "parse error" +
- position_string(pos) + ": " + what_arg;
- return parse_error(id_, pos.chars_read_total, w.c_str());
- }
-
- static parse_error create(int id_, std::size_t byte_, const std::string& what_arg)
- {
- std::string w = exception::name("parse_error", id_) + "parse error" +
- (byte_ != 0 ? (" at byte " + std::to_string(byte_)) : "") +
- ": " + what_arg;
- return parse_error(id_, byte_, w.c_str());
- }
-
- /*!
- @brief byte index of the parse error
-
- The byte index of the last read character in the input file.
-
- @note For an input with n bytes, 1 is the index of the first character and
- n+1 is the index of the terminating null byte or the end of file.
- This also holds true when reading a byte vector (CBOR or MessagePack).
- */
- const std::size_t byte;
-
- private:
- parse_error(int id_, std::size_t byte_, const char* what_arg)
- : exception(id_, what_arg), byte(byte_) {}
-
- static std::string position_string(const position_t& pos)
- {
- return " at line " + std::to_string(pos.lines_read + 1) +
- ", column " + std::to_string(pos.chars_read_current_line);
- }
-};
-
-/*!
-@brief exception indicating errors with iterators
-
-This exception is thrown if iterators passed to a library function do not match
-the expected semantics.
-
-Exceptions have ids 2xx.
-
-name / id | example message | description
------------------------------------ | --------------- | -------------------------
-json.exception.invalid_iterator.201 | iterators are not compatible | The iterators passed to constructor @ref basic_json(InputIT first, InputIT last) are not compatible, meaning they do not belong to the same container. Therefore, the range (@a first, @a last) is invalid.
-json.exception.invalid_iterator.202 | iterator does not fit current value | In an erase or insert function, the passed iterator @a pos does not belong to the JSON value for which the function was called. It hence does not define a valid position for the deletion/insertion.
-json.exception.invalid_iterator.203 | iterators do not fit current value | Either iterator passed to function @ref erase(IteratorType first, IteratorType last) does not belong to the JSON value from which values shall be erased. It hence does not define a valid range to delete values from.
-json.exception.invalid_iterator.204 | iterators out of range | When an iterator range for a primitive type (number, boolean, or string) is passed to a constructor or an erase function, this range has to be exactly (@ref begin(), @ref end()), because this is the only way the single stored value is expressed. All other ranges are invalid.
-json.exception.invalid_iterator.205 | iterator out of range | When an iterator for a primitive type (number, boolean, or string) is passed to an erase function, the iterator has to be the @ref begin() iterator, because it is the only way to address the stored value. All other iterators are invalid.
-json.exception.invalid_iterator.206 | cannot construct with iterators from null | The iterators passed to constructor @ref basic_json(InputIT first, InputIT last) belong to a JSON null value and hence to not define a valid range.
-json.exception.invalid_iterator.207 | cannot use key() for non-object iterators | The key() member function can only be used on iterators belonging to a JSON object, because other types do not have a concept of a key.
-json.exception.invalid_iterator.208 | cannot use operator[] for object iterators | The operator[] to specify a concrete offset cannot be used on iterators belonging to a JSON object, because JSON objects are unordered.
-json.exception.invalid_iterator.209 | cannot use offsets with object iterators | The offset operators (+, -, +=, -=) cannot be used on iterators belonging to a JSON object, because JSON objects are unordered.
-json.exception.invalid_iterator.210 | iterators do not fit | The iterator range passed to the insert function are not compatible, meaning they do not belong to the same container. Therefore, the range (@a first, @a last) is invalid.
-json.exception.invalid_iterator.211 | passed iterators may not belong to container | The iterator range passed to the insert function must not be a subrange of the container to insert to.
-json.exception.invalid_iterator.212 | cannot compare iterators of different containers | When two iterators are compared, they must belong to the same container.
-json.exception.invalid_iterator.213 | cannot compare order of object iterators | The order of object iterators cannot be compared, because JSON objects are unordered.
-json.exception.invalid_iterator.214 | cannot get value | Cannot get value for iterator: Either the iterator belongs to a null value or it is an iterator to a primitive type (number, boolean, or string), but the iterator is different to @ref begin().
-
-@liveexample{The following code shows how an `invalid_iterator` exception can be
-caught.,invalid_iterator}
-
-@sa - @ref exception for the base class of the library exceptions
-@sa - @ref parse_error for exceptions indicating a parse error
-@sa - @ref type_error for exceptions indicating executing a member function with
- a wrong type
-@sa - @ref out_of_range for exceptions indicating access out of the defined range
-@sa - @ref other_error for exceptions indicating other library errors
-
-@since version 3.0.0
-*/
-class invalid_iterator : public exception
-{
- public:
- static invalid_iterator create(int id_, const std::string& what_arg)
- {
- std::string w = exception::name("invalid_iterator", id_) + what_arg;
- return invalid_iterator(id_, w.c_str());
- }
-
- private:
- invalid_iterator(int id_, const char* what_arg)
- : exception(id_, what_arg) {}
-};
-
-/*!
-@brief exception indicating executing a member function with a wrong type
-
-This exception is thrown in case of a type error; that is, a library function is
-executed on a JSON value whose type does not match the expected semantics.
-
-Exceptions have ids 3xx.
-
-name / id | example message | description
------------------------------ | --------------- | -------------------------
-json.exception.type_error.301 | cannot create object from initializer list | To create an object from an initializer list, the initializer list must consist only of a list of pairs whose first element is a string. When this constraint is violated, an array is created instead.
-json.exception.type_error.302 | type must be object, but is array | During implicit or explicit value conversion, the JSON type must be compatible to the target type. For instance, a JSON string can only be converted into string types, but not into numbers or boolean types.
-json.exception.type_error.303 | incompatible ReferenceType for get_ref, actual type is object | To retrieve a reference to a value stored in a @ref basic_json object with @ref get_ref, the type of the reference must match the value type. For instance, for a JSON array, the @a ReferenceType must be @ref array_t &.
-json.exception.type_error.304 | cannot use at() with string | The @ref at() member functions can only be executed for certain JSON types.
-json.exception.type_error.305 | cannot use operator[] with string | The @ref operator[] member functions can only be executed for certain JSON types.
-json.exception.type_error.306 | cannot use value() with string | The @ref value() member functions can only be executed for certain JSON types.
-json.exception.type_error.307 | cannot use erase() with string | The @ref erase() member functions can only be executed for certain JSON types.
-json.exception.type_error.308 | cannot use push_back() with string | The @ref push_back() and @ref operator+= member functions can only be executed for certain JSON types.
-json.exception.type_error.309 | cannot use insert() with | The @ref insert() member functions can only be executed for certain JSON types.
-json.exception.type_error.310 | cannot use swap() with number | The @ref swap() member functions can only be executed for certain JSON types.
-json.exception.type_error.311 | cannot use emplace_back() with string | The @ref emplace_back() member function can only be executed for certain JSON types.
-json.exception.type_error.312 | cannot use update() with string | The @ref update() member functions can only be executed for certain JSON types.
-json.exception.type_error.313 | invalid value to unflatten | The @ref unflatten function converts an object whose keys are JSON Pointers back into an arbitrary nested JSON value. The JSON Pointers must not overlap, because then the resulting value would not be well defined.
-json.exception.type_error.314 | only objects can be unflattened | The @ref unflatten function only works for an object whose keys are JSON Pointers.
-json.exception.type_error.315 | values in object must be primitive | The @ref unflatten function only works for an object whose keys are JSON Pointers and whose values are primitive.
-json.exception.type_error.316 | invalid UTF-8 byte at index 10: 0x7E | The @ref dump function only works with UTF-8 encoded strings; that is, if you assign a `std::string` to a JSON value, make sure it is UTF-8 encoded. |
-json.exception.type_error.317 | JSON value cannot be serialized to requested format | The dynamic type of the object cannot be represented in the requested serialization format (e.g. a raw `true` or `null` JSON object cannot be serialized to BSON) |
-
-@liveexample{The following code shows how a `type_error` exception can be
-caught.,type_error}
-
-@sa - @ref exception for the base class of the library exceptions
-@sa - @ref parse_error for exceptions indicating a parse error
-@sa - @ref invalid_iterator for exceptions indicating errors with iterators
-@sa - @ref out_of_range for exceptions indicating access out of the defined range
-@sa - @ref other_error for exceptions indicating other library errors
-
-@since version 3.0.0
-*/
-class type_error : public exception
-{
- public:
- static type_error create(int id_, const std::string& what_arg)
- {
- std::string w = exception::name("type_error", id_) + what_arg;
- return type_error(id_, w.c_str());
- }
-
- private:
- type_error(int id_, const char* what_arg) : exception(id_, what_arg) {}
-};
-
-/*!
-@brief exception indicating access out of the defined range
-
-This exception is thrown in case a library function is called on an input
-parameter that exceeds the expected range, for instance in case of array
-indices or nonexisting object keys.
-
-Exceptions have ids 4xx.
-
-name / id | example message | description
-------------------------------- | --------------- | -------------------------
-json.exception.out_of_range.401 | array index 3 is out of range | The provided array index @a i is larger than @a size-1.
-json.exception.out_of_range.402 | array index '-' (3) is out of range | The special array index `-` in a JSON Pointer never describes a valid element of the array, but the index past the end. That is, it can only be used to add elements at this position, but not to read it.
-json.exception.out_of_range.403 | key 'foo' not found | The provided key was not found in the JSON object.
-json.exception.out_of_range.404 | unresolved reference token 'foo' | A reference token in a JSON Pointer could not be resolved.
-json.exception.out_of_range.405 | JSON pointer has no parent | The JSON Patch operations 'remove' and 'add' can not be applied to the root element of the JSON value.
-json.exception.out_of_range.406 | number overflow parsing '10E1000' | A parsed number could not be stored as without changing it to NaN or INF.
-json.exception.out_of_range.407 | number overflow serializing '9223372036854775808' | UBJSON and BSON only support integer numbers up to 9223372036854775807. |
-json.exception.out_of_range.408 | excessive array size: 8658170730974374167 | The size (following `#`) of an UBJSON array or object exceeds the maximal capacity. |
-json.exception.out_of_range.409 | BSON key cannot contain code point U+0000 (at byte 2) | Key identifiers to be serialized to BSON cannot contain code point U+0000, since the key is stored as zero-terminated c-string |
-
-@liveexample{The following code shows how an `out_of_range` exception can be
-caught.,out_of_range}
-
-@sa - @ref exception for the base class of the library exceptions
-@sa - @ref parse_error for exceptions indicating a parse error
-@sa - @ref invalid_iterator for exceptions indicating errors with iterators
-@sa - @ref type_error for exceptions indicating executing a member function with
- a wrong type
-@sa - @ref other_error for exceptions indicating other library errors
-
-@since version 3.0.0
-*/
-class out_of_range : public exception
-{
- public:
- static out_of_range create(int id_, const std::string& what_arg)
- {
- std::string w = exception::name("out_of_range", id_) + what_arg;
- return out_of_range(id_, w.c_str());
- }
-
- private:
- out_of_range(int id_, const char* what_arg) : exception(id_, what_arg) {}
-};
-
-/*!
-@brief exception indicating other library errors
-
-This exception is thrown in case of errors that cannot be classified with the
-other exception types.
-
-Exceptions have ids 5xx.
-
-name / id | example message | description
------------------------------- | --------------- | -------------------------
-json.exception.other_error.501 | unsuccessful: {"op":"test","path":"/baz", "value":"bar"} | A JSON Patch operation 'test' failed. The unsuccessful operation is also printed.
-
-@sa - @ref exception for the base class of the library exceptions
-@sa - @ref parse_error for exceptions indicating a parse error
-@sa - @ref invalid_iterator for exceptions indicating errors with iterators
-@sa - @ref type_error for exceptions indicating executing a member function with
- a wrong type
-@sa - @ref out_of_range for exceptions indicating access out of the defined range
-
-@liveexample{The following code shows how an `other_error` exception can be
-caught.,other_error}
-
-@since version 3.0.0
-*/
-class other_error : public exception
-{
- public:
- static other_error create(int id_, const std::string& what_arg)
- {
- std::string w = exception::name("other_error", id_) + what_arg;
- return other_error(id_, w.c_str());
- }
-
- private:
- other_error(int id_, const char* what_arg) : exception(id_, what_arg) {}
-};
-} // namespace detail
-} // namespace nlohmann
-
-// #include <nlohmann/detail/macro_scope.hpp>
-
-
-#include <utility> // pair
-
-// This file contains all internal macro definitions
-// You MUST include macro_unscope.hpp at the end of json.hpp to undef all of them
-
-// exclude unsupported compilers
-#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK)
- #if defined(__clang__)
- #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400
- #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers"
- #endif
- #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER))
- #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800
- #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers"
- #endif
- #endif
-#endif
-
-// disable float-equal warnings on GCC/clang
-#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
- #pragma GCC diagnostic push
- #pragma GCC diagnostic ignored "-Wfloat-equal"
-#endif
-
-// disable documentation warnings on clang
-#if defined(__clang__)
- #pragma GCC diagnostic push
- #pragma GCC diagnostic ignored "-Wdocumentation"
-#endif
-
-// allow for portable deprecation warnings
-#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
- #define JSON_DEPRECATED __attribute__((deprecated))
-#elif defined(_MSC_VER)
- #define JSON_DEPRECATED __declspec(deprecated)
-#else
- #define JSON_DEPRECATED
-#endif
-
-// allow for portable nodiscard warnings
-#if defined(__has_cpp_attribute)
- #if __has_cpp_attribute(nodiscard)
- #define JSON_NODISCARD [[nodiscard]]
- #elif __has_cpp_attribute(gnu::warn_unused_result)
- #define JSON_NODISCARD [[gnu::warn_unused_result]]
- #else
- #define JSON_NODISCARD
- #endif
-#else
- #define JSON_NODISCARD
-#endif
-
-// allow to disable exceptions
-#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION)
- #define JSON_THROW(exception) throw exception
- #define JSON_TRY try
- #define JSON_CATCH(exception) catch(exception)
- #define JSON_INTERNAL_CATCH(exception) catch(exception)
-#else
- #include <cstdlib>
- #define JSON_THROW(exception) std::abort()
- #define JSON_TRY if(true)
- #define JSON_CATCH(exception) if(false)
- #define JSON_INTERNAL_CATCH(exception) if(false)
-#endif
-
-// override exception macros
-#if defined(JSON_THROW_USER)
- #undef JSON_THROW
- #define JSON_THROW JSON_THROW_USER
-#endif
-#if defined(JSON_TRY_USER)
- #undef JSON_TRY
- #define JSON_TRY JSON_TRY_USER
-#endif
-#if defined(JSON_CATCH_USER)
- #undef JSON_CATCH
- #define JSON_CATCH JSON_CATCH_USER
- #undef JSON_INTERNAL_CATCH
- #define JSON_INTERNAL_CATCH JSON_CATCH_USER
-#endif
-#if defined(JSON_INTERNAL_CATCH_USER)
- #undef JSON_INTERNAL_CATCH
- #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER
-#endif
-
-// manual branch prediction
-#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
- #define JSON_LIKELY(x) __builtin_expect(x, 1)
- #define JSON_UNLIKELY(x) __builtin_expect(x, 0)
-#else
- #define JSON_LIKELY(x) x
- #define JSON_UNLIKELY(x) x
-#endif
-
-// C++ language standard detection
-#if (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464
- #define JSON_HAS_CPP_17
- #define JSON_HAS_CPP_14
-#elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
- #define JSON_HAS_CPP_14
-#endif
-
-/*!
-@brief macro to briefly define a mapping between an enum and JSON
-@def NLOHMANN_JSON_SERIALIZE_ENUM
-@since version 3.4.0
-*/
-#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \
- template<typename BasicJsonType> \
- inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \
- { \
- static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
- static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
- auto it = std::find_if(std::begin(m), std::end(m), \
- [e](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
- { \
- return ej_pair.first == e; \
- }); \
- j = ((it != std::end(m)) ? it : std::begin(m))->second; \
- } \
- template<typename BasicJsonType> \
- inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \
- { \
- static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
- static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
- auto it = std::find_if(std::begin(m), std::end(m), \
- [j](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
- { \
- return ej_pair.second == j; \
- }); \
- e = ((it != std::end(m)) ? it : std::begin(m))->first; \
- }
-
-// Ugly macros to avoid uglier copy-paste when specializing basic_json. They
-// may be removed in the future once the class is split.
-
-#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \
- template<template<typename, typename, typename...> class ObjectType, \
- template<typename, typename...> class ArrayType, \
- class StringType, class BooleanType, class NumberIntegerType, \
- class NumberUnsignedType, class NumberFloatType, \
- template<typename> class AllocatorType, \
- template<typename, typename = void> class JSONSerializer>
-
-#define NLOHMANN_BASIC_JSON_TPL \
- basic_json<ObjectType, ArrayType, StringType, BooleanType, \
- NumberIntegerType, NumberUnsignedType, NumberFloatType, \
- AllocatorType, JSONSerializer>
-
-// #include <nlohmann/detail/meta/cpp_future.hpp>
-
-
-#include <ciso646> // not
-#include <cstddef> // size_t
-#include <type_traits> // conditional, enable_if, false_type, integral_constant, is_constructible, is_integral, is_same, remove_cv, remove_reference, true_type
-
-namespace nlohmann
-{
-namespace detail
-{
-// alias templates to reduce boilerplate
-template<bool B, typename T = void>
-using enable_if_t = typename std::enable_if<B, T>::type;
-
-template<typename T>
-using uncvref_t = typename std::remove_cv<typename std::remove_reference<T>::type>::type;
-
-// implementation of C++14 index_sequence and affiliates
-// source: https://stackoverflow.com/a/32223343
-template<std::size_t... Ints>
-struct index_sequence
-{
- using type = index_sequence;
- using value_type = std::size_t;
- static constexpr std::size_t size() noexcept
- {
- return sizeof...(Ints);
- }
-};
-
-template<class Sequence1, class Sequence2>
-struct merge_and_renumber;
-
-template<std::size_t... I1, std::size_t... I2>
-struct merge_and_renumber<index_sequence<I1...>, index_sequence<I2...>>
- : index_sequence < I1..., (sizeof...(I1) + I2)... > {};
-
-template<std::size_t N>
-struct make_index_sequence
- : merge_and_renumber < typename make_index_sequence < N / 2 >::type,
- typename make_index_sequence < N - N / 2 >::type > {};
-
-template<> struct make_index_sequence<0> : index_sequence<> {};
-template<> struct make_index_sequence<1> : index_sequence<0> {};
-
-template<typename... Ts>
-using index_sequence_for = make_index_sequence<sizeof...(Ts)>;
-
-// dispatch utility (taken from ranges-v3)
-template<unsigned N> struct priority_tag : priority_tag < N - 1 > {};
-template<> struct priority_tag<0> {};
-
-// taken from ranges-v3
-template<typename T>
-struct static_const
-{
- static constexpr T value{};
-};
-
-template<typename T>
-constexpr T static_const<T>::value;
-} // namespace detail
-} // namespace nlohmann
-
-// #include <nlohmann/detail/meta/type_traits.hpp>
-
-
-#include <ciso646> // not
-#include <limits> // numeric_limits
-#include <type_traits> // false_type, is_constructible, is_integral, is_same, true_type
-#include <utility> // declval
-
-// #include <nlohmann/detail/iterators/iterator_traits.hpp>
-
-
-#include <iterator> // random_access_iterator_tag
-
-// #include <nlohmann/detail/meta/void_t.hpp>
-
-
-namespace nlohmann
-{
-namespace detail
-{
-template <typename ...Ts> struct make_void
-{
- using type = void;
-};
-template <typename ...Ts> using void_t = typename make_void<Ts...>::type;
-} // namespace detail
-} // namespace nlohmann
-
-// #include <nlohmann/detail/meta/cpp_future.hpp>
-
-
-namespace nlohmann
-{
-namespace detail
-{
-template <typename It, typename = void>
-struct iterator_types {};
-
-template <typename It>
-struct iterator_types <
- It,
- void_t<typename It::difference_type, typename It::value_type, typename It::pointer,
- typename It::reference, typename It::iterator_category >>
-{
- using difference_type = typename It::difference_type;
- using value_type = typename It::value_type;
- using pointer = typename It::pointer;
- using reference = typename It::reference;
- using iterator_category = typename It::iterator_category;
-};
-
-// This is required as some compilers implement std::iterator_traits in a way that
-// doesn't work with SFINAE. See https://github.com/nlohmann/json/issues/1341.
-template <typename T, typename = void>
-struct iterator_traits
-{
-};
-
-template <typename T>
-struct iterator_traits < T, enable_if_t < !std::is_pointer<T>::value >>
- : iterator_types<T>
-{
-};
-
-template <typename T>
-struct iterator_traits<T*, enable_if_t<std::is_object<T>::value>>
-{
- using iterator_category = std::random_access_iterator_tag;
- using value_type = T;
- using difference_type = ptrdiff_t;
- using pointer = T*;
- using reference = T&;
-};
-} // namespace detail
-} // namespace nlohmann
-
-// #include <nlohmann/detail/macro_scope.hpp>
-
-// #include <nlohmann/detail/meta/cpp_future.hpp>
-
-// #include <nlohmann/detail/meta/detected.hpp>
-
-
-#include <type_traits>
-
-// #include <nlohmann/detail/meta/void_t.hpp>
-
-
-// http://en.cppreference.com/w/cpp/experimental/is_detected
-namespace nlohmann
-{
-namespace detail
-{
-struct nonesuch
-{
- nonesuch() = delete;
- ~nonesuch() = delete;
- nonesuch(nonesuch const&) = delete;
- nonesuch(nonesuch const&&) = delete;
- void operator=(nonesuch const&) = delete;
- void operator=(nonesuch&&) = delete;
-};
-
-template <class Default,
- class AlwaysVoid,
- template <class...> class Op,
- class... Args>
-struct detector
-{
- using value_t = std::false_type;
- using type = Default;
-};
-
-template <class Default, template <class...> class Op, class... Args>
-struct detector<Default, void_t<Op<Args...>>, Op, Args...>
-{
- using value_t = std::true_type;
- using type = Op<Args...>;
-};
-
-template <template <class...> class Op, class... Args>
-using is_detected = typename detector<nonesuch, void, Op, Args...>::value_t;
-
-template <template <class...> class Op, class... Args>
-using detected_t = typename detector<nonesuch, void, Op, Args...>::type;
-
-template <class Default, template <class...> class Op, class... Args>
-using detected_or = detector<Default, void, Op, Args...>;
-
-template <class Default, template <class...> class Op, class... Args>
-using detected_or_t = typename detected_or<Default, Op, Args...>::type;
-
-template <class Expected, template <class...> class Op, class... Args>
-using is_detected_exact = std::is_same<Expected, detected_t<Op, Args...>>;
-
-template <class To, template <class...> class Op, class... Args>
-using is_detected_convertible =
- std::is_convertible<detected_t<Op, Args...>, To>;
-} // namespace detail
-} // namespace nlohmann
-
-// #include <nlohmann/json_fwd.hpp>
-#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
-#define INCLUDE_NLOHMANN_JSON_FWD_HPP_
-
-#include <cstdint> // int64_t, uint64_t
-#include <map> // map
-#include <memory> // allocator
-#include <string> // string
-#include <vector> // vector
-
-/*!
-@brief namespace for Niels Lohmann
-@see https://github.com/nlohmann
-@since version 1.0.0
-*/
-namespace nlohmann
-{
-/*!
-@brief default JSONSerializer template argument
-
-This serializer ignores the template arguments and uses ADL
-([argument-dependent lookup](https://en.cppreference.com/w/cpp/language/adl))
-for serialization.
-*/
-template<typename T = void, typename SFINAE = void>
-struct adl_serializer;
-
-template<template<typename U, typename V, typename... Args> class ObjectType =
- std::map,
- template<typename U, typename... Args> class ArrayType = std::vector,
- class StringType = std::string, class BooleanType = bool,
- class NumberIntegerType = std::int64_t,
- class NumberUnsignedType = std::uint64_t,
- class NumberFloatType = double,
- template<typename U> class AllocatorType = std::allocator,
- template<typename T, typename SFINAE = void> class JSONSerializer =
- adl_serializer>
-class basic_json;
-
-/*!
-@brief JSON Pointer
-
-A JSON pointer defines a string syntax for identifying a specific value
-within a JSON document. It can be used with functions `at` and
-`operator[]`. Furthermore, JSON pointers are the base for JSON patches.
-
-@sa [RFC 6901](https://tools.ietf.org/html/rfc6901)
-
-@since version 2.0.0
-*/
-template<typename BasicJsonType>
-class json_pointer;
-
-/*!
-@brief default JSON class
-
-This type is the default specialization of the @ref basic_json class which
-uses the standard template types.
-
-@since version 1.0.0
-*/
-using json = basic_json<>;
-} // namespace nlohmann
-
-#endif // INCLUDE_NLOHMANN_JSON_FWD_HPP_
-
-
-namespace nlohmann
-{
-/*!
-@brief detail namespace with internal helper functions
-
-This namespace collects functions that should not be exposed,
-implementations of some @ref basic_json methods, and meta-programming helpers.
-
-@since version 2.1.0
-*/
-namespace detail
-{
-/////////////
-// helpers //
-/////////////
-
-// Note to maintainers:
-//
-// Every trait in this file expects a non CV-qualified type.
-// The only exceptions are in the 'aliases for detected' section
-// (i.e. those of the form: decltype(T::member_function(std::declval<T>())))
-//
-// In this case, T has to be properly CV-qualified to constraint the function arguments
-// (e.g. to_json(BasicJsonType&, const T&))
-
-template<typename> struct is_basic_json : std::false_type {};
-
-NLOHMANN_BASIC_JSON_TPL_DECLARATION
-struct is_basic_json<NLOHMANN_BASIC_JSON_TPL> : std::true_type {};
-
-//////////////////////////
-// aliases for detected //
-//////////////////////////
-
-template <typename T>
-using mapped_type_t = typename T::mapped_type;
-
-template <typename T>
-using key_type_t = typename T::key_type;
-
-template <typename T>
-using value_type_t = typename T::value_type;
-
-template <typename T>
-using difference_type_t = typename T::difference_type;
-
-template <typename T>
-using pointer_t = typename T::pointer;
-
-template <typename T>
-using reference_t = typename T::reference;
-
-template <typename T>
-using iterator_category_t = typename T::iterator_category;
-
-template <typename T>
-using iterator_t = typename T::iterator;
-
-template <typename T, typename... Args>
-using to_json_function = decltype(T::to_json(std::declval<Args>()...));
-
-template <typename T, typename... Args>
-using from_json_function = decltype(T::from_json(std::declval<Args>()...));
-
-template <typename T, typename U>
-using get_template_function = decltype(std::declval<T>().template get<U>());
-
-// trait checking if JSONSerializer<T>::from_json(json const&, udt&) exists
-template <typename BasicJsonType, typename T, typename = void>
-struct has_from_json : std::false_type {};
-
-template <typename BasicJsonType, typename T>
-struct has_from_json<BasicJsonType, T,
- enable_if_t<not is_basic_json<T>::value>>
-{
- using serializer = typename BasicJsonType::template json_serializer<T, void>;
-
- static constexpr bool value =
- is_detected_exact<void, from_json_function, serializer,
- const BasicJsonType&, T&>::value;
-};
-
-// This trait checks if JSONSerializer<T>::from_json(json const&) exists
-// this overload is used for non-default-constructible user-defined-types
-template <typename BasicJsonType, typename T, typename = void>
-struct has_non_default_from_json : std::false_type {};
-
-template<typename BasicJsonType, typename T>
-struct has_non_default_from_json<BasicJsonType, T, enable_if_t<not is_basic_json<T>::value>>
-{
- using serializer = typename BasicJsonType::template json_serializer<T, void>;
-
- static constexpr bool value =
- is_detected_exact<T, from_json_function, serializer,
- const BasicJsonType&>::value;
-};
-
-// This trait checks if BasicJsonType::json_serializer<T>::to_json exists
-// Do not evaluate the trait when T is a basic_json type, to avoid template instantiation infinite recursion.
-template <typename BasicJsonType, typename T, typename = void>
-struct has_to_json : std::false_type {};
-
-template <typename BasicJsonType, typename T>
-struct has_to_json<BasicJsonType, T, enable_if_t<not is_basic_json<T>::value>>
-{
- using serializer = typename BasicJsonType::template json_serializer<T, void>;
-
- static constexpr bool value =
- is_detected_exact<void, to_json_function, serializer, BasicJsonType&,
- T>::value;
-};
-
-
-///////////////////
-// is_ functions //
-///////////////////
-
-template <typename T, typename = void>
-struct is_iterator_traits : std::false_type {};
-
-template <typename T>
-struct is_iterator_traits<iterator_traits<T>>
-{
- private:
- using traits = iterator_traits<T>;
-
- public:
- static constexpr auto value =
- is_detected<value_type_t, traits>::value &&
- is_detected<difference_type_t, traits>::value &&
- is_detected<pointer_t, traits>::value &&
- is_detected<iterator_category_t, traits>::value &&
- is_detected<reference_t, traits>::value;
-};
-
-// source: https://stackoverflow.com/a/37193089/4116453
-
-template <typename T, typename = void>
-struct is_complete_type : std::false_type {};
-
-template <typename T>
-struct is_complete_type<T, decltype(void(sizeof(T)))> : std::true_type {};
-
-template <typename BasicJsonType, typename CompatibleObjectType,
- typename = void>
-struct is_compatible_object_type_impl : std::false_type {};
-
-template <typename BasicJsonType, typename CompatibleObjectType>
-struct is_compatible_object_type_impl <
- BasicJsonType, CompatibleObjectType,
- enable_if_t<is_detected<mapped_type_t, CompatibleObjectType>::value and
- is_detected<key_type_t, CompatibleObjectType>::value >>
-{
-
- using object_t = typename BasicJsonType::object_t;
-
- // macOS's is_constructible does not play well with nonesuch...
- static constexpr bool value =
- std::is_constructible<typename object_t::key_type,
- typename CompatibleObjectType::key_type>::value and
- std::is_constructible<typename object_t::mapped_type,
- typename CompatibleObjectType::mapped_type>::value;
-};
-
-template <typename BasicJsonType, typename CompatibleObjectType>
-struct is_compatible_object_type
- : is_compatible_object_type_impl<BasicJsonType, CompatibleObjectType> {};
-
-template <typename BasicJsonType, typename ConstructibleObjectType,
- typename = void>
-struct is_constructible_object_type_impl : std::false_type {};
-
-template <typename BasicJsonType, typename ConstructibleObjectType>
-struct is_constructible_object_type_impl <
- BasicJsonType, ConstructibleObjectType,
- enable_if_t<is_detected<mapped_type_t, ConstructibleObjectType>::value and
- is_detected<key_type_t, ConstructibleObjectType>::value >>
-{
- using object_t = typename BasicJsonType::object_t;
-
- static constexpr bool value =
- (std::is_constructible<typename ConstructibleObjectType::key_type, typename object_t::key_type>::value and
- std::is_same<typename object_t::mapped_type, typename ConstructibleObjectType::mapped_type>::value) or
- (has_from_json<BasicJsonType, typename ConstructibleObjectType::mapped_type>::value or
- has_non_default_from_json<BasicJsonType, typename ConstructibleObjectType::mapped_type >::value);
-};
-
-template <typename BasicJsonType, typename ConstructibleObjectType>
-struct is_constructible_object_type
- : is_constructible_object_type_impl<BasicJsonType,
- ConstructibleObjectType> {};
-
-template <typename BasicJsonType, typename CompatibleStringType,
- typename = void>
-struct is_compatible_string_type_impl : std::false_type {};
-
-template <typename BasicJsonType, typename CompatibleStringType>
-struct is_compatible_string_type_impl <
- BasicJsonType, CompatibleStringType,
- enable_if_t<is_detected_exact<typename BasicJsonType::string_t::value_type,
- value_type_t, CompatibleStringType>::value >>
-{
- static constexpr auto value =
- std::is_constructible<typename BasicJsonType::string_t, CompatibleStringType>::value;
-};
-
-template <typename BasicJsonType, typename ConstructibleStringType>
-struct is_compatible_string_type
- : is_compatible_string_type_impl<BasicJsonType, ConstructibleStringType> {};
-
-template <typename BasicJsonType, typename ConstructibleStringType,
- typename = void>
-struct is_constructible_string_type_impl : std::false_type {};
-
-template <typename BasicJsonType, typename ConstructibleStringType>
-struct is_constructible_string_type_impl <
- BasicJsonType, ConstructibleStringType,
- enable_if_t<is_detected_exact<typename BasicJsonType::string_t::value_type,
- value_type_t, ConstructibleStringType>::value >>
-{
- static constexpr auto value =
- std::is_constructible<ConstructibleStringType,
- typename BasicJsonType::string_t>::value;
-};
-
-template <typename BasicJsonType, typename ConstructibleStringType>
-struct is_constructible_string_type
- : is_constructible_string_type_impl<BasicJsonType, ConstructibleStringType> {};
-
-template <typename BasicJsonType, typename CompatibleArrayType, typename = void>
-struct is_compatible_array_type_impl : std::false_type {};
-
-template <typename BasicJsonType, typename CompatibleArrayType>
-struct is_compatible_array_type_impl <
- BasicJsonType, CompatibleArrayType,
- enable_if_t<is_detected<value_type_t, CompatibleArrayType>::value and
- is_detected<iterator_t, CompatibleArrayType>::value and
-// This is needed because json_reverse_iterator has a ::iterator type...
-// Therefore it is detected as a CompatibleArrayType.
-// The real fix would be to have an Iterable concept.
- not is_iterator_traits<
- iterator_traits<CompatibleArrayType>>::value >>
-{
- static constexpr bool value =
- std::is_constructible<BasicJsonType,
- typename CompatibleArrayType::value_type>::value;
-};
-
-template <typename BasicJsonType, typename CompatibleArrayType>
-struct is_compatible_array_type
- : is_compatible_array_type_impl<BasicJsonType, CompatibleArrayType> {};
-
-template <typename BasicJsonType, typename ConstructibleArrayType, typename = void>
-struct is_constructible_array_type_impl : std::false_type {};
-
-template <typename BasicJsonType, typename ConstructibleArrayType>
-struct is_constructible_array_type_impl <
- BasicJsonType, ConstructibleArrayType,
- enable_if_t<std::is_same<ConstructibleArrayType,
- typename BasicJsonType::value_type>::value >>
- : std::true_type {};
-
-template <typename BasicJsonType, typename ConstructibleArrayType>
-struct is_constructible_array_type_impl <
- BasicJsonType, ConstructibleArrayType,
- enable_if_t<not std::is_same<ConstructibleArrayType,
- typename BasicJsonType::value_type>::value and
- is_detected<value_type_t, ConstructibleArrayType>::value and
- is_detected<iterator_t, ConstructibleArrayType>::value and
- is_complete_type<
- detected_t<value_type_t, ConstructibleArrayType>>::value >>
-{
- static constexpr bool value =
- // This is needed because json_reverse_iterator has a ::iterator type,
- // furthermore, std::back_insert_iterator (and other iterators) have a base class `iterator`...
- // Therefore it is detected as a ConstructibleArrayType.
- // The real fix would be to have an Iterable concept.
- not is_iterator_traits <
- iterator_traits<ConstructibleArrayType >>::value and
-
- (std::is_same<typename ConstructibleArrayType::value_type, typename BasicJsonType::array_t::value_type>::value or
- has_from_json<BasicJsonType,
- typename ConstructibleArrayType::value_type>::value or
- has_non_default_from_json <
- BasicJsonType, typename ConstructibleArrayType::value_type >::value);
-};
-
-template <typename BasicJsonType, typename ConstructibleArrayType>
-struct is_constructible_array_type
- : is_constructible_array_type_impl<BasicJsonType, ConstructibleArrayType> {};
-
-template <typename RealIntegerType, typename CompatibleNumberIntegerType,
- typename = void>
-struct is_compatible_integer_type_impl : std::false_type {};
-
-template <typename RealIntegerType, typename CompatibleNumberIntegerType>
-struct is_compatible_integer_type_impl <
- RealIntegerType, CompatibleNumberIntegerType,
- enable_if_t<std::is_integral<RealIntegerType>::value and
- std::is_integral<CompatibleNumberIntegerType>::value and
- not std::is_same<bool, CompatibleNumberIntegerType>::value >>
-{
- // is there an assert somewhere on overflows?
- using RealLimits = std::numeric_limits<RealIntegerType>;
- using CompatibleLimits = std::numeric_limits<CompatibleNumberIntegerType>;
-
- static constexpr auto value =
- std::is_constructible<RealIntegerType,
- CompatibleNumberIntegerType>::value and
- CompatibleLimits::is_integer and
- RealLimits::is_signed == CompatibleLimits::is_signed;
-};
-
-template <typename RealIntegerType, typename CompatibleNumberIntegerType>
-struct is_compatible_integer_type
- : is_compatible_integer_type_impl<RealIntegerType,
- CompatibleNumberIntegerType> {};
-
-template <typename BasicJsonType, typename CompatibleType, typename = void>
-struct is_compatible_type_impl: std::false_type {};
-
-template <typename BasicJsonType, typename CompatibleType>
-struct is_compatible_type_impl <
- BasicJsonType, CompatibleType,
- enable_if_t<is_complete_type<CompatibleType>::value >>
-{
- static constexpr bool value =
- has_to_json<BasicJsonType, CompatibleType>::value;
-};
-
-template <typename BasicJsonType, typename CompatibleType>
-struct is_compatible_type
- : is_compatible_type_impl<BasicJsonType, CompatibleType> {};
-} // namespace detail
-} // namespace nlohmann
-
-// #include <nlohmann/detail/value_t.hpp>
-
-
-#include <array> // array
-#include <ciso646> // and
-#include <cstddef> // size_t
-#include <cstdint> // uint8_t
-#include <string> // string
-
-namespace nlohmann
-{
-namespace detail
-{
-///////////////////////////
-// JSON type enumeration //
-///////////////////////////
-
-/*!
-@brief the JSON type enumeration
-
-This enumeration collects the different JSON types. It is internally used to
-distinguish the stored values, and the functions @ref basic_json::is_null(),
-@ref basic_json::is_object(), @ref basic_json::is_array(),
-@ref basic_json::is_string(), @ref basic_json::is_boolean(),
-@ref basic_json::is_number() (with @ref basic_json::is_number_integer(),
-@ref basic_json::is_number_unsigned(), and @ref basic_json::is_number_float()),
-@ref basic_json::is_discarded(), @ref basic_json::is_primitive(), and
-@ref basic_json::is_structured() rely on it.
-
-@note There are three enumeration entries (number_integer, number_unsigned, and
-number_float), because the library distinguishes these three types for numbers:
-@ref basic_json::number_unsigned_t is used for unsigned integers,
-@ref basic_json::number_integer_t is used for signed integers, and
-@ref basic_json::number_float_t is used for floating-point numbers or to
-approximate integers which do not fit in the limits of their respective type.
-
-@sa @ref basic_json::basic_json(const value_t value_type) -- create a JSON
-value with the default value for a given type
-
-@since version 1.0.0
-*/
-enum class value_t : std::uint8_t
-{
- null, ///< null value
- object, ///< object (unordered set of name/value pairs)
- array, ///< array (ordered collection of values)
- string, ///< string value
- boolean, ///< boolean value
- number_integer, ///< number value (signed integer)
- number_unsigned, ///< number value (unsigned integer)
- number_float, ///< number value (floating-point)
- discarded ///< discarded by the the parser callback function
-};
-
-/*!
-@brief comparison operator for JSON types
-
-Returns an ordering that is similar to Python:
-- order: null < boolean < number < object < array < string
-- furthermore, each type is not smaller than itself
-- discarded values are not comparable
-
-@since version 1.0.0
-*/
-inline bool operator<(const value_t lhs, const value_t rhs) noexcept
-{
- static constexpr std::array<std::uint8_t, 8> order = {{
- 0 /* null */, 3 /* object */, 4 /* array */, 5 /* string */,
- 1 /* boolean */, 2 /* integer */, 2 /* unsigned */, 2 /* float */
- }
- };
-
- const auto l_index = static_cast<std::size_t>(lhs);
- const auto r_index = static_cast<std::size_t>(rhs);
- return l_index < order.size() and r_index < order.size() and order[l_index] < order[r_index];
-}
-} // namespace detail
-} // namespace nlohmann
-
-
-namespace nlohmann
-{
-namespace detail
-{
-template<typename BasicJsonType>
-void from_json(const BasicJsonType& j, typename std::nullptr_t& n)
-{
- if (JSON_UNLIKELY(not j.is_null()))
- {
- JSON_THROW(type_error::create(302, "type must be null, but is " + std::string(j.type_name())));
- }
- n = nullptr;
-}
-
-// overloads for basic_json template parameters
-template<typename BasicJsonType, typename ArithmeticType,
- enable_if_t<std::is_arithmetic<ArithmeticType>::value and
- not std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
- int> = 0>
-void get_arithmetic_value(const BasicJsonType& j, ArithmeticType& val)
-{
- switch (static_cast<value_t>(j))
- {
- case value_t::number_unsigned:
- {
- val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
- break;
- }
- case value_t::number_integer:
- {
- val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
- break;
- }
- case value_t::number_float:
- {
- val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
- break;
- }
-
- default:
- JSON_THROW(type_error::create(302, "type must be number, but is " + std::string(j.type_name())));
- }
-}
-
-template<typename BasicJsonType>
-void from_json(const BasicJsonType& j, typename BasicJsonType::boolean_t& b)
-{
- if (JSON_UNLIKELY(not j.is_boolean()))
- {
- JSON_THROW(type_error::create(302, "type must be boolean, but is " + std::string(j.type_name())));
- }
- b = *j.template get_ptr<const typename BasicJsonType::boolean_t*>();
-}
-
-template<typename BasicJsonType>
-void from_json(const BasicJsonType& j, typename BasicJsonType::string_t& s)
-{
- if (JSON_UNLIKELY(not j.is_string()))
- {
- JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name())));
- }
- s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
-}
-
-template <
- typename BasicJsonType, typename ConstructibleStringType,
- enable_if_t <
- is_constructible_string_type<BasicJsonType, ConstructibleStringType>::value and
- not std::is_same<typename BasicJsonType::string_t,
- ConstructibleStringType>::value,
- int > = 0 >
-void from_json(const BasicJsonType& j, ConstructibleStringType& s)
-{
- if (JSON_UNLIKELY(not j.is_string()))
- {
- JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name())));
- }
-
- s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
-}
-
-template<typename BasicJsonType>
-void from_json(const BasicJsonType& j, typename BasicJsonType::number_float_t& val)
-{
- get_arithmetic_value(j, val);
-}
-
-template<typename BasicJsonType>
-void from_json(const BasicJsonType& j, typename BasicJsonType::number_unsigned_t& val)
-{
- get_arithmetic_value(j, val);
-}
-
-template<typename BasicJsonType>
-void from_json(const BasicJsonType& j, typename BasicJsonType::number_integer_t& val)
-{
- get_arithmetic_value(j, val);
-}
-
-template<typename BasicJsonType, typename EnumType,
- enable_if_t<std::is_enum<EnumType>::value, int> = 0>
-void from_json(const BasicJsonType& j, EnumType& e)
-{
- typename std::underlying_type<EnumType>::type val;
- get_arithmetic_value(j, val);
- e = static_cast<EnumType>(val);
-}
-
-// forward_list doesn't have an insert method
-template<typename BasicJsonType, typename T, typename Allocator,
- enable_if_t<std::is_convertible<BasicJsonType, T>::value, int> = 0>
-void from_json(const BasicJsonType& j, std::forward_list<T, Allocator>& l)
-{
- if (JSON_UNLIKELY(not j.is_array()))
- {
- JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name())));
- }
- std::transform(j.rbegin(), j.rend(),
- std::front_inserter(l), [](const BasicJsonType & i)
- {
- return i.template get<T>();
- });
-}
-
-// valarray doesn't have an insert method
-template<typename BasicJsonType, typename T,
- enable_if_t<std::is_convertible<BasicJsonType, T>::value, int> = 0>
-void from_json(const BasicJsonType& j, std::valarray<T>& l)
-{
- if (JSON_UNLIKELY(not j.is_array()))
- {
- JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name())));
- }
- l.resize(j.size());
- std::copy(j.m_value.array->begin(), j.m_value.array->end(), std::begin(l));
-}
-
-template<typename BasicJsonType>
-void from_json_array_impl(const BasicJsonType& j, typename BasicJsonType::array_t& arr, priority_tag<3> /*unused*/)
-{
- arr = *j.template get_ptr<const typename BasicJsonType::array_t*>();
-}
-
-template <typename BasicJsonType, typename T, std::size_t N>
-auto from_json_array_impl(const BasicJsonType& j, std::array<T, N>& arr,
- priority_tag<2> /*unused*/)
--> decltype(j.template get<T>(), void())
-{
- for (std::size_t i = 0; i < N; ++i)
- {
- arr[i] = j.at(i).template get<T>();
- }
-}
-
-template<typename BasicJsonType, typename ConstructibleArrayType>
-auto from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, priority_tag<1> /*unused*/)
--> decltype(
- arr.reserve(std::declval<typename ConstructibleArrayType::size_type>()),
- j.template get<typename ConstructibleArrayType::value_type>(),
- void())
-{
- using std::end;
-
- arr.reserve(j.size());
- std::transform(j.begin(), j.end(),
- std::inserter(arr, end(arr)), [](const BasicJsonType & i)
- {
- // get<BasicJsonType>() returns *this, this won't call a from_json
- // method when value_type is BasicJsonType
- return i.template get<typename ConstructibleArrayType::value_type>();
- });
-}
-
-template <typename BasicJsonType, typename ConstructibleArrayType>
-void from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr,
- priority_tag<0> /*unused*/)
-{
- using std::end;
-
- std::transform(
- j.begin(), j.end(), std::inserter(arr, end(arr)),
- [](const BasicJsonType & i)
- {
- // get<BasicJsonType>() returns *this, this won't call a from_json
- // method when value_type is BasicJsonType
- return i.template get<typename ConstructibleArrayType::value_type>();
- });
-}
-
-template <typename BasicJsonType, typename ConstructibleArrayType,
- enable_if_t <
- is_constructible_array_type<BasicJsonType, ConstructibleArrayType>::value and
- not is_constructible_object_type<BasicJsonType, ConstructibleArrayType>::value and
- not is_constructible_string_type<BasicJsonType, ConstructibleArrayType>::value and
- not is_basic_json<ConstructibleArrayType>::value,
- int > = 0 >
-
-auto from_json(const BasicJsonType& j, ConstructibleArrayType& arr)
--> decltype(from_json_array_impl(j, arr, priority_tag<3> {}),
-j.template get<typename ConstructibleArrayType::value_type>(),
-void())
-{
- if (JSON_UNLIKELY(not j.is_array()))
- {
- JSON_THROW(type_error::create(302, "type must be array, but is " +
- std::string(j.type_name())));
- }
-
- from_json_array_impl(j, arr, priority_tag<3> {});
-}
-
-template<typename BasicJsonType, typename ConstructibleObjectType,
- enable_if_t<is_constructible_object_type<BasicJsonType, ConstructibleObjectType>::value, int> = 0>
-void from_json(const BasicJsonType& j, ConstructibleObjectType& obj)
-{
- if (JSON_UNLIKELY(not j.is_object()))
- {
- JSON_THROW(type_error::create(302, "type must be object, but is " + std::string(j.type_name())));
- }
-
- auto inner_object = j.template get_ptr<const typename BasicJsonType::object_t*>();
- using value_type = typename ConstructibleObjectType::value_type;
- std::transform(
- inner_object->begin(), inner_object->end(),
- std::inserter(obj, obj.begin()),
- [](typename BasicJsonType::object_t::value_type const & p)
- {
- return value_type(p.first, p.second.template get<typename ConstructibleObjectType::mapped_type>());
- });
-}
-
-// overload for arithmetic types, not chosen for basic_json template arguments
-// (BooleanType, etc..); note: Is it really necessary to provide explicit
-// overloads for boolean_t etc. in case of a custom BooleanType which is not
-// an arithmetic type?
-template<typename BasicJsonType, typename ArithmeticType,
- enable_if_t <
- std::is_arithmetic<ArithmeticType>::value and
- not std::is_same<ArithmeticType, typename BasicJsonType::number_unsigned_t>::value and
- not std::is_same<ArithmeticType, typename BasicJsonType::number_integer_t>::value and
- not std::is_same<ArithmeticType, typename BasicJsonType::number_float_t>::value and
- not std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
- int> = 0>
-void from_json(const BasicJsonType& j, ArithmeticType& val)
-{
- switch (static_cast<value_t>(j))
- {
- case value_t::number_unsigned:
- {
- val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
- break;
- }
- case value_t::number_integer:
- {
- val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
- break;
- }
- case value_t::number_float:
- {
- val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
- break;
- }
- case value_t::boolean:
- {
- val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::boolean_t*>());
- break;
- }
-
- default:
- JSON_THROW(type_error::create(302, "type must be number, but is " + std::string(j.type_name())));
- }
-}
-
-template<typename BasicJsonType, typename A1, typename A2>
-void from_json(const BasicJsonType& j, std::pair<A1, A2>& p)
-{
- p = {j.at(0).template get<A1>(), j.at(1).template get<A2>()};
-}
-
-template<typename BasicJsonType, typename Tuple, std::size_t... Idx>
-void from_json_tuple_impl(const BasicJsonType& j, Tuple& t, index_sequence<Idx...> /*unused*/)
-{
- t = std::make_tuple(j.at(Idx).template get<typename std::tuple_element<Idx, Tuple>::type>()...);
-}
-
-template<typename BasicJsonType, typename... Args>
-void from_json(const BasicJsonType& j, std::tuple<Args...>& t)
-{
- from_json_tuple_impl(j, t, index_sequence_for<Args...> {});
-}
-
-template <typename BasicJsonType, typename Key, typename Value, typename Compare, typename Allocator,
- typename = enable_if_t<not std::is_constructible<
- typename BasicJsonType::string_t, Key>::value>>
-void from_json(const BasicJsonType& j, std::map<Key, Value, Compare, Allocator>& m)
-{
- if (JSON_UNLIKELY(not j.is_array()))
- {
- JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name())));
- }
- for (const auto& p : j)
- {
- if (JSON_UNLIKELY(not p.is_array()))
- {
- JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(p.type_name())));
- }
- m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
- }
-}
-
-template <typename BasicJsonType, typename Key, typename Value, typename Hash, typename KeyEqual, typename Allocator,
- typename = enable_if_t<not std::is_constructible<
- typename BasicJsonType::string_t, Key>::value>>
-void from_json(const BasicJsonType& j, std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>& m)
-{
- if (JSON_UNLIKELY(not j.is_array()))
- {
- JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name())));
- }
- for (const auto& p : j)
- {
- if (JSON_UNLIKELY(not p.is_array()))
- {
- JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(p.type_name())));
- }
- m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
- }
-}
-
-struct from_json_fn
-{
- template<typename BasicJsonType, typename T>
- auto operator()(const BasicJsonType& j, T& val) const
- noexcept(noexcept(from_json(j, val)))
- -> decltype(from_json(j, val), void())
- {
- return from_json(j, val);
- }
-};
-} // namespace detail
-
-/// namespace to hold default `from_json` function
-/// to see why this is required:
-/// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4381.html
-namespace
-{
-constexpr const auto& from_json = detail::static_const<detail::from_json_fn>::value;
-} // namespace
-} // namespace nlohmann
-
-// #include <nlohmann/detail/conversions/to_json.hpp>
-
-
-#include <algorithm> // copy
-#include <ciso646> // or, and, not
-#include <iterator> // begin, end
-#include <string> // string
-#include <tuple> // tuple, get
-#include <type_traits> // is_same, is_constructible, is_floating_point, is_enum, underlying_type
-#include <utility> // move, forward, declval, pair
-#include <valarray> // valarray
-#include <vector> // vector
-
-// #include <nlohmann/detail/iterators/iteration_proxy.hpp>
-
-
-#include <cstddef> // size_t
-#include <iterator> // input_iterator_tag
-#include <string> // string, to_string
-#include <tuple> // tuple_size, get, tuple_element
-
-// #include <nlohmann/detail/meta/type_traits.hpp>
-
-// #include <nlohmann/detail/value_t.hpp>
-
-
-namespace nlohmann
-{
-namespace detail
-{
-template <typename IteratorType> class iteration_proxy_value
-{
- public:
- using difference_type = std::ptrdiff_t;
- using value_type = iteration_proxy_value;
- using pointer = value_type * ;
- using reference = value_type & ;
- using iterator_category = std::input_iterator_tag;
-
- private:
- /// the iterator
- IteratorType anchor;
- /// an index for arrays (used to create key names)
- std::size_t array_index = 0;
- /// last stringified array index
- mutable std::size_t array_index_last = 0;
- /// a string representation of the array index
- mutable std::string array_index_str = "0";
- /// an empty string (to return a reference for primitive values)
- const std::string empty_str = "";
-
- public:
- explicit iteration_proxy_value(IteratorType it) noexcept : anchor(it) {}
-
- /// dereference operator (needed for range-based for)
- iteration_proxy_value& operator*()
- {
- return *this;
- }
-
- /// increment operator (needed for range-based for)
- iteration_proxy_value& operator++()
- {
- ++anchor;
- ++array_index;
-
- return *this;
- }
-
- /// equality operator (needed for InputIterator)
- bool operator==(const iteration_proxy_value& o) const
- {
- return anchor == o.anchor;
- }
-
- /// inequality operator (needed for range-based for)
- bool operator!=(const iteration_proxy_value& o) const
- {
- return anchor != o.anchor;
- }
-
- /// return key of the iterator
- const std::string& key() const
- {
- assert(anchor.m_object != nullptr);
-
- switch (anchor.m_object->type())
- {
- // use integer array index as key
- case value_t::array:
- {
- if (array_index != array_index_last)
- {
- array_index_str = std::to_string(array_index);
- array_index_last = array_index;
- }
- return array_index_str;
- }
-
- // use key from the object
- case value_t::object:
- return anchor.key();
-
- // use an empty key for all primitive types
- default:
- return empty_str;
- }
- }
-
- /// return value of the iterator
- typename IteratorType::reference value() const
- {
- return anchor.value();
- }
-};
-
-/// proxy class for the items() function
-template<typename IteratorType> class iteration_proxy
-{
- private:
- /// the container to iterate
- typename IteratorType::reference container;
-
- public:
- /// construct iteration proxy from a container
- explicit iteration_proxy(typename IteratorType::reference cont) noexcept
- : container(cont) {}
-
- /// return iterator begin (needed for range-based for)
- iteration_proxy_value<IteratorType> begin() noexcept
- {
- return iteration_proxy_value<IteratorType>(container.begin());
- }
-
- /// return iterator end (needed for range-based for)
- iteration_proxy_value<IteratorType> end() noexcept
- {
- return iteration_proxy_value<IteratorType>(container.end());
- }
-};
-// Structured Bindings Support
-// For further reference see https://blog.tartanllama.xyz/structured-bindings/
-// And see https://github.com/nlohmann/json/pull/1391
-template <std::size_t N, typename IteratorType, enable_if_t<N == 0, int> = 0>
-auto get(const nlohmann::detail::iteration_proxy_value<IteratorType>& i) -> decltype(i.key())
-{
- return i.key();
-}
-// Structured Bindings Support
-// For further reference see https://blog.tartanllama.xyz/structured-bindings/
-// And see https://github.com/nlohmann/json/pull/1391
-template <std::size_t N, typename IteratorType, enable_if_t<N == 1, int> = 0>
-auto get(const nlohmann::detail::iteration_proxy_value<IteratorType>& i) -> decltype(i.value())
-{
- return i.value();
-}
-} // namespace detail
-} // namespace nlohmann
-
-// The Addition to the STD Namespace is required to add
-// Structured Bindings Support to the iteration_proxy_value class
-// For further reference see https://blog.tartanllama.xyz/structured-bindings/
-// And see https://github.com/nlohmann/json/pull/1391
-namespace std
-{
-#if defined(__clang__)
- // Fix: https://github.com/nlohmann/json/issues/1401
- #pragma clang diagnostic push
- #pragma clang diagnostic ignored "-Wmismatched-tags"
-#endif
-template <typename IteratorType>
-class tuple_size<::nlohmann::detail::iteration_proxy_value<IteratorType>>
- : public std::integral_constant<std::size_t, 2> {};
-
-template <std::size_t N, typename IteratorType>
-class tuple_element<N, ::nlohmann::detail::iteration_proxy_value<IteratorType >>
-{
- public:
- using type = decltype(
- get<N>(std::declval <
- ::nlohmann::detail::iteration_proxy_value<IteratorType >> ()));
-};
-#if defined(__clang__)
- #pragma clang diagnostic pop
-#endif
-} // namespace std
-
-// #include <nlohmann/detail/meta/cpp_future.hpp>
-
-// #include <nlohmann/detail/meta/type_traits.hpp>
-
-// #include <nlohmann/detail/value_t.hpp>
-
-
-namespace nlohmann
-{
-namespace detail
-{
-//////////////////
-// constructors //
-//////////////////
-
-template<value_t> struct external_constructor;
-
-template<>
-struct external_constructor<value_t::boolean>
-{
- template<typename BasicJsonType>
- static void construct(BasicJsonType& j, typename BasicJsonType::boolean_t b) noexcept
- {
- j.m_type = value_t::boolean;
- j.m_value = b;
- j.assert_invariant();
- }
-};
-
-template<>
-struct external_constructor<value_t::string>
-{
- template<typename BasicJsonType>
- static void construct(BasicJsonType& j, const typename BasicJsonType::string_t& s)
- {
- j.m_type = value_t::string;
- j.m_value = s;
- j.assert_invariant();
- }
-
- template<typename BasicJsonType>
- static void construct(BasicJsonType& j, typename BasicJsonType::string_t&& s)
- {
- j.m_type = value_t::string;
- j.m_value = std::move(s);
- j.assert_invariant();
- }
-
- template<typename BasicJsonType, typename CompatibleStringType,
- enable_if_t<not std::is_same<CompatibleStringType, typename BasicJsonType::string_t>::value,
- int> = 0>
- static void construct(BasicJsonType& j, const CompatibleStringType& str)
- {
- j.m_type = value_t::string;
- j.m_value.string = j.template create<typename BasicJsonType::string_t>(str);
- j.assert_invariant();
- }
-};
-
-template<>
-struct external_constructor<value_t::number_float>
-{
- template<typename BasicJsonType>
- static void construct(BasicJsonType& j, typename BasicJsonType::number_float_t val) noexcept
- {
- j.m_type = value_t::number_float;
- j.m_value = val;
- j.assert_invariant();
- }
-};
-
-template<>
-struct external_constructor<value_t::number_unsigned>
-{
- template<typename BasicJsonType>
- static void construct(BasicJsonType& j, typename BasicJsonType::number_unsigned_t val) noexcept
- {
- j.m_type = value_t::number_unsigned;
- j.m_value = val;
- j.assert_invariant();
- }
-};
-
-template<>
-struct external_constructor<value_t::number_integer>
-{
- template<typename BasicJsonType>
- static void construct(BasicJsonType& j, typename BasicJsonType::number_integer_t val) noexcept
- {
- j.m_type = value_t::number_integer;
- j.m_value = val;
- j.assert_invariant();
- }
-};
-
-template<>
-struct external_constructor<value_t::array>
-{
- template<typename BasicJsonType>
- static void construct(BasicJsonType& j, const typename BasicJsonType::array_t& arr)
- {
- j.m_type = value_t::array;
- j.m_value = arr;
- j.assert_invariant();
- }
-
- template<typename BasicJsonType>
- static void construct(BasicJsonType& j, typename BasicJsonType::array_t&& arr)
- {
- j.m_type = value_t::array;
- j.m_value = std::move(arr);
- j.assert_invariant();
- }
-
- template<typename BasicJsonType, typename CompatibleArrayType,
- enable_if_t<not std::is_same<CompatibleArrayType, typename BasicJsonType::array_t>::value,
- int> = 0>
- static void construct(BasicJsonType& j, const CompatibleArrayType& arr)
- {
- using std::begin;
- using std::end;
- j.m_type = value_t::array;
- j.m_value.array = j.template create<typename BasicJsonType::array_t>(begin(arr), end(arr));
- j.assert_invariant();
- }
-
- template<typename BasicJsonType>
- static void construct(BasicJsonType& j, const std::vector<bool>& arr)
- {
- j.m_type = value_t::array;
- j.m_value = value_t::array;
- j.m_value.array->reserve(arr.size());
- for (const bool x : arr)
- {
- j.m_value.array->push_back(x);
- }
- j.assert_invariant();
- }
-
- template<typename BasicJsonType, typename T,
- enable_if_t<std::is_convertible<T, BasicJsonType>::value, int> = 0>
- static void construct(BasicJsonType& j, const std::valarray<T>& arr)
- {
- j.m_type = value_t::array;
- j.m_value = value_t::array;
- j.m_value.array->resize(arr.size());
- std::copy(std::begin(arr), std::end(arr), j.m_value.array->begin());
- j.assert_invariant();
- }
-};
-
-template<>
-struct external_constructor<value_t::object>
-{
- template<typename BasicJsonType>
- static void construct(BasicJsonType& j, const typename BasicJsonType::object_t& obj)
- {
- j.m_type = value_t::object;
- j.m_value = obj;
- j.assert_invariant();
- }
-
- template<typename BasicJsonType>
- static void construct(BasicJsonType& j, typename BasicJsonType::object_t&& obj)
- {
- j.m_type = value_t::object;
- j.m_value = std::move(obj);
- j.assert_invariant();
- }
-
- template<typename BasicJsonType, typename CompatibleObjectType,
- enable_if_t<not std::is_same<CompatibleObjectType, typename BasicJsonType::object_t>::value, int> = 0>
- static void construct(BasicJsonType& j, const CompatibleObjectType& obj)
- {
- using std::begin;
- using std::end;
-
- j.m_type = value_t::object;
- j.m_value.object = j.template create<typename BasicJsonType::object_t>(begin(obj), end(obj));
- j.assert_invariant();
- }
-};
-
-/////////////
-// to_json //
-/////////////
-
-template<typename BasicJsonType, typename T,
- enable_if_t<std::is_same<T, typename BasicJsonType::boolean_t>::value, int> = 0>
-void to_json(BasicJsonType& j, T b) noexcept
-{
- external_constructor<value_t::boolean>::construct(j, b);
-}
-
-template<typename BasicJsonType, typename CompatibleString,
- enable_if_t<std::is_constructible<typename BasicJsonType::string_t, CompatibleString>::value, int> = 0>
-void to_json(BasicJsonType& j, const CompatibleString& s)
-{
- external_constructor<value_t::string>::construct(j, s);
-}
-
-template<typename BasicJsonType>
-void to_json(BasicJsonType& j, typename BasicJsonType::string_t&& s)
-{
- external_constructor<value_t::string>::construct(j, std::move(s));
-}
-
-template<typename BasicJsonType, typename FloatType,
- enable_if_t<std::is_floating_point<FloatType>::value, int> = 0>
-void to_json(BasicJsonType& j, FloatType val) noexcept
-{
- external_constructor<value_t::number_float>::construct(j, static_cast<typename BasicJsonType::number_float_t>(val));
-}
-
-template<typename BasicJsonType, typename CompatibleNumberUnsignedType,
- enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_unsigned_t, CompatibleNumberUnsignedType>::value, int> = 0>
-void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val) noexcept
-{
- external_constructor<value_t::number_unsigned>::construct(j, static_cast<typename BasicJsonType::number_unsigned_t>(val));
-}
-
-template<typename BasicJsonType, typename CompatibleNumberIntegerType,
- enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_integer_t, CompatibleNumberIntegerType>::value, int> = 0>
-void to_json(BasicJsonType& j, CompatibleNumberIntegerType val) noexcept
-{
- external_constructor<value_t::number_integer>::construct(j, static_cast<typename BasicJsonType::number_integer_t>(val));
-}
-
-template<typename BasicJsonType, typename EnumType,
- enable_if_t<std::is_enum<EnumType>::value, int> = 0>
-void to_json(BasicJsonType& j, EnumType e) noexcept
-{
- using underlying_type = typename std::underlying_type<EnumType>::type;
- external_constructor<value_t::number_integer>::construct(j, static_cast<underlying_type>(e));
-}
-
-template<typename BasicJsonType>
-void to_json(BasicJsonType& j, const std::vector<bool>& e)
-{
- external_constructor<value_t::array>::construct(j, e);
-}
-
-template <typename BasicJsonType, typename CompatibleArrayType,
- enable_if_t<is_compatible_array_type<BasicJsonType,
- CompatibleArrayType>::value and
- not is_compatible_object_type<
- BasicJsonType, CompatibleArrayType>::value and
- not is_compatible_string_type<BasicJsonType, CompatibleArrayType>::value and
- not is_basic_json<CompatibleArrayType>::value,
- int> = 0>
-void to_json(BasicJsonType& j, const CompatibleArrayType& arr)
-{
- external_constructor<value_t::array>::construct(j, arr);
-}
-
-template<typename BasicJsonType, typename T,
- enable_if_t<std::is_convertible<T, BasicJsonType>::value, int> = 0>
-void to_json(BasicJsonType& j, const std::valarray<T>& arr)
-{
- external_constructor<value_t::array>::construct(j, std::move(arr));
-}
-
-template<typename BasicJsonType>
-void to_json(BasicJsonType& j, typename BasicJsonType::array_t&& arr)
-{
- external_constructor<value_t::array>::construct(j, std::move(arr));
-}
-
-template<typename BasicJsonType, typename CompatibleObjectType,
- enable_if_t<is_compatible_object_type<BasicJsonType, CompatibleObjectType>::value and not is_basic_json<CompatibleObjectType>::value, int> = 0>
-void to_json(BasicJsonType& j, const CompatibleObjectType& obj)
-{
- external_constructor<value_t::object>::construct(j, obj);
-}
-
-template<typename BasicJsonType>
-void to_json(BasicJsonType& j, typename BasicJsonType::object_t&& obj)
-{
- external_constructor<value_t::object>::construct(j, std::move(obj));
-}
-
-template <
- typename BasicJsonType, typename T, std::size_t N,
- enable_if_t<not std::is_constructible<typename BasicJsonType::string_t,
- const T(&)[N]>::value,
- int> = 0 >
-void to_json(BasicJsonType& j, const T(&arr)[N])
-{
- external_constructor<value_t::array>::construct(j, arr);
-}
-
-template<typename BasicJsonType, typename... Args>
-void to_json(BasicJsonType& j, const std::pair<Args...>& p)
-{
- j = { p.first, p.second };
-}
-
-// for https://github.com/nlohmann/json/pull/1134
-template < typename BasicJsonType, typename T,
- enable_if_t<std::is_same<T, iteration_proxy_value<typename BasicJsonType::iterator>>::value, int> = 0>
-void to_json(BasicJsonType& j, const T& b)
-{
- j = { {b.key(), b.value()} };
-}
-
-template<typename BasicJsonType, typename Tuple, std::size_t... Idx>
-void to_json_tuple_impl(BasicJsonType& j, const Tuple& t, index_sequence<Idx...> /*unused*/)
-{
- j = { std::get<Idx>(t)... };
-}
-
-template<typename BasicJsonType, typename... Args>
-void to_json(BasicJsonType& j, const std::tuple<Args...>& t)
-{
- to_json_tuple_impl(j, t, index_sequence_for<Args...> {});
-}
-
-struct to_json_fn
-{
- template<typename BasicJsonType, typename T>
- auto operator()(BasicJsonType& j, T&& val) const noexcept(noexcept(to_json(j, std::forward<T>(val))))
- -> decltype(to_json(j, std::forward<T>(val)), void())
- {
- return to_json(j, std::forward<T>(val));
- }
-};
-} // namespace detail
-
-/// namespace to hold default `to_json` function
-namespace
-{
-constexpr const auto& to_json = detail::static_const<detail::to_json_fn>::value;
-} // namespace
-} // namespace nlohmann
-
-
-namespace nlohmann
-{
-
-template<typename, typename>
-struct adl_serializer
-{
- /*!
- @brief convert a JSON value to any value type
-
- This function is usually called by the `get()` function of the
- @ref basic_json class (either explicit or via conversion operators).
-
- @param[in] j JSON value to read from
- @param[in,out] val value to write to
- */
- template<typename BasicJsonType, typename ValueType>
- static auto from_json(BasicJsonType&& j, ValueType& val) noexcept(
- noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), val)))
- -> decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), val), void())
- {
- ::nlohmann::from_json(std::forward<BasicJsonType>(j), val);
- }
-
- /*!
- @brief convert any value type to a JSON value
-
- This function is usually called by the constructors of the @ref basic_json
- class.
-
- @param[in,out] j JSON value to write to
- @param[in] val value to read from
- */
- template <typename BasicJsonType, typename ValueType>
- static auto to_json(BasicJsonType& j, ValueType&& val) noexcept(
- noexcept(::nlohmann::to_json(j, std::forward<ValueType>(val))))
- -> decltype(::nlohmann::to_json(j, std::forward<ValueType>(val)), void())
- {
- ::nlohmann::to_json(j, std::forward<ValueType>(val));
- }
-};
-
-} // namespace nlohmann
-
-// #include <nlohmann/detail/conversions/from_json.hpp>
-
-// #include <nlohmann/detail/conversions/to_json.hpp>
-
-// #include <nlohmann/detail/exceptions.hpp>
-
-// #include <nlohmann/detail/input/binary_reader.hpp>
-
-
-#include <algorithm> // generate_n
-#include <array> // array
-#include <cassert> // assert
-#include <cmath> // ldexp
-#include <cstddef> // size_t
-#include <cstdint> // uint8_t, uint16_t, uint32_t, uint64_t
-#include <cstdio> // snprintf
-#include <cstring> // memcpy
-#include <iterator> // back_inserter
-#include <limits> // numeric_limits
-#include <string> // char_traits, string
-#include <utility> // make_pair, move
-
-// #include <nlohmann/detail/exceptions.hpp>
-
-// #include <nlohmann/detail/input/input_adapters.hpp>
-
-
-#include <array> // array
-#include <cassert> // assert
-#include <cstddef> // size_t
-#include <cstdio> //FILE *
-#include <cstring> // strlen
-#include <istream> // istream
-#include <iterator> // begin, end, iterator_traits, random_access_iterator_tag, distance, next
-#include <memory> // shared_ptr, make_shared, addressof
-#include <numeric> // accumulate
-#include <string> // string, char_traits
-#include <type_traits> // enable_if, is_base_of, is_pointer, is_integral, remove_pointer
-#include <utility> // pair, declval
-
-// #include <nlohmann/detail/iterators/iterator_traits.hpp>
-
-// #include <nlohmann/detail/macro_scope.hpp>
-
-
-namespace nlohmann
-{
-namespace detail
-{
-/// the supported input formats
-enum class input_format_t { json, cbor, msgpack, ubjson, bson };
-
-////////////////////
-// input adapters //
-////////////////////
-
-/*!
-@brief abstract input adapter interface
-
-Produces a stream of std::char_traits<char>::int_type characters from a
-std::istream, a buffer, or some other input type. Accepts the return of
-exactly one non-EOF character for future input. The int_type characters
-returned consist of all valid char values as positive values (typically
-unsigned char), plus an EOF value outside that range, specified by the value
-of the function std::char_traits<char>::eof(). This value is typically -1, but
-could be any arbitrary value which is not a valid char value.
-*/
-struct input_adapter_protocol
-{
- /// get a character [0,255] or std::char_traits<char>::eof().
- virtual std::char_traits<char>::int_type get_character() = 0;
- virtual ~input_adapter_protocol() = default;
-};
-
-/// a type to simplify interfaces
-using input_adapter_t = std::shared_ptr<input_adapter_protocol>;
-
-/*!
-Input adapter for stdio file access. This adapter read only 1 byte and do not use any
- buffer. This adapter is a very low level adapter.
-*/
-class file_input_adapter : public input_adapter_protocol
-{
- public:
- explicit file_input_adapter(std::FILE* f) noexcept
- : m_file(f)
- {}
-
- // make class move-only
- file_input_adapter(const file_input_adapter&) = delete;
- file_input_adapter(file_input_adapter&&) = default;
- file_input_adapter& operator=(const file_input_adapter&) = delete;
- file_input_adapter& operator=(file_input_adapter&&) = default;
- ~file_input_adapter() override = default;
-
- std::char_traits<char>::int_type get_character() noexcept override
- {
- return std::fgetc(m_file);
- }
-
- private:
- /// the file pointer to read from
- std::FILE* m_file;
-};
-
-
-/*!
-Input adapter for a (caching) istream. Ignores a UFT Byte Order Mark at
-beginning of input. Does not support changing the underlying std::streambuf
-in mid-input. Maintains underlying std::istream and std::streambuf to support
-subsequent use of standard std::istream operations to process any input
-characters following those used in parsing the JSON input. Clears the
-std::istream flags; any input errors (e.g., EOF) will be detected by the first
-subsequent call for input from the std::istream.
-*/
-class input_stream_adapter : public input_adapter_protocol
-{
- public:
- ~input_stream_adapter() override
- {
- // clear stream flags; we use underlying streambuf I/O, do not
- // maintain ifstream flags, except eof
- is.clear(is.rdstate() & std::ios::eofbit);
- }
-
- explicit input_stream_adapter(std::istream& i)
- : is(i), sb(*i.rdbuf())
- {}
-
- // delete because of pointer members
- input_stream_adapter(const input_stream_adapter&) = delete;
- input_stream_adapter& operator=(input_stream_adapter&) = delete;
- input_stream_adapter(input_stream_adapter&&) = delete;
- input_stream_adapter& operator=(input_stream_adapter&&) = delete;
-
- // std::istream/std::streambuf use std::char_traits<char>::to_int_type, to
- // ensure that std::char_traits<char>::eof() and the character 0xFF do not
- // end up as the same value, eg. 0xFFFFFFFF.
- std::char_traits<char>::int_type get_character() override
- {
- auto res = sb.sbumpc();
- // set eof manually, as we don't use the istream interface.
- if (res == EOF)
- {
- is.clear(is.rdstate() | std::ios::eofbit);
- }
- return res;
- }
-
- private:
- /// the associated input stream
- std::istream& is;
- std::streambuf& sb;
-};
-
-/// input adapter for buffer input
-class input_buffer_adapter : public input_adapter_protocol
-{
- public:
- input_buffer_adapter(const char* b, const std::size_t l) noexcept
- : cursor(b), limit(b + l)
- {}
-
- // delete because of pointer members
- input_buffer_adapter(const input_buffer_adapter&) = delete;
- input_buffer_adapter& operator=(input_buffer_adapter&) = delete;
- input_buffer_adapter(input_buffer_adapter&&) = delete;
- input_buffer_adapter& operator=(input_buffer_adapter&&) = delete;
- ~input_buffer_adapter() override = default;
-
- std::char_traits<char>::int_type get_character() noexcept override
- {
- if (JSON_LIKELY(cursor < limit))
- {
- return std::char_traits<char>::to_int_type(*(cursor++));
- }
-
- return std::char_traits<char>::eof();
- }
-
- private:
- /// pointer to the current character
- const char* cursor;
- /// pointer past the last character
- const char* const limit;
-};
-
-template<typename WideStringType, size_t T>
-struct wide_string_input_helper
-{
- // UTF-32
- static void fill_buffer(const WideStringType& str,
- size_t& current_wchar,
- std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
- size_t& utf8_bytes_index,
- size_t& utf8_bytes_filled)
- {
- utf8_bytes_index = 0;
-
- if (current_wchar == str.size())
- {
- utf8_bytes[0] = std::char_traits<char>::eof();
- utf8_bytes_filled = 1;
- }
- else
- {
- // get the current character
- const auto wc = static_cast<unsigned int>(str[current_wchar++]);
-
- // UTF-32 to UTF-8 encoding
- if (wc < 0x80)
- {
- utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(wc);
- utf8_bytes_filled = 1;
- }
- else if (wc <= 0x7FF)
- {
- utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xC0u | ((wc >> 6u) & 0x1Fu));
- utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | (wc & 0x3Fu));
- utf8_bytes_filled = 2;
- }
- else if (wc <= 0xFFFF)
- {
- utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xE0u | ((wc >> 12u) & 0x0Fu));
- utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | ((wc >> 6u) & 0x3Fu));
- utf8_bytes[2] = static_cast<std::char_traits<char>::int_type>(0x80u | (wc & 0x3Fu));
- utf8_bytes_filled = 3;
- }
- else if (wc <= 0x10FFFF)
- {
- utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xF0u | ((wc >> 18u) & 0x07u));
- utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | ((wc >> 12u) & 0x3Fu));
- utf8_bytes[2] = static_cast<std::char_traits<char>::int_type>(0x80u | ((wc >> 6u) & 0x3Fu));
- utf8_bytes[3] = static_cast<std::char_traits<char>::int_type>(0x80u | (wc & 0x3Fu));
- utf8_bytes_filled = 4;
- }
- else
- {
- // unknown character
- utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(wc);
- utf8_bytes_filled = 1;
- }
- }
- }
-};
-
-template<typename WideStringType>
-struct wide_string_input_helper<WideStringType, 2>
-{
- // UTF-16
- static void fill_buffer(const WideStringType& str,
- size_t& current_wchar,
- std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
- size_t& utf8_bytes_index,
- size_t& utf8_bytes_filled)
- {
- utf8_bytes_index = 0;
-
- if (current_wchar == str.size())
- {
- utf8_bytes[0] = std::char_traits<char>::eof();
- utf8_bytes_filled = 1;
- }
- else
- {
- // get the current character
- const auto wc = static_cast<unsigned int>(str[current_wchar++]);
-
- // UTF-16 to UTF-8 encoding
- if (wc < 0x80)
- {
- utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(wc);
- utf8_bytes_filled = 1;
- }
- else if (wc <= 0x7FF)
- {
- utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xC0u | ((wc >> 6u)));
- utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | (wc & 0x3Fu));
- utf8_bytes_filled = 2;
- }
- else if (0xD800 > wc or wc >= 0xE000)
- {
- utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xE0u | ((wc >> 12u)));
- utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | ((wc >> 6u) & 0x3Fu));
- utf8_bytes[2] = static_cast<std::char_traits<char>::int_type>(0x80u | (wc & 0x3Fu));
- utf8_bytes_filled = 3;
- }
- else
- {
- if (current_wchar < str.size())
- {
- const auto wc2 = static_cast<unsigned int>(str[current_wchar++]);
- const auto charcode = 0x10000u + (((wc & 0x3FFu) << 10u) | (wc2 & 0x3FFu));
- utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xF0u | (charcode >> 18u));
- utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | ((charcode >> 12u) & 0x3Fu));
- utf8_bytes[2] = static_cast<std::char_traits<char>::int_type>(0x80u | ((charcode >> 6u) & 0x3Fu));
- utf8_bytes[3] = static_cast<std::char_traits<char>::int_type>(0x80u | (charcode & 0x3Fu));
- utf8_bytes_filled = 4;
- }
- else
- {
- // unknown character
- ++current_wchar;
- utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(wc);
- utf8_bytes_filled = 1;
- }
- }
- }
- }
-};
-
-template<typename WideStringType>
-class wide_string_input_adapter : public input_adapter_protocol
-{
- public:
- explicit wide_string_input_adapter(const WideStringType& w) noexcept
- : str(w)
- {}
-
- std::char_traits<char>::int_type get_character() noexcept override
- {
- // check if buffer needs to be filled
- if (utf8_bytes_index == utf8_bytes_filled)
- {
- fill_buffer<sizeof(typename WideStringType::value_type)>();
-
- assert(utf8_bytes_filled > 0);
- assert(utf8_bytes_index == 0);
- }
-
- // use buffer
- assert(utf8_bytes_filled > 0);
- assert(utf8_bytes_index < utf8_bytes_filled);
- return utf8_bytes[utf8_bytes_index++];
- }
-
- private:
- template<size_t T>
- void fill_buffer()
- {
- wide_string_input_helper<WideStringType, T>::fill_buffer(str, current_wchar, utf8_bytes, utf8_bytes_index, utf8_bytes_filled);
- }
-
- /// the wstring to process
- const WideStringType& str;
-
- /// index of the current wchar in str
- std::size_t current_wchar = 0;
-
- /// a buffer for UTF-8 bytes
- std::array<std::char_traits<char>::int_type, 4> utf8_bytes = {{0, 0, 0, 0}};
-
- /// index to the utf8_codes array for the next valid byte
- std::size_t utf8_bytes_index = 0;
- /// number of valid bytes in the utf8_codes array
- std::size_t utf8_bytes_filled = 0;
-};
-
-class input_adapter
-{
- public:
- // native support
- input_adapter(std::FILE* file)
- : ia(std::make_shared<file_input_adapter>(file)) {}
- /// input adapter for input stream
- input_adapter(std::istream& i)
- : ia(std::make_shared<input_stream_adapter>(i)) {}
-
- /// input adapter for input stream
- input_adapter(std::istream&& i)
- : ia(std::make_shared<input_stream_adapter>(i)) {}
-
- input_adapter(const std::wstring& ws)
- : ia(std::make_shared<wide_string_input_adapter<std::wstring>>(ws)) {}
-
- input_adapter(const std::u16string& ws)
- : ia(std::make_shared<wide_string_input_adapter<std::u16string>>(ws)) {}
-
- input_adapter(const std::u32string& ws)
- : ia(std::make_shared<wide_string_input_adapter<std::u32string>>(ws)) {}
-
- /// input adapter for buffer
- template<typename CharT,
- typename std::enable_if<
- std::is_pointer<CharT>::value and
- std::is_integral<typename std::remove_pointer<CharT>::type>::value and
- sizeof(typename std::remove_pointer<CharT>::type) == 1,
- int>::type = 0>
- input_adapter(CharT b, std::size_t l)
- : ia(std::make_shared<input_buffer_adapter>(reinterpret_cast<const char*>(b), l)) {}
-
- // derived support
-
- /// input adapter for string literal
- template<typename CharT,
- typename std::enable_if<
- std::is_pointer<CharT>::value and
- std::is_integral<typename std::remove_pointer<CharT>::type>::value and
- sizeof(typename std::remove_pointer<CharT>::type) == 1,
- int>::type = 0>
- input_adapter(CharT b)
- : input_adapter(reinterpret_cast<const char*>(b),
- std::strlen(reinterpret_cast<const char*>(b))) {}
-
- /// input adapter for iterator range with contiguous storage
- template<class IteratorType,
- typename std::enable_if<
- std::is_same<typename iterator_traits<IteratorType>::iterator_category, std::random_access_iterator_tag>::value,
- int>::type = 0>
- input_adapter(IteratorType first, IteratorType last)
- {
-#ifndef NDEBUG
- // assertion to check that the iterator range is indeed contiguous,
- // see http://stackoverflow.com/a/35008842/266378 for more discussion
- const auto is_contiguous = std::accumulate(
- first, last, std::pair<bool, int>(true, 0),
- [&first](std::pair<bool, int> res, decltype(*first) val)
- {
- res.first &= (val == *(std::next(std::addressof(*first), res.second++)));
- return res;
- }).first;
- assert(is_contiguous);
-#endif
-
- // assertion to check that each element is 1 byte long
- static_assert(
- sizeof(typename iterator_traits<IteratorType>::value_type) == 1,
- "each element in the iterator range must have the size of 1 byte");
-
- const auto len = static_cast<size_t>(std::distance(first, last));
- if (JSON_LIKELY(len > 0))
- {
- // there is at least one element: use the address of first
- ia = std::make_shared<input_buffer_adapter>(reinterpret_cast<const char*>(&(*first)), len);
- }
- else
- {
- // the address of first cannot be used: use nullptr
- ia = std::make_shared<input_buffer_adapter>(nullptr, len);
- }
- }
-
- /// input adapter for array
- template<class T, std::size_t N>
- input_adapter(T (&array)[N])
- : input_adapter(std::begin(array), std::end(array)) {}
-
- /// input adapter for contiguous container
- template<class ContiguousContainer, typename
- std::enable_if<not std::is_pointer<ContiguousContainer>::value and
- std::is_base_of<std::random_access_iterator_tag, typename iterator_traits<decltype(std::begin(std::declval<ContiguousContainer const>()))>::iterator_category>::value,
- int>::type = 0>
- input_adapter(const ContiguousContainer& c)
- : input_adapter(std::begin(c), std::end(c)) {}
-
- operator input_adapter_t()
- {
- return ia;
- }
-
- private:
- /// the actual adapter
- input_adapter_t ia = nullptr;
-};
-} // namespace detail
-} // namespace nlohmann
-
-// #include <nlohmann/detail/input/json_sax.hpp>
-
-
-#include <cassert> // assert
-#include <cstddef>
-#include <string> // string
-#include <utility> // move
-#include <vector> // vector
-
-// #include <nlohmann/detail/exceptions.hpp>
-
-// #include <nlohmann/detail/macro_scope.hpp>
-
-
-namespace nlohmann
-{
-
-/*!
-@brief SAX interface
-
-This class describes the SAX interface used by @ref nlohmann::json::sax_parse.
-Each function is called in different situations while the input is parsed. The
-boolean return value informs the parser whether to continue processing the
-input.
-*/
-template<typename BasicJsonType>
-struct json_sax
-{
- /// type for (signed) integers
- using number_integer_t = typename BasicJsonType::number_integer_t;
- /// type for unsigned integers
- using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
- /// type for floating-point numbers
- using number_float_t = typename BasicJsonType::number_float_t;
- /// type for strings
- using string_t = typename BasicJsonType::string_t;
-
- /*!
- @brief a null value was read
- @return whether parsing should proceed
- */
- virtual bool null() = 0;
-
- /*!
- @brief a boolean value was read
- @param[in] val boolean value
- @return whether parsing should proceed
- */
- virtual bool boolean(bool val) = 0;
-
- /*!
- @brief an integer number was read
- @param[in] val integer value
- @return whether parsing should proceed
- */
- virtual bool number_integer(number_integer_t val) = 0;
-
- /*!
- @brief an unsigned integer number was read
- @param[in] val unsigned integer value
- @return whether parsing should proceed
- */
- virtual bool number_unsigned(number_unsigned_t val) = 0;
-
- /*!
- @brief an floating-point number was read
- @param[in] val floating-point value
- @param[in] s raw token value
- @return whether parsing should proceed
- */
- virtual bool number_float(number_float_t val, const string_t& s) = 0;
-
- /*!
- @brief a string was read
- @param[in] val string value
- @return whether parsing should proceed
- @note It is safe to move the passed string.
- */
- virtual bool string(string_t& val) = 0;
-
- /*!
- @brief the beginning of an object was read
- @param[in] elements number of object elements or -1 if unknown
- @return whether parsing should proceed
- @note binary formats may report the number of elements
- */
- virtual bool start_object(std::size_t elements) = 0;
-
- /*!
- @brief an object key was read
- @param[in] val object key
- @return whether parsing should proceed
- @note It is safe to move the passed string.
- */
- virtual bool key(string_t& val) = 0;
-
- /*!
- @brief the end of an object was read
- @return whether parsing should proceed
- */
- virtual bool end_object() = 0;
-
- /*!
- @brief the beginning of an array was read
- @param[in] elements number of array elements or -1 if unknown
- @return whether parsing should proceed
- @note binary formats may report the number of elements
- */
- virtual bool start_array(std::size_t elements) = 0;
-
- /*!
- @brief the end of an array was read
- @return whether parsing should proceed
- */
- virtual bool end_array() = 0;
-
- /*!
- @brief a parse error occurred
- @param[in] position the position in the input where the error occurs
- @param[in] last_token the last read token
- @param[in] ex an exception object describing the error
- @return whether parsing should proceed (must return false)
- */
- virtual bool parse_error(std::size_t position,
- const std::string& last_token,
- const detail::exception& ex) = 0;
-
- virtual ~json_sax() = default;
-};
-
-
-namespace detail
-{
-/*!
-@brief SAX implementation to create a JSON value from SAX events
-
-This class implements the @ref json_sax interface and processes the SAX events
-to create a JSON value which makes it basically a DOM parser. The structure or
-hierarchy of the JSON value is managed by the stack `ref_stack` which contains
-a pointer to the respective array or object for each recursion depth.
-
-After successful parsing, the value that is passed by reference to the
-constructor contains the parsed value.
-
-@tparam BasicJsonType the JSON type
-*/
-template<typename BasicJsonType>
-class json_sax_dom_parser
-{
- public:
- using number_integer_t = typename BasicJsonType::number_integer_t;
- using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
- using number_float_t = typename BasicJsonType::number_float_t;
- using string_t = typename BasicJsonType::string_t;
-
- /*!
- @param[in, out] r reference to a JSON value that is manipulated while
- parsing
- @param[in] allow_exceptions_ whether parse errors yield exceptions
- */
- explicit json_sax_dom_parser(BasicJsonType& r, const bool allow_exceptions_ = true)
- : root(r), allow_exceptions(allow_exceptions_)
- {}
-
- // make class move-only
- json_sax_dom_parser(const json_sax_dom_parser&) = delete;
- json_sax_dom_parser(json_sax_dom_parser&&) = default;
- json_sax_dom_parser& operator=(const json_sax_dom_parser&) = delete;
- json_sax_dom_parser& operator=(json_sax_dom_parser&&) = default;
- ~json_sax_dom_parser() = default;
-
- bool null()
- {
- handle_value(nullptr);
- return true;
- }
-
- bool boolean(bool val)
- {
- handle_value(val);
- return true;
- }
-
- bool number_integer(number_integer_t val)
- {
- handle_value(val);
- return true;
- }
-
- bool number_unsigned(number_unsigned_t val)
- {
- handle_value(val);
- return true;
- }
-
- bool number_float(number_float_t val, const string_t& /*unused*/)
- {
- handle_value(val);
- return true;
- }
-
- bool string(string_t& val)
- {
- handle_value(val);
- return true;
- }
-
- bool start_object(std::size_t len)
- {
- ref_stack.push_back(handle_value(BasicJsonType::value_t::object));
-
- if (JSON_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size()))
- {
- JSON_THROW(out_of_range::create(408,
- "excessive object size: " + std::to_string(len)));
- }
-
- return true;
- }
-
- bool key(string_t& val)
- {
- // add null at given key and store the reference for later
- object_element = &(ref_stack.back()->m_value.object->operator[](val));
- return true;
- }
-
- bool end_object()
- {
- ref_stack.pop_back();
- return true;
- }
-
- bool start_array(std::size_t len)
- {
- ref_stack.push_back(handle_value(BasicJsonType::value_t::array));
-
- if (JSON_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size()))
- {
- JSON_THROW(out_of_range::create(408,
- "excessive array size: " + std::to_string(len)));
- }
-
- return true;
- }
-
- bool end_array()
- {
- ref_stack.pop_back();
- return true;
- }
-
- bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/,
- const detail::exception& ex)
- {
- errored = true;
- if (allow_exceptions)
- {
- // determine the proper exception type from the id
- switch ((ex.id / 100) % 100)
- {
- case 1:
- JSON_THROW(*static_cast<const detail::parse_error*>(&ex));
- case 4:
- JSON_THROW(*static_cast<const detail::out_of_range*>(&ex));
- // LCOV_EXCL_START
- case 2:
- JSON_THROW(*static_cast<const detail::invalid_iterator*>(&ex));
- case 3:
- JSON_THROW(*static_cast<const detail::type_error*>(&ex));
- case 5:
- JSON_THROW(*static_cast<const detail::other_error*>(&ex));
- default:
- assert(false);
- // LCOV_EXCL_STOP
- }
- }
- return false;
- }
-
- constexpr bool is_errored() const
- {
- return errored;
- }
-
- private:
- /*!
- @invariant If the ref stack is empty, then the passed value will be the new
- root.
- @invariant If the ref stack contains a value, then it is an array or an
- object to which we can add elements
- */
- template<typename Value>
- BasicJsonType* handle_value(Value&& v)
- {
- if (ref_stack.empty())
- {
- root = BasicJsonType(std::forward<Value>(v));
- return &root;
- }
-
- assert(ref_stack.back()->is_array() or ref_stack.back()->is_object());
-
- if (ref_stack.back()->is_array())
- {
- ref_stack.back()->m_value.array->emplace_back(std::forward<Value>(v));
- return &(ref_stack.back()->m_value.array->back());
- }
-
- assert(ref_stack.back()->is_object());
- assert(object_element);
- *object_element = BasicJsonType(std::forward<Value>(v));
- return object_element;
- }
-
- /// the parsed JSON value
- BasicJsonType& root;
- /// stack to model hierarchy of values
- std::vector<BasicJsonType*> ref_stack {};
- /// helper to hold the reference for the next object element
- BasicJsonType* object_element = nullptr;
- /// whether a syntax error occurred
- bool errored = false;
- /// whether to throw exceptions in case of errors
- const bool allow_exceptions = true;
-};
-
-template<typename BasicJsonType>
-class json_sax_dom_callback_parser
-{
- public:
- using number_integer_t = typename BasicJsonType::number_integer_t;
- using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
- using number_float_t = typename BasicJsonType::number_float_t;
- using string_t = typename BasicJsonType::string_t;
- using parser_callback_t = typename BasicJsonType::parser_callback_t;
- using parse_event_t = typename BasicJsonType::parse_event_t;
-
- json_sax_dom_callback_parser(BasicJsonType& r,
- const parser_callback_t cb,
- const bool allow_exceptions_ = true)
- : root(r), callback(cb), allow_exceptions(allow_exceptions_)
- {
- keep_stack.push_back(true);
- }
-
- // make class move-only
- json_sax_dom_callback_parser(const json_sax_dom_callback_parser&) = delete;
- json_sax_dom_callback_parser(json_sax_dom_callback_parser&&) = default;
- json_sax_dom_callback_parser& operator=(const json_sax_dom_callback_parser&) = delete;
- json_sax_dom_callback_parser& operator=(json_sax_dom_callback_parser&&) = default;
- ~json_sax_dom_callback_parser() = default;
-
- bool null()
- {
- handle_value(nullptr);
- return true;
- }
-
- bool boolean(bool val)
- {
- handle_value(val);
- return true;
- }
-
- bool number_integer(number_integer_t val)
- {
- handle_value(val);
- return true;
- }
-
- bool number_unsigned(number_unsigned_t val)
- {
- handle_value(val);
- return true;
- }
-
- bool number_float(number_float_t val, const string_t& /*unused*/)
- {
- handle_value(val);
- return true;
- }
-
- bool string(string_t& val)
- {
- handle_value(val);
- return true;
- }
-
- bool start_object(std::size_t len)
- {
- // check callback for object start
- const bool keep = callback(static_cast<int>(ref_stack.size()), parse_event_t::object_start, discarded);
- keep_stack.push_back(keep);
-
- auto val = handle_value(BasicJsonType::value_t::object, true);
- ref_stack.push_back(val.second);
-
- // check object limit
- if (ref_stack.back() and JSON_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size()))
- {
- JSON_THROW(out_of_range::create(408, "excessive object size: " + std::to_string(len)));
- }
-
- return true;
- }
-
- bool key(string_t& val)
- {
- BasicJsonType k = BasicJsonType(val);
-
- // check callback for key
- const bool keep = callback(static_cast<int>(ref_stack.size()), parse_event_t::key, k);
- key_keep_stack.push_back(keep);
-
- // add discarded value at given key and store the reference for later
- if (keep and ref_stack.back())
- {
- object_element = &(ref_stack.back()->m_value.object->operator[](val) = discarded);
- }
-
- return true;
- }
-
- bool end_object()
- {
- if (ref_stack.back() and not callback(static_cast<int>(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back()))
- {
- // discard object
- *ref_stack.back() = discarded;
- }
-
- assert(not ref_stack.empty());
- assert(not keep_stack.empty());
- ref_stack.pop_back();
- keep_stack.pop_back();
-
- if (not ref_stack.empty() and ref_stack.back() and ref_stack.back()->is_object())
- {
- // remove discarded value
- for (auto it = ref_stack.back()->begin(); it != ref_stack.back()->end(); ++it)
- {
- if (it->is_discarded())
- {
- ref_stack.back()->erase(it);
- break;
- }
- }
- }
-
- return true;
- }
-
- bool start_array(std::size_t len)
- {
- const bool keep = callback(static_cast<int>(ref_stack.size()), parse_event_t::array_start, discarded);
- keep_stack.push_back(keep);
-
- auto val = handle_value(BasicJsonType::value_t::array, true);
- ref_stack.push_back(val.second);
-
- // check array limit
- if (ref_stack.back() and JSON_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size()))
- {
- JSON_THROW(out_of_range::create(408, "excessive array size: " + std::to_string(len)));
- }
-
- return true;
- }
-
- bool end_array()
- {
- bool keep = true;
-
- if (ref_stack.back())
- {
- keep = callback(static_cast<int>(ref_stack.size()) - 1, parse_event_t::array_end, *ref_stack.back());
- if (not keep)
- {
- // discard array
- *ref_stack.back() = discarded;
- }
- }
-
- assert(not ref_stack.empty());
- assert(not keep_stack.empty());
- ref_stack.pop_back();
- keep_stack.pop_back();
-
- // remove discarded value
- if (not keep and not ref_stack.empty() and ref_stack.back()->is_array())
- {
- ref_stack.back()->m_value.array->pop_back();
- }
-
- return true;
- }
-
- bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/,
- const detail::exception& ex)
- {
- errored = true;
- if (allow_exceptions)
- {
- // determine the proper exception type from the id
- switch ((ex.id / 100) % 100)
- {
- case 1:
- JSON_THROW(*static_cast<const detail::parse_error*>(&ex));
- case 4:
- JSON_THROW(*static_cast<const detail::out_of_range*>(&ex));
- // LCOV_EXCL_START
- case 2:
- JSON_THROW(*static_cast<const detail::invalid_iterator*>(&ex));
- case 3:
- JSON_THROW(*static_cast<const detail::type_error*>(&ex));
- case 5:
- JSON_THROW(*static_cast<const detail::other_error*>(&ex));
- default:
- assert(false);
- // LCOV_EXCL_STOP
- }
- }
- return false;
- }
-
- constexpr bool is_errored() const
- {
- return errored;
- }
-
- private:
- /*!
- @param[in] v value to add to the JSON value we build during parsing
- @param[in] skip_callback whether we should skip calling the callback
- function; this is required after start_array() and
- start_object() SAX events, because otherwise we would call the
- callback function with an empty array or object, respectively.
-
- @invariant If the ref stack is empty, then the passed value will be the new
- root.
- @invariant If the ref stack contains a value, then it is an array or an
- object to which we can add elements
-
- @return pair of boolean (whether value should be kept) and pointer (to the
- passed value in the ref_stack hierarchy; nullptr if not kept)
- */
- template<typename Value>
- std::pair<bool, BasicJsonType*> handle_value(Value&& v, const bool skip_callback = false)
- {
- assert(not keep_stack.empty());
-
- // do not handle this value if we know it would be added to a discarded
- // container
- if (not keep_stack.back())
- {
- return {false, nullptr};
- }
-
- // create value
- auto value = BasicJsonType(std::forward<Value>(v));
-
- // check callback
- const bool keep = skip_callback or callback(static_cast<int>(ref_stack.size()), parse_event_t::value, value);
-
- // do not handle this value if we just learnt it shall be discarded
- if (not keep)
- {
- return {false, nullptr};
- }
-
- if (ref_stack.empty())
- {
- root = std::move(value);
- return {true, &root};
- }
-
- // skip this value if we already decided to skip the parent
- // (https://github.com/nlohmann/json/issues/971#issuecomment-413678360)
- if (not ref_stack.back())
- {
- return {false, nullptr};
- }
-
- // we now only expect arrays and objects
- assert(ref_stack.back()->is_array() or ref_stack.back()->is_object());
-
- // array
- if (ref_stack.back()->is_array())
- {
- ref_stack.back()->m_value.array->push_back(std::move(value));
- return {true, &(ref_stack.back()->m_value.array->back())};
- }
-
- // object
- assert(ref_stack.back()->is_object());
- // check if we should store an element for the current key
- assert(not key_keep_stack.empty());
- const bool store_element = key_keep_stack.back();
- key_keep_stack.pop_back();
-
- if (not store_element)
- {
- return {false, nullptr};
- }
-
- assert(object_element);
- *object_element = std::move(value);
- return {true, object_element};
- }
-
- /// the parsed JSON value
- BasicJsonType& root;
- /// stack to model hierarchy of values
- std::vector<BasicJsonType*> ref_stack {};
- /// stack to manage which values to keep
- std::vector<bool> keep_stack {};
- /// stack to manage which object keys to keep
- std::vector<bool> key_keep_stack {};
- /// helper to hold the reference for the next object element
- BasicJsonType* object_element = nullptr;
- /// whether a syntax error occurred
- bool errored = false;
- /// callback function
- const parser_callback_t callback = nullptr;
- /// whether to throw exceptions in case of errors
- const bool allow_exceptions = true;
- /// a discarded value for the callback
- BasicJsonType discarded = BasicJsonType::value_t::discarded;
-};
-
-template<typename BasicJsonType>
-class json_sax_acceptor
-{
- public:
- using number_integer_t = typename BasicJsonType::number_integer_t;
- using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
- using number_float_t = typename BasicJsonType::number_float_t;
- using string_t = typename BasicJsonType::string_t;
-
- bool null()
- {
- return true;
- }
-
- bool boolean(bool /*unused*/)
- {
- return true;
- }
-
- bool number_integer(number_integer_t /*unused*/)
- {
- return true;
- }
-
- bool number_unsigned(number_unsigned_t /*unused*/)
- {
- return true;
- }
-
- bool number_float(number_float_t /*unused*/, const string_t& /*unused*/)
- {
- return true;
- }
-
- bool string(string_t& /*unused*/)
- {
- return true;
- }
-
- bool start_object(std::size_t /*unused*/ = std::size_t(-1))
- {
- return true;
- }
-
- bool key(string_t& /*unused*/)
- {
- return true;
- }
-
- bool end_object()
- {
- return true;
- }
-
- bool start_array(std::size_t /*unused*/ = std::size_t(-1))
- {
- return true;
- }
-
- bool end_array()
- {
- return true;
- }
-
- bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, const detail::exception& /*unused*/)
- {
- return false;
- }
-};
-} // namespace detail
-
-} // namespace nlohmann
-
-// #include <nlohmann/detail/macro_scope.hpp>
-
-// #include <nlohmann/detail/meta/is_sax.hpp>
-
-
-#include <cstdint> // size_t
-#include <utility> // declval
-#include <string> // string
-
-// #include <nlohmann/detail/meta/detected.hpp>
-
-// #include <nlohmann/detail/meta/type_traits.hpp>
-
-
-namespace nlohmann
-{
-namespace detail
-{
-template <typename T>
-using null_function_t = decltype(std::declval<T&>().null());
-
-template <typename T>
-using boolean_function_t =
- decltype(std::declval<T&>().boolean(std::declval<bool>()));
-
-template <typename T, typename Integer>
-using number_integer_function_t =
- decltype(std::declval<T&>().number_integer(std::declval<Integer>()));
-
-template <typename T, typename Unsigned>
-using number_unsigned_function_t =
- decltype(std::declval<T&>().number_unsigned(std::declval<Unsigned>()));
-
-template <typename T, typename Float, typename String>
-using number_float_function_t = decltype(std::declval<T&>().number_float(
- std::declval<Float>(), std::declval<const String&>()));
-
-template <typename T, typename String>
-using string_function_t =
- decltype(std::declval<T&>().string(std::declval<String&>()));
-
-template <typename T>
-using start_object_function_t =
- decltype(std::declval<T&>().start_object(std::declval<std::size_t>()));
-
-template <typename T, typename String>
-using key_function_t =
- decltype(std::declval<T&>().key(std::declval<String&>()));
-
-template <typename T>
-using end_object_function_t = decltype(std::declval<T&>().end_object());
-
-template <typename T>
-using start_array_function_t =
- decltype(std::declval<T&>().start_array(std::declval<std::size_t>()));
-
-template <typename T>
-using end_array_function_t = decltype(std::declval<T&>().end_array());
-
-template <typename T, typename Exception>
-using parse_error_function_t = decltype(std::declval<T&>().parse_error(
- std::declval<std::size_t>(), std::declval<const std::string&>(),
- std::declval<const Exception&>()));
-
-template <typename SAX, typename BasicJsonType>
-struct is_sax
-{
- private:
- static_assert(is_basic_json<BasicJsonType>::value,
- "BasicJsonType must be of type basic_json<...>");
-
- using number_integer_t = typename BasicJsonType::number_integer_t;
- using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
- using number_float_t = typename BasicJsonType::number_float_t;
- using string_t = typename BasicJsonType::string_t;
- using exception_t = typename BasicJsonType::exception;
-
- public:
- static constexpr bool value =
- is_detected_exact<bool, null_function_t, SAX>::value &&
- is_detected_exact<bool, boolean_function_t, SAX>::value &&
- is_detected_exact<bool, number_integer_function_t, SAX,
- number_integer_t>::value &&
- is_detected_exact<bool, number_unsigned_function_t, SAX,
- number_unsigned_t>::value &&
- is_detected_exact<bool, number_float_function_t, SAX, number_float_t,
- string_t>::value &&
- is_detected_exact<bool, string_function_t, SAX, string_t>::value &&
- is_detected_exact<bool, start_object_function_t, SAX>::value &&
- is_detected_exact<bool, key_function_t, SAX, string_t>::value &&
- is_detected_exact<bool, end_object_function_t, SAX>::value &&
- is_detected_exact<bool, start_array_function_t, SAX>::value &&
- is_detected_exact<bool, end_array_function_t, SAX>::value &&
- is_detected_exact<bool, parse_error_function_t, SAX, exception_t>::value;
-};
-
-template <typename SAX, typename BasicJsonType>
-struct is_sax_static_asserts
-{
- private:
- static_assert(is_basic_json<BasicJsonType>::value,
- "BasicJsonType must be of type basic_json<...>");
-
- using number_integer_t = typename BasicJsonType::number_integer_t;
- using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
- using number_float_t = typename BasicJsonType::number_float_t;
- using string_t = typename BasicJsonType::string_t;
- using exception_t = typename BasicJsonType::exception;
-
- public:
- static_assert(is_detected_exact<bool, null_function_t, SAX>::value,
- "Missing/invalid function: bool null()");
- static_assert(is_detected_exact<bool, boolean_function_t, SAX>::value,
- "Missing/invalid function: bool boolean(bool)");
- static_assert(is_detected_exact<bool, boolean_function_t, SAX>::value,
- "Missing/invalid function: bool boolean(bool)");
- static_assert(
- is_detected_exact<bool, number_integer_function_t, SAX,
- number_integer_t>::value,
- "Missing/invalid function: bool number_integer(number_integer_t)");
- static_assert(
- is_detected_exact<bool, number_unsigned_function_t, SAX,
- number_unsigned_t>::value,
- "Missing/invalid function: bool number_unsigned(number_unsigned_t)");
- static_assert(is_detected_exact<bool, number_float_function_t, SAX,
- number_float_t, string_t>::value,
- "Missing/invalid function: bool number_float(number_float_t, const string_t&)");
- static_assert(
- is_detected_exact<bool, string_function_t, SAX, string_t>::value,
- "Missing/invalid function: bool string(string_t&)");
- static_assert(is_detected_exact<bool, start_object_function_t, SAX>::value,
- "Missing/invalid function: bool start_object(std::size_t)");
- static_assert(is_detected_exact<bool, key_function_t, SAX, string_t>::value,
- "Missing/invalid function: bool key(string_t&)");
- static_assert(is_detected_exact<bool, end_object_function_t, SAX>::value,
- "Missing/invalid function: bool end_object()");
- static_assert(is_detected_exact<bool, start_array_function_t, SAX>::value,
- "Missing/invalid function: bool start_array(std::size_t)");
- static_assert(is_detected_exact<bool, end_array_function_t, SAX>::value,
- "Missing/invalid function: bool end_array()");
- static_assert(
- is_detected_exact<bool, parse_error_function_t, SAX, exception_t>::value,
- "Missing/invalid function: bool parse_error(std::size_t, const "
- "std::string&, const exception&)");
-};
-} // namespace detail
-} // namespace nlohmann
-
-// #include <nlohmann/detail/value_t.hpp>
-
-
-namespace nlohmann
-{
-namespace detail
-{
-///////////////////
-// binary reader //
-///////////////////
-
-/*!
-@brief deserialization of CBOR, MessagePack, and UBJSON values
-*/
-template<typename BasicJsonType, typename SAX = json_sax_dom_parser<BasicJsonType>>
-class binary_reader
-{
- using number_integer_t = typename BasicJsonType::number_integer_t;
- using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
- using number_float_t = typename BasicJsonType::number_float_t;
- using string_t = typename BasicJsonType::string_t;
- using json_sax_t = SAX;
-
- public:
- /*!
- @brief create a binary reader
-
- @param[in] adapter input adapter to read from
- */
- explicit binary_reader(input_adapter_t adapter) : ia(std::move(adapter))
- {
- (void)detail::is_sax_static_asserts<SAX, BasicJsonType> {};
- assert(ia);
- }
-
- // make class move-only
- binary_reader(const binary_reader&) = delete;
- binary_reader(binary_reader&&) = default;
- binary_reader& operator=(const binary_reader&) = delete;
- binary_reader& operator=(binary_reader&&) = default;
- ~binary_reader() = default;
-
- /*!
- @param[in] format the binary format to parse
- @param[in] sax_ a SAX event processor
- @param[in] strict whether to expect the input to be consumed completed
-
- @return
- */
- bool sax_parse(const input_format_t format,
- json_sax_t* sax_,
- const bool strict = true)
- {
- sax = sax_;
- bool result = false;
-
- switch (format)
- {
- case input_format_t::bson:
- result = parse_bson_internal();
- break;
-
- case input_format_t::cbor:
- result = parse_cbor_internal();
- break;
-
- case input_format_t::msgpack:
- result = parse_msgpack_internal();
- break;
-
- case input_format_t::ubjson:
- result = parse_ubjson_internal();
- break;
-
- default: // LCOV_EXCL_LINE
- assert(false); // LCOV_EXCL_LINE
- }
-
- // strict mode: next byte must be EOF
- if (result and strict)
- {
- if (format == input_format_t::ubjson)
- {
- get_ignore_noop();
- }
- else
- {
- get();
- }
-
- if (JSON_UNLIKELY(current != std::char_traits<char>::eof()))
- {
- return sax->parse_error(chars_read, get_token_string(),
- parse_error::create(110, chars_read, exception_message(format, "expected end of input; last byte: 0x" + get_token_string(), "value")));
- }
- }
-
- return result;
- }
-
- /*!
- @brief determine system byte order
-
- @return true if and only if system's byte order is little endian
-
- @note from http://stackoverflow.com/a/1001328/266378
- */
- static constexpr bool little_endianess(int num = 1) noexcept
- {
- return *reinterpret_cast<char*>(&num) == 1;
- }
-
- private:
- //////////
- // BSON //
- //////////
-
- /*!
- @brief Reads in a BSON-object and passes it to the SAX-parser.
- @return whether a valid BSON-value was passed to the SAX parser
- */
- bool parse_bson_internal()
- {
- std::int32_t document_size;
- get_number<std::int32_t, true>(input_format_t::bson, document_size);
-
- if (JSON_UNLIKELY(not sax->start_object(std::size_t(-1))))
- {
- return false;
- }
-
- if (JSON_UNLIKELY(not parse_bson_element_list(/*is_array*/false)))
- {
- return false;
- }
-
- return sax->end_object();
- }
-
- /*!
- @brief Parses a C-style string from the BSON input.
- @param[in, out] result A reference to the string variable where the read
- string is to be stored.
- @return `true` if the \x00-byte indicating the end of the string was
- encountered before the EOF; false` indicates an unexpected EOF.
- */
- bool get_bson_cstr(string_t& result)
- {
- auto out = std::back_inserter(result);
- while (true)
- {
- get();
- if (JSON_UNLIKELY(not unexpect_eof(input_format_t::bson, "cstring")))
- {
- return false;
- }
- if (current == 0x00)
- {
- return true;
- }
- *out++ = static_cast<char>(current);
- }
-
- return true;
- }
-
- /*!
- @brief Parses a zero-terminated string of length @a len from the BSON
- input.
- @param[in] len The length (including the zero-byte at the end) of the
- string to be read.
- @param[in, out] result A reference to the string variable where the read
- string is to be stored.
- @tparam NumberType The type of the length @a len
- @pre len >= 1
- @return `true` if the string was successfully parsed
- */
- template<typename NumberType>
- bool get_bson_string(const NumberType len, string_t& result)
- {
- if (JSON_UNLIKELY(len < 1))
- {
- auto last_token = get_token_string();
- return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::bson, "string length must be at least 1, is " + std::to_string(len), "string")));
- }
-
- return get_string(input_format_t::bson, len - static_cast<NumberType>(1), result) and get() != std::char_traits<char>::eof();
- }
-
- /*!
- @brief Read a BSON document element of the given @a element_type.
- @param[in] element_type The BSON element type, c.f. http://bsonspec.org/spec.html
- @param[in] element_type_parse_position The position in the input stream,
- where the `element_type` was read.
- @warning Not all BSON element types are supported yet. An unsupported
- @a element_type will give rise to a parse_error.114:
- Unsupported BSON record type 0x...
- @return whether a valid BSON-object/array was passed to the SAX parser
- */
- bool parse_bson_element_internal(const int element_type,
- const std::size_t element_type_parse_position)
- {
- switch (element_type)
- {
- case 0x01: // double
- {
- double number;
- return get_number<double, true>(input_format_t::bson, number) and sax->number_float(static_cast<number_float_t>(number), "");
- }
-
- case 0x02: // string
- {
- std::int32_t len;
- string_t value;
- return get_number<std::int32_t, true>(input_format_t::bson, len) and get_bson_string(len, value) and sax->string(value);
- }
-
- case 0x03: // object
- {
- return parse_bson_internal();
- }
-
- case 0x04: // array
- {
- return parse_bson_array();
- }
-
- case 0x08: // boolean
- {
- return sax->boolean(get() != 0);
- }
-
- case 0x0A: // null
- {
- return sax->null();
- }
-
- case 0x10: // int32
- {
- std::int32_t value;
- return get_number<std::int32_t, true>(input_format_t::bson, value) and sax->number_integer(value);
- }
-
- case 0x12: // int64
- {
- std::int64_t value;
- return get_number<std::int64_t, true>(input_format_t::bson, value) and sax->number_integer(value);
- }
-
- default: // anything else not supported (yet)
- {
- std::array<char, 3> cr{{}};
- (std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast<unsigned char>(element_type));
- return sax->parse_error(element_type_parse_position, std::string(cr.data()), parse_error::create(114, element_type_parse_position, "Unsupported BSON record type 0x" + std::string(cr.data())));
- }
- }
- }
-
- /*!
- @brief Read a BSON element list (as specified in the BSON-spec)
-
- The same binary layout is used for objects and arrays, hence it must be
- indicated with the argument @a is_array which one is expected
- (true --> array, false --> object).
-
- @param[in] is_array Determines if the element list being read is to be
- treated as an object (@a is_array == false), or as an
- array (@a is_array == true).
- @return whether a valid BSON-object/array was passed to the SAX parser
- */
- bool parse_bson_element_list(const bool is_array)
- {
- string_t key;
- while (int element_type = get())
- {
- if (JSON_UNLIKELY(not unexpect_eof(input_format_t::bson, "element list")))
- {
- return false;
- }
-
- const std::size_t element_type_parse_position = chars_read;
- if (JSON_UNLIKELY(not get_bson_cstr(key)))
- {
- return false;
- }
-
- if (not is_array and not sax->key(key))
- {
- return false;
- }
-
- if (JSON_UNLIKELY(not parse_bson_element_internal(element_type, element_type_parse_position)))
- {
- return false;
- }
-
- // get_bson_cstr only appends
- key.clear();
- }
-
- return true;
- }
-
- /*!
- @brief Reads an array from the BSON input and passes it to the SAX-parser.
- @return whether a valid BSON-array was passed to the SAX parser
- */
- bool parse_bson_array()
- {
- std::int32_t document_size;
- get_number<std::int32_t, true>(input_format_t::bson, document_size);
-
- if (JSON_UNLIKELY(not sax->start_array(std::size_t(-1))))
- {
- return false;
- }
-
- if (JSON_UNLIKELY(not parse_bson_element_list(/*is_array*/true)))
- {
- return false;
- }
-
- return sax->end_array();
- }
-
- //////////
- // CBOR //
- //////////
-
- /*!
- @param[in] get_char whether a new character should be retrieved from the
- input (true, default) or whether the last read
- character should be considered instead
-
- @return whether a valid CBOR value was passed to the SAX parser
- */
- bool parse_cbor_internal(const bool get_char = true)
- {
- switch (get_char ? get() : current)
- {
- // EOF
- case std::char_traits<char>::eof():
- return unexpect_eof(input_format_t::cbor, "value");
-
- // Integer 0x00..0x17 (0..23)
- case 0x00:
- case 0x01:
- case 0x02:
- case 0x03:
- case 0x04:
- case 0x05:
- case 0x06:
- case 0x07:
- case 0x08:
- case 0x09:
- case 0x0A:
- case 0x0B:
- case 0x0C:
- case 0x0D:
- case 0x0E:
- case 0x0F:
- case 0x10:
- case 0x11:
- case 0x12:
- case 0x13:
- case 0x14:
- case 0x15:
- case 0x16:
- case 0x17:
- return sax->number_unsigned(static_cast<number_unsigned_t>(current));
-
- case 0x18: // Unsigned integer (one-byte uint8_t follows)
- {
- std::uint8_t number;
- return get_number(input_format_t::cbor, number) and sax->number_unsigned(number);
- }
-
- case 0x19: // Unsigned integer (two-byte uint16_t follows)
- {
- std::uint16_t number;
- return get_number(input_format_t::cbor, number) and sax->number_unsigned(number);
- }
-
- case 0x1A: // Unsigned integer (four-byte uint32_t follows)
- {
- std::uint32_t number;
- return get_number(input_format_t::cbor, number) and sax->number_unsigned(number);
- }
-
- case 0x1B: // Unsigned integer (eight-byte uint64_t follows)
- {
- std::uint64_t number;
- return get_number(input_format_t::cbor, number) and sax->number_unsigned(number);
- }
-
- // Negative integer -1-0x00..-1-0x17 (-1..-24)
- case 0x20:
- case 0x21:
- case 0x22:
- case 0x23:
- case 0x24:
- case 0x25:
- case 0x26:
- case 0x27:
- case 0x28:
- case 0x29:
- case 0x2A:
- case 0x2B:
- case 0x2C:
- case 0x2D:
- case 0x2E:
- case 0x2F:
- case 0x30:
- case 0x31:
- case 0x32:
- case 0x33:
- case 0x34:
- case 0x35:
- case 0x36:
- case 0x37:
- return sax->number_integer(static_cast<std::int8_t>(0x20 - 1 - current));
-
- case 0x38: // Negative integer (one-byte uint8_t follows)
- {
- std::uint8_t number;
- return get_number(input_format_t::cbor, number) and sax->number_integer(static_cast<number_integer_t>(-1) - number);
- }
-
- case 0x39: // Negative integer -1-n (two-byte uint16_t follows)
- {
- std::uint16_t number;
- return get_number(input_format_t::cbor, number) and sax->number_integer(static_cast<number_integer_t>(-1) - number);
- }
-
- case 0x3A: // Negative integer -1-n (four-byte uint32_t follows)
- {
- std::uint32_t number;
- return get_number(input_format_t::cbor, number) and sax->number_integer(static_cast<number_integer_t>(-1) - number);
- }
-
- case 0x3B: // Negative integer -1-n (eight-byte uint64_t follows)
- {
- std::uint64_t number;
- return get_number(input_format_t::cbor, number) and sax->number_integer(static_cast<number_integer_t>(-1)
- - static_cast<number_integer_t>(number));
- }
-
- // UTF-8 string (0x00..0x17 bytes follow)
- case 0x60:
- case 0x61:
- case 0x62:
- case 0x63:
- case 0x64:
- case 0x65:
- case 0x66:
- case 0x67:
- case 0x68:
- case 0x69:
- case 0x6A:
- case 0x6B:
- case 0x6C:
- case 0x6D:
- case 0x6E:
- case 0x6F:
- case 0x70:
- case 0x71:
- case 0x72:
- case 0x73:
- case 0x74:
- case 0x75:
- case 0x76:
- case 0x77:
- case 0x78: // UTF-8 string (one-byte uint8_t for n follows)
- case 0x79: // UTF-8 string (two-byte uint16_t for n follow)
- case 0x7A: // UTF-8 string (four-byte uint32_t for n follow)
- case 0x7B: // UTF-8 string (eight-byte uint64_t for n follow)
- case 0x7F: // UTF-8 string (indefinite length)
- {
- string_t s;
- return get_cbor_string(s) and sax->string(s);
- }
-
- // array (0x00..0x17 data items follow)
- case 0x80:
- case 0x81:
- case 0x82:
- case 0x83:
- case 0x84:
- case 0x85:
- case 0x86:
- case 0x87:
- case 0x88:
- case 0x89:
- case 0x8A:
- case 0x8B:
- case 0x8C:
- case 0x8D:
- case 0x8E:
- case 0x8F:
- case 0x90:
- case 0x91:
- case 0x92:
- case 0x93:
- case 0x94:
- case 0x95:
- case 0x96:
- case 0x97:
- return get_cbor_array(static_cast<std::size_t>(static_cast<unsigned int>(current) & 0x1Fu));
-
- case 0x98: // array (one-byte uint8_t for n follows)
- {
- std::uint8_t len;
- return get_number(input_format_t::cbor, len) and get_cbor_array(static_cast<std::size_t>(len));
- }
-
- case 0x99: // array (two-byte uint16_t for n follow)
- {
- std::uint16_t len;
- return get_number(input_format_t::cbor, len) and get_cbor_array(static_cast<std::size_t>(len));
- }
-
- case 0x9A: // array (four-byte uint32_t for n follow)
- {
- std::uint32_t len;
- return get_number(input_format_t::cbor, len) and get_cbor_array(static_cast<std::size_t>(len));
- }
-
- case 0x9B: // array (eight-byte uint64_t for n follow)
- {
- std::uint64_t len;
- return get_number(input_format_t::cbor, len) and get_cbor_array(static_cast<std::size_t>(len));
- }
-
- case 0x9F: // array (indefinite length)
- return get_cbor_array(std::size_t(-1));
-
- // map (0x00..0x17 pairs of data items follow)
- case 0xA0:
- case 0xA1:
- case 0xA2:
- case 0xA3:
- case 0xA4:
- case 0xA5:
- case 0xA6:
- case 0xA7:
- case 0xA8:
- case 0xA9:
- case 0xAA:
- case 0xAB:
- case 0xAC:
- case 0xAD:
- case 0xAE:
- case 0xAF:
- case 0xB0:
- case 0xB1:
- case 0xB2:
- case 0xB3:
- case 0xB4:
- case 0xB5:
- case 0xB6:
- case 0xB7:
- return get_cbor_object(static_cast<std::size_t>(static_cast<unsigned int>(current) & 0x1Fu));
-
- case 0xB8: // map (one-byte uint8_t for n follows)
- {
- std::uint8_t len;
- return get_number(input_format_t::cbor, len) and get_cbor_object(static_cast<std::size_t>(len));
- }
-
- case 0xB9: // map (two-byte uint16_t for n follow)
- {
- std::uint16_t len;
- return get_number(input_format_t::cbor, len) and get_cbor_object(static_cast<std::size_t>(len));
- }
-
- case 0xBA: // map (four-byte uint32_t for n follow)
- {
- std::uint32_t len;
- return get_number(input_format_t::cbor, len) and get_cbor_object(static_cast<std::size_t>(len));
- }
-
- case 0xBB: // map (eight-byte uint64_t for n follow)
- {
- std::uint64_t len;
- return get_number(input_format_t::cbor, len) and get_cbor_object(static_cast<std::size_t>(len));
- }
-
- case 0xBF: // map (indefinite length)
- return get_cbor_object(std::size_t(-1));
-
- case 0xF4: // false
- return sax->boolean(false);
-
- case 0xF5: // true
- return sax->boolean(true);
-
- case 0xF6: // null
- return sax->null();
-
- case 0xF9: // Half-Precision Float (two-byte IEEE 754)
- {
- const int byte1_raw = get();
- if (JSON_UNLIKELY(not unexpect_eof(input_format_t::cbor, "number")))
- {
- return false;
- }
- const int byte2_raw = get();
- if (JSON_UNLIKELY(not unexpect_eof(input_format_t::cbor, "number")))
- {
- return false;
- }
-
- const auto byte1 = static_cast<unsigned char>(byte1_raw);
- const auto byte2 = static_cast<unsigned char>(byte2_raw);
-
- // code from RFC 7049, Appendix D, Figure 3:
- // As half-precision floating-point numbers were only added
- // to IEEE 754 in 2008, today's programming platforms often
- // still only have limited support for them. It is very
- // easy to include at least decoding support for them even
- // without such support. An example of a small decoder for
- // half-precision floating-point numbers in the C language
- // is shown in Fig. 3.
- const auto half = static_cast<unsigned int>((byte1 << 8u) + byte2);
- const double val = [&half]
- {
- const int exp = (half >> 10u) & 0x1Fu;
- const unsigned int mant = half & 0x3FFu;
- assert(0 <= exp and exp <= 32);
- assert(0 <= mant and mant <= 1024);
- switch (exp)
- {
- case 0:
- return std::ldexp(mant, -24);
- case 31:
- return (mant == 0)
- ? std::numeric_limits<double>::infinity()
- : std::numeric_limits<double>::quiet_NaN();
- default:
- return std::ldexp(mant + 1024, exp - 25);
- }
- }();
- return sax->number_float((half & 0x8000u) != 0
- ? static_cast<number_float_t>(-val)
- : static_cast<number_float_t>(val), "");
- }
-
- case 0xFA: // Single-Precision Float (four-byte IEEE 754)
- {
- float number;
- return get_number(input_format_t::cbor, number) and sax->number_float(static_cast<number_float_t>(number), "");
- }
-
- case 0xFB: // Double-Precision Float (eight-byte IEEE 754)
- {
- double number;
- return get_number(input_format_t::cbor, number) and sax->number_float(static_cast<number_float_t>(number), "");
- }
-
- default: // anything else (0xFF is handled inside the other types)
- {
- auto last_token = get_token_string();
- return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::cbor, "invalid byte: 0x" + last_token, "value")));
- }
- }
- }
-
- /*!
- @brief reads a CBOR string
-
- This function first reads starting bytes to determine the expected
- string length and then copies this number of bytes into a string.
- Additionally, CBOR's strings with indefinite lengths are supported.
-
- @param[out] result created string
-
- @return whether string creation completed
- */
- bool get_cbor_string(string_t& result)
- {
- if (JSON_UNLIKELY(not unexpect_eof(input_format_t::cbor, "string")))
- {
- return false;
- }
-
- switch (current)
- {
- // UTF-8 string (0x00..0x17 bytes follow)
- case 0x60:
- case 0x61:
- case 0x62:
- case 0x63:
- case 0x64:
- case 0x65:
- case 0x66:
- case 0x67:
- case 0x68:
- case 0x69:
- case 0x6A:
- case 0x6B:
- case 0x6C:
- case 0x6D:
- case 0x6E:
- case 0x6F:
- case 0x70:
- case 0x71:
- case 0x72:
- case 0x73:
- case 0x74:
- case 0x75:
- case 0x76:
- case 0x77:
- {
- return get_string(input_format_t::cbor, static_cast<unsigned int>(current) & 0x1Fu, result);
- }
-
- case 0x78: // UTF-8 string (one-byte uint8_t for n follows)
- {
- std::uint8_t len;
- return get_number(input_format_t::cbor, len) and get_string(input_format_t::cbor, len, result);
- }
-
- case 0x79: // UTF-8 string (two-byte uint16_t for n follow)
- {
- std::uint16_t len;
- return get_number(input_format_t::cbor, len) and get_string(input_format_t::cbor, len, result);
- }
-
- case 0x7A: // UTF-8 string (four-byte uint32_t for n follow)
- {
- std::uint32_t len;
- return get_number(input_format_t::cbor, len) and get_string(input_format_t::cbor, len, result);
- }
-
- case 0x7B: // UTF-8 string (eight-byte uint64_t for n follow)
- {
- std::uint64_t len;
- return get_number(input_format_t::cbor, len) and get_string(input_format_t::cbor, len, result);
- }
-
- case 0x7F: // UTF-8 string (indefinite length)
- {
- while (get() != 0xFF)
- {
- string_t chunk;
- if (not get_cbor_string(chunk))
- {
- return false;
- }
- result.append(chunk);
- }
- return true;
- }
-
- default:
- {
- auto last_token = get_token_string();
- return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::cbor, "expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x" + last_token, "string")));
- }
- }
- }
-
- /*!
- @param[in] len the length of the array or std::size_t(-1) for an
- array of indefinite size
- @return whether array creation completed
- */
- bool get_cbor_array(const std::size_t len)
- {
- if (JSON_UNLIKELY(not sax->start_array(len)))
- {
- return false;
- }
-
- if (len != std::size_t(-1))
- {
- for (std::size_t i = 0; i < len; ++i)
- {
- if (JSON_UNLIKELY(not parse_cbor_internal()))
- {
- return false;
- }
- }
- }
- else
- {
- while (get() != 0xFF)
- {
- if (JSON_UNLIKELY(not parse_cbor_internal(false)))
- {
- return false;
- }
- }
- }
-
- return sax->end_array();
- }
-
- /*!
- @param[in] len the length of the object or std::size_t(-1) for an
- object of indefinite size
- @return whether object creation completed
- */
- bool get_cbor_object(const std::size_t len)
- {
- if (JSON_UNLIKELY(not sax->start_object(len)))
- {
- return false;
- }
-
- string_t key;
- if (len != std::size_t(-1))
- {
- for (std::size_t i = 0; i < len; ++i)
- {
- get();
- if (JSON_UNLIKELY(not get_cbor_string(key) or not sax->key(key)))
- {
- return false;
- }
-
- if (JSON_UNLIKELY(not parse_cbor_internal()))
- {
- return false;
- }
- key.clear();
- }
- }
- else
- {
- while (get() != 0xFF)
- {
- if (JSON_UNLIKELY(not get_cbor_string(key) or not sax->key(key)))
- {
- return false;
- }
-
- if (JSON_UNLIKELY(not parse_cbor_internal()))
- {
- return false;
- }
- key.clear();
- }
- }
-
- return sax->end_object();
- }
-
- /////////////
- // MsgPack //
- /////////////
-
- /*!
- @return whether a valid MessagePack value was passed to the SAX parser
- */
- bool parse_msgpack_internal()
- {
- switch (get())
- {
- // EOF
- case std::char_traits<char>::eof():
- return unexpect_eof(input_format_t::msgpack, "value");
-
- // positive fixint
- case 0x00:
- case 0x01:
- case 0x02:
- case 0x03:
- case 0x04:
- case 0x05:
- case 0x06:
- case 0x07:
- case 0x08:
- case 0x09:
- case 0x0A:
- case 0x0B:
- case 0x0C:
- case 0x0D:
- case 0x0E:
- case 0x0F:
- case 0x10:
- case 0x11:
- case 0x12:
- case 0x13:
- case 0x14:
- case 0x15:
- case 0x16:
- case 0x17:
- case 0x18:
- case 0x19:
- case 0x1A:
- case 0x1B:
- case 0x1C:
- case 0x1D:
- case 0x1E:
- case 0x1F:
- case 0x20:
- case 0x21:
- case 0x22:
- case 0x23:
- case 0x24:
- case 0x25:
- case 0x26:
- case 0x27:
- case 0x28:
- case 0x29:
- case 0x2A:
- case 0x2B:
- case 0x2C:
- case 0x2D:
- case 0x2E:
- case 0x2F:
- case 0x30:
- case 0x31:
- case 0x32:
- case 0x33:
- case 0x34:
- case 0x35:
- case 0x36:
- case 0x37:
- case 0x38:
- case 0x39:
- case 0x3A:
- case 0x3B:
- case 0x3C:
- case 0x3D:
- case 0x3E:
- case 0x3F:
- case 0x40:
- case 0x41:
- case 0x42:
- case 0x43:
- case 0x44:
- case 0x45:
- case 0x46:
- case 0x47:
- case 0x48:
- case 0x49:
- case 0x4A:
- case 0x4B:
- case 0x4C:
- case 0x4D:
- case 0x4E:
- case 0x4F:
- case 0x50:
- case 0x51:
- case 0x52:
- case 0x53:
- case 0x54:
- case 0x55:
- case 0x56:
- case 0x57:
- case 0x58:
- case 0x59:
- case 0x5A:
- case 0x5B:
- case 0x5C:
- case 0x5D:
- case 0x5E:
- case 0x5F:
- case 0x60:
- case 0x61:
- case 0x62:
- case 0x63:
- case 0x64:
- case 0x65:
- case 0x66:
- case 0x67:
- case 0x68:
- case 0x69:
- case 0x6A:
- case 0x6B:
- case 0x6C:
- case 0x6D:
- case 0x6E:
- case 0x6F:
- case 0x70:
- case 0x71:
- case 0x72:
- case 0x73:
- case 0x74:
- case 0x75:
- case 0x76:
- case 0x77:
- case 0x78:
- case 0x79:
- case 0x7A:
- case 0x7B:
- case 0x7C:
- case 0x7D:
- case 0x7E:
- case 0x7F:
- return sax->number_unsigned(static_cast<number_unsigned_t>(current));
-
- // fixmap
- case 0x80:
- case 0x81:
- case 0x82:
- case 0x83:
- case 0x84:
- case 0x85:
- case 0x86:
- case 0x87:
- case 0x88:
- case 0x89:
- case 0x8A:
- case 0x8B:
- case 0x8C:
- case 0x8D:
- case 0x8E:
- case 0x8F:
- return get_msgpack_object(static_cast<std::size_t>(static_cast<unsigned int>(current) & 0x0Fu));
-
- // fixarray
- case 0x90:
- case 0x91:
- case 0x92:
- case 0x93:
- case 0x94:
- case 0x95:
- case 0x96:
- case 0x97:
- case 0x98:
- case 0x99:
- case 0x9A:
- case 0x9B:
- case 0x9C:
- case 0x9D:
- case 0x9E:
- case 0x9F:
- return get_msgpack_array(static_cast<std::size_t>(static_cast<unsigned int>(current) & 0x0Fu));
-
- // fixstr
- case 0xA0:
- case 0xA1:
- case 0xA2:
- case 0xA3:
- case 0xA4:
- case 0xA5:
- case 0xA6:
- case 0xA7:
- case 0xA8:
- case 0xA9:
- case 0xAA:
- case 0xAB:
- case 0xAC:
- case 0xAD:
- case 0xAE:
- case 0xAF:
- case 0xB0:
- case 0xB1:
- case 0xB2:
- case 0xB3:
- case 0xB4:
- case 0xB5:
- case 0xB6:
- case 0xB7:
- case 0xB8:
- case 0xB9:
- case 0xBA:
- case 0xBB:
- case 0xBC:
- case 0xBD:
- case 0xBE:
- case 0xBF:
- {
- string_t s;
- return get_msgpack_string(s) and sax->string(s);
- }
-
- case 0xC0: // nil
- return sax->null();
-
- case 0xC2: // false
- return sax->boolean(false);
-
- case 0xC3: // true
- return sax->boolean(true);
-
- case 0xCA: // float 32
- {
- float number;
- return get_number(input_format_t::msgpack, number) and sax->number_float(static_cast<number_float_t>(number), "");
- }
-
- case 0xCB: // float 64
- {
- double number;
- return get_number(input_format_t::msgpack, number) and sax->number_float(static_cast<number_float_t>(number), "");
- }
-
- case 0xCC: // uint 8
- {
- std::uint8_t number;
- return get_number(input_format_t::msgpack, number) and sax->number_unsigned(number);
- }
-
- case 0xCD: // uint 16
- {
- std::uint16_t number;
- return get_number(input_format_t::msgpack, number) and sax->number_unsigned(number);
- }
-
- case 0xCE: // uint 32
- {
- std::uint32_t number;
- return get_number(input_format_t::msgpack, number) and sax->number_unsigned(number);
- }
-
- case 0xCF: // uint 64
- {
- std::uint64_t number;
- return get_number(input_format_t::msgpack, number) and sax->number_unsigned(number);
- }
-
- case 0xD0: // int 8
- {
- std::int8_t number;
- return get_number(input_format_t::msgpack, number) and sax->number_integer(number);
- }
-
- case 0xD1: // int 16
- {
- std::int16_t number;
- return get_number(input_format_t::msgpack, number) and sax->number_integer(number);
- }
-
- case 0xD2: // int 32
- {
- std::int32_t number;
- return get_number(input_format_t::msgpack, number) and sax->number_integer(number);
- }
-
- case 0xD3: // int 64
- {
- std::int64_t number;
- return get_number(input_format_t::msgpack, number) and sax->number_integer(number);
- }
-
- case 0xD9: // str 8
- case 0xDA: // str 16
- case 0xDB: // str 32
- {
- string_t s;
- return get_msgpack_string(s) and sax->string(s);
- }
-
- case 0xDC: // array 16
- {
- std::uint16_t len;
- return get_number(input_format_t::msgpack, len) and get_msgpack_array(static_cast<std::size_t>(len));
- }
-
- case 0xDD: // array 32
- {
- std::uint32_t len;
- return get_number(input_format_t::msgpack, len) and get_msgpack_array(static_cast<std::size_t>(len));
- }
-
- case 0xDE: // map 16
- {
- std::uint16_t len;
- return get_number(input_format_t::msgpack, len) and get_msgpack_object(static_cast<std::size_t>(len));
- }
-
- case 0xDF: // map 32
- {
- std::uint32_t len;
- return get_number(input_format_t::msgpack, len) and get_msgpack_object(static_cast<std::size_t>(len));
- }
-
- // negative fixint
- case 0xE0:
- case 0xE1:
- case 0xE2:
- case 0xE3:
- case 0xE4:
- case 0xE5:
- case 0xE6:
- case 0xE7:
- case 0xE8:
- case 0xE9:
- case 0xEA:
- case 0xEB:
- case 0xEC:
- case 0xED:
- case 0xEE:
- case 0xEF:
- case 0xF0:
- case 0xF1:
- case 0xF2:
- case 0xF3:
- case 0xF4:
- case 0xF5:
- case 0xF6:
- case 0xF7:
- case 0xF8:
- case 0xF9:
- case 0xFA:
- case 0xFB:
- case 0xFC:
- case 0xFD:
- case 0xFE:
- case 0xFF:
- return sax->number_integer(static_cast<std::int8_t>(current));
-
- default: // anything else
- {
- auto last_token = get_token_string();
- return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::msgpack, "invalid byte: 0x" + last_token, "value")));
- }
- }
- }
-
- /*!
- @brief reads a MessagePack string
-
- This function first reads starting bytes to determine the expected
- string length and then copies this number of bytes into a string.
-
- @param[out] result created string
-
- @return whether string creation completed
- */
- bool get_msgpack_string(string_t& result)
- {
- if (JSON_UNLIKELY(not unexpect_eof(input_format_t::msgpack, "string")))
- {
- return false;
- }
-
- switch (current)
- {
- // fixstr
- case 0xA0:
- case 0xA1:
- case 0xA2:
- case 0xA3:
- case 0xA4:
- case 0xA5:
- case 0xA6:
- case 0xA7:
- case 0xA8:
- case 0xA9:
- case 0xAA:
- case 0xAB:
- case 0xAC:
- case 0xAD:
- case 0xAE:
- case 0xAF:
- case 0xB0:
- case 0xB1:
- case 0xB2:
- case 0xB3:
- case 0xB4:
- case 0xB5:
- case 0xB6:
- case 0xB7:
- case 0xB8:
- case 0xB9:
- case 0xBA:
- case 0xBB:
- case 0xBC:
- case 0xBD:
- case 0xBE:
- case 0xBF:
- {
- return get_string(input_format_t::msgpack, static_cast<unsigned int>(current) & 0x1Fu, result);
- }
-
- case 0xD9: // str 8
- {
- std::uint8_t len;
- return get_number(input_format_t::msgpack, len) and get_string(input_format_t::msgpack, len, result);
- }
-
- case 0xDA: // str 16
- {
- std::uint16_t len;
- return get_number(input_format_t::msgpack, len) and get_string(input_format_t::msgpack, len, result);
- }
-
- case 0xDB: // str 32
- {
- std::uint32_t len;
- return get_number(input_format_t::msgpack, len) and get_string(input_format_t::msgpack, len, result);
- }
-
- default:
- {
- auto last_token = get_token_string();
- return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::msgpack, "expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0x" + last_token, "string")));
- }
- }
- }
-
- /*!
- @param[in] len the length of the array
- @return whether array creation completed
- */
- bool get_msgpack_array(const std::size_t len)
- {
- if (JSON_UNLIKELY(not sax->start_array(len)))
- {
- return false;
- }
-
- for (std::size_t i = 0; i < len; ++i)
- {
- if (JSON_UNLIKELY(not parse_msgpack_internal()))
- {
- return false;
- }
- }
-
- return sax->end_array();
- }
-
- /*!
- @param[in] len the length of the object
- @return whether object creation completed
- */
- bool get_msgpack_object(const std::size_t len)
- {
- if (JSON_UNLIKELY(not sax->start_object(len)))
- {
- return false;
- }
-
- string_t key;
- for (std::size_t i = 0; i < len; ++i)
- {
- get();
- if (JSON_UNLIKELY(not get_msgpack_string(key) or not sax->key(key)))
- {
- return false;
- }
-
- if (JSON_UNLIKELY(not parse_msgpack_internal()))
- {
- return false;
- }
- key.clear();
- }
-
- return sax->end_object();
- }
-
- ////////////
- // UBJSON //
- ////////////
-
- /*!
- @param[in] get_char whether a new character should be retrieved from the
- input (true, default) or whether the last read
- character should be considered instead
-
- @return whether a valid UBJSON value was passed to the SAX parser
- */
- bool parse_ubjson_internal(const bool get_char = true)
- {
- return get_ubjson_value(get_char ? get_ignore_noop() : current);
- }
-
- /*!
- @brief reads a UBJSON string
-
- This function is either called after reading the 'S' byte explicitly
- indicating a string, or in case of an object key where the 'S' byte can be
- left out.
-
- @param[out] result created string
- @param[in] get_char whether a new character should be retrieved from the
- input (true, default) or whether the last read
- character should be considered instead
-
- @return whether string creation completed
- */
- bool get_ubjson_string(string_t& result, const bool get_char = true)
- {
- if (get_char)
- {
- get(); // TODO(niels): may we ignore N here?
- }
-
- if (JSON_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "value")))
- {
- return false;
- }
-
- switch (current)
- {
- case 'U':
- {
- std::uint8_t len;
- return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result);
- }
-
- case 'i':
- {
- std::int8_t len;
- return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result);
- }
-
- case 'I':
- {
- std::int16_t len;
- return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result);
- }
-
- case 'l':
- {
- std::int32_t len;
- return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result);
- }
-
- case 'L':
- {
- std::int64_t len;
- return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result);
- }
-
- default:
- auto last_token = get_token_string();
- return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::ubjson, "expected length type specification (U, i, I, l, L); last byte: 0x" + last_token, "string")));
- }
- }
-
- /*!
- @param[out] result determined size
- @return whether size determination completed
- */
- bool get_ubjson_size_value(std::size_t& result)
- {
- switch (get_ignore_noop())
- {
- case 'U':
- {
- std::uint8_t number;
- if (JSON_UNLIKELY(not get_number(input_format_t::ubjson, number)))
- {
- return false;
- }
- result = static_cast<std::size_t>(number);
- return true;
- }
-
- case 'i':
- {
- std::int8_t number;
- if (JSON_UNLIKELY(not get_number(input_format_t::ubjson, number)))
- {
- return false;
- }
- result = static_cast<std::size_t>(number);
- return true;
- }
-
- case 'I':
- {
- std::int16_t number;
- if (JSON_UNLIKELY(not get_number(input_format_t::ubjson, number)))
- {
- return false;
- }
- result = static_cast<std::size_t>(number);
- return true;
- }
-
- case 'l':
- {
- std::int32_t number;
- if (JSON_UNLIKELY(not get_number(input_format_t::ubjson, number)))
- {
- return false;
- }
- result = static_cast<std::size_t>(number);
- return true;
- }
-
- case 'L':
- {
- std::int64_t number;
- if (JSON_UNLIKELY(not get_number(input_format_t::ubjson, number)))
- {
- return false;
- }
- result = static_cast<std::size_t>(number);
- return true;
- }
-
- default:
- {
- auto last_token = get_token_string();
- return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::ubjson, "expected length type specification (U, i, I, l, L) after '#'; last byte: 0x" + last_token, "size")));
- }
- }
- }
-
- /*!
- @brief determine the type and size for a container
-
- In the optimized UBJSON format, a type and a size can be provided to allow
- for a more compact representation.
-
- @param[out] result pair of the size and the type
-
- @return whether pair creation completed
- */
- bool get_ubjson_size_type(std::pair<std::size_t, int>& result)
- {
- result.first = string_t::npos; // size
- result.second = 0; // type
-
- get_ignore_noop();
-
- if (current == '$')
- {
- result.second = get(); // must not ignore 'N', because 'N' maybe the type
- if (JSON_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "type")))
- {
- return false;
- }
-
- get_ignore_noop();
- if (JSON_UNLIKELY(current != '#'))
- {
- if (JSON_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "value")))
- {
- return false;
- }
- auto last_token = get_token_string();
- return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::ubjson, "expected '#' after type information; last byte: 0x" + last_token, "size")));
- }
-
- return get_ubjson_size_value(result.first);
- }
-
- if (current == '#')
- {
- return get_ubjson_size_value(result.first);
- }
-
- return true;
- }
-
- /*!
- @param prefix the previously read or set type prefix
- @return whether value creation completed
- */
- bool get_ubjson_value(const int prefix)
- {
- switch (prefix)
- {
- case std::char_traits<char>::eof(): // EOF
- return unexpect_eof(input_format_t::ubjson, "value");
-
- case 'T': // true
- return sax->boolean(true);
- case 'F': // false
- return sax->boolean(false);
-
- case 'Z': // null
- return sax->null();
-
- case 'U':
- {
- std::uint8_t number;
- return get_number(input_format_t::ubjson, number) and sax->number_unsigned(number);
- }
-
- case 'i':
- {
- std::int8_t number;
- return get_number(input_format_t::ubjson, number) and sax->number_integer(number);
- }
-
- case 'I':
- {
- std::int16_t number;
- return get_number(input_format_t::ubjson, number) and sax->number_integer(number);
- }
-
- case 'l':
- {
- std::int32_t number;
- return get_number(input_format_t::ubjson, number) and sax->number_integer(number);
- }
-
- case 'L':
- {
- std::int64_t number;
- return get_number(input_format_t::ubjson, number) and sax->number_integer(number);
- }
-
- case 'd':
- {
- float number;
- return get_number(input_format_t::ubjson, number) and sax->number_float(static_cast<number_float_t>(number), "");
- }
-
- case 'D':
- {
- double number;
- return get_number(input_format_t::ubjson, number) and sax->number_float(static_cast<number_float_t>(number), "");
- }
-
- case 'C': // char
- {
- get();
- if (JSON_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "char")))
- {
- return false;
- }
- if (JSON_UNLIKELY(current > 127))
- {
- auto last_token = get_token_string();
- return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::ubjson, "byte after 'C' must be in range 0x00..0x7F; last byte: 0x" + last_token, "char")));
- }
- string_t s(1, static_cast<char>(current));
- return sax->string(s);
- }
-
- case 'S': // string
- {
- string_t s;
- return get_ubjson_string(s) and sax->string(s);
- }
-
- case '[': // array
- return get_ubjson_array();
-
- case '{': // object
- return get_ubjson_object();
-
- default: // anything else
- {
- auto last_token = get_token_string();
- return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::ubjson, "invalid byte: 0x" + last_token, "value")));
- }
- }
- }
-
- /*!
- @return whether array creation completed
- */
- bool get_ubjson_array()
- {
- std::pair<std::size_t, int> size_and_type;
- if (JSON_UNLIKELY(not get_ubjson_size_type(size_and_type)))
- {
- return false;
- }
-
- if (size_and_type.first != string_t::npos)
- {
- if (JSON_UNLIKELY(not sax->start_array(size_and_type.first)))
- {
- return false;
- }
-
- if (size_and_type.second != 0)
- {
- if (size_and_type.second != 'N')
- {
- for (std::size_t i = 0; i < size_and_type.first; ++i)
- {
- if (JSON_UNLIKELY(not get_ubjson_value(size_and_type.second)))
- {
- return false;
- }
- }
- }
- }
- else
- {
- for (std::size_t i = 0; i < size_and_type.first; ++i)
- {
- if (JSON_UNLIKELY(not parse_ubjson_internal()))
- {
- return false;
- }
- }
- }
- }
- else
- {
- if (JSON_UNLIKELY(not sax->start_array(std::size_t(-1))))
- {
- return false;
- }
-
- while (current != ']')
- {
- if (JSON_UNLIKELY(not parse_ubjson_internal(false)))
- {
- return false;
- }
- get_ignore_noop();
- }
- }
-
- return sax->end_array();
- }
-
- /*!
- @return whether object creation completed
- */
- bool get_ubjson_object()
- {
- std::pair<std::size_t, int> size_and_type;
- if (JSON_UNLIKELY(not get_ubjson_size_type(size_and_type)))
- {
- return false;
- }
-
- string_t key;
- if (size_and_type.first != string_t::npos)
- {
- if (JSON_UNLIKELY(not sax->start_object(size_and_type.first)))
- {
- return false;
- }
-
- if (size_and_type.second != 0)
- {
- for (std::size_t i = 0; i < size_and_type.first; ++i)
- {
- if (JSON_UNLIKELY(not get_ubjson_string(key) or not sax->key(key)))
- {
- return false;
- }
- if (JSON_UNLIKELY(not get_ubjson_value(size_and_type.second)))
- {
- return false;
- }
- key.clear();
- }
- }
- else
- {
- for (std::size_t i = 0; i < size_and_type.first; ++i)
- {
- if (JSON_UNLIKELY(not get_ubjson_string(key) or not sax->key(key)))
- {
- return false;
- }
- if (JSON_UNLIKELY(not parse_ubjson_internal()))
- {
- return false;
- }
- key.clear();
- }
- }
- }
- else
- {
- if (JSON_UNLIKELY(not sax->start_object(std::size_t(-1))))
- {
- return false;
- }
-
- while (current != '}')
- {
- if (JSON_UNLIKELY(not get_ubjson_string(key, false) or not sax->key(key)))
- {
- return false;
- }
- if (JSON_UNLIKELY(not parse_ubjson_internal()))
- {
- return false;
- }
- get_ignore_noop();
- key.clear();
- }
- }
-
- return sax->end_object();
- }
-
- ///////////////////////
- // Utility functions //
- ///////////////////////
-
- /*!
- @brief get next character from the input
-
- This function provides the interface to the used input adapter. It does
- not throw in case the input reached EOF, but returns a -'ve valued
- `std::char_traits<char>::eof()` in that case.
-
- @return character read from the input
- */
- int get()
- {
- ++chars_read;
- return current = ia->get_character();
- }
-
- /*!
- @return character read from the input after ignoring all 'N' entries
- */
- int get_ignore_noop()
- {
- do
- {
- get();
- }
- while (current == 'N');
-
- return current;
- }
-
- /*
- @brief read a number from the input
-
- @tparam NumberType the type of the number
- @param[in] format the current format (for diagnostics)
- @param[out] result number of type @a NumberType
-
- @return whether conversion completed
-
- @note This function needs to respect the system's endianess, because
- bytes in CBOR, MessagePack, and UBJSON are stored in network order
- (big endian) and therefore need reordering on little endian systems.
- */
- template<typename NumberType, bool InputIsLittleEndian = false>
- bool get_number(const input_format_t format, NumberType& result)
- {
- // step 1: read input into array with system's byte order
- std::array<std::uint8_t, sizeof(NumberType)> vec;
- for (std::size_t i = 0; i < sizeof(NumberType); ++i)
- {
- get();
- if (JSON_UNLIKELY(not unexpect_eof(format, "number")))
- {
- return false;
- }
-
- // reverse byte order prior to conversion if necessary
- if (is_little_endian != InputIsLittleEndian)
- {
- vec[sizeof(NumberType) - i - 1] = static_cast<std::uint8_t>(current);
- }
- else
- {
- vec[i] = static_cast<std::uint8_t>(current); // LCOV_EXCL_LINE
- }
- }
-
- // step 2: convert array into number of type T and return
- std::memcpy(&result, vec.data(), sizeof(NumberType));
- return true;
- }
-
- /*!
- @brief create a string by reading characters from the input
-
- @tparam NumberType the type of the number
- @param[in] format the current format (for diagnostics)
- @param[in] len number of characters to read
- @param[out] result string created by reading @a len bytes
-
- @return whether string creation completed
-
- @note We can not reserve @a len bytes for the result, because @a len
- may be too large. Usually, @ref unexpect_eof() detects the end of
- the input before we run out of string memory.
- */
- template<typename NumberType>
- bool get_string(const input_format_t format,
- const NumberType len,
- string_t& result)
- {
- bool success = true;
- std::generate_n(std::back_inserter(result), len, [this, &success, &format]()
- {
- get();
- if (JSON_UNLIKELY(not unexpect_eof(format, "string")))
- {
- success = false;
- }
- return static_cast<char>(current);
- });
- return success;
- }
-
- /*!
- @param[in] format the current format (for diagnostics)
- @param[in] context further context information (for diagnostics)
- @return whether the last read character is not EOF
- */
- bool unexpect_eof(const input_format_t format, const char* context) const
- {
- if (JSON_UNLIKELY(current == std::char_traits<char>::eof()))
- {
- return sax->parse_error(chars_read, "<end of file>",
- parse_error::create(110, chars_read, exception_message(format, "unexpected end of input", context)));
- }
- return true;
- }
-
- /*!
- @return a string representation of the last read byte
- */
- std::string get_token_string() const
- {
- std::array<char, 3> cr{{}};
- (std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast<unsigned char>(current));
- return std::string{cr.data()};
- }
-
- /*!
- @param[in] format the current format
- @param[in] detail a detailed error message
- @param[in] context further contect information
- @return a message string to use in the parse_error exceptions
- */
- std::string exception_message(const input_format_t format,
- const std::string& detail,
- const std::string& context) const
- {
- std::string error_msg = "syntax error while parsing ";
-
- switch (format)
- {
- case input_format_t::cbor:
- error_msg += "CBOR";
- break;
-
- case input_format_t::msgpack:
- error_msg += "MessagePack";
- break;
-
- case input_format_t::ubjson:
- error_msg += "UBJSON";
- break;
-
- case input_format_t::bson:
- error_msg += "BSON";
- break;
-
- default: // LCOV_EXCL_LINE
- assert(false); // LCOV_EXCL_LINE
- }
-
- return error_msg + " " + context + ": " + detail;
- }
-
- private:
- /// input adapter
- input_adapter_t ia = nullptr;
-
- /// the current character
- int current = std::char_traits<char>::eof();
-
- /// the number of characters read
- std::size_t chars_read = 0;
-
- /// whether we can assume little endianess
- const bool is_little_endian = little_endianess();
-
- /// the SAX parser
- json_sax_t* sax = nullptr;
-};
-} // namespace detail
-} // namespace nlohmann
-
-// #include <nlohmann/detail/input/input_adapters.hpp>
-
-// #include <nlohmann/detail/input/lexer.hpp>
-
-
-#include <array> // array
-#include <clocale> // localeconv
-#include <cstddef> // size_t
-#include <cstdio> // snprintf
-#include <cstdlib> // strtof, strtod, strtold, strtoll, strtoull
-#include <initializer_list> // initializer_list
-#include <string> // char_traits, string
-#include <utility> // move
-#include <vector> // vector
-
-// #include <nlohmann/detail/input/input_adapters.hpp>
-
-// #include <nlohmann/detail/input/position_t.hpp>
-
-// #include <nlohmann/detail/macro_scope.hpp>
-
-
-namespace nlohmann
-{
-namespace detail
-{
-///////////
-// lexer //
-///////////
-
-/*!
-@brief lexical analysis
-
-This class organizes the lexical analysis during JSON deserialization.
-*/
-template<typename BasicJsonType>
-class lexer
-{
- using number_integer_t = typename BasicJsonType::number_integer_t;
- using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
- using number_float_t = typename BasicJsonType::number_float_t;
- using string_t = typename BasicJsonType::string_t;
-
- public:
- /// token types for the parser
- enum class token_type
- {
- uninitialized, ///< indicating the scanner is uninitialized
- literal_true, ///< the `true` literal
- literal_false, ///< the `false` literal
- literal_null, ///< the `null` literal
- value_string, ///< a string -- use get_string() for actual value
- value_unsigned, ///< an unsigned integer -- use get_number_unsigned() for actual value
- value_integer, ///< a signed integer -- use get_number_integer() for actual value
- value_float, ///< an floating point number -- use get_number_float() for actual value
- begin_array, ///< the character for array begin `[`
- begin_object, ///< the character for object begin `{`
- end_array, ///< the character for array end `]`
- end_object, ///< the character for object end `}`
- name_separator, ///< the name separator `:`
- value_separator, ///< the value separator `,`
- parse_error, ///< indicating a parse error
- end_of_input, ///< indicating the end of the input buffer
- literal_or_value ///< a literal or the begin of a value (only for diagnostics)
- };
-
- /// return name of values of type token_type (only used for errors)
- static const char* token_type_name(const token_type t) noexcept
- {
- switch (t)
- {
- case token_type::uninitialized:
- return "<uninitialized>";
- case token_type::literal_true:
- return "true literal";
- case token_type::literal_false:
- return "false literal";
- case token_type::literal_null:
- return "null literal";
- case token_type::value_string:
- return "string literal";
- case lexer::token_type::value_unsigned:
- case lexer::token_type::value_integer:
- case lexer::token_type::value_float:
- return "number literal";
- case token_type::begin_array:
- return "'['";
- case token_type::begin_object:
- return "'{'";
- case token_type::end_array:
- return "']'";
- case token_type::end_object:
- return "'}'";
- case token_type::name_separator:
- return "':'";
- case token_type::value_separator:
- return "','";
- case token_type::parse_error:
- return "<parse error>";
- case token_type::end_of_input:
- return "end of input";
- case token_type::literal_or_value:
- return "'[', '{', or a literal";
- // LCOV_EXCL_START
- default: // catch non-enum values
- return "unknown token";
- // LCOV_EXCL_STOP
- }
- }
-
- explicit lexer(detail::input_adapter_t&& adapter)
- : ia(std::move(adapter)), decimal_point_char(get_decimal_point()) {}
-
- // delete because of pointer members
- lexer(const lexer&) = delete;
- lexer(lexer&&) = delete;
- lexer& operator=(lexer&) = delete;
- lexer& operator=(lexer&&) = delete;
- ~lexer() = default;
-
- private:
- /////////////////////
- // locales
- /////////////////////
-
- /// return the locale-dependent decimal point
- static char get_decimal_point() noexcept
- {
- const auto loc = localeconv();
- assert(loc != nullptr);
- return (loc->decimal_point == nullptr) ? '.' : *(loc->decimal_point);
- }
-
- /////////////////////
- // scan functions
- /////////////////////
-
- /*!
- @brief get codepoint from 4 hex characters following `\u`
-
- For input "\u c1 c2 c3 c4" the codepoint is:
- (c1 * 0x1000) + (c2 * 0x0100) + (c3 * 0x0010) + c4
- = (c1 << 12) + (c2 << 8) + (c3 << 4) + (c4 << 0)
-
- Furthermore, the possible characters '0'..'9', 'A'..'F', and 'a'..'f'
- must be converted to the integers 0x0..0x9, 0xA..0xF, 0xA..0xF, resp. The
- conversion is done by subtracting the offset (0x30, 0x37, and 0x57)
- between the ASCII value of the character and the desired integer value.
-
- @return codepoint (0x0000..0xFFFF) or -1 in case of an error (e.g. EOF or
- non-hex character)
- */
- int get_codepoint()
- {
- // this function only makes sense after reading `\u`
- assert(current == 'u');
- int codepoint = 0;
-
- const auto factors = { 12u, 8u, 4u, 0u };
- for (const auto factor : factors)
- {
- get();
-
- if (current >= '0' and current <= '9')
- {
- codepoint += static_cast<int>((static_cast<unsigned int>(current) - 0x30u) << factor);
- }
- else if (current >= 'A' and current <= 'F')
- {
- codepoint += static_cast<int>((static_cast<unsigned int>(current) - 0x37u) << factor);
- }
- else if (current >= 'a' and current <= 'f')
- {
- codepoint += static_cast<int>((static_cast<unsigned int>(current) - 0x57u) << factor);
- }
- else
- {
- return -1;
- }
- }
-
- assert(0x0000 <= codepoint and codepoint <= 0xFFFF);
- return codepoint;
- }
-
- /*!
- @brief check if the next byte(s) are inside a given range
-
- Adds the current byte and, for each passed range, reads a new byte and
- checks if it is inside the range. If a violation was detected, set up an
- error message and return false. Otherwise, return true.
-
- @param[in] ranges list of integers; interpreted as list of pairs of
- inclusive lower and upper bound, respectively
-
- @pre The passed list @a ranges must have 2, 4, or 6 elements; that is,
- 1, 2, or 3 pairs. This precondition is enforced by an assertion.
-
- @return true if and only if no range violation was detected
- */
- bool next_byte_in_range(std::initializer_list<int> ranges)
- {
- assert(ranges.size() == 2 or ranges.size() == 4 or ranges.size() == 6);
- add(current);
-
- for (auto range = ranges.begin(); range != ranges.end(); ++range)
- {
- get();
- if (JSON_LIKELY(*range <= current and current <= *(++range)))
- {
- add(current);
- }
- else
- {
- error_message = "invalid string: ill-formed UTF-8 byte";
- return false;
- }
- }
-
- return true;
- }
-
- /*!
- @brief scan a string literal
-
- This function scans a string according to Sect. 7 of RFC 7159. While
- scanning, bytes are escaped and copied into buffer token_buffer. Then the
- function returns successfully, token_buffer is *not* null-terminated (as it
- may contain \0 bytes), and token_buffer.size() is the number of bytes in the
- string.
-
- @return token_type::value_string if string could be successfully scanned,
- token_type::parse_error otherwise
-
- @note In case of errors, variable error_message contains a textual
- description.
- */
- token_type scan_string()
- {
- // reset token_buffer (ignore opening quote)
- reset();
-
- // we entered the function by reading an open quote
- assert(current == '\"');
-
- while (true)
- {
- // get next character
- switch (get())
- {
- // end of file while parsing string
- case std::char_traits<char>::eof():
- {
- error_message = "invalid string: missing closing quote";
- return token_type::parse_error;
- }
-
- // closing quote
- case '\"':
- {
- return token_type::value_string;
- }
-
- // escapes
- case '\\':
- {
- switch (get())
- {
- // quotation mark
- case '\"':
- add('\"');
- break;
- // reverse solidus
- case '\\':
- add('\\');
- break;
- // solidus
- case '/':
- add('/');
- break;
- // backspace
- case 'b':
- add('\b');
- break;
- // form feed
- case 'f':
- add('\f');
- break;
- // line feed
- case 'n':
- add('\n');
- break;
- // carriage return
- case 'r':
- add('\r');
- break;
- // tab
- case 't':
- add('\t');
- break;
-
- // unicode escapes
- case 'u':
- {
- const int codepoint1 = get_codepoint();
- int codepoint = codepoint1; // start with codepoint1
-
- if (JSON_UNLIKELY(codepoint1 == -1))
- {
- error_message = "invalid string: '\\u' must be followed by 4 hex digits";
- return token_type::parse_error;
- }
-
- // check if code point is a high surrogate
- if (0xD800 <= codepoint1 and codepoint1 <= 0xDBFF)
- {
- // expect next \uxxxx entry
- if (JSON_LIKELY(get() == '\\' and get() == 'u'))
- {
- const int codepoint2 = get_codepoint();
-
- if (JSON_UNLIKELY(codepoint2 == -1))
- {
- error_message = "invalid string: '\\u' must be followed by 4 hex digits";
- return token_type::parse_error;
- }
-
- // check if codepoint2 is a low surrogate
- if (JSON_LIKELY(0xDC00 <= codepoint2 and codepoint2 <= 0xDFFF))
- {
- // overwrite codepoint
- codepoint = static_cast<int>(
- // high surrogate occupies the most significant 22 bits
- (static_cast<unsigned int>(codepoint1) << 10u)
- // low surrogate occupies the least significant 15 bits
- + static_cast<unsigned int>(codepoint2)
- // there is still the 0xD800, 0xDC00 and 0x10000 noise
- // in the result so we have to subtract with:
- // (0xD800 << 10) + DC00 - 0x10000 = 0x35FDC00
- - 0x35FDC00u);
- }
- else
- {
- error_message = "invalid string: surrogate U+DC00..U+DFFF must be followed by U+DC00..U+DFFF";
- return token_type::parse_error;
- }
- }
- else
- {
- error_message = "invalid string: surrogate U+DC00..U+DFFF must be followed by U+DC00..U+DFFF";
- return token_type::parse_error;
- }
- }
- else
- {
- if (JSON_UNLIKELY(0xDC00 <= codepoint1 and codepoint1 <= 0xDFFF))
- {
- error_message = "invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF";
- return token_type::parse_error;
- }
- }
-
- // result of the above calculation yields a proper codepoint
- assert(0x00 <= codepoint and codepoint <= 0x10FFFF);
-
- // translate codepoint into bytes
- if (codepoint < 0x80)
- {
- // 1-byte characters: 0xxxxxxx (ASCII)
- add(codepoint);
- }
- else if (codepoint <= 0x7FF)
- {
- // 2-byte characters: 110xxxxx 10xxxxxx
- add(static_cast<int>(0xC0u | (static_cast<unsigned int>(codepoint) >> 6u)));
- add(static_cast<int>(0x80u | (static_cast<unsigned int>(codepoint) & 0x3Fu)));
- }
- else if (codepoint <= 0xFFFF)
- {
- // 3-byte characters: 1110xxxx 10xxxxxx 10xxxxxx
- add(static_cast<int>(0xE0u | (static_cast<unsigned int>(codepoint) >> 12u)));
- add(static_cast<int>(0x80u | ((static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
- add(static_cast<int>(0x80u | (static_cast<unsigned int>(codepoint) & 0x3Fu)));
- }
- else
- {
- // 4-byte characters: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
- add(static_cast<int>(0xF0u | (static_cast<unsigned int>(codepoint) >> 18u)));
- add(static_cast<int>(0x80u | ((static_cast<unsigned int>(codepoint) >> 12u) & 0x3Fu)));
- add(static_cast<int>(0x80u | ((static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
- add(static_cast<int>(0x80u | (static_cast<unsigned int>(codepoint) & 0x3Fu)));
- }
-
- break;
- }
-
- // other characters after escape
- default:
- error_message = "invalid string: forbidden character after backslash";
- return token_type::parse_error;
- }
-
- break;
- }
-
- // invalid control characters
- case 0x00:
- {
- error_message = "invalid string: control character U+0000 (NUL) must be escaped to \\u0000";
- return token_type::parse_error;
- }
-
- case 0x01:
- {
- error_message = "invalid string: control character U+0001 (SOH) must be escaped to \\u0001";
- return token_type::parse_error;
- }
-
- case 0x02:
- {
- error_message = "invalid string: control character U+0002 (STX) must be escaped to \\u0002";
- return token_type::parse_error;
- }
-
- case 0x03:
- {
- error_message = "invalid string: control character U+0003 (ETX) must be escaped to \\u0003";
- return token_type::parse_error;
- }
-
- case 0x04:
- {
- error_message = "invalid string: control character U+0004 (EOT) must be escaped to \\u0004";
- return token_type::parse_error;
- }
-
- case 0x05:
- {
- error_message = "invalid string: control character U+0005 (ENQ) must be escaped to \\u0005";
- return token_type::parse_error;
- }
-
- case 0x06:
- {
- error_message = "invalid string: control character U+0006 (ACK) must be escaped to \\u0006";
- return token_type::parse_error;
- }
-
- case 0x07:
- {
- error_message = "invalid string: control character U+0007 (BEL) must be escaped to \\u0007";
- return token_type::parse_error;
- }
-
- case 0x08:
- {
- error_message = "invalid string: control character U+0008 (BS) must be escaped to \\u0008 or \\b";
- return token_type::parse_error;
- }
-
- case 0x09:
- {
- error_message = "invalid string: control character U+0009 (HT) must be escaped to \\u0009 or \\t";
- return token_type::parse_error;
- }
-
- case 0x0A:
- {
- error_message = "invalid string: control character U+000A (LF) must be escaped to \\u000A or \\n";
- return token_type::parse_error;
- }
-
- case 0x0B:
- {
- error_message = "invalid string: control character U+000B (VT) must be escaped to \\u000B";
- return token_type::parse_error;
- }
-
- case 0x0C:
- {
- error_message = "invalid string: control character U+000C (FF) must be escaped to \\u000C or \\f";
- return token_type::parse_error;
- }
-
- case 0x0D:
- {
- error_message = "invalid string: control character U+000D (CR) must be escaped to \\u000D or \\r";
- return token_type::parse_error;
- }
-
- case 0x0E:
- {
- error_message = "invalid string: control character U+000E (SO) must be escaped to \\u000E";
- return token_type::parse_error;
- }
-
- case 0x0F:
- {
- error_message = "invalid string: control character U+000F (SI) must be escaped to \\u000F";
- return token_type::parse_error;
- }
-
- case 0x10:
- {
- error_message = "invalid string: control character U+0010 (DLE) must be escaped to \\u0010";
- return token_type::parse_error;
- }
-
- case 0x11:
- {
- error_message = "invalid string: control character U+0011 (DC1) must be escaped to \\u0011";
- return token_type::parse_error;
- }
-
- case 0x12:
- {
- error_message = "invalid string: control character U+0012 (DC2) must be escaped to \\u0012";
- return token_type::parse_error;
- }
-
- case 0x13:
- {
- error_message = "invalid string: control character U+0013 (DC3) must be escaped to \\u0013";
- return token_type::parse_error;
- }
-
- case 0x14:
- {
- error_message = "invalid string: control character U+0014 (DC4) must be escaped to \\u0014";
- return token_type::parse_error;
- }
-
- case 0x15:
- {
- error_message = "invalid string: control character U+0015 (NAK) must be escaped to \\u0015";
- return token_type::parse_error;
- }
-
- case 0x16:
- {
- error_message = "invalid string: control character U+0016 (SYN) must be escaped to \\u0016";
- return token_type::parse_error;
- }
-
- case 0x17:
- {
- error_message = "invalid string: control character U+0017 (ETB) must be escaped to \\u0017";
- return token_type::parse_error;
- }
-
- case 0x18:
- {
- error_message = "invalid string: control character U+0018 (CAN) must be escaped to \\u0018";
- return token_type::parse_error;
- }
-
- case 0x19:
- {
- error_message = "invalid string: control character U+0019 (EM) must be escaped to \\u0019";
- return token_type::parse_error;
- }
-
- case 0x1A:
- {
- error_message = "invalid string: control character U+001A (SUB) must be escaped to \\u001A";
- return token_type::parse_error;
- }
-
- case 0x1B:
- {
- error_message = "invalid string: control character U+001B (ESC) must be escaped to \\u001B";
- return token_type::parse_error;
- }
-
- case 0x1C:
- {
- error_message = "invalid string: control character U+001C (FS) must be escaped to \\u001C";
- return token_type::parse_error;
- }
-
- case 0x1D:
- {
- error_message = "invalid string: control character U+001D (GS) must be escaped to \\u001D";
- return token_type::parse_error;
- }
-
- case 0x1E:
- {
- error_message = "invalid string: control character U+001E (RS) must be escaped to \\u001E";
- return token_type::parse_error;
- }
-
- case 0x1F:
- {
- error_message = "invalid string: control character U+001F (US) must be escaped to \\u001F";
- return token_type::parse_error;
- }
-
- // U+0020..U+007F (except U+0022 (quote) and U+005C (backspace))
- case 0x20:
- case 0x21:
- case 0x23:
- case 0x24:
- case 0x25:
- case 0x26:
- case 0x27:
- case 0x28:
- case 0x29:
- case 0x2A:
- case 0x2B:
- case 0x2C:
- case 0x2D:
- case 0x2E:
- case 0x2F:
- case 0x30:
- case 0x31:
- case 0x32:
- case 0x33:
- case 0x34:
- case 0x35:
- case 0x36:
- case 0x37:
- case 0x38:
- case 0x39:
- case 0x3A:
- case 0x3B:
- case 0x3C:
- case 0x3D:
- case 0x3E:
- case 0x3F:
- case 0x40:
- case 0x41:
- case 0x42:
- case 0x43:
- case 0x44:
- case 0x45:
- case 0x46:
- case 0x47:
- case 0x48:
- case 0x49:
- case 0x4A:
- case 0x4B:
- case 0x4C:
- case 0x4D:
- case 0x4E:
- case 0x4F:
- case 0x50:
- case 0x51:
- case 0x52:
- case 0x53:
- case 0x54:
- case 0x55:
- case 0x56:
- case 0x57:
- case 0x58:
- case 0x59:
- case 0x5A:
- case 0x5B:
- case 0x5D:
- case 0x5E:
- case 0x5F:
- case 0x60:
- case 0x61:
- case 0x62:
- case 0x63:
- case 0x64:
- case 0x65:
- case 0x66:
- case 0x67:
- case 0x68:
- case 0x69:
- case 0x6A:
- case 0x6B:
- case 0x6C:
- case 0x6D:
- case 0x6E:
- case 0x6F:
- case 0x70:
- case 0x71:
- case 0x72:
- case 0x73:
- case 0x74:
- case 0x75:
- case 0x76:
- case 0x77:
- case 0x78:
- case 0x79:
- case 0x7A:
- case 0x7B:
- case 0x7C:
- case 0x7D:
- case 0x7E:
- case 0x7F:
- {
- add(current);
- break;
- }
-
- // U+0080..U+07FF: bytes C2..DF 80..BF
- case 0xC2:
- case 0xC3:
- case 0xC4:
- case 0xC5:
- case 0xC6:
- case 0xC7:
- case 0xC8:
- case 0xC9:
- case 0xCA:
- case 0xCB:
- case 0xCC:
- case 0xCD:
- case 0xCE:
- case 0xCF:
- case 0xD0:
- case 0xD1:
- case 0xD2:
- case 0xD3:
- case 0xD4:
- case 0xD5:
- case 0xD6:
- case 0xD7:
- case 0xD8:
- case 0xD9:
- case 0xDA:
- case 0xDB:
- case 0xDC:
- case 0xDD:
- case 0xDE:
- case 0xDF:
- {
- if (JSON_UNLIKELY(not next_byte_in_range({0x80, 0xBF})))
- {
- return token_type::parse_error;
- }
- break;
- }
-
- // U+0800..U+0FFF: bytes E0 A0..BF 80..BF
- case 0xE0:
- {
- if (JSON_UNLIKELY(not (next_byte_in_range({0xA0, 0xBF, 0x80, 0xBF}))))
- {
- return token_type::parse_error;
- }
- break;
- }
-
- // U+1000..U+CFFF: bytes E1..EC 80..BF 80..BF
- // U+E000..U+FFFF: bytes EE..EF 80..BF 80..BF
- case 0xE1:
- case 0xE2:
- case 0xE3:
- case 0xE4:
- case 0xE5:
- case 0xE6:
- case 0xE7:
- case 0xE8:
- case 0xE9:
- case 0xEA:
- case 0xEB:
- case 0xEC:
- case 0xEE:
- case 0xEF:
- {
- if (JSON_UNLIKELY(not (next_byte_in_range({0x80, 0xBF, 0x80, 0xBF}))))
- {
- return token_type::parse_error;
- }
- break;
- }
-
- // U+D000..U+D7FF: bytes ED 80..9F 80..BF
- case 0xED:
- {
- if (JSON_UNLIKELY(not (next_byte_in_range({0x80, 0x9F, 0x80, 0xBF}))))
- {
- return token_type::parse_error;
- }
- break;
- }
-
- // U+10000..U+3FFFF F0 90..BF 80..BF 80..BF
- case 0xF0:
- {
- if (JSON_UNLIKELY(not (next_byte_in_range({0x90, 0xBF, 0x80, 0xBF, 0x80, 0xBF}))))
- {
- return token_type::parse_error;
- }
- break;
- }
-
- // U+40000..U+FFFFF F1..F3 80..BF 80..BF 80..BF
- case 0xF1:
- case 0xF2:
- case 0xF3:
- {
- if (JSON_UNLIKELY(not (next_byte_in_range({0x80, 0xBF, 0x80, 0xBF, 0x80, 0xBF}))))
- {
- return token_type::parse_error;
- }
- break;
- }
-
- // U+100000..U+10FFFF F4 80..8F 80..BF 80..BF
- case 0xF4:
- {
- if (JSON_UNLIKELY(not (next_byte_in_range({0x80, 0x8F, 0x80, 0xBF, 0x80, 0xBF}))))
- {
- return token_type::parse_error;
- }
- break;
- }
-
- // remaining bytes (80..C1 and F5..FF) are ill-formed
- default:
- {
- error_message = "invalid string: ill-formed UTF-8 byte";
- return token_type::parse_error;
- }
- }
- }
- }
-
- static void strtof(float& f, const char* str, char** endptr) noexcept
- {
- f = std::strtof(str, endptr);
- }
-
- static void strtof(double& f, const char* str, char** endptr) noexcept
- {
- f = std::strtod(str, endptr);
- }
-
- static void strtof(long double& f, const char* str, char** endptr) noexcept
- {
- f = std::strtold(str, endptr);
- }
-
- /*!
- @brief scan a number literal
-
- This function scans a string according to Sect. 6 of RFC 7159.
-
- The function is realized with a deterministic finite state machine derived
- from the grammar described in RFC 7159. Starting in state "init", the
- input is read and used to determined the next state. Only state "done"
- accepts the number. State "error" is a trap state to model errors. In the
- table below, "anything" means any character but the ones listed before.
-
- state | 0 | 1-9 | e E | + | - | . | anything
- ---------|----------|----------|----------|---------|---------|----------|-----------
- init | zero | any1 | [error] | [error] | minus | [error] | [error]
- minus | zero | any1 | [error] | [error] | [error] | [error] | [error]
- zero | done | done | exponent | done | done | decimal1 | done
- any1 | any1 | any1 | exponent | done | done | decimal1 | done
- decimal1 | decimal2 | [error] | [error] | [error] | [error] | [error] | [error]
- decimal2 | decimal2 | decimal2 | exponent | done | done | done | done
- exponent | any2 | any2 | [error] | sign | sign | [error] | [error]
- sign | any2 | any2 | [error] | [error] | [error] | [error] | [error]
- any2 | any2 | any2 | done | done | done | done | done
-
- The state machine is realized with one label per state (prefixed with
- "scan_number_") and `goto` statements between them. The state machine
- contains cycles, but any cycle can be left when EOF is read. Therefore,
- the function is guaranteed to terminate.
-
- During scanning, the read bytes are stored in token_buffer. This string is
- then converted to a signed integer, an unsigned integer, or a
- floating-point number.
-
- @return token_type::value_unsigned, token_type::value_integer, or
- token_type::value_float if number could be successfully scanned,
- token_type::parse_error otherwise
-
- @note The scanner is independent of the current locale. Internally, the
- locale's decimal point is used instead of `.` to work with the
- locale-dependent converters.
- */
- token_type scan_number() // lgtm [cpp/use-of-goto]
- {
- // reset token_buffer to store the number's bytes
- reset();
-
- // the type of the parsed number; initially set to unsigned; will be
- // changed if minus sign, decimal point or exponent is read
- token_type number_type = token_type::value_unsigned;
-
- // state (init): we just found out we need to scan a number
- switch (current)
- {
- case '-':
- {
- add(current);
- goto scan_number_minus;
- }
-
- case '0':
- {
- add(current);
- goto scan_number_zero;
- }
-
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- {
- add(current);
- goto scan_number_any1;
- }
-
- // all other characters are rejected outside scan_number()
- default: // LCOV_EXCL_LINE
- assert(false); // LCOV_EXCL_LINE
- }
-
-scan_number_minus:
- // state: we just parsed a leading minus sign
- number_type = token_type::value_integer;
- switch (get())
- {
- case '0':
- {
- add(current);
- goto scan_number_zero;
- }
-
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- {
- add(current);
- goto scan_number_any1;
- }
-
- default:
- {
- error_message = "invalid number; expected digit after '-'";
- return token_type::parse_error;
- }
- }
-
-scan_number_zero:
- // state: we just parse a zero (maybe with a leading minus sign)
- switch (get())
- {
- case '.':
- {
- add(decimal_point_char);
- goto scan_number_decimal1;
- }
-
- case 'e':
- case 'E':
- {
- add(current);
- goto scan_number_exponent;
- }
-
- default:
- goto scan_number_done;
- }
-
-scan_number_any1:
- // state: we just parsed a number 0-9 (maybe with a leading minus sign)
- switch (get())
- {
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- {
- add(current);
- goto scan_number_any1;
- }
-
- case '.':
- {
- add(decimal_point_char);
- goto scan_number_decimal1;
- }
-
- case 'e':
- case 'E':
- {
- add(current);
- goto scan_number_exponent;
- }
-
- default:
- goto scan_number_done;
- }
-
-scan_number_decimal1:
- // state: we just parsed a decimal point
- number_type = token_type::value_float;
- switch (get())
- {
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- {
- add(current);
- goto scan_number_decimal2;
- }
-
- default:
- {
- error_message = "invalid number; expected digit after '.'";
- return token_type::parse_error;
- }
- }
-
-scan_number_decimal2:
- // we just parsed at least one number after a decimal point
- switch (get())
- {
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- {
- add(current);
- goto scan_number_decimal2;
- }
-
- case 'e':
- case 'E':
- {
- add(current);
- goto scan_number_exponent;
- }
-
- default:
- goto scan_number_done;
- }
-
-scan_number_exponent:
- // we just parsed an exponent
- number_type = token_type::value_float;
- switch (get())
- {
- case '+':
- case '-':
- {
- add(current);
- goto scan_number_sign;
- }
-
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- {
- add(current);
- goto scan_number_any2;
- }
-
- default:
- {
- error_message =
- "invalid number; expected '+', '-', or digit after exponent";
- return token_type::parse_error;
- }
- }
-
-scan_number_sign:
- // we just parsed an exponent sign
- switch (get())
- {
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- {
- add(current);
- goto scan_number_any2;
- }
-
- default:
- {
- error_message = "invalid number; expected digit after exponent sign";
- return token_type::parse_error;
- }
- }
-
-scan_number_any2:
- // we just parsed a number after the exponent or exponent sign
- switch (get())
- {
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- {
- add(current);
- goto scan_number_any2;
- }
-
- default:
- goto scan_number_done;
- }
-
-scan_number_done:
- // unget the character after the number (we only read it to know that
- // we are done scanning a number)
- unget();
-
- char* endptr = nullptr;
- errno = 0;
-
- // try to parse integers first and fall back to floats
- if (number_type == token_type::value_unsigned)
- {
- const auto x = std::strtoull(token_buffer.data(), &endptr, 10);
-
- // we checked the number format before
- assert(endptr == token_buffer.data() + token_buffer.size());
-
- if (errno == 0)
- {
- value_unsigned = static_cast<number_unsigned_t>(x);
- if (value_unsigned == x)
- {
- return token_type::value_unsigned;
- }
- }
- }
- else if (number_type == token_type::value_integer)
- {
- const auto x = std::strtoll(token_buffer.data(), &endptr, 10);
-
- // we checked the number format before
- assert(endptr == token_buffer.data() + token_buffer.size());
-
- if (errno == 0)
- {
- value_integer = static_cast<number_integer_t>(x);
- if (value_integer == x)
- {
- return token_type::value_integer;
- }
- }
- }
-
- // this code is reached if we parse a floating-point number or if an
- // integer conversion above failed
- strtof(value_float, token_buffer.data(), &endptr);
-
- // we checked the number format before
- assert(endptr == token_buffer.data() + token_buffer.size());
-
- return token_type::value_float;
- }
-
- /*!
- @param[in] literal_text the literal text to expect
- @param[in] length the length of the passed literal text
- @param[in] return_type the token type to return on success
- */
- token_type scan_literal(const char* literal_text, const std::size_t length,
- token_type return_type)
- {
- assert(current == literal_text[0]);
- for (std::size_t i = 1; i < length; ++i)
- {
- if (JSON_UNLIKELY(get() != literal_text[i]))
- {
- error_message = "invalid literal";
- return token_type::parse_error;
- }
- }
- return return_type;
- }
-
- /////////////////////
- // input management
- /////////////////////
-
- /// reset token_buffer; current character is beginning of token
- void reset() noexcept
- {
- token_buffer.clear();
- token_string.clear();
- token_string.push_back(std::char_traits<char>::to_char_type(current));
- }
-
- /*
- @brief get next character from the input
-
- This function provides the interface to the used input adapter. It does
- not throw in case the input reached EOF, but returns a
- `std::char_traits<char>::eof()` in that case. Stores the scanned characters
- for use in error messages.
-
- @return character read from the input
- */
- std::char_traits<char>::int_type get()
- {
- ++position.chars_read_total;
- ++position.chars_read_current_line;
-
- if (next_unget)
- {
- // just reset the next_unget variable and work with current
- next_unget = false;
- }
- else
- {
- current = ia->get_character();
- }
-
- if (JSON_LIKELY(current != std::char_traits<char>::eof()))
- {
- token_string.push_back(std::char_traits<char>::to_char_type(current));
- }
-
- if (current == '\n')
- {
- ++position.lines_read;
- position.chars_read_current_line = 0;
- }
-
- return current;
- }
-
- /*!
- @brief unget current character (read it again on next get)
-
- We implement unget by setting variable next_unget to true. The input is not
- changed - we just simulate ungetting by modifying chars_read_total,
- chars_read_current_line, and token_string. The next call to get() will
- behave as if the unget character is read again.
- */
- void unget()
- {
- next_unget = true;
-
- --position.chars_read_total;
-
- // in case we "unget" a newline, we have to also decrement the lines_read
- if (position.chars_read_current_line == 0)
- {
- if (position.lines_read > 0)
- {
- --position.lines_read;
- }
- }
- else
- {
- --position.chars_read_current_line;
- }
-
- if (JSON_LIKELY(current != std::char_traits<char>::eof()))
- {
- assert(not token_string.empty());
- token_string.pop_back();
- }
- }
-
- /// add a character to token_buffer
- void add(int c)
- {
- token_buffer.push_back(std::char_traits<char>::to_char_type(c));
- }
-
- public:
- /////////////////////
- // value getters
- /////////////////////
-
- /// return integer value
- constexpr number_integer_t get_number_integer() const noexcept
- {
- return value_integer;
- }
-
- /// return unsigned integer value
- constexpr number_unsigned_t get_number_unsigned() const noexcept
- {
- return value_unsigned;
- }
-
- /// return floating-point value
- constexpr number_float_t get_number_float() const noexcept
- {
- return value_float;
- }
-
- /// return current string value (implicitly resets the token; useful only once)
- string_t& get_string()
- {
- return token_buffer;
- }
-
- /////////////////////
- // diagnostics
- /////////////////////
-
- /// return position of last read token
- constexpr position_t get_position() const noexcept
- {
- return position;
- }
-
- /// return the last read token (for errors only). Will never contain EOF
- /// (an arbitrary value that is not a valid char value, often -1), because
- /// 255 may legitimately occur. May contain NUL, which should be escaped.
- std::string get_token_string() const
- {
- // escape control characters
- std::string result;
- for (const auto c : token_string)
- {
- if ('\x00' <= c and c <= '\x1F')
- {
- // escape control characters
- std::array<char, 9> cs{{}};
- (std::snprintf)(cs.data(), cs.size(), "<U+%.4X>", static_cast<unsigned char>(c));
- result += cs.data();
- }
- else
- {
- // add character as is
- result.push_back(c);
- }
- }
-
- return result;
- }
-
- /// return syntax error message
- constexpr const char* get_error_message() const noexcept
- {
- return error_message;
- }
-
- /////////////////////
- // actual scanner
- /////////////////////
-
- /*!
- @brief skip the UTF-8 byte order mark
- @return true iff there is no BOM or the correct BOM has been skipped
- */
- bool skip_bom()
- {
- if (get() == 0xEF)
- {
- // check if we completely parse the BOM
- return get() == 0xBB and get() == 0xBF;
- }
-
- // the first character is not the beginning of the BOM; unget it to
- // process is later
- unget();
- return true;
- }
-
- token_type scan()
- {
- // initially, skip the BOM
- if (position.chars_read_total == 0 and not skip_bom())
- {
- error_message = "invalid BOM; must be 0xEF 0xBB 0xBF if given";
- return token_type::parse_error;
- }
-
- // read next character and ignore whitespace
- do
- {
- get();
- }
- while (current == ' ' or current == '\t' or current == '\n' or current == '\r');
-
- switch (current)
- {
- // structural characters
- case '[':
- return token_type::begin_array;
- case ']':
- return token_type::end_array;
- case '{':
- return token_type::begin_object;
- case '}':
- return token_type::end_object;
- case ':':
- return token_type::name_separator;
- case ',':
- return token_type::value_separator;
-
- // literals
- case 't':
- return scan_literal("true", 4, token_type::literal_true);
- case 'f':
- return scan_literal("false", 5, token_type::literal_false);
- case 'n':
- return scan_literal("null", 4, token_type::literal_null);
-
- // string
- case '\"':
- return scan_string();
-
- // number
- case '-':
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- return scan_number();
-
- // end of input (the null byte is needed when parsing from
- // string literals)
- case '\0':
- case std::char_traits<char>::eof():
- return token_type::end_of_input;
-
- // error
- default:
- error_message = "invalid literal";
- return token_type::parse_error;
- }
- }
-
- private:
- /// input adapter
- detail::input_adapter_t ia = nullptr;
-
- /// the current character
- std::char_traits<char>::int_type current = std::char_traits<char>::eof();
-
- /// whether the next get() call should just return current
- bool next_unget = false;
-
- /// the start position of the current token
- position_t position {};
-
- /// raw input token string (for error messages)
- std::vector<char> token_string {};
-
- /// buffer for variable-length tokens (numbers, strings)
- string_t token_buffer {};
-
- /// a description of occurred lexer errors
- const char* error_message = "";
-
- // number values
- number_integer_t value_integer = 0;
- number_unsigned_t value_unsigned = 0;
- number_float_t value_float = 0;
-
- /// the decimal point
- const char decimal_point_char = '.';
-};
-} // namespace detail
-} // namespace nlohmann
-
-// #include <nlohmann/detail/input/parser.hpp>
-
-
-#include <cassert> // assert
-#include <cmath> // isfinite
-#include <cstdint> // uint8_t
-#include <functional> // function
-#include <string> // string
-#include <utility> // move
-#include <vector> // vector
-
-// #include <nlohmann/detail/exceptions.hpp>
-
-// #include <nlohmann/detail/input/input_adapters.hpp>
-
-// #include <nlohmann/detail/input/json_sax.hpp>
-
-// #include <nlohmann/detail/input/lexer.hpp>
-
-// #include <nlohmann/detail/macro_scope.hpp>
-
-// #include <nlohmann/detail/meta/is_sax.hpp>
-
-// #include <nlohmann/detail/value_t.hpp>
-
-
-namespace nlohmann
-{
-namespace detail
-{
-////////////
-// parser //
-////////////
-
-/*!
-@brief syntax analysis
-
-This class implements a recursive decent parser.
-*/
-template<typename BasicJsonType>
-class parser
-{
- using number_integer_t = typename BasicJsonType::number_integer_t;
- using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
- using number_float_t = typename BasicJsonType::number_float_t;
- using string_t = typename BasicJsonType::string_t;
- using lexer_t = lexer<BasicJsonType>;
- using token_type = typename lexer_t::token_type;
-
- public:
- enum class parse_event_t : uint8_t
- {
- /// the parser read `{` and started to process a JSON object
- object_start,
- /// the parser read `}` and finished processing a JSON object
- object_end,
- /// the parser read `[` and started to process a JSON array
- array_start,
- /// the parser read `]` and finished processing a JSON array
- array_end,
- /// the parser read a key of a value in an object
- key,
- /// the parser finished reading a JSON value
- value
- };
-
- using parser_callback_t =
- std::function<bool(int depth, parse_event_t event, BasicJsonType& parsed)>;
-
- /// a parser reading from an input adapter
- explicit parser(detail::input_adapter_t&& adapter,
- const parser_callback_t cb = nullptr,
- const bool allow_exceptions_ = true)
- : callback(cb), m_lexer(std::move(adapter)), allow_exceptions(allow_exceptions_)
- {
- // read first token
- get_token();
- }
-
- /*!
- @brief public parser interface
-
- @param[in] strict whether to expect the last token to be EOF
- @param[in,out] result parsed JSON value
-
- @throw parse_error.101 in case of an unexpected token
- @throw parse_error.102 if to_unicode fails or surrogate error
- @throw parse_error.103 if to_unicode fails
- */
- void parse(const bool strict, BasicJsonType& result)
- {
- if (callback)
- {
- json_sax_dom_callback_parser<BasicJsonType> sdp(result, callback, allow_exceptions);
- sax_parse_internal(&sdp);
- result.assert_invariant();
-
- // in strict mode, input must be completely read
- if (strict and (get_token() != token_type::end_of_input))
- {
- sdp.parse_error(m_lexer.get_position(),
- m_lexer.get_token_string(),
- parse_error::create(101, m_lexer.get_position(),
- exception_message(token_type::end_of_input, "value")));
- }
-
- // in case of an error, return discarded value
- if (sdp.is_errored())
- {
- result = value_t::discarded;
- return;
- }
-
- // set top-level value to null if it was discarded by the callback
- // function
- if (result.is_discarded())
- {
- result = nullptr;
- }
- }
- else
- {
- json_sax_dom_parser<BasicJsonType> sdp(result, allow_exceptions);
- sax_parse_internal(&sdp);
- result.assert_invariant();
-
- // in strict mode, input must be completely read
- if (strict and (get_token() != token_type::end_of_input))
- {
- sdp.parse_error(m_lexer.get_position(),
- m_lexer.get_token_string(),
- parse_error::create(101, m_lexer.get_position(),
- exception_message(token_type::end_of_input, "value")));
- }
-
- // in case of an error, return discarded value
- if (sdp.is_errored())
- {
- result = value_t::discarded;
- return;
- }
- }
- }
-
- /*!
- @brief public accept interface
-
- @param[in] strict whether to expect the last token to be EOF
- @return whether the input is a proper JSON text
- */
- bool accept(const bool strict = true)
- {
- json_sax_acceptor<BasicJsonType> sax_acceptor;
- return sax_parse(&sax_acceptor, strict);
- }
-
- template <typename SAX>
- bool sax_parse(SAX* sax, const bool strict = true)
- {
- (void)detail::is_sax_static_asserts<SAX, BasicJsonType> {};
- const bool result = sax_parse_internal(sax);
-
- // strict mode: next byte must be EOF
- if (result and strict and (get_token() != token_type::end_of_input))
- {
- return sax->parse_error(m_lexer.get_position(),
- m_lexer.get_token_string(),
- parse_error::create(101, m_lexer.get_position(),
- exception_message(token_type::end_of_input, "value")));
- }
-
- return result;
- }
-
- private:
- template <typename SAX>
- bool sax_parse_internal(SAX* sax)
- {
- // stack to remember the hierarchy of structured values we are parsing
- // true = array; false = object
- std::vector<bool> states;
- // value to avoid a goto (see comment where set to true)
- bool skip_to_state_evaluation = false;
-
- while (true)
- {
- if (not skip_to_state_evaluation)
- {
- // invariant: get_token() was called before each iteration
- switch (last_token)
- {
- case token_type::begin_object:
- {
- if (JSON_UNLIKELY(not sax->start_object(std::size_t(-1))))
- {
- return false;
- }
-
- // closing } -> we are done
- if (get_token() == token_type::end_object)
- {
- if (JSON_UNLIKELY(not sax->end_object()))
- {
- return false;
- }
- break;
- }
-
- // parse key
- if (JSON_UNLIKELY(last_token != token_type::value_string))
- {
- return sax->parse_error(m_lexer.get_position(),
- m_lexer.get_token_string(),
- parse_error::create(101, m_lexer.get_position(),
- exception_message(token_type::value_string, "object key")));
- }
- if (JSON_UNLIKELY(not sax->key(m_lexer.get_string())))
- {
- return false;
- }
-
- // parse separator (:)
- if (JSON_UNLIKELY(get_token() != token_type::name_separator))
- {
- return sax->parse_error(m_lexer.get_position(),
- m_lexer.get_token_string(),
- parse_error::create(101, m_lexer.get_position(),
- exception_message(token_type::name_separator, "object separator")));
- }
-
- // remember we are now inside an object
- states.push_back(false);
-
- // parse values
- get_token();
- continue;
- }
-
- case token_type::begin_array:
- {
- if (JSON_UNLIKELY(not sax->start_array(std::size_t(-1))))
- {
- return false;
- }
-
- // closing ] -> we are done
- if (get_token() == token_type::end_array)
- {
- if (JSON_UNLIKELY(not sax->end_array()))
- {
- return false;
- }
- break;
- }
-
- // remember we are now inside an array
- states.push_back(true);
-
- // parse values (no need to call get_token)
- continue;
- }
-
- case token_type::value_float:
- {
- const auto res = m_lexer.get_number_float();
-
- if (JSON_UNLIKELY(not std::isfinite(res)))
- {
- return sax->parse_error(m_lexer.get_position(),
- m_lexer.get_token_string(),
- out_of_range::create(406, "number overflow parsing '" + m_lexer.get_token_string() + "'"));
- }
-
- if (JSON_UNLIKELY(not sax->number_float(res, m_lexer.get_string())))
- {
- return false;
- }
-
- break;
- }
-
- case token_type::literal_false:
- {
- if (JSON_UNLIKELY(not sax->boolean(false)))
- {
- return false;
- }
- break;
- }
-
- case token_type::literal_null:
- {
- if (JSON_UNLIKELY(not sax->null()))
- {
- return false;
- }
- break;
- }
-
- case token_type::literal_true:
- {
- if (JSON_UNLIKELY(not sax->boolean(true)))
- {
- return false;
- }
- break;
- }
-
- case token_type::value_integer:
- {
- if (JSON_UNLIKELY(not sax->number_integer(m_lexer.get_number_integer())))
- {
- return false;
- }
- break;
- }
-
- case token_type::value_string:
- {
- if (JSON_UNLIKELY(not sax->string(m_lexer.get_string())))
- {
- return false;
- }
- break;
- }
-
- case token_type::value_unsigned:
- {
- if (JSON_UNLIKELY(not sax->number_unsigned(m_lexer.get_number_unsigned())))
- {
- return false;
- }
- break;
- }
-
- case token_type::parse_error:
- {
- // using "uninitialized" to avoid "expected" message
- return sax->parse_error(m_lexer.get_position(),
- m_lexer.get_token_string(),
- parse_error::create(101, m_lexer.get_position(),
- exception_message(token_type::uninitialized, "value")));
- }
-
- default: // the last token was unexpected
- {
- return sax->parse_error(m_lexer.get_position(),
- m_lexer.get_token_string(),
- parse_error::create(101, m_lexer.get_position(),
- exception_message(token_type::literal_or_value, "value")));
- }
- }
- }
- else
- {
- skip_to_state_evaluation = false;
- }
-
- // we reached this line after we successfully parsed a value
- if (states.empty())
- {
- // empty stack: we reached the end of the hierarchy: done
- return true;
- }
-
- if (states.back()) // array
- {
- // comma -> next value
- if (get_token() == token_type::value_separator)
- {
- // parse a new value
- get_token();
- continue;
- }
-
- // closing ]
- if (JSON_LIKELY(last_token == token_type::end_array))
- {
- if (JSON_UNLIKELY(not sax->end_array()))
- {
- return false;
- }
-
- // We are done with this array. Before we can parse a
- // new value, we need to evaluate the new state first.
- // By setting skip_to_state_evaluation to false, we
- // are effectively jumping to the beginning of this if.
- assert(not states.empty());
- states.pop_back();
- skip_to_state_evaluation = true;
- continue;
- }
-
- return sax->parse_error(m_lexer.get_position(),
- m_lexer.get_token_string(),
- parse_error::create(101, m_lexer.get_position(),
- exception_message(token_type::end_array, "array")));
- }
- else // object
- {
- // comma -> next value
- if (get_token() == token_type::value_separator)
- {
- // parse key
- if (JSON_UNLIKELY(get_token() != token_type::value_string))
- {
- return sax->parse_error(m_lexer.get_position(),
- m_lexer.get_token_string(),
- parse_error::create(101, m_lexer.get_position(),
- exception_message(token_type::value_string, "object key")));
- }
-
- if (JSON_UNLIKELY(not sax->key(m_lexer.get_string())))
- {
- return false;
- }
-
- // parse separator (:)
- if (JSON_UNLIKELY(get_token() != token_type::name_separator))
- {
- return sax->parse_error(m_lexer.get_position(),
- m_lexer.get_token_string(),
- parse_error::create(101, m_lexer.get_position(),
- exception_message(token_type::name_separator, "object separator")));
- }
-
- // parse values
- get_token();
- continue;
- }
-
- // closing }
- if (JSON_LIKELY(last_token == token_type::end_object))
- {
- if (JSON_UNLIKELY(not sax->end_object()))
- {
- return false;
- }
-
- // We are done with this object. Before we can parse a
- // new value, we need to evaluate the new state first.
- // By setting skip_to_state_evaluation to false, we
- // are effectively jumping to the beginning of this if.
- assert(not states.empty());
- states.pop_back();
- skip_to_state_evaluation = true;
- continue;
- }
-
- return sax->parse_error(m_lexer.get_position(),
- m_lexer.get_token_string(),
- parse_error::create(101, m_lexer.get_position(),
- exception_message(token_type::end_object, "object")));
- }
- }
- }
-
- /// get next token from lexer
- token_type get_token()
- {
- return last_token = m_lexer.scan();
- }
-
- std::string exception_message(const token_type expected, const std::string& context)
- {
- std::string error_msg = "syntax error ";
-
- if (not context.empty())
- {
- error_msg += "while parsing " + context + " ";
- }
-
- error_msg += "- ";
-
- if (last_token == token_type::parse_error)
- {
- error_msg += std::string(m_lexer.get_error_message()) + "; last read: '" +
- m_lexer.get_token_string() + "'";
- }
- else
- {
- error_msg += "unexpected " + std::string(lexer_t::token_type_name(last_token));
- }
-
- if (expected != token_type::uninitialized)
- {
- error_msg += "; expected " + std::string(lexer_t::token_type_name(expected));
- }
-
- return error_msg;
- }
-
- private:
- /// callback function
- const parser_callback_t callback = nullptr;
- /// the type of the last read token
- token_type last_token = token_type::uninitialized;
- /// the lexer
- lexer_t m_lexer;
- /// whether to throw exceptions in case of errors
- const bool allow_exceptions = true;
-};
-} // namespace detail
-} // namespace nlohmann
-
-// #include <nlohmann/detail/iterators/internal_iterator.hpp>
-
-
-// #include <nlohmann/detail/iterators/primitive_iterator.hpp>
-
-
-#include <cstddef> // ptrdiff_t
-#include <limits> // numeric_limits
-
-namespace nlohmann
-{
-namespace detail
-{
-/*
-@brief an iterator for primitive JSON types
-
-This class models an iterator for primitive JSON types (boolean, number,
-string). It's only purpose is to allow the iterator/const_iterator classes
-to "iterate" over primitive values. Internally, the iterator is modeled by
-a `difference_type` variable. Value begin_value (`0`) models the begin,
-end_value (`1`) models past the end.
-*/
-class primitive_iterator_t
-{
- private:
- using difference_type = std::ptrdiff_t;
- static constexpr difference_type begin_value = 0;
- static constexpr difference_type end_value = begin_value + 1;
-
- /// iterator as signed integer type
- difference_type m_it = (std::numeric_limits<std::ptrdiff_t>::min)();
-
- public:
- constexpr difference_type get_value() const noexcept
- {
- return m_it;
- }
-
- /// set iterator to a defined beginning
- void set_begin() noexcept
- {
- m_it = begin_value;
- }
-
- /// set iterator to a defined past the end
- void set_end() noexcept
- {
- m_it = end_value;
- }
-
- /// return whether the iterator can be dereferenced
- constexpr bool is_begin() const noexcept
- {
- return m_it == begin_value;
- }
-
- /// return whether the iterator is at end
- constexpr bool is_end() const noexcept
- {
- return m_it == end_value;
- }
-
- friend constexpr bool operator==(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
- {
- return lhs.m_it == rhs.m_it;
- }
-
- friend constexpr bool operator<(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
- {
- return lhs.m_it < rhs.m_it;
- }
-
- primitive_iterator_t operator+(difference_type n) noexcept
- {
- auto result = *this;
- result += n;
- return result;
- }
-
- friend constexpr difference_type operator-(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
- {
- return lhs.m_it - rhs.m_it;
- }
-
- primitive_iterator_t& operator++() noexcept
- {
- ++m_it;
- return *this;
- }
-
- primitive_iterator_t const operator++(int) noexcept
- {
- auto result = *this;
- ++m_it;
- return result;
- }
-
- primitive_iterator_t& operator--() noexcept
- {
- --m_it;
- return *this;
- }
-
- primitive_iterator_t const operator--(int) noexcept
- {
- auto result = *this;
- --m_it;
- return result;
- }
-
- primitive_iterator_t& operator+=(difference_type n) noexcept
- {
- m_it += n;
- return *this;
- }
-
- primitive_iterator_t& operator-=(difference_type n) noexcept
- {
- m_it -= n;
- return *this;
- }
-};
-} // namespace detail
-} // namespace nlohmann
-
-
-namespace nlohmann
-{
-namespace detail
-{
-/*!
-@brief an iterator value
-
-@note This structure could easily be a union, but MSVC currently does not allow
-unions members with complex constructors, see https://github.com/nlohmann/json/pull/105.
-*/
-template<typename BasicJsonType> struct internal_iterator
-{
- /// iterator for JSON objects
- typename BasicJsonType::object_t::iterator object_iterator {};
- /// iterator for JSON arrays
- typename BasicJsonType::array_t::iterator array_iterator {};
- /// generic iterator for all other types
- primitive_iterator_t primitive_iterator {};
-};
-} // namespace detail
-} // namespace nlohmann
-
-// #include <nlohmann/detail/iterators/iter_impl.hpp>
-
-
-#include <ciso646> // not
-#include <iterator> // iterator, random_access_iterator_tag, bidirectional_iterator_tag, advance, next
-#include <type_traits> // conditional, is_const, remove_const
-
-// #include <nlohmann/detail/exceptions.hpp>
-
-// #include <nlohmann/detail/iterators/internal_iterator.hpp>
-
-// #include <nlohmann/detail/iterators/primitive_iterator.hpp>
-
-// #include <nlohmann/detail/macro_scope.hpp>
-
-// #include <nlohmann/detail/meta/cpp_future.hpp>
-
-// #include <nlohmann/detail/meta/type_traits.hpp>
-
-// #include <nlohmann/detail/value_t.hpp>
-
-
-namespace nlohmann
-{
-namespace detail
-{
-// forward declare, to be able to friend it later on
-template<typename IteratorType> class iteration_proxy;
-template<typename IteratorType> class iteration_proxy_value;
-
-/*!
-@brief a template for a bidirectional iterator for the @ref basic_json class
-This class implements a both iterators (iterator and const_iterator) for the
-@ref basic_json class.
-@note An iterator is called *initialized* when a pointer to a JSON value has
- been set (e.g., by a constructor or a copy assignment). If the iterator is
- default-constructed, it is *uninitialized* and most methods are undefined.
- **The library uses assertions to detect calls on uninitialized iterators.**
-@requirement The class satisfies the following concept requirements:
--
-[BidirectionalIterator](https://en.cppreference.com/w/cpp/named_req/BidirectionalIterator):
- The iterator that can be moved can be moved in both directions (i.e.
- incremented and decremented).
-@since version 1.0.0, simplified in version 2.0.9, change to bidirectional
- iterators in version 3.0.0 (see https://github.com/nlohmann/json/issues/593)
-*/
-template<typename BasicJsonType>
-class iter_impl
-{
- /// allow basic_json to access private members
- friend iter_impl<typename std::conditional<std::is_const<BasicJsonType>::value, typename std::remove_const<BasicJsonType>::type, const BasicJsonType>::type>;
- friend BasicJsonType;
- friend iteration_proxy<iter_impl>;
- friend iteration_proxy_value<iter_impl>;
-
- using object_t = typename BasicJsonType::object_t;
- using array_t = typename BasicJsonType::array_t;
- // make sure BasicJsonType is basic_json or const basic_json
- static_assert(is_basic_json<typename std::remove_const<BasicJsonType>::type>::value,
- "iter_impl only accepts (const) basic_json");
-
- public:
-
- /// The std::iterator class template (used as a base class to provide typedefs) is deprecated in C++17.
- /// The C++ Standard has never required user-defined iterators to derive from std::iterator.
- /// A user-defined iterator should provide publicly accessible typedefs named
- /// iterator_category, value_type, difference_type, pointer, and reference.
- /// Note that value_type is required to be non-const, even for constant iterators.
- using iterator_category = std::bidirectional_iterator_tag;
-
- /// the type of the values when the iterator is dereferenced
- using value_type = typename BasicJsonType::value_type;
- /// a type to represent differences between iterators
- using difference_type = typename BasicJsonType::difference_type;
- /// defines a pointer to the type iterated over (value_type)
- using pointer = typename std::conditional<std::is_const<BasicJsonType>::value,
- typename BasicJsonType::const_pointer,
- typename BasicJsonType::pointer>::type;
- /// defines a reference to the type iterated over (value_type)
- using reference =
- typename std::conditional<std::is_const<BasicJsonType>::value,
- typename BasicJsonType::const_reference,
- typename BasicJsonType::reference>::type;
-
- /// default constructor
- iter_impl() = default;
-
- /*!
- @brief constructor for a given JSON instance
- @param[in] object pointer to a JSON object for this iterator
- @pre object != nullptr
- @post The iterator is initialized; i.e. `m_object != nullptr`.
- */
- explicit iter_impl(pointer object) noexcept : m_object(object)
- {
- assert(m_object != nullptr);
-
- switch (m_object->m_type)
- {
- case value_t::object:
- {
- m_it.object_iterator = typename object_t::iterator();
- break;
- }
-
- case value_t::array:
- {
- m_it.array_iterator = typename array_t::iterator();
- break;
- }
-
- default:
- {
- m_it.primitive_iterator = primitive_iterator_t();
- break;
- }
- }
- }
-
- /*!
- @note The conventional copy constructor and copy assignment are implicitly
- defined. Combined with the following converting constructor and
- assignment, they support: (1) copy from iterator to iterator, (2)
- copy from const iterator to const iterator, and (3) conversion from
- iterator to const iterator. However conversion from const iterator
- to iterator is not defined.
- */
-
- /*!
- @brief converting constructor
- @param[in] other non-const iterator to copy from
- @note It is not checked whether @a other is initialized.
- */
- iter_impl(const iter_impl<typename std::remove_const<BasicJsonType>::type>& other) noexcept
- : m_object(other.m_object), m_it(other.m_it) {}
-
- /*!
- @brief converting assignment
- @param[in,out] other non-const iterator to copy from
- @return const/non-const iterator
- @note It is not checked whether @a other is initialized.
- */
- iter_impl& operator=(const iter_impl<typename std::remove_const<BasicJsonType>::type>& other) noexcept
- {
- m_object = other.m_object;
- m_it = other.m_it;
- return *this;
- }
-
- private:
- /*!
- @brief set the iterator to the first value
- @pre The iterator is initialized; i.e. `m_object != nullptr`.
- */
- void set_begin() noexcept
- {
- assert(m_object != nullptr);
-
- switch (m_object->m_type)
- {
- case value_t::object:
- {
- m_it.object_iterator = m_object->m_value.object->begin();
- break;
- }
-
- case value_t::array:
- {
- m_it.array_iterator = m_object->m_value.array->begin();
- break;
- }
-
- case value_t::null:
- {
- // set to end so begin()==end() is true: null is empty
- m_it.primitive_iterator.set_end();
- break;
- }
-
- default:
- {
- m_it.primitive_iterator.set_begin();
- break;
- }
- }
- }
-
- /*!
- @brief set the iterator past the last value
- @pre The iterator is initialized; i.e. `m_object != nullptr`.
- */
- void set_end() noexcept
- {
- assert(m_object != nullptr);
-
- switch (m_object->m_type)
- {
- case value_t::object:
- {
- m_it.object_iterator = m_object->m_value.object->end();
- break;
- }
-
- case value_t::array:
- {
- m_it.array_iterator = m_object->m_value.array->end();
- break;
- }
-
- default:
- {
- m_it.primitive_iterator.set_end();
- break;
- }
- }
- }
-
- public:
- /*!
- @brief return a reference to the value pointed to by the iterator
- @pre The iterator is initialized; i.e. `m_object != nullptr`.
- */
- reference operator*() const
- {
- assert(m_object != nullptr);
-
- switch (m_object->m_type)
- {
- case value_t::object:
- {
- assert(m_it.object_iterator != m_object->m_value.object->end());
- return m_it.object_iterator->second;
- }
-
- case value_t::array:
- {
- assert(m_it.array_iterator != m_object->m_value.array->end());
- return *m_it.array_iterator;
- }
-
- case value_t::null:
- JSON_THROW(invalid_iterator::create(214, "cannot get value"));
-
- default:
- {
- if (JSON_LIKELY(m_it.primitive_iterator.is_begin()))
- {
- return *m_object;
- }
-
- JSON_THROW(invalid_iterator::create(214, "cannot get value"));
- }
- }
- }
-
- /*!
- @brief dereference the iterator
- @pre The iterator is initialized; i.e. `m_object != nullptr`.
- */
- pointer operator->() const
- {
- assert(m_object != nullptr);
-
- switch (m_object->m_type)
- {
- case value_t::object:
- {
- assert(m_it.object_iterator != m_object->m_value.object->end());
- return &(m_it.object_iterator->second);
- }
-
- case value_t::array:
- {
- assert(m_it.array_iterator != m_object->m_value.array->end());
- return &*m_it.array_iterator;
- }
-
- default:
- {
- if (JSON_LIKELY(m_it.primitive_iterator.is_begin()))
- {
- return m_object;
- }
-
- JSON_THROW(invalid_iterator::create(214, "cannot get value"));
- }
- }
- }
-
- /*!
- @brief post-increment (it++)
- @pre The iterator is initialized; i.e. `m_object != nullptr`.
- */
- iter_impl const operator++(int)
- {
- auto result = *this;
- ++(*this);
- return result;
- }
-
- /*!
- @brief pre-increment (++it)
- @pre The iterator is initialized; i.e. `m_object != nullptr`.
- */
- iter_impl& operator++()
- {
- assert(m_object != nullptr);
-
- switch (m_object->m_type)
- {
- case value_t::object:
- {
- std::advance(m_it.object_iterator, 1);
- break;
- }
-
- case value_t::array:
- {
- std::advance(m_it.array_iterator, 1);
- break;
- }
-
- default:
- {
- ++m_it.primitive_iterator;
- break;
- }
- }
-
- return *this;
- }
-
- /*!
- @brief post-decrement (it--)
- @pre The iterator is initialized; i.e. `m_object != nullptr`.
- */
- iter_impl const operator--(int)
- {
- auto result = *this;
- --(*this);
- return result;
- }
-
- /*!
- @brief pre-decrement (--it)
- @pre The iterator is initialized; i.e. `m_object != nullptr`.
- */
- iter_impl& operator--()
- {
- assert(m_object != nullptr);
-
- switch (m_object->m_type)
- {
- case value_t::object:
- {
- std::advance(m_it.object_iterator, -1);
- break;
- }
-
- case value_t::array:
- {
- std::advance(m_it.array_iterator, -1);
- break;
- }
-
- default:
- {
- --m_it.primitive_iterator;
- break;
- }
- }
-
- return *this;
- }
-
- /*!
- @brief comparison: equal
- @pre The iterator is initialized; i.e. `m_object != nullptr`.
- */
- bool operator==(const iter_impl& other) const
- {
- // if objects are not the same, the comparison is undefined
- if (JSON_UNLIKELY(m_object != other.m_object))
- {
- JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers"));
- }
-
- assert(m_object != nullptr);
-
- switch (m_object->m_type)
- {
- case value_t::object:
- return (m_it.object_iterator == other.m_it.object_iterator);
-
- case value_t::array:
- return (m_it.array_iterator == other.m_it.array_iterator);
-
- default:
- return (m_it.primitive_iterator == other.m_it.primitive_iterator);
- }
- }
-
- /*!
- @brief comparison: not equal
- @pre The iterator is initialized; i.e. `m_object != nullptr`.
- */
- bool operator!=(const iter_impl& other) const
- {
- return not operator==(other);
- }
-
- /*!
- @brief comparison: smaller
- @pre The iterator is initialized; i.e. `m_object != nullptr`.
- */
- bool operator<(const iter_impl& other) const
- {
- // if objects are not the same, the comparison is undefined
- if (JSON_UNLIKELY(m_object != other.m_object))
- {
- JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers"));
- }
-
- assert(m_object != nullptr);
-
- switch (m_object->m_type)
- {
- case value_t::object:
- JSON_THROW(invalid_iterator::create(213, "cannot compare order of object iterators"));
-
- case value_t::array:
- return (m_it.array_iterator < other.m_it.array_iterator);
-
- default:
- return (m_it.primitive_iterator < other.m_it.primitive_iterator);
- }
- }
-
- /*!
- @brief comparison: less than or equal
- @pre The iterator is initialized; i.e. `m_object != nullptr`.
- */
- bool operator<=(const iter_impl& other) const
- {
- return not other.operator < (*this);
- }
-
- /*!
- @brief comparison: greater than
- @pre The iterator is initialized; i.e. `m_object != nullptr`.
- */
- bool operator>(const iter_impl& other) const
- {
- return not operator<=(other);
- }
-
- /*!
- @brief comparison: greater than or equal
- @pre The iterator is initialized; i.e. `m_object != nullptr`.
- */
- bool operator>=(const iter_impl& other) const
- {
- return not operator<(other);
- }
-
- /*!
- @brief add to iterator
- @pre The iterator is initialized; i.e. `m_object != nullptr`.
- */
- iter_impl& operator+=(difference_type i)
- {
- assert(m_object != nullptr);
-
- switch (m_object->m_type)
- {
- case value_t::object:
- JSON_THROW(invalid_iterator::create(209, "cannot use offsets with object iterators"));
-
- case value_t::array:
- {
- std::advance(m_it.array_iterator, i);
- break;
- }
-
- default:
- {
- m_it.primitive_iterator += i;
- break;
- }
- }
-
- return *this;
- }
-
- /*!
- @brief subtract from iterator
- @pre The iterator is initialized; i.e. `m_object != nullptr`.
- */
- iter_impl& operator-=(difference_type i)
- {
- return operator+=(-i);
- }
-
- /*!
- @brief add to iterator
- @pre The iterator is initialized; i.e. `m_object != nullptr`.
- */
- iter_impl operator+(difference_type i) const
- {
- auto result = *this;
- result += i;
- return result;
- }
-
- /*!
- @brief addition of distance and iterator
- @pre The iterator is initialized; i.e. `m_object != nullptr`.
- */
- friend iter_impl operator+(difference_type i, const iter_impl& it)
- {
- auto result = it;
- result += i;
- return result;
- }
-
- /*!
- @brief subtract from iterator
- @pre The iterator is initialized; i.e. `m_object != nullptr`.
- */
- iter_impl operator-(difference_type i) const
- {
- auto result = *this;
- result -= i;
- return result;
- }
-
- /*!
- @brief return difference
- @pre The iterator is initialized; i.e. `m_object != nullptr`.
- */
- difference_type operator-(const iter_impl& other) const
- {
- assert(m_object != nullptr);
-
- switch (m_object->m_type)
- {
- case value_t::object:
- JSON_THROW(invalid_iterator::create(209, "cannot use offsets with object iterators"));
-
- case value_t::array:
- return m_it.array_iterator - other.m_it.array_iterator;
-
- default:
- return m_it.primitive_iterator - other.m_it.primitive_iterator;
- }
- }
-
- /*!
- @brief access to successor
- @pre The iterator is initialized; i.e. `m_object != nullptr`.
- */
- reference operator[](difference_type n) const
- {
- assert(m_object != nullptr);
-
- switch (m_object->m_type)
- {
- case value_t::object:
- JSON_THROW(invalid_iterator::create(208, "cannot use operator[] for object iterators"));
-
- case value_t::array:
- return *std::next(m_it.array_iterator, n);
-
- case value_t::null:
- JSON_THROW(invalid_iterator::create(214, "cannot get value"));
-
- default:
- {
- if (JSON_LIKELY(m_it.primitive_iterator.get_value() == -n))
- {
- return *m_object;
- }
-
- JSON_THROW(invalid_iterator::create(214, "cannot get value"));
- }
- }
- }
-
- /*!
- @brief return the key of an object iterator
- @pre The iterator is initialized; i.e. `m_object != nullptr`.
- */
- const typename object_t::key_type& key() const
- {
- assert(m_object != nullptr);
-
- if (JSON_LIKELY(m_object->is_object()))
- {
- return m_it.object_iterator->first;
- }
-
- JSON_THROW(invalid_iterator::create(207, "cannot use key() for non-object iterators"));
- }
-
- /*!
- @brief return the value of an iterator
- @pre The iterator is initialized; i.e. `m_object != nullptr`.
- */
- reference value() const
- {
- return operator*();
- }
-
- private:
- /// associated JSON instance
- pointer m_object = nullptr;
- /// the actual iterator of the associated instance
- internal_iterator<typename std::remove_const<BasicJsonType>::type> m_it {};
-};
-} // namespace detail
-} // namespace nlohmann
-
-// #include <nlohmann/detail/iterators/iteration_proxy.hpp>
-
-// #include <nlohmann/detail/iterators/json_reverse_iterator.hpp>
-
-
-#include <cstddef> // ptrdiff_t
-#include <iterator> // reverse_iterator
-#include <utility> // declval
-
-namespace nlohmann
-{
-namespace detail
-{
-//////////////////////
-// reverse_iterator //
-//////////////////////
-
-/*!
-@brief a template for a reverse iterator class
-
-@tparam Base the base iterator type to reverse. Valid types are @ref
-iterator (to create @ref reverse_iterator) and @ref const_iterator (to
-create @ref const_reverse_iterator).
-
-@requirement The class satisfies the following concept requirements:
--
-[BidirectionalIterator](https://en.cppreference.com/w/cpp/named_req/BidirectionalIterator):
- The iterator that can be moved can be moved in both directions (i.e.
- incremented and decremented).
-- [OutputIterator](https://en.cppreference.com/w/cpp/named_req/OutputIterator):
- It is possible to write to the pointed-to element (only if @a Base is
- @ref iterator).
-
-@since version 1.0.0
-*/
-template<typename Base>
-class json_reverse_iterator : public std::reverse_iterator<Base>
-{
- public:
- using difference_type = std::ptrdiff_t;
- /// shortcut to the reverse iterator adapter
- using base_iterator = std::reverse_iterator<Base>;
- /// the reference type for the pointed-to element
- using reference = typename Base::reference;
-
- /// create reverse iterator from iterator
- explicit json_reverse_iterator(const typename base_iterator::iterator_type& it) noexcept
- : base_iterator(it) {}
-
- /// create reverse iterator from base class
- explicit json_reverse_iterator(const base_iterator& it) noexcept : base_iterator(it) {}
-
- /// post-increment (it++)
- json_reverse_iterator const operator++(int)
- {
- return static_cast<json_reverse_iterator>(base_iterator::operator++(1));
- }
-
- /// pre-increment (++it)
- json_reverse_iterator& operator++()
- {
- return static_cast<json_reverse_iterator&>(base_iterator::operator++());
- }
-
- /// post-decrement (it--)
- json_reverse_iterator const operator--(int)
- {
- return static_cast<json_reverse_iterator>(base_iterator::operator--(1));
- }
-
- /// pre-decrement (--it)
- json_reverse_iterator& operator--()
- {
- return static_cast<json_reverse_iterator&>(base_iterator::operator--());
- }
-
- /// add to iterator
- json_reverse_iterator& operator+=(difference_type i)
- {
- return static_cast<json_reverse_iterator&>(base_iterator::operator+=(i));
- }
-
- /// add to iterator
- json_reverse_iterator operator+(difference_type i) const
- {
- return static_cast<json_reverse_iterator>(base_iterator::operator+(i));
- }
-
- /// subtract from iterator
- json_reverse_iterator operator-(difference_type i) const
- {
- return static_cast<json_reverse_iterator>(base_iterator::operator-(i));
- }
-
- /// return difference
- difference_type operator-(const json_reverse_iterator& other) const
- {
- return base_iterator(*this) - base_iterator(other);
- }
-
- /// access to successor
- reference operator[](difference_type n) const
- {
- return *(this->operator+(n));
- }
-
- /// return the key of an object iterator
- auto key() const -> decltype(std::declval<Base>().key())
- {
- auto it = --this->base();
- return it.key();
- }
-
- /// return the value of an iterator
- reference value() const
- {
- auto it = --this->base();
- return it.operator * ();
- }
-};
-} // namespace detail
-} // namespace nlohmann
-
-// #include <nlohmann/detail/iterators/primitive_iterator.hpp>
-
-// #include <nlohmann/detail/json_pointer.hpp>
-
-
-#include <algorithm> // all_of
-#include <cassert> // assert
-#include <numeric> // accumulate
-#include <string> // string
-#include <utility> // move
-#include <vector> // vector
-
-// #include <nlohmann/detail/exceptions.hpp>
-
-// #include <nlohmann/detail/macro_scope.hpp>
-
-// #include <nlohmann/detail/value_t.hpp>
-
-
-namespace nlohmann
-{
-template<typename BasicJsonType>
-class json_pointer
-{
- // allow basic_json to access private members
- NLOHMANN_BASIC_JSON_TPL_DECLARATION
- friend class basic_json;
-
- public:
- /*!
- @brief create JSON pointer
-
- Create a JSON pointer according to the syntax described in
- [Section 3 of RFC6901](https://tools.ietf.org/html/rfc6901#section-3).
-
- @param[in] s string representing the JSON pointer; if omitted, the empty
- string is assumed which references the whole JSON value
-
- @throw parse_error.107 if the given JSON pointer @a s is nonempty and does
- not begin with a slash (`/`); see example below
-
- @throw parse_error.108 if a tilde (`~`) in the given JSON pointer @a s is
- not followed by `0` (representing `~`) or `1` (representing `/`); see
- example below
-
- @liveexample{The example shows the construction several valid JSON pointers
- as well as the exceptional behavior.,json_pointer}
-
- @since version 2.0.0
- */
- explicit json_pointer(const std::string& s = "")
- : reference_tokens(split(s))
- {}
-
- /*!
- @brief return a string representation of the JSON pointer
-
- @invariant For each JSON pointer `ptr`, it holds:
- @code {.cpp}
- ptr == json_pointer(ptr.to_string());
- @endcode
-
- @return a string representation of the JSON pointer
-
- @liveexample{The example shows the result of `to_string`.,json_pointer__to_string}
-
- @since version 2.0.0
- */
- std::string to_string() const
- {
- return std::accumulate(reference_tokens.begin(), reference_tokens.end(),
- std::string{},
- [](const std::string & a, const std::string & b)
- {
- return a + "/" + escape(b);
- });
- }
-
- /// @copydoc to_string()
- operator std::string() const
- {
- return to_string();
- }
-
- /*!
- @brief append another JSON pointer at the end of this JSON pointer
-
- @param[in] ptr JSON pointer to append
- @return JSON pointer with @a ptr appended
-
- @liveexample{The example shows the usage of `operator/=`.,json_pointer__operator_add}
-
- @complexity Linear in the length of @a ptr.
-
- @sa @ref operator/=(std::string) to append a reference token
- @sa @ref operator/=(std::size_t) to append an array index
- @sa @ref operator/(const json_pointer&, const json_pointer&) for a binary operator
-
- @since version 3.6.0
- */
- json_pointer& operator/=(const json_pointer& ptr)
- {
- reference_tokens.insert(reference_tokens.end(),
- ptr.reference_tokens.begin(),
- ptr.reference_tokens.end());
- return *this;
- }
-
- /*!
- @brief append an unescaped reference token at the end of this JSON pointer
-
- @param[in] token reference token to append
- @return JSON pointer with @a token appended without escaping @a token
-
- @liveexample{The example shows the usage of `operator/=`.,json_pointer__operator_add}
-
- @complexity Amortized constant.
-
- @sa @ref operator/=(const json_pointer&) to append a JSON pointer
- @sa @ref operator/=(std::size_t) to append an array index
- @sa @ref operator/(const json_pointer&, std::size_t) for a binary operator
-
- @since version 3.6.0
- */
- json_pointer& operator/=(std::string token)
- {
- push_back(std::move(token));
- return *this;
- }
-
- /*!
- @brief append an array index at the end of this JSON pointer
-
- @param[in] array_index array index ot append
- @return JSON pointer with @a array_index appended
-
- @liveexample{The example shows the usage of `operator/=`.,json_pointer__operator_add}
-
- @complexity Amortized constant.
-
- @sa @ref operator/=(const json_pointer&) to append a JSON pointer
- @sa @ref operator/=(std::string) to append a reference token
- @sa @ref operator/(const json_pointer&, std::string) for a binary operator
-
- @since version 3.6.0
- */
- json_pointer& operator/=(std::size_t array_index)
- {
- return *this /= std::to_string(array_index);
- }
-
- /*!
- @brief create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer
-
- @param[in] lhs JSON pointer
- @param[in] rhs JSON pointer
- @return a new JSON pointer with @a rhs appended to @a lhs
-
- @liveexample{The example shows the usage of `operator/`.,json_pointer__operator_add_binary}
-
- @complexity Linear in the length of @a lhs and @a rhs.
-
- @sa @ref operator/=(const json_pointer&) to append a JSON pointer
-
- @since version 3.6.0
- */
- friend json_pointer operator/(const json_pointer& lhs,
- const json_pointer& rhs)
- {
- return json_pointer(lhs) /= rhs;
- }
-
- /*!
- @brief create a new JSON pointer by appending the unescaped token at the end of the JSON pointer
-
- @param[in] ptr JSON pointer
- @param[in] token reference token
- @return a new JSON pointer with unescaped @a token appended to @a ptr
-
- @liveexample{The example shows the usage of `operator/`.,json_pointer__operator_add_binary}
-
- @complexity Linear in the length of @a ptr.
-
- @sa @ref operator/=(std::string) to append a reference token
-
- @since version 3.6.0
- */
- friend json_pointer operator/(const json_pointer& ptr, std::string token)
- {
- return json_pointer(ptr) /= std::move(token);
- }
-
- /*!
- @brief create a new JSON pointer by appending the array-index-token at the end of the JSON pointer
-
- @param[in] ptr JSON pointer
- @param[in] array_index array index
- @return a new JSON pointer with @a array_index appended to @a ptr
-
- @liveexample{The example shows the usage of `operator/`.,json_pointer__operator_add_binary}
-
- @complexity Linear in the length of @a ptr.
-
- @sa @ref operator/=(std::size_t) to append an array index
-
- @since version 3.6.0
- */
- friend json_pointer operator/(const json_pointer& ptr, std::size_t array_index)
- {
- return json_pointer(ptr) /= array_index;
- }
-
- /*!
- @brief returns the parent of this JSON pointer
-
- @return parent of this JSON pointer; in case this JSON pointer is the root,
- the root itself is returned
-
- @complexity Linear in the length of the JSON pointer.
-
- @liveexample{The example shows the result of `parent_pointer` for different
- JSON Pointers.,json_pointer__parent_pointer}
-
- @since version 3.6.0
- */
- json_pointer parent_pointer() const
- {
- if (empty())
- {
- return *this;
- }
-
- json_pointer res = *this;
- res.pop_back();
- return res;
- }
-
- /*!
- @brief remove last reference token
-
- @pre not `empty()`
-
- @liveexample{The example shows the usage of `pop_back`.,json_pointer__pop_back}
-
- @complexity Constant.
-
- @throw out_of_range.405 if JSON pointer has no parent
-
- @since version 3.6.0
- */
- void pop_back()
- {
- if (JSON_UNLIKELY(empty()))
- {
- JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent"));
- }
-
- reference_tokens.pop_back();
- }
-
- /*!
- @brief return last reference token
-
- @pre not `empty()`
- @return last reference token
-
- @liveexample{The example shows the usage of `back`.,json_pointer__back}
-
- @complexity Constant.
-
- @throw out_of_range.405 if JSON pointer has no parent
-
- @since version 3.6.0
- */
- const std::string& back()
- {
- if (JSON_UNLIKELY(empty()))
- {
- JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent"));
- }
-
- return reference_tokens.back();
- }
-
- /*!
- @brief append an unescaped token at the end of the reference pointer
-
- @param[in] token token to add
-
- @complexity Amortized constant.
-
- @liveexample{The example shows the result of `push_back` for different
- JSON Pointers.,json_pointer__push_back}
-
- @since version 3.6.0
- */
- void push_back(const std::string& token)
- {
- reference_tokens.push_back(token);
- }
-
- /// @copydoc push_back(const std::string&)
- void push_back(std::string&& token)
- {
- reference_tokens.push_back(std::move(token));
- }
-
- /*!
- @brief return whether pointer points to the root document
-
- @return true iff the JSON pointer points to the root document
-
- @complexity Constant.
-
- @exceptionsafety No-throw guarantee: this function never throws exceptions.
-
- @liveexample{The example shows the result of `empty` for different JSON
- Pointers.,json_pointer__empty}
-
- @since version 3.6.0
- */
- bool empty() const noexcept
- {
- return reference_tokens.empty();
- }
-
- private:
- /*!
- @param[in] s reference token to be converted into an array index
-
- @return integer representation of @a s
-
- @throw out_of_range.404 if string @a s could not be converted to an integer
- */
- static int array_index(const std::string& s)
- {
- std::size_t processed_chars = 0;
- const int res = std::stoi(s, &processed_chars);
-
- // check if the string was completely read
- if (JSON_UNLIKELY(processed_chars != s.size()))
- {
- JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + s + "'"));
- }
-
- return res;
- }
-
- json_pointer top() const
- {
- if (JSON_UNLIKELY(empty()))
- {
- JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent"));
- }
-
- json_pointer result = *this;
- result.reference_tokens = {reference_tokens[0]};
- return result;
- }
-
- /*!
- @brief create and return a reference to the pointed to value
-
- @complexity Linear in the number of reference tokens.
-
- @throw parse_error.109 if array index is not a number
- @throw type_error.313 if value cannot be unflattened
- */
- BasicJsonType& get_and_create(BasicJsonType& j) const
- {
- using size_type = typename BasicJsonType::size_type;
- auto result = &j;
-
- // in case no reference tokens exist, return a reference to the JSON value
- // j which will be overwritten by a primitive value
- for (const auto& reference_token : reference_tokens)
- {
- switch (result->m_type)
- {
- case detail::value_t::null:
- {
- if (reference_token == "0")
- {
- // start a new array if reference token is 0
- result = &result->operator[](0);
- }
- else
- {
- // start a new object otherwise
- result = &result->operator[](reference_token);
- }
- break;
- }
-
- case detail::value_t::object:
- {
- // create an entry in the object
- result = &result->operator[](reference_token);
- break;
- }
-
- case detail::value_t::array:
- {
- // create an entry in the array
- JSON_TRY
- {
- result = &result->operator[](static_cast<size_type>(array_index(reference_token)));
- }
- JSON_CATCH(std::invalid_argument&)
- {
- JSON_THROW(detail::parse_error::create(109, 0, "array index '" + reference_token + "' is not a number"));
- }
- break;
- }
-
- /*
- The following code is only reached if there exists a reference
- token _and_ the current value is primitive. In this case, we have
- an error situation, because primitive values may only occur as
- single value; that is, with an empty list of reference tokens.
- */
- default:
- JSON_THROW(detail::type_error::create(313, "invalid value to unflatten"));
- }
- }
-
- return *result;
- }
-
- /*!
- @brief return a reference to the pointed to value
-
- @note This version does not throw if a value is not present, but tries to
- create nested values instead. For instance, calling this function
- with pointer `"/this/that"` on a null value is equivalent to calling
- `operator[]("this").operator[]("that")` on that value, effectively
- changing the null value to an object.
-
- @param[in] ptr a JSON value
-
- @return reference to the JSON value pointed to by the JSON pointer
-
- @complexity Linear in the length of the JSON pointer.
-
- @throw parse_error.106 if an array index begins with '0'
- @throw parse_error.109 if an array index was not a number
- @throw out_of_range.404 if the JSON pointer can not be resolved
- */
- BasicJsonType& get_unchecked(BasicJsonType* ptr) const
- {
- using size_type = typename BasicJsonType::size_type;
- for (const auto& reference_token : reference_tokens)
- {
- // convert null values to arrays or objects before continuing
- if (ptr->m_type == detail::value_t::null)
- {
- // check if reference token is a number
- const bool nums =
- std::all_of(reference_token.begin(), reference_token.end(),
- [](const char x)
- {
- return x >= '0' and x <= '9';
- });
-
- // change value to array for numbers or "-" or to object otherwise
- *ptr = (nums or reference_token == "-")
- ? detail::value_t::array
- : detail::value_t::object;
- }
-
- switch (ptr->m_type)
- {
- case detail::value_t::object:
- {
- // use unchecked object access
- ptr = &ptr->operator[](reference_token);
- break;
- }
-
- case detail::value_t::array:
- {
- // error condition (cf. RFC 6901, Sect. 4)
- if (JSON_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0'))
- {
- JSON_THROW(detail::parse_error::create(106, 0,
- "array index '" + reference_token +
- "' must not begin with '0'"));
- }
-
- if (reference_token == "-")
- {
- // explicitly treat "-" as index beyond the end
- ptr = &ptr->operator[](ptr->m_value.array->size());
- }
- else
- {
- // convert array index to number; unchecked access
- JSON_TRY
- {
- ptr = &ptr->operator[](
- static_cast<size_type>(array_index(reference_token)));
- }
- JSON_CATCH(std::invalid_argument&)
- {
- JSON_THROW(detail::parse_error::create(109, 0, "array index '" + reference_token + "' is not a number"));
- }
- }
- break;
- }
-
- default:
- JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'"));
- }
- }
-
- return *ptr;
- }
-
- /*!
- @throw parse_error.106 if an array index begins with '0'
- @throw parse_error.109 if an array index was not a number
- @throw out_of_range.402 if the array index '-' is used
- @throw out_of_range.404 if the JSON pointer can not be resolved
- */
- BasicJsonType& get_checked(BasicJsonType* ptr) const
- {
- using size_type = typename BasicJsonType::size_type;
- for (const auto& reference_token : reference_tokens)
- {
- switch (ptr->m_type)
- {
- case detail::value_t::object:
- {
- // note: at performs range check
- ptr = &ptr->at(reference_token);
- break;
- }
-
- case detail::value_t::array:
- {
- if (JSON_UNLIKELY(reference_token == "-"))
- {
- // "-" always fails the range check
- JSON_THROW(detail::out_of_range::create(402,
- "array index '-' (" + std::to_string(ptr->m_value.array->size()) +
- ") is out of range"));
- }
-
- // error condition (cf. RFC 6901, Sect. 4)
- if (JSON_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0'))
- {
- JSON_THROW(detail::parse_error::create(106, 0,
- "array index '" + reference_token +
- "' must not begin with '0'"));
- }
-
- // note: at performs range check
- JSON_TRY
- {
- ptr = &ptr->at(static_cast<size_type>(array_index(reference_token)));
- }
- JSON_CATCH(std::invalid_argument&)
- {
- JSON_THROW(detail::parse_error::create(109, 0, "array index '" + reference_token + "' is not a number"));
- }
- break;
- }
-
- default:
- JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'"));
- }
- }
-
- return *ptr;
- }
-
- /*!
- @brief return a const reference to the pointed to value
-
- @param[in] ptr a JSON value
-
- @return const reference to the JSON value pointed to by the JSON
- pointer
-
- @throw parse_error.106 if an array index begins with '0'
- @throw parse_error.109 if an array index was not a number
- @throw out_of_range.402 if the array index '-' is used
- @throw out_of_range.404 if the JSON pointer can not be resolved
- */
- const BasicJsonType& get_unchecked(const BasicJsonType* ptr) const
- {
- using size_type = typename BasicJsonType::size_type;
- for (const auto& reference_token : reference_tokens)
- {
- switch (ptr->m_type)
- {
- case detail::value_t::object:
- {
- // use unchecked object access
- ptr = &ptr->operator[](reference_token);
- break;
- }
-
- case detail::value_t::array:
- {
- if (JSON_UNLIKELY(reference_token == "-"))
- {
- // "-" cannot be used for const access
- JSON_THROW(detail::out_of_range::create(402,
- "array index '-' (" + std::to_string(ptr->m_value.array->size()) +
- ") is out of range"));
- }
-
- // error condition (cf. RFC 6901, Sect. 4)
- if (JSON_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0'))
- {
- JSON_THROW(detail::parse_error::create(106, 0,
- "array index '" + reference_token +
- "' must not begin with '0'"));
- }
-
- // use unchecked array access
- JSON_TRY
- {
- ptr = &ptr->operator[](
- static_cast<size_type>(array_index(reference_token)));
- }
- JSON_CATCH(std::invalid_argument&)
- {
- JSON_THROW(detail::parse_error::create(109, 0, "array index '" + reference_token + "' is not a number"));
- }
- break;
- }
-
- default:
- JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'"));
- }
- }
-
- return *ptr;
- }
-
- /*!
- @throw parse_error.106 if an array index begins with '0'
- @throw parse_error.109 if an array index was not a number
- @throw out_of_range.402 if the array index '-' is used
- @throw out_of_range.404 if the JSON pointer can not be resolved
- */
- const BasicJsonType& get_checked(const BasicJsonType* ptr) const
- {
- using size_type = typename BasicJsonType::size_type;
- for (const auto& reference_token : reference_tokens)
- {
- switch (ptr->m_type)
- {
- case detail::value_t::object:
- {
- // note: at performs range check
- ptr = &ptr->at(reference_token);
- break;
- }
-
- case detail::value_t::array:
- {
- if (JSON_UNLIKELY(reference_token == "-"))
- {
- // "-" always fails the range check
- JSON_THROW(detail::out_of_range::create(402,
- "array index '-' (" + std::to_string(ptr->m_value.array->size()) +
- ") is out of range"));
- }
-
- // error condition (cf. RFC 6901, Sect. 4)
- if (JSON_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0'))
- {
- JSON_THROW(detail::parse_error::create(106, 0,
- "array index '" + reference_token +
- "' must not begin with '0'"));
- }
-
- // note: at performs range check
- JSON_TRY
- {
- ptr = &ptr->at(static_cast<size_type>(array_index(reference_token)));
- }
- JSON_CATCH(std::invalid_argument&)
- {
- JSON_THROW(detail::parse_error::create(109, 0, "array index '" + reference_token + "' is not a number"));
- }
- break;
- }
-
- default:
- JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'"));
- }
- }
-
- return *ptr;
- }
-
- /*!
- @brief split the string input to reference tokens
-
- @note This function is only called by the json_pointer constructor.
- All exceptions below are documented there.
-
- @throw parse_error.107 if the pointer is not empty or begins with '/'
- @throw parse_error.108 if character '~' is not followed by '0' or '1'
- */
- static std::vector<std::string> split(const std::string& reference_string)
- {
- std::vector<std::string> result;
-
- // special case: empty reference string -> no reference tokens
- if (reference_string.empty())
- {
- return result;
- }
-
- // check if nonempty reference string begins with slash
- if (JSON_UNLIKELY(reference_string[0] != '/'))
- {
- JSON_THROW(detail::parse_error::create(107, 1,
- "JSON pointer must be empty or begin with '/' - was: '" +
- reference_string + "'"));
- }
-
- // extract the reference tokens:
- // - slash: position of the last read slash (or end of string)
- // - start: position after the previous slash
- for (
- // search for the first slash after the first character
- std::size_t slash = reference_string.find_first_of('/', 1),
- // set the beginning of the first reference token
- start = 1;
- // we can stop if start == 0 (if slash == std::string::npos)
- start != 0;
- // set the beginning of the next reference token
- // (will eventually be 0 if slash == std::string::npos)
- start = (slash == std::string::npos) ? 0 : slash + 1,
- // find next slash
- slash = reference_string.find_first_of('/', start))
- {
- // use the text between the beginning of the reference token
- // (start) and the last slash (slash).
- auto reference_token = reference_string.substr(start, slash - start);
-
- // check reference tokens are properly escaped
- for (std::size_t pos = reference_token.find_first_of('~');
- pos != std::string::npos;
- pos = reference_token.find_first_of('~', pos + 1))
- {
- assert(reference_token[pos] == '~');
-
- // ~ must be followed by 0 or 1
- if (JSON_UNLIKELY(pos == reference_token.size() - 1 or
- (reference_token[pos + 1] != '0' and
- reference_token[pos + 1] != '1')))
- {
- JSON_THROW(detail::parse_error::create(108, 0, "escape character '~' must be followed with '0' or '1'"));
- }
- }
-
- // finally, store the reference token
- unescape(reference_token);
- result.push_back(reference_token);
- }
-
- return result;
- }
-
- /*!
- @brief replace all occurrences of a substring by another string
-
- @param[in,out] s the string to manipulate; changed so that all
- occurrences of @a f are replaced with @a t
- @param[in] f the substring to replace with @a t
- @param[in] t the string to replace @a f
-
- @pre The search string @a f must not be empty. **This precondition is
- enforced with an assertion.**
-
- @since version 2.0.0
- */
- static void replace_substring(std::string& s, const std::string& f,
- const std::string& t)
- {
- assert(not f.empty());
- for (auto pos = s.find(f); // find first occurrence of f
- pos != std::string::npos; // make sure f was found
- s.replace(pos, f.size(), t), // replace with t, and
- pos = s.find(f, pos + t.size())) // find next occurrence of f
- {}
- }
-
- /// escape "~" to "~0" and "/" to "~1"
- static std::string escape(std::string s)
- {
- replace_substring(s, "~", "~0");
- replace_substring(s, "/", "~1");
- return s;
- }
-
- /// unescape "~1" to tilde and "~0" to slash (order is important!)
- static void unescape(std::string& s)
- {
- replace_substring(s, "~1", "/");
- replace_substring(s, "~0", "~");
- }
-
- /*!
- @param[in] reference_string the reference string to the current value
- @param[in] value the value to consider
- @param[in,out] result the result object to insert values to
-
- @note Empty objects or arrays are flattened to `null`.
- */
- static void flatten(const std::string& reference_string,
- const BasicJsonType& value,
- BasicJsonType& result)
- {
- switch (value.m_type)
- {
- case detail::value_t::array:
- {
- if (value.m_value.array->empty())
- {
- // flatten empty array as null
- result[reference_string] = nullptr;
- }
- else
- {
- // iterate array and use index as reference string
- for (std::size_t i = 0; i < value.m_value.array->size(); ++i)
- {
- flatten(reference_string + "/" + std::to_string(i),
- value.m_value.array->operator[](i), result);
- }
- }
- break;
- }
-
- case detail::value_t::object:
- {
- if (value.m_value.object->empty())
- {
- // flatten empty object as null
- result[reference_string] = nullptr;
- }
- else
- {
- // iterate object and use keys as reference string
- for (const auto& element : *value.m_value.object)
- {
- flatten(reference_string + "/" + escape(element.first), element.second, result);
- }
- }
- break;
- }
-
- default:
- {
- // add primitive value with its reference string
- result[reference_string] = value;
- break;
- }
- }
- }
-
- /*!
- @param[in] value flattened JSON
-
- @return unflattened JSON
-
- @throw parse_error.109 if array index is not a number
- @throw type_error.314 if value is not an object
- @throw type_error.315 if object values are not primitive
- @throw type_error.313 if value cannot be unflattened
- */
- static BasicJsonType
- unflatten(const BasicJsonType& value)
- {
- if (JSON_UNLIKELY(not value.is_object()))
- {
- JSON_THROW(detail::type_error::create(314, "only objects can be unflattened"));
- }
-
- BasicJsonType result;
-
- // iterate the JSON object values
- for (const auto& element : *value.m_value.object)
- {
- if (JSON_UNLIKELY(not element.second.is_primitive()))
- {
- JSON_THROW(detail::type_error::create(315, "values in object must be primitive"));
- }
-
- // assign value to reference pointed to by JSON pointer; Note that if
- // the JSON pointer is "" (i.e., points to the whole value), function
- // get_and_create returns a reference to result itself. An assignment
- // will then create a primitive value.
- json_pointer(element.first).get_and_create(result) = element.second;
- }
-
- return result;
- }
-
- /*!
- @brief compares two JSON pointers for equality
-
- @param[in] lhs JSON pointer to compare
- @param[in] rhs JSON pointer to compare
- @return whether @a lhs is equal to @a rhs
-
- @complexity Linear in the length of the JSON pointer
-
- @exceptionsafety No-throw guarantee: this function never throws exceptions.
- */
- friend bool operator==(json_pointer const& lhs,
- json_pointer const& rhs) noexcept
- {
- return lhs.reference_tokens == rhs.reference_tokens;
- }
-
- /*!
- @brief compares two JSON pointers for inequality
-
- @param[in] lhs JSON pointer to compare
- @param[in] rhs JSON pointer to compare
- @return whether @a lhs is not equal @a rhs
-
- @complexity Linear in the length of the JSON pointer
-
- @exceptionsafety No-throw guarantee: this function never throws exceptions.
- */
- friend bool operator!=(json_pointer const& lhs,
- json_pointer const& rhs) noexcept
- {
- return not (lhs == rhs);
- }
-
- /// the reference tokens
- std::vector<std::string> reference_tokens;
-};
-} // namespace nlohmann
-
-// #include <nlohmann/detail/json_ref.hpp>
-
-
-#include <initializer_list>
-#include <utility>
-
-// #include <nlohmann/detail/meta/type_traits.hpp>
-
-
-namespace nlohmann
-{
-namespace detail
-{
-template<typename BasicJsonType>
-class json_ref
-{
- public:
- using value_type = BasicJsonType;
-
- json_ref(value_type&& value)
- : owned_value(std::move(value)), value_ref(&owned_value), is_rvalue(true)
- {}
-
- json_ref(const value_type& value)
- : value_ref(const_cast<value_type*>(&value)), is_rvalue(false)
- {}
-
- json_ref(std::initializer_list<json_ref> init)
- : owned_value(init), value_ref(&owned_value), is_rvalue(true)
- {}
-
- template <
- class... Args,
- enable_if_t<std::is_constructible<value_type, Args...>::value, int> = 0 >
- json_ref(Args && ... args)
- : owned_value(std::forward<Args>(args)...), value_ref(&owned_value),
- is_rvalue(true) {}
-
- // class should be movable only
- json_ref(json_ref&&) = default;
- json_ref(const json_ref&) = delete;
- json_ref& operator=(const json_ref&) = delete;
- json_ref& operator=(json_ref&&) = delete;
- ~json_ref() = default;
-
- value_type moved_or_copied() const
- {
- if (is_rvalue)
- {
- return std::move(*value_ref);
- }
- return *value_ref;
- }
-
- value_type const& operator*() const
- {
- return *static_cast<value_type const*>(value_ref);
- }
-
- value_type const* operator->() const
- {
- return static_cast<value_type const*>(value_ref);
- }
-
- private:
- mutable value_type owned_value = nullptr;
- value_type* value_ref = nullptr;
- const bool is_rvalue;
-};
-} // namespace detail
-} // namespace nlohmann
-
-// #include <nlohmann/detail/macro_scope.hpp>
-
-// #include <nlohmann/detail/meta/cpp_future.hpp>
-
-// #include <nlohmann/detail/meta/type_traits.hpp>
-
-// #include <nlohmann/detail/output/binary_writer.hpp>
-
-
-#include <algorithm> // reverse
-#include <array> // array
-#include <cstdint> // uint8_t, uint16_t, uint32_t, uint64_t
-#include <cstring> // memcpy
-#include <limits> // numeric_limits
-#include <string> // string
-
-// #include <nlohmann/detail/input/binary_reader.hpp>
-
-// #include <nlohmann/detail/output/output_adapters.hpp>
-
-
-#include <algorithm> // copy
-#include <cstddef> // size_t
-#include <ios> // streamsize
-#include <iterator> // back_inserter
-#include <memory> // shared_ptr, make_shared
-#include <ostream> // basic_ostream
-#include <string> // basic_string
-#include <vector> // vector
-
-namespace nlohmann
-{
-namespace detail
-{
-/// abstract output adapter interface
-template<typename CharType> struct output_adapter_protocol
-{
- virtual void write_character(CharType c) = 0;
- virtual void write_characters(const CharType* s, std::size_t length) = 0;
- virtual ~output_adapter_protocol() = default;
-};
-
-/// a type to simplify interfaces
-template<typename CharType>
-using output_adapter_t = std::shared_ptr<output_adapter_protocol<CharType>>;
-
-/// output adapter for byte vectors
-template<typename CharType>
-class output_vector_adapter : public output_adapter_protocol<CharType>
-{
- public:
- explicit output_vector_adapter(std::vector<CharType>& vec) noexcept
- : v(vec)
- {}
-
- void write_character(CharType c) override
- {
- v.push_back(c);
- }
-
- void write_characters(const CharType* s, std::size_t length) override
- {
- std::copy(s, s + length, std::back_inserter(v));
- }
-
- private:
- std::vector<CharType>& v;
-};
-
-/// output adapter for output streams
-template<typename CharType>
-class output_stream_adapter : public output_adapter_protocol<CharType>
-{
- public:
- explicit output_stream_adapter(std::basic_ostream<CharType>& s) noexcept
- : stream(s)
- {}
-
- void write_character(CharType c) override
- {
- stream.put(c);
- }
-
- void write_characters(const CharType* s, std::size_t length) override
- {
- stream.write(s, static_cast<std::streamsize>(length));
- }
-
- private:
- std::basic_ostream<CharType>& stream;
-};
-
-/// output adapter for basic_string
-template<typename CharType, typename StringType = std::basic_string<CharType>>
-class output_string_adapter : public output_adapter_protocol<CharType>
-{
- public:
- explicit output_string_adapter(StringType& s) noexcept
- : str(s)
- {}
-
- void write_character(CharType c) override
- {
- str.push_back(c);
- }
-
- void write_characters(const CharType* s, std::size_t length) override
- {
- str.append(s, length);
- }
-
- private:
- StringType& str;
-};
-
-template<typename CharType, typename StringType = std::basic_string<CharType>>
-class output_adapter
-{
- public:
- output_adapter(std::vector<CharType>& vec)
- : oa(std::make_shared<output_vector_adapter<CharType>>(vec)) {}
-
- output_adapter(std::basic_ostream<CharType>& s)
- : oa(std::make_shared<output_stream_adapter<CharType>>(s)) {}
-
- output_adapter(StringType& s)
- : oa(std::make_shared<output_string_adapter<CharType, StringType>>(s)) {}
-
- operator output_adapter_t<CharType>()
- {
- return oa;
- }
-
- private:
- output_adapter_t<CharType> oa = nullptr;
-};
-} // namespace detail
-} // namespace nlohmann
-
-
-namespace nlohmann
-{
-namespace detail
-{
-///////////////////
-// binary writer //
-///////////////////
-
-/*!
-@brief serialization to CBOR and MessagePack values
-*/
-template<typename BasicJsonType, typename CharType>
-class binary_writer
-{
- using string_t = typename BasicJsonType::string_t;
-
- public:
- /*!
- @brief create a binary writer
-
- @param[in] adapter output adapter to write to
- */
- explicit binary_writer(output_adapter_t<CharType> adapter) : oa(adapter)
- {
- assert(oa);
- }
-
- /*!
- @param[in] j JSON value to serialize
- @pre j.type() == value_t::object
- */
- void write_bson(const BasicJsonType& j)
- {
- switch (j.type())
- {
- case value_t::object:
- {
- write_bson_object(*j.m_value.object);
- break;
- }
-
- default:
- {
- JSON_THROW(type_error::create(317, "to serialize to BSON, top-level type must be object, but is " + std::string(j.type_name())));
- }
- }
- }
-
- /*!
- @param[in] j JSON value to serialize
- */
- void write_cbor(const BasicJsonType& j)
- {
- switch (j.type())
- {
- case value_t::null:
- {
- oa->write_character(to_char_type(0xF6));
- break;
- }
-
- case value_t::boolean:
- {
- oa->write_character(j.m_value.boolean
- ? to_char_type(0xF5)
- : to_char_type(0xF4));
- break;
- }
-
- case value_t::number_integer:
- {
- if (j.m_value.number_integer >= 0)
- {
- // CBOR does not differentiate between positive signed
- // integers and unsigned integers. Therefore, we used the
- // code from the value_t::number_unsigned case here.
- if (j.m_value.number_integer <= 0x17)
- {
- write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
- }
- else if (j.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
- {
- oa->write_character(to_char_type(0x18));
- write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
- }
- else if (j.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)())
- {
- oa->write_character(to_char_type(0x19));
- write_number(static_cast<std::uint16_t>(j.m_value.number_integer));
- }
- else if (j.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)())
- {
- oa->write_character(to_char_type(0x1A));
- write_number(static_cast<std::uint32_t>(j.m_value.number_integer));
- }
- else
- {
- oa->write_character(to_char_type(0x1B));
- write_number(static_cast<std::uint64_t>(j.m_value.number_integer));
- }
- }
- else
- {
- // The conversions below encode the sign in the first
- // byte, and the value is converted to a positive number.
- const auto positive_number = -1 - j.m_value.number_integer;
- if (j.m_value.number_integer >= -24)
- {
- write_number(static_cast<std::uint8_t>(0x20 + positive_number));
- }
- else if (positive_number <= (std::numeric_limits<std::uint8_t>::max)())
- {
- oa->write_character(to_char_type(0x38));
- write_number(static_cast<std::uint8_t>(positive_number));
- }
- else if (positive_number <= (std::numeric_limits<std::uint16_t>::max)())
- {
- oa->write_character(to_char_type(0x39));
- write_number(static_cast<std::uint16_t>(positive_number));
- }
- else if (positive_number <= (std::numeric_limits<std::uint32_t>::max)())
- {
- oa->write_character(to_char_type(0x3A));
- write_number(static_cast<std::uint32_t>(positive_number));
- }
- else
- {
- oa->write_character(to_char_type(0x3B));
- write_number(static_cast<std::uint64_t>(positive_number));
- }
- }
- break;
- }
-
- case value_t::number_unsigned:
- {
- if (j.m_value.number_unsigned <= 0x17)
- {
- write_number(static_cast<std::uint8_t>(j.m_value.number_unsigned));
- }
- else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
- {
- oa->write_character(to_char_type(0x18));
- write_number(static_cast<std::uint8_t>(j.m_value.number_unsigned));
- }
- else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
- {
- oa->write_character(to_char_type(0x19));
- write_number(static_cast<std::uint16_t>(j.m_value.number_unsigned));
- }
- else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
- {
- oa->write_character(to_char_type(0x1A));
- write_number(static_cast<std::uint32_t>(j.m_value.number_unsigned));
- }
- else
- {
- oa->write_character(to_char_type(0x1B));
- write_number(static_cast<std::uint64_t>(j.m_value.number_unsigned));
- }
- break;
- }
-
- case value_t::number_float:
- {
- oa->write_character(get_cbor_float_prefix(j.m_value.number_float));
- write_number(j.m_value.number_float);
- break;
- }
-
- case value_t::string:
- {
- // step 1: write control byte and the string length
- const auto N = j.m_value.string->size();
- if (N <= 0x17)
- {
- write_number(static_cast<std::uint8_t>(0x60 + N));
- }
- else if (N <= (std::numeric_limits<std::uint8_t>::max)())
- {
- oa->write_character(to_char_type(0x78));
- write_number(static_cast<std::uint8_t>(N));
- }
- else if (N <= (std::numeric_limits<std::uint16_t>::max)())
- {
- oa->write_character(to_char_type(0x79));
- write_number(static_cast<std::uint16_t>(N));
- }
- else if (N <= (std::numeric_limits<std::uint32_t>::max)())
- {
- oa->write_character(to_char_type(0x7A));
- write_number(static_cast<std::uint32_t>(N));
- }
- // LCOV_EXCL_START
- else if (N <= (std::numeric_limits<std::uint64_t>::max)())
- {
- oa->write_character(to_char_type(0x7B));
- write_number(static_cast<std::uint64_t>(N));
- }
- // LCOV_EXCL_STOP
-
- // step 2: write the string
- oa->write_characters(
- reinterpret_cast<const CharType*>(j.m_value.string->c_str()),
- j.m_value.string->size());
- break;
- }
-
- case value_t::array:
- {
- // step 1: write control byte and the array size
- const auto N = j.m_value.array->size();
- if (N <= 0x17)
- {
- write_number(static_cast<std::uint8_t>(0x80 + N));
- }
- else if (N <= (std::numeric_limits<std::uint8_t>::max)())
- {
- oa->write_character(to_char_type(0x98));
- write_number(static_cast<std::uint8_t>(N));
- }
- else if (N <= (std::numeric_limits<std::uint16_t>::max)())
- {
- oa->write_character(to_char_type(0x99));
- write_number(static_cast<std::uint16_t>(N));
- }
- else if (N <= (std::numeric_limits<std::uint32_t>::max)())
- {
- oa->write_character(to_char_type(0x9A));
- write_number(static_cast<std::uint32_t>(N));
- }
- // LCOV_EXCL_START
- else if (N <= (std::numeric_limits<std::uint64_t>::max)())
- {
- oa->write_character(to_char_type(0x9B));
- write_number(static_cast<std::uint64_t>(N));
- }
- // LCOV_EXCL_STOP
-
- // step 2: write each element
- for (const auto& el : *j.m_value.array)
- {
- write_cbor(el);
- }
- break;
- }
-
- case value_t::object:
- {
- // step 1: write control byte and the object size
- const auto N = j.m_value.object->size();
- if (N <= 0x17)
- {
- write_number(static_cast<std::uint8_t>(0xA0 + N));
- }
- else if (N <= (std::numeric_limits<std::uint8_t>::max)())
- {
- oa->write_character(to_char_type(0xB8));
- write_number(static_cast<std::uint8_t>(N));
- }
- else if (N <= (std::numeric_limits<std::uint16_t>::max)())
- {
- oa->write_character(to_char_type(0xB9));
- write_number(static_cast<std::uint16_t>(N));
- }
- else if (N <= (std::numeric_limits<std::uint32_t>::max)())
- {
- oa->write_character(to_char_type(0xBA));
- write_number(static_cast<std::uint32_t>(N));
- }
- // LCOV_EXCL_START
- else if (N <= (std::numeric_limits<std::uint64_t>::max)())
- {
- oa->write_character(to_char_type(0xBB));
- write_number(static_cast<std::uint64_t>(N));
- }
- // LCOV_EXCL_STOP
-
- // step 2: write each element
- for (const auto& el : *j.m_value.object)
- {
- write_cbor(el.first);
- write_cbor(el.second);
- }
- break;
- }
-
- default:
- break;
- }
- }
-
- /*!
- @param[in] j JSON value to serialize
- */
- void write_msgpack(const BasicJsonType& j)
- {
- switch (j.type())
- {
- case value_t::null: // nil
- {
- oa->write_character(to_char_type(0xC0));
- break;
- }
-
- case value_t::boolean: // true and false
- {
- oa->write_character(j.m_value.boolean
- ? to_char_type(0xC3)
- : to_char_type(0xC2));
- break;
- }
-
- case value_t::number_integer:
- {
- if (j.m_value.number_integer >= 0)
- {
- // MessagePack does not differentiate between positive
- // signed integers and unsigned integers. Therefore, we used
- // the code from the value_t::number_unsigned case here.
- if (j.m_value.number_unsigned < 128)
- {
- // positive fixnum
- write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
- }
- else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
- {
- // uint 8
- oa->write_character(to_char_type(0xCC));
- write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
- }
- else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
- {
- // uint 16
- oa->write_character(to_char_type(0xCD));
- write_number(static_cast<std::uint16_t>(j.m_value.number_integer));
- }
- else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
- {
- // uint 32
- oa->write_character(to_char_type(0xCE));
- write_number(static_cast<std::uint32_t>(j.m_value.number_integer));
- }
- else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
- {
- // uint 64
- oa->write_character(to_char_type(0xCF));
- write_number(static_cast<std::uint64_t>(j.m_value.number_integer));
- }
- }
- else
- {
- if (j.m_value.number_integer >= -32)
- {
- // negative fixnum
- write_number(static_cast<std::int8_t>(j.m_value.number_integer));
- }
- else if (j.m_value.number_integer >= (std::numeric_limits<std::int8_t>::min)() and
- j.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
- {
- // int 8
- oa->write_character(to_char_type(0xD0));
- write_number(static_cast<std::int8_t>(j.m_value.number_integer));
- }
- else if (j.m_value.number_integer >= (std::numeric_limits<std::int16_t>::min)() and
- j.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
- {
- // int 16
- oa->write_character(to_char_type(0xD1));
- write_number(static_cast<std::int16_t>(j.m_value.number_integer));
- }
- else if (j.m_value.number_integer >= (std::numeric_limits<std::int32_t>::min)() and
- j.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
- {
- // int 32
- oa->write_character(to_char_type(0xD2));
- write_number(static_cast<std::int32_t>(j.m_value.number_integer));
- }
- else if (j.m_value.number_integer >= (std::numeric_limits<std::int64_t>::min)() and
- j.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
- {
- // int 64
- oa->write_character(to_char_type(0xD3));
- write_number(static_cast<std::int64_t>(j.m_value.number_integer));
- }
- }
- break;
- }
-
- case value_t::number_unsigned:
- {
- if (j.m_value.number_unsigned < 128)
- {
- // positive fixnum
- write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
- }
- else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
- {
- // uint 8
- oa->write_character(to_char_type(0xCC));
- write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
- }
- else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
- {
- // uint 16
- oa->write_character(to_char_type(0xCD));
- write_number(static_cast<std::uint16_t>(j.m_value.number_integer));
- }
- else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
- {
- // uint 32
- oa->write_character(to_char_type(0xCE));
- write_number(static_cast<std::uint32_t>(j.m_value.number_integer));
- }
- else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
- {
- // uint 64
- oa->write_character(to_char_type(0xCF));
- write_number(static_cast<std::uint64_t>(j.m_value.number_integer));
- }
- break;
- }
-
- case value_t::number_float:
- {
- oa->write_character(get_msgpack_float_prefix(j.m_value.number_float));
- write_number(j.m_value.number_float);
- break;
- }
-
- case value_t::string:
- {
- // step 1: write control byte and the string length
- const auto N = j.m_value.string->size();
- if (N <= 31)
- {
- // fixstr
- write_number(static_cast<std::uint8_t>(0xA0 | N));
- }
- else if (N <= (std::numeric_limits<std::uint8_t>::max)())
- {
- // str 8
- oa->write_character(to_char_type(0xD9));
- write_number(static_cast<std::uint8_t>(N));
- }
- else if (N <= (std::numeric_limits<std::uint16_t>::max)())
- {
- // str 16
- oa->write_character(to_char_type(0xDA));
- write_number(static_cast<std::uint16_t>(N));
- }
- else if (N <= (std::numeric_limits<std::uint32_t>::max)())
- {
- // str 32
- oa->write_character(to_char_type(0xDB));
- write_number(static_cast<std::uint32_t>(N));
- }
-
- // step 2: write the string
- oa->write_characters(
- reinterpret_cast<const CharType*>(j.m_value.string->c_str()),
- j.m_value.string->size());
- break;
- }
-
- case value_t::array:
- {
- // step 1: write control byte and the array size
- const auto N = j.m_value.array->size();
- if (N <= 15)
- {
- // fixarray
- write_number(static_cast<std::uint8_t>(0x90 | N));
- }
- else if (N <= (std::numeric_limits<std::uint16_t>::max)())
- {
- // array 16
- oa->write_character(to_char_type(0xDC));
- write_number(static_cast<std::uint16_t>(N));
- }
- else if (N <= (std::numeric_limits<std::uint32_t>::max)())
- {
- // array 32
- oa->write_character(to_char_type(0xDD));
- write_number(static_cast<std::uint32_t>(N));
- }
-
- // step 2: write each element
- for (const auto& el : *j.m_value.array)
- {
- write_msgpack(el);
- }
- break;
- }
-
- case value_t::object:
- {
- // step 1: write control byte and the object size
- const auto N = j.m_value.object->size();
- if (N <= 15)
- {
- // fixmap
- write_number(static_cast<std::uint8_t>(0x80 | (N & 0xF)));
- }
- else if (N <= (std::numeric_limits<std::uint16_t>::max)())
- {
- // map 16
- oa->write_character(to_char_type(0xDE));
- write_number(static_cast<std::uint16_t>(N));
- }
- else if (N <= (std::numeric_limits<std::uint32_t>::max)())
- {
- // map 32
- oa->write_character(to_char_type(0xDF));
- write_number(static_cast<std::uint32_t>(N));
- }
-
- // step 2: write each element
- for (const auto& el : *j.m_value.object)
- {
- write_msgpack(el.first);
- write_msgpack(el.second);
- }
- break;
- }
-
- default:
- break;
- }
- }
-
- /*!
- @param[in] j JSON value to serialize
- @param[in] use_count whether to use '#' prefixes (optimized format)
- @param[in] use_type whether to use '$' prefixes (optimized format)
- @param[in] add_prefix whether prefixes need to be used for this value
- */
- void write_ubjson(const BasicJsonType& j, const bool use_count,
- const bool use_type, const bool add_prefix = true)
- {
- switch (j.type())
- {
- case value_t::null:
- {
- if (add_prefix)
- {
- oa->write_character(to_char_type('Z'));
- }
- break;
- }
-
- case value_t::boolean:
- {
- if (add_prefix)
- {
- oa->write_character(j.m_value.boolean
- ? to_char_type('T')
- : to_char_type('F'));
- }
- break;
- }
-
- case value_t::number_integer:
- {
- write_number_with_ubjson_prefix(j.m_value.number_integer, add_prefix);
- break;
- }
-
- case value_t::number_unsigned:
- {
- write_number_with_ubjson_prefix(j.m_value.number_unsigned, add_prefix);
- break;
- }
-
- case value_t::number_float:
- {
- write_number_with_ubjson_prefix(j.m_value.number_float, add_prefix);
- break;
- }
-
- case value_t::string:
- {
- if (add_prefix)
- {
- oa->write_character(to_char_type('S'));
- }
- write_number_with_ubjson_prefix(j.m_value.string->size(), true);
- oa->write_characters(
- reinterpret_cast<const CharType*>(j.m_value.string->c_str()),
- j.m_value.string->size());
- break;
- }
-
- case value_t::array:
- {
- if (add_prefix)
- {
- oa->write_character(to_char_type('['));
- }
-
- bool prefix_required = true;
- if (use_type and not j.m_value.array->empty())
- {
- assert(use_count);
- const CharType first_prefix = ubjson_prefix(j.front());
- const bool same_prefix = std::all_of(j.begin() + 1, j.end(),
- [this, first_prefix](const BasicJsonType & v)
- {
- return ubjson_prefix(v) == first_prefix;
- });
-
- if (same_prefix)
- {
- prefix_required = false;
- oa->write_character(to_char_type('$'));
- oa->write_character(first_prefix);
- }
- }
-
- if (use_count)
- {
- oa->write_character(to_char_type('#'));
- write_number_with_ubjson_prefix(j.m_value.array->size(), true);
- }
-
- for (const auto& el : *j.m_value.array)
- {
- write_ubjson(el, use_count, use_type, prefix_required);
- }
-
- if (not use_count)
- {
- oa->write_character(to_char_type(']'));
- }
-
- break;
- }
-
- case value_t::object:
- {
- if (add_prefix)
- {
- oa->write_character(to_char_type('{'));
- }
-
- bool prefix_required = true;
- if (use_type and not j.m_value.object->empty())
- {
- assert(use_count);
- const CharType first_prefix = ubjson_prefix(j.front());
- const bool same_prefix = std::all_of(j.begin(), j.end(),
- [this, first_prefix](const BasicJsonType & v)
- {
- return ubjson_prefix(v) == first_prefix;
- });
-
- if (same_prefix)
- {
- prefix_required = false;
- oa->write_character(to_char_type('$'));
- oa->write_character(first_prefix);
- }
- }
-
- if (use_count)
- {
- oa->write_character(to_char_type('#'));
- write_number_with_ubjson_prefix(j.m_value.object->size(), true);
- }
-
- for (const auto& el : *j.m_value.object)
- {
- write_number_with_ubjson_prefix(el.first.size(), true);
- oa->write_characters(
- reinterpret_cast<const CharType*>(el.first.c_str()),
- el.first.size());
- write_ubjson(el.second, use_count, use_type, prefix_required);
- }
-
- if (not use_count)
- {
- oa->write_character(to_char_type('}'));
- }
-
- break;
- }
-
- default:
- break;
- }
- }
-
- private:
- //////////
- // BSON //
- //////////
-
- /*!
- @return The size of a BSON document entry header, including the id marker
- and the entry name size (and its null-terminator).
- */
- static std::size_t calc_bson_entry_header_size(const string_t& name)
- {
- const auto it = name.find(static_cast<typename string_t::value_type>(0));
- if (JSON_UNLIKELY(it != BasicJsonType::string_t::npos))
- {
- JSON_THROW(out_of_range::create(409,
- "BSON key cannot contain code point U+0000 (at byte " + std::to_string(it) + ")"));
- }
-
- return /*id*/ 1ul + name.size() + /*zero-terminator*/1u;
- }
-
- /*!
- @brief Writes the given @a element_type and @a name to the output adapter
- */
- void write_bson_entry_header(const string_t& name,
- const std::uint8_t element_type)
- {
- oa->write_character(to_char_type(element_type)); // boolean
- oa->write_characters(
- reinterpret_cast<const CharType*>(name.c_str()),
- name.size() + 1u);
- }
-
- /*!
- @brief Writes a BSON element with key @a name and boolean value @a value
- */
- void write_bson_boolean(const string_t& name,
- const bool value)
- {
- write_bson_entry_header(name, 0x08);
- oa->write_character(value ? to_char_type(0x01) : to_char_type(0x00));
- }
-
- /*!
- @brief Writes a BSON element with key @a name and double value @a value
- */
- void write_bson_double(const string_t& name,
- const double value)
- {
- write_bson_entry_header(name, 0x01);
- write_number<double, true>(value);
- }
-
- /*!
- @return The size of the BSON-encoded string in @a value
- */
- static std::size_t calc_bson_string_size(const string_t& value)
- {
- return sizeof(std::int32_t) + value.size() + 1ul;
- }
-
- /*!
- @brief Writes a BSON element with key @a name and string value @a value
- */
- void write_bson_string(const string_t& name,
- const string_t& value)
- {
- write_bson_entry_header(name, 0x02);
-
- write_number<std::int32_t, true>(static_cast<std::int32_t>(value.size() + 1ul));
- oa->write_characters(
- reinterpret_cast<const CharType*>(value.c_str()),
- value.size() + 1);
- }
-
- /*!
- @brief Writes a BSON element with key @a name and null value
- */
- void write_bson_null(const string_t& name)
- {
- write_bson_entry_header(name, 0x0A);
- }
-
- /*!
- @return The size of the BSON-encoded integer @a value
- */
- static std::size_t calc_bson_integer_size(const std::int64_t value)
- {
- return (std::numeric_limits<std::int32_t>::min)() <= value and value <= (std::numeric_limits<std::int32_t>::max)()
- ? sizeof(std::int32_t)
- : sizeof(std::int64_t);
- }
-
- /*!
- @brief Writes a BSON element with key @a name and integer @a value
- */
- void write_bson_integer(const string_t& name,
- const std::int64_t value)
- {
- if ((std::numeric_limits<std::int32_t>::min)() <= value and value <= (std::numeric_limits<std::int32_t>::max)())
- {
- write_bson_entry_header(name, 0x10); // int32
- write_number<std::int32_t, true>(static_cast<std::int32_t>(value));
- }
- else
- {
- write_bson_entry_header(name, 0x12); // int64
- write_number<std::int64_t, true>(static_cast<std::int64_t>(value));
- }
- }
-
- /*!
- @return The size of the BSON-encoded unsigned integer in @a j
- */
- static constexpr std::size_t calc_bson_unsigned_size(const std::uint64_t value) noexcept
- {
- return (value <= static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)()))
- ? sizeof(std::int32_t)
- : sizeof(std::int64_t);
- }
-
- /*!
- @brief Writes a BSON element with key @a name and unsigned @a value
- */
- void write_bson_unsigned(const string_t& name,
- const std::uint64_t value)
- {
- if (value <= static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)()))
- {
- write_bson_entry_header(name, 0x10 /* int32 */);
- write_number<std::int32_t, true>(static_cast<std::int32_t>(value));
- }
- else if (value <= static_cast<std::uint64_t>((std::numeric_limits<std::int64_t>::max)()))
- {
- write_bson_entry_header(name, 0x12 /* int64 */);
- write_number<std::int64_t, true>(static_cast<std::int64_t>(value));
- }
- else
- {
- JSON_THROW(out_of_range::create(407, "integer number " + std::to_string(value) + " cannot be represented by BSON as it does not fit int64"));
- }
- }
-
- /*!
- @brief Writes a BSON element with key @a name and object @a value
- */
- void write_bson_object_entry(const string_t& name,
- const typename BasicJsonType::object_t& value)
- {
- write_bson_entry_header(name, 0x03); // object
- write_bson_object(value);
- }
-
- /*!
- @return The size of the BSON-encoded array @a value
- */
- static std::size_t calc_bson_array_size(const typename BasicJsonType::array_t& value)
- {
- std::size_t embedded_document_size = 0ul;
- std::size_t array_index = 0ul;
-
- for (const auto& el : value)
- {
- embedded_document_size += calc_bson_element_size(std::to_string(array_index++), el);
- }
-
- return sizeof(std::int32_t) + embedded_document_size + 1ul;
- }
-
- /*!
- @brief Writes a BSON element with key @a name and array @a value
- */
- void write_bson_array(const string_t& name,
- const typename BasicJsonType::array_t& value)
- {
- write_bson_entry_header(name, 0x04); // array
- write_number<std::int32_t, true>(static_cast<std::int32_t>(calc_bson_array_size(value)));
-
- std::size_t array_index = 0ul;
-
- for (const auto& el : value)
- {
- write_bson_element(std::to_string(array_index++), el);
- }
-
- oa->write_character(to_char_type(0x00));
- }
-
- /*!
- @brief Calculates the size necessary to serialize the JSON value @a j with its @a name
- @return The calculated size for the BSON document entry for @a j with the given @a name.
- */
- static std::size_t calc_bson_element_size(const string_t& name,
- const BasicJsonType& j)
- {
- const auto header_size = calc_bson_entry_header_size(name);
- switch (j.type())
- {
- case value_t::object:
- return header_size + calc_bson_object_size(*j.m_value.object);
-
- case value_t::array:
- return header_size + calc_bson_array_size(*j.m_value.array);
-
- case value_t::boolean:
- return header_size + 1ul;
-
- case value_t::number_float:
- return header_size + 8ul;
-
- case value_t::number_integer:
- return header_size + calc_bson_integer_size(j.m_value.number_integer);
-
- case value_t::number_unsigned:
- return header_size + calc_bson_unsigned_size(j.m_value.number_unsigned);
-
- case value_t::string:
- return header_size + calc_bson_string_size(*j.m_value.string);
-
- case value_t::null:
- return header_size + 0ul;
-
- // LCOV_EXCL_START
- default:
- assert(false);
- return 0ul;
- // LCOV_EXCL_STOP
- }
- }
-
- /*!
- @brief Serializes the JSON value @a j to BSON and associates it with the
- key @a name.
- @param name The name to associate with the JSON entity @a j within the
- current BSON document
- @return The size of the BSON entry
- */
- void write_bson_element(const string_t& name,
- const BasicJsonType& j)
- {
- switch (j.type())
- {
- case value_t::object:
- return write_bson_object_entry(name, *j.m_value.object);
-
- case value_t::array:
- return write_bson_array(name, *j.m_value.array);
-
- case value_t::boolean:
- return write_bson_boolean(name, j.m_value.boolean);
-
- case value_t::number_float:
- return write_bson_double(name, j.m_value.number_float);
-
- case value_t::number_integer:
- return write_bson_integer(name, j.m_value.number_integer);
-
- case value_t::number_unsigned:
- return write_bson_unsigned(name, j.m_value.number_unsigned);
-
- case value_t::string:
- return write_bson_string(name, *j.m_value.string);
-
- case value_t::null:
- return write_bson_null(name);
-
- // LCOV_EXCL_START
- default:
- assert(false);
- return;
- // LCOV_EXCL_STOP
- }
- }
-
- /*!
- @brief Calculates the size of the BSON serialization of the given
- JSON-object @a j.
- @param[in] j JSON value to serialize
- @pre j.type() == value_t::object
- */
- static std::size_t calc_bson_object_size(const typename BasicJsonType::object_t& value)
- {
- std::size_t document_size = std::accumulate(value.begin(), value.end(), 0ul,
- [](size_t result, const typename BasicJsonType::object_t::value_type & el)
- {
- return result += calc_bson_element_size(el.first, el.second);
- });
-
- return sizeof(std::int32_t) + document_size + 1ul;
- }
-
- /*!
- @param[in] j JSON value to serialize
- @pre j.type() == value_t::object
- */
- void write_bson_object(const typename BasicJsonType::object_t& value)
- {
- write_number<std::int32_t, true>(static_cast<std::int32_t>(calc_bson_object_size(value)));
-
- for (const auto& el : value)
- {
- write_bson_element(el.first, el.second);
- }
-
- oa->write_character(to_char_type(0x00));
- }
-
- //////////
- // CBOR //
- //////////
-
- static constexpr CharType get_cbor_float_prefix(float /*unused*/)
- {
- return to_char_type(0xFA); // Single-Precision Float
- }
-
- static constexpr CharType get_cbor_float_prefix(double /*unused*/)
- {
- return to_char_type(0xFB); // Double-Precision Float
- }
-
- /////////////
- // MsgPack //
- /////////////
-
- static constexpr CharType get_msgpack_float_prefix(float /*unused*/)
- {
- return to_char_type(0xCA); // float 32
- }
-
- static constexpr CharType get_msgpack_float_prefix(double /*unused*/)
- {
- return to_char_type(0xCB); // float 64
- }
-
- ////////////
- // UBJSON //
- ////////////
-
- // UBJSON: write number (floating point)
- template<typename NumberType, typename std::enable_if<
- std::is_floating_point<NumberType>::value, int>::type = 0>
- void write_number_with_ubjson_prefix(const NumberType n,
- const bool add_prefix)
- {
- if (add_prefix)
- {
- oa->write_character(get_ubjson_float_prefix(n));
- }
- write_number(n);
- }
-
- // UBJSON: write number (unsigned integer)
- template<typename NumberType, typename std::enable_if<
- std::is_unsigned<NumberType>::value, int>::type = 0>
- void write_number_with_ubjson_prefix(const NumberType n,
- const bool add_prefix)
- {
- if (n <= static_cast<std::uint64_t>((std::numeric_limits<std::int8_t>::max)()))
- {
- if (add_prefix)
- {
- oa->write_character(to_char_type('i')); // int8
- }
- write_number(static_cast<std::uint8_t>(n));
- }
- else if (n <= (std::numeric_limits<std::uint8_t>::max)())
- {
- if (add_prefix)
- {
- oa->write_character(to_char_type('U')); // uint8
- }
- write_number(static_cast<std::uint8_t>(n));
- }
- else if (n <= static_cast<std::uint64_t>((std::numeric_limits<std::int16_t>::max)()))
- {
- if (add_prefix)
- {
- oa->write_character(to_char_type('I')); // int16
- }
- write_number(static_cast<std::int16_t>(n));
- }
- else if (n <= static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)()))
- {
- if (add_prefix)
- {
- oa->write_character(to_char_type('l')); // int32
- }
- write_number(static_cast<std::int32_t>(n));
- }
- else if (n <= static_cast<std::uint64_t>((std::numeric_limits<std::int64_t>::max)()))
- {
- if (add_prefix)
- {
- oa->write_character(to_char_type('L')); // int64
- }
- write_number(static_cast<std::int64_t>(n));
- }
- else
- {
- JSON_THROW(out_of_range::create(407, "integer number " + std::to_string(n) + " cannot be represented by UBJSON as it does not fit int64"));
- }
- }
-
- // UBJSON: write number (signed integer)
- template<typename NumberType, typename std::enable_if<
- std::is_signed<NumberType>::value and
- not std::is_floating_point<NumberType>::value, int>::type = 0>
- void write_number_with_ubjson_prefix(const NumberType n,
- const bool add_prefix)
- {
- if ((std::numeric_limits<std::int8_t>::min)() <= n and n <= (std::numeric_limits<std::int8_t>::max)())
- {
- if (add_prefix)
- {
- oa->write_character(to_char_type('i')); // int8
- }
- write_number(static_cast<std::int8_t>(n));
- }
- else if (static_cast<std::int64_t>((std::numeric_limits<std::uint8_t>::min)()) <= n and n <= static_cast<std::int64_t>((std::numeric_limits<std::uint8_t>::max)()))
- {
- if (add_prefix)
- {
- oa->write_character(to_char_type('U')); // uint8
- }
- write_number(static_cast<std::uint8_t>(n));
- }
- else if ((std::numeric_limits<std::int16_t>::min)() <= n and n <= (std::numeric_limits<std::int16_t>::max)())
- {
- if (add_prefix)
- {
- oa->write_character(to_char_type('I')); // int16
- }
- write_number(static_cast<std::int16_t>(n));
- }
- else if ((std::numeric_limits<std::int32_t>::min)() <= n and n <= (std::numeric_limits<std::int32_t>::max)())
- {
- if (add_prefix)
- {
- oa->write_character(to_char_type('l')); // int32
- }
- write_number(static_cast<std::int32_t>(n));
- }
- else if ((std::numeric_limits<std::int64_t>::min)() <= n and n <= (std::numeric_limits<std::int64_t>::max)())
- {
- if (add_prefix)
- {
- oa->write_character(to_char_type('L')); // int64
- }
- write_number(static_cast<std::int64_t>(n));
- }
- // LCOV_EXCL_START
- else
- {
- JSON_THROW(out_of_range::create(407, "integer number " + std::to_string(n) + " cannot be represented by UBJSON as it does not fit int64"));
- }
- // LCOV_EXCL_STOP
- }
-
- /*!
- @brief determine the type prefix of container values
-
- @note This function does not need to be 100% accurate when it comes to
- integer limits. In case a number exceeds the limits of int64_t,
- this will be detected by a later call to function
- write_number_with_ubjson_prefix. Therefore, we return 'L' for any
- value that does not fit the previous limits.
- */
- CharType ubjson_prefix(const BasicJsonType& j) const noexcept
- {
- switch (j.type())
- {
- case value_t::null:
- return 'Z';
-
- case value_t::boolean:
- return j.m_value.boolean ? 'T' : 'F';
-
- case value_t::number_integer:
- {
- if ((std::numeric_limits<std::int8_t>::min)() <= j.m_value.number_integer and j.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
- {
- return 'i';
- }
- if ((std::numeric_limits<std::uint8_t>::min)() <= j.m_value.number_integer and j.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
- {
- return 'U';
- }
- if ((std::numeric_limits<std::int16_t>::min)() <= j.m_value.number_integer and j.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
- {
- return 'I';
- }
- if ((std::numeric_limits<std::int32_t>::min)() <= j.m_value.number_integer and j.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
- {
- return 'l';
- }
- // no check and assume int64_t (see note above)
- return 'L';
- }
-
- case value_t::number_unsigned:
- {
- if (j.m_value.number_unsigned <= (std::numeric_limits<std::int8_t>::max)())
- {
- return 'i';
- }
- if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
- {
- return 'U';
- }
- if (j.m_value.number_unsigned <= (std::numeric_limits<std::int16_t>::max)())
- {
- return 'I';
- }
- if (j.m_value.number_unsigned <= (std::numeric_limits<std::int32_t>::max)())
- {
- return 'l';
- }
- // no check and assume int64_t (see note above)
- return 'L';
- }
-
- case value_t::number_float:
- return get_ubjson_float_prefix(j.m_value.number_float);
-
- case value_t::string:
- return 'S';
-
- case value_t::array:
- return '[';
-
- case value_t::object:
- return '{';
-
- default: // discarded values
- return 'N';
- }
- }
-
- static constexpr CharType get_ubjson_float_prefix(float /*unused*/)
- {
- return 'd'; // float 32
- }
-
- static constexpr CharType get_ubjson_float_prefix(double /*unused*/)
- {
- return 'D'; // float 64
- }
-
- ///////////////////////
- // Utility functions //
- ///////////////////////
-
- /*
- @brief write a number to output input
- @param[in] n number of type @a NumberType
- @tparam NumberType the type of the number
- @tparam OutputIsLittleEndian Set to true if output data is
- required to be little endian
-
- @note This function needs to respect the system's endianess, because bytes
- in CBOR, MessagePack, and UBJSON are stored in network order (big
- endian) and therefore need reordering on little endian systems.
- */
- template<typename NumberType, bool OutputIsLittleEndian = false>
- void write_number(const NumberType n)
- {
- // step 1: write number to array of length NumberType
- std::array<CharType, sizeof(NumberType)> vec;
- std::memcpy(vec.data(), &n, sizeof(NumberType));
-
- // step 2: write array to output (with possible reordering)
- if (is_little_endian != OutputIsLittleEndian)
- {
- // reverse byte order prior to conversion if necessary
- std::reverse(vec.begin(), vec.end());
- }
-
- oa->write_characters(vec.data(), sizeof(NumberType));
- }
-
- public:
- // The following to_char_type functions are implement the conversion
- // between uint8_t and CharType. In case CharType is not unsigned,
- // such a conversion is required to allow values greater than 128.
- // See <https://github.com/nlohmann/json/issues/1286> for a discussion.
- template < typename C = CharType,
- enable_if_t < std::is_signed<C>::value and std::is_signed<char>::value > * = nullptr >
- static constexpr CharType to_char_type(std::uint8_t x) noexcept
- {
- return *reinterpret_cast<char*>(&x);
- }
-
- template < typename C = CharType,
- enable_if_t < std::is_signed<C>::value and std::is_unsigned<char>::value > * = nullptr >
- static CharType to_char_type(std::uint8_t x) noexcept
- {
- static_assert(sizeof(std::uint8_t) == sizeof(CharType), "size of CharType must be equal to std::uint8_t");
- static_assert(std::is_pod<CharType>::value, "CharType must be POD");
- CharType result;
- std::memcpy(&result, &x, sizeof(x));
- return result;
- }
-
- template<typename C = CharType,
- enable_if_t<std::is_unsigned<C>::value>* = nullptr>
- static constexpr CharType to_char_type(std::uint8_t x) noexcept
- {
- return x;
- }
-
- template < typename InputCharType, typename C = CharType,
- enable_if_t <
- std::is_signed<C>::value and
- std::is_signed<char>::value and
- std::is_same<char, typename std::remove_cv<InputCharType>::type>::value
- > * = nullptr >
- static constexpr CharType to_char_type(InputCharType x) noexcept
- {
- return x;
- }
-
- private:
- /// whether we can assume little endianess
- const bool is_little_endian = binary_reader<BasicJsonType>::little_endianess();
-
- /// the output
- output_adapter_t<CharType> oa = nullptr;
-};
-} // namespace detail
-} // namespace nlohmann
-
-// #include <nlohmann/detail/output/output_adapters.hpp>
-
-// #include <nlohmann/detail/output/serializer.hpp>
-
-
-#include <algorithm> // reverse, remove, fill, find, none_of
-#include <array> // array
-#include <cassert> // assert
-#include <ciso646> // and, or
-#include <clocale> // localeconv, lconv
-#include <cmath> // labs, isfinite, isnan, signbit
-#include <cstddef> // size_t, ptrdiff_t
-#include <cstdint> // uint8_t
-#include <cstdio> // snprintf
-#include <limits> // numeric_limits
-#include <string> // string
-#include <type_traits> // is_same
-#include <utility> // move
-
-// #include <nlohmann/detail/conversions/to_chars.hpp>
-
-
-#include <array> // array
-#include <cassert> // assert
-#include <ciso646> // or, and, not
-#include <cmath> // signbit, isfinite
-#include <cstdint> // intN_t, uintN_t
-#include <cstring> // memcpy, memmove
-#include <limits> // numeric_limits
-#include <type_traits> // conditional
-
-namespace nlohmann
-{
-namespace detail
-{
-
-/*!
-@brief implements the Grisu2 algorithm for binary to decimal floating-point
-conversion.
-
-This implementation is a slightly modified version of the reference
-implementation which may be obtained from
-http://florian.loitsch.com/publications (bench.tar.gz).
-
-The code is distributed under the MIT license, Copyright (c) 2009 Florian Loitsch.
-
-For a detailed description of the algorithm see:
-
-[1] Loitsch, "Printing Floating-Point Numbers Quickly and Accurately with
- Integers", Proceedings of the ACM SIGPLAN 2010 Conference on Programming
- Language Design and Implementation, PLDI 2010
-[2] Burger, Dybvig, "Printing Floating-Point Numbers Quickly and Accurately",
- Proceedings of the ACM SIGPLAN 1996 Conference on Programming Language
- Design and Implementation, PLDI 1996
-*/
-namespace dtoa_impl
-{
-
-template <typename Target, typename Source>
-Target reinterpret_bits(const Source source)
-{
- static_assert(sizeof(Target) == sizeof(Source), "size mismatch");
-
- Target target;
- std::memcpy(&target, &source, sizeof(Source));
- return target;
-}
-
-struct diyfp // f * 2^e
-{
- static constexpr int kPrecision = 64; // = q
-
- std::uint64_t f = 0;
- int e = 0;
-
- constexpr diyfp(std::uint64_t f_, int e_) noexcept : f(f_), e(e_) {}
-
- /*!
- @brief returns x - y
- @pre x.e == y.e and x.f >= y.f
- */
- static diyfp sub(const diyfp& x, const diyfp& y) noexcept
- {
- assert(x.e == y.e);
- assert(x.f >= y.f);
-
- return {x.f - y.f, x.e};
- }
-
- /*!
- @brief returns x * y
- @note The result is rounded. (Only the upper q bits are returned.)
- */
- static diyfp mul(const diyfp& x, const diyfp& y) noexcept
- {
- static_assert(kPrecision == 64, "internal error");
-
- // Computes:
- // f = round((x.f * y.f) / 2^q)
- // e = x.e + y.e + q
-
- // Emulate the 64-bit * 64-bit multiplication:
- //
- // p = u * v
- // = (u_lo + 2^32 u_hi) (v_lo + 2^32 v_hi)
- // = (u_lo v_lo ) + 2^32 ((u_lo v_hi ) + (u_hi v_lo )) + 2^64 (u_hi v_hi )
- // = (p0 ) + 2^32 ((p1 ) + (p2 )) + 2^64 (p3 )
- // = (p0_lo + 2^32 p0_hi) + 2^32 ((p1_lo + 2^32 p1_hi) + (p2_lo + 2^32 p2_hi)) + 2^64 (p3 )
- // = (p0_lo ) + 2^32 (p0_hi + p1_lo + p2_lo ) + 2^64 (p1_hi + p2_hi + p3)
- // = (p0_lo ) + 2^32 (Q ) + 2^64 (H )
- // = (p0_lo ) + 2^32 (Q_lo + 2^32 Q_hi ) + 2^64 (H )
- //
- // (Since Q might be larger than 2^32 - 1)
- //
- // = (p0_lo + 2^32 Q_lo) + 2^64 (Q_hi + H)
- //
- // (Q_hi + H does not overflow a 64-bit int)
- //
- // = p_lo + 2^64 p_hi
-
- const std::uint64_t u_lo = x.f & 0xFFFFFFFFu;
- const std::uint64_t u_hi = x.f >> 32u;
- const std::uint64_t v_lo = y.f & 0xFFFFFFFFu;
- const std::uint64_t v_hi = y.f >> 32u;
-
- const std::uint64_t p0 = u_lo * v_lo;
- const std::uint64_t p1 = u_lo * v_hi;
- const std::uint64_t p2 = u_hi * v_lo;
- const std::uint64_t p3 = u_hi * v_hi;
-
- const std::uint64_t p0_hi = p0 >> 32u;
- const std::uint64_t p1_lo = p1 & 0xFFFFFFFFu;
- const std::uint64_t p1_hi = p1 >> 32u;
- const std::uint64_t p2_lo = p2 & 0xFFFFFFFFu;
- const std::uint64_t p2_hi = p2 >> 32u;
-
- std::uint64_t Q = p0_hi + p1_lo + p2_lo;
-
- // The full product might now be computed as
- //
- // p_hi = p3 + p2_hi + p1_hi + (Q >> 32)
- // p_lo = p0_lo + (Q << 32)
- //
- // But in this particular case here, the full p_lo is not required.
- // Effectively we only need to add the highest bit in p_lo to p_hi (and
- // Q_hi + 1 does not overflow).
-
- Q += std::uint64_t{1} << (64u - 32u - 1u); // round, ties up
-
- const std::uint64_t h = p3 + p2_hi + p1_hi + (Q >> 32u);
-
- return {h, x.e + y.e + 64};
- }
-
- /*!
- @brief normalize x such that the significand is >= 2^(q-1)
- @pre x.f != 0
- */
- static diyfp normalize(diyfp x) noexcept
- {
- assert(x.f != 0);
-
- while ((x.f >> 63u) == 0)
- {
- x.f <<= 1u;
- x.e--;
- }
-
- return x;
- }
-
- /*!
- @brief normalize x such that the result has the exponent E
- @pre e >= x.e and the upper e - x.e bits of x.f must be zero.
- */
- static diyfp normalize_to(const diyfp& x, const int target_exponent) noexcept
- {
- const int delta = x.e - target_exponent;
-
- assert(delta >= 0);
- assert(((x.f << delta) >> delta) == x.f);
-
- return {x.f << delta, target_exponent};
- }
-};
-
-struct boundaries
-{
- diyfp w;
- diyfp minus;
- diyfp plus;
-};
-
-/*!
-Compute the (normalized) diyfp representing the input number 'value' and its
-boundaries.
-
-@pre value must be finite and positive
-*/
-template <typename FloatType>
-boundaries compute_boundaries(FloatType value)
-{
- assert(std::isfinite(value));
- assert(value > 0);
-
- // Convert the IEEE representation into a diyfp.
- //
- // If v is denormal:
- // value = 0.F * 2^(1 - bias) = ( F) * 2^(1 - bias - (p-1))
- // If v is normalized:
- // value = 1.F * 2^(E - bias) = (2^(p-1) + F) * 2^(E - bias - (p-1))
-
- static_assert(std::numeric_limits<FloatType>::is_iec559,
- "internal error: dtoa_short requires an IEEE-754 floating-point implementation");
-
- constexpr int kPrecision = std::numeric_limits<FloatType>::digits; // = p (includes the hidden bit)
- constexpr int kBias = std::numeric_limits<FloatType>::max_exponent - 1 + (kPrecision - 1);
- constexpr int kMinExp = 1 - kBias;
- constexpr std::uint64_t kHiddenBit = std::uint64_t{1} << (kPrecision - 1); // = 2^(p-1)
-
- using bits_type = typename std::conditional<kPrecision == 24, std::uint32_t, std::uint64_t >::type;
-
- const std::uint64_t bits = reinterpret_bits<bits_type>(value);
- const std::uint64_t E = bits >> (kPrecision - 1);
- const std::uint64_t F = bits & (kHiddenBit - 1);
-
- const bool is_denormal = E == 0;
- const diyfp v = is_denormal
- ? diyfp(F, kMinExp)
- : diyfp(F + kHiddenBit, static_cast<int>(E) - kBias);
-
- // Compute the boundaries m- and m+ of the floating-point value
- // v = f * 2^e.
- //
- // Determine v- and v+, the floating-point predecessor and successor if v,
- // respectively.
- //
- // v- = v - 2^e if f != 2^(p-1) or e == e_min (A)
- // = v - 2^(e-1) if f == 2^(p-1) and e > e_min (B)
- //
- // v+ = v + 2^e
- //
- // Let m- = (v- + v) / 2 and m+ = (v + v+) / 2. All real numbers _strictly_
- // between m- and m+ round to v, regardless of how the input rounding
- // algorithm breaks ties.
- //
- // ---+-------------+-------------+-------------+-------------+--- (A)
- // v- m- v m+ v+
- //
- // -----------------+------+------+-------------+-------------+--- (B)
- // v- m- v m+ v+
-
- const bool lower_boundary_is_closer = F == 0 and E > 1;
- const diyfp m_plus = diyfp(2 * v.f + 1, v.e - 1);
- const diyfp m_minus = lower_boundary_is_closer
- ? diyfp(4 * v.f - 1, v.e - 2) // (B)
- : diyfp(2 * v.f - 1, v.e - 1); // (A)
-
- // Determine the normalized w+ = m+.
- const diyfp w_plus = diyfp::normalize(m_plus);
-
- // Determine w- = m- such that e_(w-) = e_(w+).
- const diyfp w_minus = diyfp::normalize_to(m_minus, w_plus.e);
-
- return {diyfp::normalize(v), w_minus, w_plus};
-}
-
-// Given normalized diyfp w, Grisu needs to find a (normalized) cached
-// power-of-ten c, such that the exponent of the product c * w = f * 2^e lies
-// within a certain range [alpha, gamma] (Definition 3.2 from [1])
-//
-// alpha <= e = e_c + e_w + q <= gamma
-//
-// or
-//
-// f_c * f_w * 2^alpha <= f_c 2^(e_c) * f_w 2^(e_w) * 2^q
-// <= f_c * f_w * 2^gamma
-//
-// Since c and w are normalized, i.e. 2^(q-1) <= f < 2^q, this implies
-//
-// 2^(q-1) * 2^(q-1) * 2^alpha <= c * w * 2^q < 2^q * 2^q * 2^gamma
-//
-// or
-//
-// 2^(q - 2 + alpha) <= c * w < 2^(q + gamma)
-//
-// The choice of (alpha,gamma) determines the size of the table and the form of
-// the digit generation procedure. Using (alpha,gamma)=(-60,-32) works out well
-// in practice:
-//
-// The idea is to cut the number c * w = f * 2^e into two parts, which can be
-// processed independently: An integral part p1, and a fractional part p2:
-//
-// f * 2^e = ( (f div 2^-e) * 2^-e + (f mod 2^-e) ) * 2^e
-// = (f div 2^-e) + (f mod 2^-e) * 2^e
-// = p1 + p2 * 2^e
-//
-// The conversion of p1 into decimal form requires a series of divisions and
-// modulos by (a power of) 10. These operations are faster for 32-bit than for
-// 64-bit integers, so p1 should ideally fit into a 32-bit integer. This can be
-// achieved by choosing
-//
-// -e >= 32 or e <= -32 := gamma
-//
-// In order to convert the fractional part
-//
-// p2 * 2^e = p2 / 2^-e = d[-1] / 10^1 + d[-2] / 10^2 + ...
-//
-// into decimal form, the fraction is repeatedly multiplied by 10 and the digits
-// d[-i] are extracted in order:
-//
-// (10 * p2) div 2^-e = d[-1]
-// (10 * p2) mod 2^-e = d[-2] / 10^1 + ...
-//
-// The multiplication by 10 must not overflow. It is sufficient to choose
-//
-// 10 * p2 < 16 * p2 = 2^4 * p2 <= 2^64.
-//
-// Since p2 = f mod 2^-e < 2^-e,
-//
-// -e <= 60 or e >= -60 := alpha
-
-constexpr int kAlpha = -60;
-constexpr int kGamma = -32;
-
-struct cached_power // c = f * 2^e ~= 10^k
-{
- std::uint64_t f;
- int e;
- int k;
-};
-
-/*!
-For a normalized diyfp w = f * 2^e, this function returns a (normalized) cached
-power-of-ten c = f_c * 2^e_c, such that the exponent of the product w * c
-satisfies (Definition 3.2 from [1])
-
- alpha <= e_c + e + q <= gamma.
-*/
-inline cached_power get_cached_power_for_binary_exponent(int e)
-{
- // Now
- //
- // alpha <= e_c + e + q <= gamma (1)
- // ==> f_c * 2^alpha <= c * 2^e * 2^q
- //
- // and since the c's are normalized, 2^(q-1) <= f_c,
- //
- // ==> 2^(q - 1 + alpha) <= c * 2^(e + q)
- // ==> 2^(alpha - e - 1) <= c
- //
- // If c were an exakt power of ten, i.e. c = 10^k, one may determine k as
- //
- // k = ceil( log_10( 2^(alpha - e - 1) ) )
- // = ceil( (alpha - e - 1) * log_10(2) )
- //
- // From the paper:
- // "In theory the result of the procedure could be wrong since c is rounded,
- // and the computation itself is approximated [...]. In practice, however,
- // this simple function is sufficient."
- //
- // For IEEE double precision floating-point numbers converted into
- // normalized diyfp's w = f * 2^e, with q = 64,
- //
- // e >= -1022 (min IEEE exponent)
- // -52 (p - 1)
- // -52 (p - 1, possibly normalize denormal IEEE numbers)
- // -11 (normalize the diyfp)
- // = -1137
- //
- // and
- //
- // e <= +1023 (max IEEE exponent)
- // -52 (p - 1)
- // -11 (normalize the diyfp)
- // = 960
- //
- // This binary exponent range [-1137,960] results in a decimal exponent
- // range [-307,324]. One does not need to store a cached power for each
- // k in this range. For each such k it suffices to find a cached power
- // such that the exponent of the product lies in [alpha,gamma].
- // This implies that the difference of the decimal exponents of adjacent
- // table entries must be less than or equal to
- //
- // floor( (gamma - alpha) * log_10(2) ) = 8.
- //
- // (A smaller distance gamma-alpha would require a larger table.)
-
- // NB:
- // Actually this function returns c, such that -60 <= e_c + e + 64 <= -34.
-
- constexpr int kCachedPowersMinDecExp = -300;
- constexpr int kCachedPowersDecStep = 8;
-
- static constexpr std::array<cached_power, 79> kCachedPowers =
- {
- {
- { 0xAB70FE17C79AC6CA, -1060, -300 },
- { 0xFF77B1FCBEBCDC4F, -1034, -292 },
- { 0xBE5691EF416BD60C, -1007, -284 },
- { 0x8DD01FAD907FFC3C, -980, -276 },
- { 0xD3515C2831559A83, -954, -268 },
- { 0x9D71AC8FADA6C9B5, -927, -260 },
- { 0xEA9C227723EE8BCB, -901, -252 },
- { 0xAECC49914078536D, -874, -244 },
- { 0x823C12795DB6CE57, -847, -236 },
- { 0xC21094364DFB5637, -821, -228 },
- { 0x9096EA6F3848984F, -794, -220 },
- { 0xD77485CB25823AC7, -768, -212 },
- { 0xA086CFCD97BF97F4, -741, -204 },
- { 0xEF340A98172AACE5, -715, -196 },
- { 0xB23867FB2A35B28E, -688, -188 },
- { 0x84C8D4DFD2C63F3B, -661, -180 },
- { 0xC5DD44271AD3CDBA, -635, -172 },
- { 0x936B9FCEBB25C996, -608, -164 },
- { 0xDBAC6C247D62A584, -582, -156 },
- { 0xA3AB66580D5FDAF6, -555, -148 },
- { 0xF3E2F893DEC3F126, -529, -140 },
- { 0xB5B5ADA8AAFF80B8, -502, -132 },
- { 0x87625F056C7C4A8B, -475, -124 },
- { 0xC9BCFF6034C13053, -449, -116 },
- { 0x964E858C91BA2655, -422, -108 },
- { 0xDFF9772470297EBD, -396, -100 },
- { 0xA6DFBD9FB8E5B88F, -369, -92 },
- { 0xF8A95FCF88747D94, -343, -84 },
- { 0xB94470938FA89BCF, -316, -76 },
- { 0x8A08F0F8BF0F156B, -289, -68 },
- { 0xCDB02555653131B6, -263, -60 },
- { 0x993FE2C6D07B7FAC, -236, -52 },
- { 0xE45C10C42A2B3B06, -210, -44 },
- { 0xAA242499697392D3, -183, -36 },
- { 0xFD87B5F28300CA0E, -157, -28 },
- { 0xBCE5086492111AEB, -130, -20 },
- { 0x8CBCCC096F5088CC, -103, -12 },
- { 0xD1B71758E219652C, -77, -4 },
- { 0x9C40000000000000, -50, 4 },
- { 0xE8D4A51000000000, -24, 12 },
- { 0xAD78EBC5AC620000, 3, 20 },
- { 0x813F3978F8940984, 30, 28 },
- { 0xC097CE7BC90715B3, 56, 36 },
- { 0x8F7E32CE7BEA5C70, 83, 44 },
- { 0xD5D238A4ABE98068, 109, 52 },
- { 0x9F4F2726179A2245, 136, 60 },
- { 0xED63A231D4C4FB27, 162, 68 },
- { 0xB0DE65388CC8ADA8, 189, 76 },
- { 0x83C7088E1AAB65DB, 216, 84 },
- { 0xC45D1DF942711D9A, 242, 92 },
- { 0x924D692CA61BE758, 269, 100 },
- { 0xDA01EE641A708DEA, 295, 108 },
- { 0xA26DA3999AEF774A, 322, 116 },
- { 0xF209787BB47D6B85, 348, 124 },
- { 0xB454E4A179DD1877, 375, 132 },
- { 0x865B86925B9BC5C2, 402, 140 },
- { 0xC83553C5C8965D3D, 428, 148 },
- { 0x952AB45CFA97A0B3, 455, 156 },
- { 0xDE469FBD99A05FE3, 481, 164 },
- { 0xA59BC234DB398C25, 508, 172 },
- { 0xF6C69A72A3989F5C, 534, 180 },
- { 0xB7DCBF5354E9BECE, 561, 188 },
- { 0x88FCF317F22241E2, 588, 196 },
- { 0xCC20CE9BD35C78A5, 614, 204 },
- { 0x98165AF37B2153DF, 641, 212 },
- { 0xE2A0B5DC971F303A, 667, 220 },
- { 0xA8D9D1535CE3B396, 694, 228 },
- { 0xFB9B7CD9A4A7443C, 720, 236 },
- { 0xBB764C4CA7A44410, 747, 244 },
- { 0x8BAB8EEFB6409C1A, 774, 252 },
- { 0xD01FEF10A657842C, 800, 260 },
- { 0x9B10A4E5E9913129, 827, 268 },
- { 0xE7109BFBA19C0C9D, 853, 276 },
- { 0xAC2820D9623BF429, 880, 284 },
- { 0x80444B5E7AA7CF85, 907, 292 },
- { 0xBF21E44003ACDD2D, 933, 300 },
- { 0x8E679C2F5E44FF8F, 960, 308 },
- { 0xD433179D9C8CB841, 986, 316 },
- { 0x9E19DB92B4E31BA9, 1013, 324 },
- }
- };
-
- // This computation gives exactly the same results for k as
- // k = ceil((kAlpha - e - 1) * 0.30102999566398114)
- // for |e| <= 1500, but doesn't require floating-point operations.
- // NB: log_10(2) ~= 78913 / 2^18
- assert(e >= -1500);
- assert(e <= 1500);
- const int f = kAlpha - e - 1;
- const int k = (f * 78913) / (1 << 18) + static_cast<int>(f > 0);
-
- const int index = (-kCachedPowersMinDecExp + k + (kCachedPowersDecStep - 1)) / kCachedPowersDecStep;
- assert(index >= 0);
- assert(static_cast<std::size_t>(index) < kCachedPowers.size());
-
- const cached_power cached = kCachedPowers[static_cast<std::size_t>(index)];
- assert(kAlpha <= cached.e + e + 64);
- assert(kGamma >= cached.e + e + 64);
-
- return cached;
-}
-
-/*!
-For n != 0, returns k, such that pow10 := 10^(k-1) <= n < 10^k.
-For n == 0, returns 1 and sets pow10 := 1.
-*/
-inline int find_largest_pow10(const std::uint32_t n, std::uint32_t& pow10)
-{
- // LCOV_EXCL_START
- if (n >= 1000000000)
- {
- pow10 = 1000000000;
- return 10;
- }
- // LCOV_EXCL_STOP
- else if (n >= 100000000)
- {
- pow10 = 100000000;
- return 9;
- }
- else if (n >= 10000000)
- {
- pow10 = 10000000;
- return 8;
- }
- else if (n >= 1000000)
- {
- pow10 = 1000000;
- return 7;
- }
- else if (n >= 100000)
- {
- pow10 = 100000;
- return 6;
- }
- else if (n >= 10000)
- {
- pow10 = 10000;
- return 5;
- }
- else if (n >= 1000)
- {
- pow10 = 1000;
- return 4;
- }
- else if (n >= 100)
- {
- pow10 = 100;
- return 3;
- }
- else if (n >= 10)
- {
- pow10 = 10;
- return 2;
- }
- else
- {
- pow10 = 1;
- return 1;
- }
-}
-
-inline void grisu2_round(char* buf, int len, std::uint64_t dist, std::uint64_t delta,
- std::uint64_t rest, std::uint64_t ten_k)
-{
- assert(len >= 1);
- assert(dist <= delta);
- assert(rest <= delta);
- assert(ten_k > 0);
-
- // <--------------------------- delta ---->
- // <---- dist --------->
- // --------------[------------------+-------------------]--------------
- // M- w M+
- //
- // ten_k
- // <------>
- // <---- rest ---->
- // --------------[------------------+----+--------------]--------------
- // w V
- // = buf * 10^k
- //
- // ten_k represents a unit-in-the-last-place in the decimal representation
- // stored in buf.
- // Decrement buf by ten_k while this takes buf closer to w.
-
- // The tests are written in this order to avoid overflow in unsigned
- // integer arithmetic.
-
- while (rest < dist
- and delta - rest >= ten_k
- and (rest + ten_k < dist or dist - rest > rest + ten_k - dist))
- {
- assert(buf[len - 1] != '0');
- buf[len - 1]--;
- rest += ten_k;
- }
-}
-
-/*!
-Generates V = buffer * 10^decimal_exponent, such that M- <= V <= M+.
-M- and M+ must be normalized and share the same exponent -60 <= e <= -32.
-*/
-inline void grisu2_digit_gen(char* buffer, int& length, int& decimal_exponent,
- diyfp M_minus, diyfp w, diyfp M_plus)
-{
- static_assert(kAlpha >= -60, "internal error");
- static_assert(kGamma <= -32, "internal error");
-
- // Generates the digits (and the exponent) of a decimal floating-point
- // number V = buffer * 10^decimal_exponent in the range [M-, M+]. The diyfp's
- // w, M- and M+ share the same exponent e, which satisfies alpha <= e <= gamma.
- //
- // <--------------------------- delta ---->
- // <---- dist --------->
- // --------------[------------------+-------------------]--------------
- // M- w M+
- //
- // Grisu2 generates the digits of M+ from left to right and stops as soon as
- // V is in [M-,M+].
-
- assert(M_plus.e >= kAlpha);
- assert(M_plus.e <= kGamma);
-
- std::uint64_t delta = diyfp::sub(M_plus, M_minus).f; // (significand of (M+ - M-), implicit exponent is e)
- std::uint64_t dist = diyfp::sub(M_plus, w ).f; // (significand of (M+ - w ), implicit exponent is e)
-
- // Split M+ = f * 2^e into two parts p1 and p2 (note: e < 0):
- //
- // M+ = f * 2^e
- // = ((f div 2^-e) * 2^-e + (f mod 2^-e)) * 2^e
- // = ((p1 ) * 2^-e + (p2 )) * 2^e
- // = p1 + p2 * 2^e
-
- const diyfp one(std::uint64_t{1} << -M_plus.e, M_plus.e);
-
- auto p1 = static_cast<std::uint32_t>(M_plus.f >> -one.e); // p1 = f div 2^-e (Since -e >= 32, p1 fits into a 32-bit int.)
- std::uint64_t p2 = M_plus.f & (one.f - 1); // p2 = f mod 2^-e
-
- // 1)
- //
- // Generate the digits of the integral part p1 = d[n-1]...d[1]d[0]
-
- assert(p1 > 0);
-
- std::uint32_t pow10;
- const int k = find_largest_pow10(p1, pow10);
-
- // 10^(k-1) <= p1 < 10^k, pow10 = 10^(k-1)
- //
- // p1 = (p1 div 10^(k-1)) * 10^(k-1) + (p1 mod 10^(k-1))
- // = (d[k-1] ) * 10^(k-1) + (p1 mod 10^(k-1))
- //
- // M+ = p1 + p2 * 2^e
- // = d[k-1] * 10^(k-1) + (p1 mod 10^(k-1)) + p2 * 2^e
- // = d[k-1] * 10^(k-1) + ((p1 mod 10^(k-1)) * 2^-e + p2) * 2^e
- // = d[k-1] * 10^(k-1) + ( rest) * 2^e
- //
- // Now generate the digits d[n] of p1 from left to right (n = k-1,...,0)
- //
- // p1 = d[k-1]...d[n] * 10^n + d[n-1]...d[0]
- //
- // but stop as soon as
- //
- // rest * 2^e = (d[n-1]...d[0] * 2^-e + p2) * 2^e <= delta * 2^e
-
- int n = k;
- while (n > 0)
- {
- // Invariants:
- // M+ = buffer * 10^n + (p1 + p2 * 2^e) (buffer = 0 for n = k)
- // pow10 = 10^(n-1) <= p1 < 10^n
- //
- const std::uint32_t d = p1 / pow10; // d = p1 div 10^(n-1)
- const std::uint32_t r = p1 % pow10; // r = p1 mod 10^(n-1)
- //
- // M+ = buffer * 10^n + (d * 10^(n-1) + r) + p2 * 2^e
- // = (buffer * 10 + d) * 10^(n-1) + (r + p2 * 2^e)
- //
- assert(d <= 9);
- buffer[length++] = static_cast<char>('0' + d); // buffer := buffer * 10 + d
- //
- // M+ = buffer * 10^(n-1) + (r + p2 * 2^e)
- //
- p1 = r;
- n--;
- //
- // M+ = buffer * 10^n + (p1 + p2 * 2^e)
- // pow10 = 10^n
- //
-
- // Now check if enough digits have been generated.
- // Compute
- //
- // p1 + p2 * 2^e = (p1 * 2^-e + p2) * 2^e = rest * 2^e
- //
- // Note:
- // Since rest and delta share the same exponent e, it suffices to
- // compare the significands.
- const std::uint64_t rest = (std::uint64_t{p1} << -one.e) + p2;
- if (rest <= delta)
- {
- // V = buffer * 10^n, with M- <= V <= M+.
-
- decimal_exponent += n;
-
- // We may now just stop. But instead look if the buffer could be
- // decremented to bring V closer to w.
- //
- // pow10 = 10^n is now 1 ulp in the decimal representation V.
- // The rounding procedure works with diyfp's with an implicit
- // exponent of e.
- //
- // 10^n = (10^n * 2^-e) * 2^e = ulp * 2^e
- //
- const std::uint64_t ten_n = std::uint64_t{pow10} << -one.e;
- grisu2_round(buffer, length, dist, delta, rest, ten_n);
-
- return;
- }
-
- pow10 /= 10;
- //
- // pow10 = 10^(n-1) <= p1 < 10^n
- // Invariants restored.
- }
-
- // 2)
- //
- // The digits of the integral part have been generated:
- //
- // M+ = d[k-1]...d[1]d[0] + p2 * 2^e
- // = buffer + p2 * 2^e
- //
- // Now generate the digits of the fractional part p2 * 2^e.
- //
- // Note:
- // No decimal point is generated: the exponent is adjusted instead.
- //
- // p2 actually represents the fraction
- //
- // p2 * 2^e
- // = p2 / 2^-e
- // = d[-1] / 10^1 + d[-2] / 10^2 + ...
- //
- // Now generate the digits d[-m] of p1 from left to right (m = 1,2,...)
- //
- // p2 * 2^e = d[-1]d[-2]...d[-m] * 10^-m
- // + 10^-m * (d[-m-1] / 10^1 + d[-m-2] / 10^2 + ...)
- //
- // using
- //
- // 10^m * p2 = ((10^m * p2) div 2^-e) * 2^-e + ((10^m * p2) mod 2^-e)
- // = ( d) * 2^-e + ( r)
- //
- // or
- // 10^m * p2 * 2^e = d + r * 2^e
- //
- // i.e.
- //
- // M+ = buffer + p2 * 2^e
- // = buffer + 10^-m * (d + r * 2^e)
- // = (buffer * 10^m + d) * 10^-m + 10^-m * r * 2^e
- //
- // and stop as soon as 10^-m * r * 2^e <= delta * 2^e
-
- assert(p2 > delta);
-
- int m = 0;
- for (;;)
- {
- // Invariant:
- // M+ = buffer * 10^-m + 10^-m * (d[-m-1] / 10 + d[-m-2] / 10^2 + ...) * 2^e
- // = buffer * 10^-m + 10^-m * (p2 ) * 2^e
- // = buffer * 10^-m + 10^-m * (1/10 * (10 * p2) ) * 2^e
- // = buffer * 10^-m + 10^-m * (1/10 * ((10*p2 div 2^-e) * 2^-e + (10*p2 mod 2^-e)) * 2^e
- //
- assert(p2 <= (std::numeric_limits<std::uint64_t>::max)() / 10);
- p2 *= 10;
- const std::uint64_t d = p2 >> -one.e; // d = (10 * p2) div 2^-e
- const std::uint64_t r = p2 & (one.f - 1); // r = (10 * p2) mod 2^-e
- //
- // M+ = buffer * 10^-m + 10^-m * (1/10 * (d * 2^-e + r) * 2^e
- // = buffer * 10^-m + 10^-m * (1/10 * (d + r * 2^e))
- // = (buffer * 10 + d) * 10^(-m-1) + 10^(-m-1) * r * 2^e
- //
- assert(d <= 9);
- buffer[length++] = static_cast<char>('0' + d); // buffer := buffer * 10 + d
- //
- // M+ = buffer * 10^(-m-1) + 10^(-m-1) * r * 2^e
- //
- p2 = r;
- m++;
- //
- // M+ = buffer * 10^-m + 10^-m * p2 * 2^e
- // Invariant restored.
-
- // Check if enough digits have been generated.
- //
- // 10^-m * p2 * 2^e <= delta * 2^e
- // p2 * 2^e <= 10^m * delta * 2^e
- // p2 <= 10^m * delta
- delta *= 10;
- dist *= 10;
- if (p2 <= delta)
- {
- break;
- }
- }
-
- // V = buffer * 10^-m, with M- <= V <= M+.
-
- decimal_exponent -= m;
-
- // 1 ulp in the decimal representation is now 10^-m.
- // Since delta and dist are now scaled by 10^m, we need to do the
- // same with ulp in order to keep the units in sync.
- //
- // 10^m * 10^-m = 1 = 2^-e * 2^e = ten_m * 2^e
- //
- const std::uint64_t ten_m = one.f;
- grisu2_round(buffer, length, dist, delta, p2, ten_m);
-
- // By construction this algorithm generates the shortest possible decimal
- // number (Loitsch, Theorem 6.2) which rounds back to w.
- // For an input number of precision p, at least
- //
- // N = 1 + ceil(p * log_10(2))
- //
- // decimal digits are sufficient to identify all binary floating-point
- // numbers (Matula, "In-and-Out conversions").
- // This implies that the algorithm does not produce more than N decimal
- // digits.
- //
- // N = 17 for p = 53 (IEEE double precision)
- // N = 9 for p = 24 (IEEE single precision)
-}
-
-/*!
-v = buf * 10^decimal_exponent
-len is the length of the buffer (number of decimal digits)
-The buffer must be large enough, i.e. >= max_digits10.
-*/
-inline void grisu2(char* buf, int& len, int& decimal_exponent,
- diyfp m_minus, diyfp v, diyfp m_plus)
-{
- assert(m_plus.e == m_minus.e);
- assert(m_plus.e == v.e);
-
- // --------(-----------------------+-----------------------)-------- (A)
- // m- v m+
- //
- // --------------------(-----------+-----------------------)-------- (B)
- // m- v m+
- //
- // First scale v (and m- and m+) such that the exponent is in the range
- // [alpha, gamma].
-
- const cached_power cached = get_cached_power_for_binary_exponent(m_plus.e);
-
- const diyfp c_minus_k(cached.f, cached.e); // = c ~= 10^-k
-
- // The exponent of the products is = v.e + c_minus_k.e + q and is in the range [alpha,gamma]
- const diyfp w = diyfp::mul(v, c_minus_k);
- const diyfp w_minus = diyfp::mul(m_minus, c_minus_k);
- const diyfp w_plus = diyfp::mul(m_plus, c_minus_k);
-
- // ----(---+---)---------------(---+---)---------------(---+---)----
- // w- w w+
- // = c*m- = c*v = c*m+
- //
- // diyfp::mul rounds its result and c_minus_k is approximated too. w, w- and
- // w+ are now off by a small amount.
- // In fact:
- //
- // w - v * 10^k < 1 ulp
- //
- // To account for this inaccuracy, add resp. subtract 1 ulp.
- //
- // --------+---[---------------(---+---)---------------]---+--------
- // w- M- w M+ w+
- //
- // Now any number in [M-, M+] (bounds included) will round to w when input,
- // regardless of how the input rounding algorithm breaks ties.
- //
- // And digit_gen generates the shortest possible such number in [M-, M+].
- // Note that this does not mean that Grisu2 always generates the shortest
- // possible number in the interval (m-, m+).
- const diyfp M_minus(w_minus.f + 1, w_minus.e);
- const diyfp M_plus (w_plus.f - 1, w_plus.e );
-
- decimal_exponent = -cached.k; // = -(-k) = k
-
- grisu2_digit_gen(buf, len, decimal_exponent, M_minus, w, M_plus);
-}
-
-/*!
-v = buf * 10^decimal_exponent
-len is the length of the buffer (number of decimal digits)
-The buffer must be large enough, i.e. >= max_digits10.
-*/
-template <typename FloatType>
-void grisu2(char* buf, int& len, int& decimal_exponent, FloatType value)
-{
- static_assert(diyfp::kPrecision >= std::numeric_limits<FloatType>::digits + 3,
- "internal error: not enough precision");
-
- assert(std::isfinite(value));
- assert(value > 0);
-
- // If the neighbors (and boundaries) of 'value' are always computed for double-precision
- // numbers, all float's can be recovered using strtod (and strtof). However, the resulting
- // decimal representations are not exactly "short".
- //
- // The documentation for 'std::to_chars' (https://en.cppreference.com/w/cpp/utility/to_chars)
- // says "value is converted to a string as if by std::sprintf in the default ("C") locale"
- // and since sprintf promotes float's to double's, I think this is exactly what 'std::to_chars'
- // does.
- // On the other hand, the documentation for 'std::to_chars' requires that "parsing the
- // representation using the corresponding std::from_chars function recovers value exactly". That
- // indicates that single precision floating-point numbers should be recovered using
- // 'std::strtof'.
- //
- // NB: If the neighbors are computed for single-precision numbers, there is a single float
- // (7.0385307e-26f) which can't be recovered using strtod. The resulting double precision
- // value is off by 1 ulp.
-#if 0
- const boundaries w = compute_boundaries(static_cast<double>(value));
-#else
- const boundaries w = compute_boundaries(value);
-#endif
-
- grisu2(buf, len, decimal_exponent, w.minus, w.w, w.plus);
-}
-
-/*!
-@brief appends a decimal representation of e to buf
-@return a pointer to the element following the exponent.
-@pre -1000 < e < 1000
-*/
-inline char* append_exponent(char* buf, int e)
-{
- assert(e > -1000);
- assert(e < 1000);
-
- if (e < 0)
- {
- e = -e;
- *buf++ = '-';
- }
- else
- {
- *buf++ = '+';
- }
-
- auto k = static_cast<std::uint32_t>(e);
- if (k < 10)
- {
- // Always print at least two digits in the exponent.
- // This is for compatibility with printf("%g").
- *buf++ = '0';
- *buf++ = static_cast<char>('0' + k);
- }
- else if (k < 100)
- {
- *buf++ = static_cast<char>('0' + k / 10);
- k %= 10;
- *buf++ = static_cast<char>('0' + k);
- }
- else
- {
- *buf++ = static_cast<char>('0' + k / 100);
- k %= 100;
- *buf++ = static_cast<char>('0' + k / 10);
- k %= 10;
- *buf++ = static_cast<char>('0' + k);
- }
-
- return buf;
-}
-
-/*!
-@brief prettify v = buf * 10^decimal_exponent
-
-If v is in the range [10^min_exp, 10^max_exp) it will be printed in fixed-point
-notation. Otherwise it will be printed in exponential notation.
-
-@pre min_exp < 0
-@pre max_exp > 0
-*/
-inline char* format_buffer(char* buf, int len, int decimal_exponent,
- int min_exp, int max_exp)
-{
- assert(min_exp < 0);
- assert(max_exp > 0);
-
- const int k = len;
- const int n = len + decimal_exponent;
-
- // v = buf * 10^(n-k)
- // k is the length of the buffer (number of decimal digits)
- // n is the position of the decimal point relative to the start of the buffer.
-
- if (k <= n and n <= max_exp)
- {
- // digits[000]
- // len <= max_exp + 2
-
- std::memset(buf + k, '0', static_cast<size_t>(n - k));
- // Make it look like a floating-point number (#362, #378)
- buf[n + 0] = '.';
- buf[n + 1] = '0';
- return buf + (n + 2);
- }
-
- if (0 < n and n <= max_exp)
- {
- // dig.its
- // len <= max_digits10 + 1
-
- assert(k > n);
-
- std::memmove(buf + (n + 1), buf + n, static_cast<size_t>(k - n));
- buf[n] = '.';
- return buf + (k + 1);
- }
-
- if (min_exp < n and n <= 0)
- {
- // 0.[000]digits
- // len <= 2 + (-min_exp - 1) + max_digits10
-
- std::memmove(buf + (2 + -n), buf, static_cast<size_t>(k));
- buf[0] = '0';
- buf[1] = '.';
- std::memset(buf + 2, '0', static_cast<size_t>(-n));
- return buf + (2 + (-n) + k);
- }
-
- if (k == 1)
- {
- // dE+123
- // len <= 1 + 5
-
- buf += 1;
- }
- else
- {
- // d.igitsE+123
- // len <= max_digits10 + 1 + 5
-
- std::memmove(buf + 2, buf + 1, static_cast<size_t>(k - 1));
- buf[1] = '.';
- buf += 1 + k;
- }
-
- *buf++ = 'e';
- return append_exponent(buf, n - 1);
-}
-
-} // namespace dtoa_impl
-
-/*!
-@brief generates a decimal representation of the floating-point number value in [first, last).
-
-The format of the resulting decimal representation is similar to printf's %g
-format. Returns an iterator pointing past-the-end of the decimal representation.
-
-@note The input number must be finite, i.e. NaN's and Inf's are not supported.
-@note The buffer must be large enough.
-@note The result is NOT null-terminated.
-*/
-template <typename FloatType>
-char* to_chars(char* first, const char* last, FloatType value)
-{
- static_cast<void>(last); // maybe unused - fix warning
- assert(std::isfinite(value));
-
- // Use signbit(value) instead of (value < 0) since signbit works for -0.
- if (std::signbit(value))
- {
- value = -value;
- *first++ = '-';
- }
-
- if (value == 0) // +-0
- {
- *first++ = '0';
- // Make it look like a floating-point number (#362, #378)
- *first++ = '.';
- *first++ = '0';
- return first;
- }
-
- assert(last - first >= std::numeric_limits<FloatType>::max_digits10);
-
- // Compute v = buffer * 10^decimal_exponent.
- // The decimal digits are stored in the buffer, which needs to be interpreted
- // as an unsigned decimal integer.
- // len is the length of the buffer, i.e. the number of decimal digits.
- int len = 0;
- int decimal_exponent = 0;
- dtoa_impl::grisu2(first, len, decimal_exponent, value);
-
- assert(len <= std::numeric_limits<FloatType>::max_digits10);
-
- // Format the buffer like printf("%.*g", prec, value)
- constexpr int kMinExp = -4;
- // Use digits10 here to increase compatibility with version 2.
- constexpr int kMaxExp = std::numeric_limits<FloatType>::digits10;
-
- assert(last - first >= kMaxExp + 2);
- assert(last - first >= 2 + (-kMinExp - 1) + std::numeric_limits<FloatType>::max_digits10);
- assert(last - first >= std::numeric_limits<FloatType>::max_digits10 + 6);
-
- return dtoa_impl::format_buffer(first, len, decimal_exponent, kMinExp, kMaxExp);
-}
-
-} // namespace detail
-} // namespace nlohmann
-
-// #include <nlohmann/detail/exceptions.hpp>
-
-// #include <nlohmann/detail/macro_scope.hpp>
-
-// #include <nlohmann/detail/meta/cpp_future.hpp>
-
-// #include <nlohmann/detail/output/binary_writer.hpp>
-
-// #include <nlohmann/detail/output/output_adapters.hpp>
-
-// #include <nlohmann/detail/value_t.hpp>
-
-
-namespace nlohmann
-{
-namespace detail
-{
-///////////////////
-// serialization //
-///////////////////
-
-/// how to treat decoding errors
-enum class error_handler_t
-{
- strict, ///< throw a type_error exception in case of invalid UTF-8
- replace, ///< replace invalid UTF-8 sequences with U+FFFD
- ignore ///< ignore invalid UTF-8 sequences
-};
-
-template<typename BasicJsonType>
-class serializer
-{
- using string_t = typename BasicJsonType::string_t;
- using number_float_t = typename BasicJsonType::number_float_t;
- using number_integer_t = typename BasicJsonType::number_integer_t;
- using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
- static constexpr std::uint8_t UTF8_ACCEPT = 0;
- static constexpr std::uint8_t UTF8_REJECT = 1;
-
- public:
- /*!
- @param[in] s output stream to serialize to
- @param[in] ichar indentation character to use
- @param[in] error_handler_ how to react on decoding errors
- */
- serializer(output_adapter_t<char> s, const char ichar,
- error_handler_t error_handler_ = error_handler_t::strict)
- : o(std::move(s))
- , loc(std::localeconv())
- , thousands_sep(loc->thousands_sep == nullptr ? '\0' : * (loc->thousands_sep))
- , decimal_point(loc->decimal_point == nullptr ? '\0' : * (loc->decimal_point))
- , indent_char(ichar)
- , indent_string(512, indent_char)
- , error_handler(error_handler_)
- {}
-
- // delete because of pointer members
- serializer(const serializer&) = delete;
- serializer& operator=(const serializer&) = delete;
- serializer(serializer&&) = delete;
- serializer& operator=(serializer&&) = delete;
- ~serializer() = default;
-
- /*!
- @brief internal implementation of the serialization function
-
- This function is called by the public member function dump and organizes
- the serialization internally. The indentation level is propagated as
- additional parameter. In case of arrays and objects, the function is
- called recursively.
-
- - strings and object keys are escaped using `escape_string()`
- - integer numbers are converted implicitly via `operator<<`
- - floating-point numbers are converted to a string using `"%g"` format
-
- @param[in] val value to serialize
- @param[in] pretty_print whether the output shall be pretty-printed
- @param[in] indent_step the indent level
- @param[in] current_indent the current indent level (only used internally)
- */
- void dump(const BasicJsonType& val, const bool pretty_print,
- const bool ensure_ascii,
- const unsigned int indent_step,
- const unsigned int current_indent = 0)
- {
- switch (val.m_type)
- {
- case value_t::object:
- {
- if (val.m_value.object->empty())
- {
- o->write_characters("{}", 2);
- return;
- }
-
- if (pretty_print)
- {
- o->write_characters("{\n", 2);
-
- // variable to hold indentation for recursive calls
- const auto new_indent = current_indent + indent_step;
- if (JSON_UNLIKELY(indent_string.size() < new_indent))
- {
- indent_string.resize(indent_string.size() * 2, ' ');
- }
-
- // first n-1 elements
- auto i = val.m_value.object->cbegin();
- for (std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++i)
- {
- o->write_characters(indent_string.c_str(), new_indent);
- o->write_character('\"');
- dump_escaped(i->first, ensure_ascii);
- o->write_characters("\": ", 3);
- dump(i->second, true, ensure_ascii, indent_step, new_indent);
- o->write_characters(",\n", 2);
- }
-
- // last element
- assert(i != val.m_value.object->cend());
- assert(std::next(i) == val.m_value.object->cend());
- o->write_characters(indent_string.c_str(), new_indent);
- o->write_character('\"');
- dump_escaped(i->first, ensure_ascii);
- o->write_characters("\": ", 3);
- dump(i->second, true, ensure_ascii, indent_step, new_indent);
-
- o->write_character('\n');
- o->write_characters(indent_string.c_str(), current_indent);
- o->write_character('}');
- }
- else
- {
- o->write_character('{');
-
- // first n-1 elements
- auto i = val.m_value.object->cbegin();
- for (std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++i)
- {
- o->write_character('\"');
- dump_escaped(i->first, ensure_ascii);
- o->write_characters("\":", 2);
- dump(i->second, false, ensure_ascii, indent_step, current_indent);
- o->write_character(',');
- }
-
- // last element
- assert(i != val.m_value.object->cend());
- assert(std::next(i) == val.m_value.object->cend());
- o->write_character('\"');
- dump_escaped(i->first, ensure_ascii);
- o->write_characters("\":", 2);
- dump(i->second, false, ensure_ascii, indent_step, current_indent);
-
- o->write_character('}');
- }
-
- return;
- }
-
- case value_t::array:
- {
- if (val.m_value.array->empty())
- {
- o->write_characters("[]", 2);
- return;
- }
-
- if (pretty_print)
- {
- o->write_characters("[\n", 2);
-
- // variable to hold indentation for recursive calls
- const auto new_indent = current_indent + indent_step;
- if (JSON_UNLIKELY(indent_string.size() < new_indent))
- {
- indent_string.resize(indent_string.size() * 2, ' ');
- }
-
- // first n-1 elements
- for (auto i = val.m_value.array->cbegin();
- i != val.m_value.array->cend() - 1; ++i)
- {
- o->write_characters(indent_string.c_str(), new_indent);
- dump(*i, true, ensure_ascii, indent_step, new_indent);
- o->write_characters(",\n", 2);
- }
-
- // last element
- assert(not val.m_value.array->empty());
- o->write_characters(indent_string.c_str(), new_indent);
- dump(val.m_value.array->back(), true, ensure_ascii, indent_step, new_indent);
-
- o->write_character('\n');
- o->write_characters(indent_string.c_str(), current_indent);
- o->write_character(']');
- }
- else
- {
- o->write_character('[');
-
- // first n-1 elements
- for (auto i = val.m_value.array->cbegin();
- i != val.m_value.array->cend() - 1; ++i)
- {
- dump(*i, false, ensure_ascii, indent_step, current_indent);
- o->write_character(',');
- }
-
- // last element
- assert(not val.m_value.array->empty());
- dump(val.m_value.array->back(), false, ensure_ascii, indent_step, current_indent);
-
- o->write_character(']');
- }
-
- return;
- }
-
- case value_t::string:
- {
- o->write_character('\"');
- dump_escaped(*val.m_value.string, ensure_ascii);
- o->write_character('\"');
- return;
- }
-
- case value_t::boolean:
- {
- if (val.m_value.boolean)
- {
- o->write_characters("true", 4);
- }
- else
- {
- o->write_characters("false", 5);
- }
- return;
- }
-
- case value_t::number_integer:
- {
- dump_integer(val.m_value.number_integer);
- return;
- }
-
- case value_t::number_unsigned:
- {
- dump_integer(val.m_value.number_unsigned);
- return;
- }
-
- case value_t::number_float:
- {
- dump_float(val.m_value.number_float);
- return;
- }
-
- case value_t::discarded:
- {
- o->write_characters("<discarded>", 11);
- return;
- }
-
- case value_t::null:
- {
- o->write_characters("null", 4);
- return;
- }
-
- default: // LCOV_EXCL_LINE
- assert(false); // LCOV_EXCL_LINE
- }
- }
-
- private:
- /*!
- @brief dump escaped string
-
- Escape a string by replacing certain special characters by a sequence of an
- escape character (backslash) and another character and other control
- characters by a sequence of "\u" followed by a four-digit hex
- representation. The escaped string is written to output stream @a o.
-
- @param[in] s the string to escape
- @param[in] ensure_ascii whether to escape non-ASCII characters with
- \uXXXX sequences
-
- @complexity Linear in the length of string @a s.
- */
- void dump_escaped(const string_t& s, const bool ensure_ascii)
- {
- std::uint32_t codepoint;
- std::uint8_t state = UTF8_ACCEPT;
- std::size_t bytes = 0; // number of bytes written to string_buffer
-
- // number of bytes written at the point of the last valid byte
- std::size_t bytes_after_last_accept = 0;
- std::size_t undumped_chars = 0;
-
- for (std::size_t i = 0; i < s.size(); ++i)
- {
- const auto byte = static_cast<uint8_t>(s[i]);
-
- switch (decode(state, codepoint, byte))
- {
- case UTF8_ACCEPT: // decode found a new code point
- {
- switch (codepoint)
- {
- case 0x08: // backspace
- {
- string_buffer[bytes++] = '\\';
- string_buffer[bytes++] = 'b';
- break;
- }
-
- case 0x09: // horizontal tab
- {
- string_buffer[bytes++] = '\\';
- string_buffer[bytes++] = 't';
- break;
- }
-
- case 0x0A: // newline
- {
- string_buffer[bytes++] = '\\';
- string_buffer[bytes++] = 'n';
- break;
- }
-
- case 0x0C: // formfeed
- {
- string_buffer[bytes++] = '\\';
- string_buffer[bytes++] = 'f';
- break;
- }
-
- case 0x0D: // carriage return
- {
- string_buffer[bytes++] = '\\';
- string_buffer[bytes++] = 'r';
- break;
- }
-
- case 0x22: // quotation mark
- {
- string_buffer[bytes++] = '\\';
- string_buffer[bytes++] = '\"';
- break;
- }
-
- case 0x5C: // reverse solidus
- {
- string_buffer[bytes++] = '\\';
- string_buffer[bytes++] = '\\';
- break;
- }
-
- default:
- {
- // escape control characters (0x00..0x1F) or, if
- // ensure_ascii parameter is used, non-ASCII characters
- if ((codepoint <= 0x1F) or (ensure_ascii and (codepoint >= 0x7F)))
- {
- if (codepoint <= 0xFFFF)
- {
- (std::snprintf)(string_buffer.data() + bytes, 7, "\\u%04x",
- static_cast<std::uint16_t>(codepoint));
- bytes += 6;
- }
- else
- {
- (std::snprintf)(string_buffer.data() + bytes, 13, "\\u%04x\\u%04x",
- static_cast<std::uint16_t>(0xD7C0u + (codepoint >> 10u)),
- static_cast<std::uint16_t>(0xDC00u + (codepoint & 0x3FFu)));
- bytes += 12;
- }
- }
- else
- {
- // copy byte to buffer (all previous bytes
- // been copied have in default case above)
- string_buffer[bytes++] = s[i];
- }
- break;
- }
- }
-
- // write buffer and reset index; there must be 13 bytes
- // left, as this is the maximal number of bytes to be
- // written ("\uxxxx\uxxxx\0") for one code point
- if (string_buffer.size() - bytes < 13)
- {
- o->write_characters(string_buffer.data(), bytes);
- bytes = 0;
- }
-
- // remember the byte position of this accept
- bytes_after_last_accept = bytes;
- undumped_chars = 0;
- break;
- }
-
- case UTF8_REJECT: // decode found invalid UTF-8 byte
- {
- switch (error_handler)
- {
- case error_handler_t::strict:
- {
- std::string sn(3, '\0');
- (std::snprintf)(&sn[0], sn.size(), "%.2X", byte);
- JSON_THROW(type_error::create(316, "invalid UTF-8 byte at index " + std::to_string(i) + ": 0x" + sn));
- }
-
- case error_handler_t::ignore:
- case error_handler_t::replace:
- {
- // in case we saw this character the first time, we
- // would like to read it again, because the byte
- // may be OK for itself, but just not OK for the
- // previous sequence
- if (undumped_chars > 0)
- {
- --i;
- }
-
- // reset length buffer to the last accepted index;
- // thus removing/ignoring the invalid characters
- bytes = bytes_after_last_accept;
-
- if (error_handler == error_handler_t::replace)
- {
- // add a replacement character
- if (ensure_ascii)
- {
- string_buffer[bytes++] = '\\';
- string_buffer[bytes++] = 'u';
- string_buffer[bytes++] = 'f';
- string_buffer[bytes++] = 'f';
- string_buffer[bytes++] = 'f';
- string_buffer[bytes++] = 'd';
- }
- else
- {
- string_buffer[bytes++] = detail::binary_writer<BasicJsonType, char>::to_char_type('\xEF');
- string_buffer[bytes++] = detail::binary_writer<BasicJsonType, char>::to_char_type('\xBF');
- string_buffer[bytes++] = detail::binary_writer<BasicJsonType, char>::to_char_type('\xBD');
- }
-
- // write buffer and reset index; there must be 13 bytes
- // left, as this is the maximal number of bytes to be
- // written ("\uxxxx\uxxxx\0") for one code point
- if (string_buffer.size() - bytes < 13)
- {
- o->write_characters(string_buffer.data(), bytes);
- bytes = 0;
- }
-
- bytes_after_last_accept = bytes;
- }
-
- undumped_chars = 0;
-
- // continue processing the string
- state = UTF8_ACCEPT;
- break;
- }
-
- default: // LCOV_EXCL_LINE
- assert(false); // LCOV_EXCL_LINE
- }
- break;
- }
-
- default: // decode found yet incomplete multi-byte code point
- {
- if (not ensure_ascii)
- {
- // code point will not be escaped - copy byte to buffer
- string_buffer[bytes++] = s[i];
- }
- ++undumped_chars;
- break;
- }
- }
- }
-
- // we finished processing the string
- if (JSON_LIKELY(state == UTF8_ACCEPT))
- {
- // write buffer
- if (bytes > 0)
- {
- o->write_characters(string_buffer.data(), bytes);
- }
- }
- else
- {
- // we finish reading, but do not accept: string was incomplete
- switch (error_handler)
- {
- case error_handler_t::strict:
- {
- std::string sn(3, '\0');
- (std::snprintf)(&sn[0], sn.size(), "%.2X", static_cast<std::uint8_t>(s.back()));
- JSON_THROW(type_error::create(316, "incomplete UTF-8 string; last byte: 0x" + sn));
- }
-
- case error_handler_t::ignore:
- {
- // write all accepted bytes
- o->write_characters(string_buffer.data(), bytes_after_last_accept);
- break;
- }
-
- case error_handler_t::replace:
- {
- // write all accepted bytes
- o->write_characters(string_buffer.data(), bytes_after_last_accept);
- // add a replacement character
- if (ensure_ascii)
- {
- o->write_characters("\\ufffd", 6);
- }
- else
- {
- o->write_characters("\xEF\xBF\xBD", 3);
- }
- break;
- }
-
- default: // LCOV_EXCL_LINE
- assert(false); // LCOV_EXCL_LINE
- }
- }
- }
-
- /*!
- @brief count digits
-
- Count the number of decimal (base 10) digits for an input unsigned integer.
-
- @param[in] x unsigned integer number to count its digits
- @return number of decimal digits
- */
- inline unsigned int count_digits(number_unsigned_t x) noexcept
- {
- unsigned int n_digits = 1;
- for (;;)
- {
- if (x < 10)
- {
- return n_digits;
- }
- if (x < 100)
- {
- return n_digits + 1;
- }
- if (x < 1000)
- {
- return n_digits + 2;
- }
- if (x < 10000)
- {
- return n_digits + 3;
- }
- x = x / 10000u;
- n_digits += 4;
- }
- }
-
- /*!
- @brief dump an integer
-
- Dump a given integer to output stream @a o. Works internally with
- @a number_buffer.
-
- @param[in] x integer number (signed or unsigned) to dump
- @tparam NumberType either @a number_integer_t or @a number_unsigned_t
- */
- template<typename NumberType, detail::enable_if_t<
- std::is_same<NumberType, number_unsigned_t>::value or
- std::is_same<NumberType, number_integer_t>::value,
- int> = 0>
- void dump_integer(NumberType x)
- {
- static constexpr std::array<std::array<char, 2>, 100> digits_to_99
- {
- {
- {{'0', '0'}}, {{'0', '1'}}, {{'0', '2'}}, {{'0', '3'}}, {{'0', '4'}}, {{'0', '5'}}, {{'0', '6'}}, {{'0', '7'}}, {{'0', '8'}}, {{'0', '9'}},
- {{'1', '0'}}, {{'1', '1'}}, {{'1', '2'}}, {{'1', '3'}}, {{'1', '4'}}, {{'1', '5'}}, {{'1', '6'}}, {{'1', '7'}}, {{'1', '8'}}, {{'1', '9'}},
- {{'2', '0'}}, {{'2', '1'}}, {{'2', '2'}}, {{'2', '3'}}, {{'2', '4'}}, {{'2', '5'}}, {{'2', '6'}}, {{'2', '7'}}, {{'2', '8'}}, {{'2', '9'}},
- {{'3', '0'}}, {{'3', '1'}}, {{'3', '2'}}, {{'3', '3'}}, {{'3', '4'}}, {{'3', '5'}}, {{'3', '6'}}, {{'3', '7'}}, {{'3', '8'}}, {{'3', '9'}},
- {{'4', '0'}}, {{'4', '1'}}, {{'4', '2'}}, {{'4', '3'}}, {{'4', '4'}}, {{'4', '5'}}, {{'4', '6'}}, {{'4', '7'}}, {{'4', '8'}}, {{'4', '9'}},
- {{'5', '0'}}, {{'5', '1'}}, {{'5', '2'}}, {{'5', '3'}}, {{'5', '4'}}, {{'5', '5'}}, {{'5', '6'}}, {{'5', '7'}}, {{'5', '8'}}, {{'5', '9'}},
- {{'6', '0'}}, {{'6', '1'}}, {{'6', '2'}}, {{'6', '3'}}, {{'6', '4'}}, {{'6', '5'}}, {{'6', '6'}}, {{'6', '7'}}, {{'6', '8'}}, {{'6', '9'}},
- {{'7', '0'}}, {{'7', '1'}}, {{'7', '2'}}, {{'7', '3'}}, {{'7', '4'}}, {{'7', '5'}}, {{'7', '6'}}, {{'7', '7'}}, {{'7', '8'}}, {{'7', '9'}},
- {{'8', '0'}}, {{'8', '1'}}, {{'8', '2'}}, {{'8', '3'}}, {{'8', '4'}}, {{'8', '5'}}, {{'8', '6'}}, {{'8', '7'}}, {{'8', '8'}}, {{'8', '9'}},
- {{'9', '0'}}, {{'9', '1'}}, {{'9', '2'}}, {{'9', '3'}}, {{'9', '4'}}, {{'9', '5'}}, {{'9', '6'}}, {{'9', '7'}}, {{'9', '8'}}, {{'9', '9'}},
- }
- };
-
- // special case for "0"
- if (x == 0)
- {
- o->write_character('0');
- return;
- }
-
- // use a pointer to fill the buffer
- auto buffer_ptr = number_buffer.begin();
-
- const bool is_negative = std::is_same<NumberType, number_integer_t>::value and not(x >= 0); // see issue #755
- number_unsigned_t abs_value;
-
- unsigned int n_chars;
-
- if (is_negative)
- {
- *buffer_ptr = '-';
- abs_value = static_cast<number_unsigned_t>(std::abs(static_cast<std::intmax_t>(x)));
-
- // account one more byte for the minus sign
- n_chars = 1 + count_digits(abs_value);
- }
- else
- {
- abs_value = static_cast<number_unsigned_t>(x);
- n_chars = count_digits(abs_value);
- }
-
- // spare 1 byte for '\0'
- assert(n_chars < number_buffer.size() - 1);
-
- // jump to the end to generate the string from backward
- // so we later avoid reversing the result
- buffer_ptr += n_chars;
-
- // Fast int2ascii implementation inspired by "Fastware" talk by Andrei Alexandrescu
- // See: https://www.youtube.com/watch?v=o4-CwDo2zpg
- while (abs_value >= 100)
- {
- const auto digits_index = static_cast<unsigned>((abs_value % 100));
- abs_value /= 100;
- *(--buffer_ptr) = digits_to_99[digits_index][1];
- *(--buffer_ptr) = digits_to_99[digits_index][0];
- }
-
- if (abs_value >= 10)
- {
- const auto digits_index = static_cast<unsigned>(abs_value);
- *(--buffer_ptr) = digits_to_99[digits_index][1];
- *(--buffer_ptr) = digits_to_99[digits_index][0];
- }
- else
- {
- *(--buffer_ptr) = static_cast<char>('0' + abs_value);
- }
-
- o->write_characters(number_buffer.data(), n_chars);
- }
-
- /*!
- @brief dump a floating-point number
-
- Dump a given floating-point number to output stream @a o. Works internally
- with @a number_buffer.
-
- @param[in] x floating-point number to dump
- */
- void dump_float(number_float_t x)
- {
- // NaN / inf
- if (not std::isfinite(x))
- {
- o->write_characters("null", 4);
- return;
- }
-
- // If number_float_t is an IEEE-754 single or double precision number,
- // use the Grisu2 algorithm to produce short numbers which are
- // guaranteed to round-trip, using strtof and strtod, resp.
- //
- // NB: The test below works if <long double> == <double>.
- static constexpr bool is_ieee_single_or_double
- = (std::numeric_limits<number_float_t>::is_iec559 and std::numeric_limits<number_float_t>::digits == 24 and std::numeric_limits<number_float_t>::max_exponent == 128) or
- (std::numeric_limits<number_float_t>::is_iec559 and std::numeric_limits<number_float_t>::digits == 53 and std::numeric_limits<number_float_t>::max_exponent == 1024);
-
- dump_float(x, std::integral_constant<bool, is_ieee_single_or_double>());
- }
-
- void dump_float(number_float_t x, std::true_type /*is_ieee_single_or_double*/)
- {
- char* begin = number_buffer.data();
- char* end = ::nlohmann::detail::to_chars(begin, begin + number_buffer.size(), x);
-
- o->write_characters(begin, static_cast<size_t>(end - begin));
- }
-
- void dump_float(number_float_t x, std::false_type /*is_ieee_single_or_double*/)
- {
- // get number of digits for a float -> text -> float round-trip
- static constexpr auto d = std::numeric_limits<number_float_t>::max_digits10;
-
- // the actual conversion
- std::ptrdiff_t len = (std::snprintf)(number_buffer.data(), number_buffer.size(), "%.*g", d, x);
-
- // negative value indicates an error
- assert(len > 0);
- // check if buffer was large enough
- assert(static_cast<std::size_t>(len) < number_buffer.size());
-
- // erase thousands separator
- if (thousands_sep != '\0')
- {
- const auto end = std::remove(number_buffer.begin(),
- number_buffer.begin() + len, thousands_sep);
- std::fill(end, number_buffer.end(), '\0');
- assert((end - number_buffer.begin()) <= len);
- len = (end - number_buffer.begin());
- }
-
- // convert decimal point to '.'
- if (decimal_point != '\0' and decimal_point != '.')
- {
- const auto dec_pos = std::find(number_buffer.begin(), number_buffer.end(), decimal_point);
- if (dec_pos != number_buffer.end())
- {
- *dec_pos = '.';
- }
- }
-
- o->write_characters(number_buffer.data(), static_cast<std::size_t>(len));
-
- // determine if need to append ".0"
- const bool value_is_int_like =
- std::none_of(number_buffer.begin(), number_buffer.begin() + len + 1,
- [](char c)
- {
- return c == '.' or c == 'e';
- });
-
- if (value_is_int_like)
- {
- o->write_characters(".0", 2);
- }
- }
-
- /*!
- @brief check whether a string is UTF-8 encoded
-
- The function checks each byte of a string whether it is UTF-8 encoded. The
- result of the check is stored in the @a state parameter. The function must
- be called initially with state 0 (accept). State 1 means the string must
- be rejected, because the current byte is not allowed. If the string is
- completely processed, but the state is non-zero, the string ended
- prematurely; that is, the last byte indicated more bytes should have
- followed.
-
- @param[in,out] state the state of the decoding
- @param[in,out] codep codepoint (valid only if resulting state is UTF8_ACCEPT)
- @param[in] byte next byte to decode
- @return new state
-
- @note The function has been edited: a std::array is used.
-
- @copyright Copyright (c) 2008-2009 Bjoern Hoehrmann <bjoern@hoehrmann.de>
- @sa http://bjoern.hoehrmann.de/utf-8/decoder/dfa/
- */
- static std::uint8_t decode(std::uint8_t& state, std::uint32_t& codep, const std::uint8_t byte) noexcept
- {
- static const std::array<std::uint8_t, 400> utf8d =
- {
- {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 00..1F
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 20..3F
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 40..5F
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 60..7F
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, // 80..9F
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // A0..BF
- 8, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // C0..DF
- 0xA, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, 0x3, // E0..EF
- 0xB, 0x6, 0x6, 0x6, 0x5, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, // F0..FF
- 0x0, 0x1, 0x2, 0x3, 0x5, 0x8, 0x7, 0x1, 0x1, 0x1, 0x4, 0x6, 0x1, 0x1, 0x1, 0x1, // s0..s0
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, // s1..s2
- 1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, // s3..s4
- 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, // s5..s6
- 1, 3, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // s7..s8
- }
- };
-
- const std::uint8_t type = utf8d[byte];
-
- codep = (state != UTF8_ACCEPT)
- ? (byte & 0x3fu) | (codep << 6u)
- : (0xFFu >> type) & (byte);
-
- state = utf8d[256u + state * 16u + type];
- return state;
- }
-
- private:
- /// the output of the serializer
- output_adapter_t<char> o = nullptr;
-
- /// a (hopefully) large enough character buffer
- std::array<char, 64> number_buffer{{}};
-
- /// the locale
- const std::lconv* loc = nullptr;
- /// the locale's thousand separator character
- const char thousands_sep = '\0';
- /// the locale's decimal point character
- const char decimal_point = '\0';
-
- /// string buffer
- std::array<char, 512> string_buffer{{}};
-
- /// the indentation character
- const char indent_char;
- /// the indentation string
- string_t indent_string;
-
- /// error_handler how to react on decoding errors
- const error_handler_t error_handler;
-};
-} // namespace detail
-} // namespace nlohmann
-
-// #include <nlohmann/detail/value_t.hpp>
-
-// #include <nlohmann/json_fwd.hpp>
-
-
-/*!
-@brief namespace for Niels Lohmann
-@see https://github.com/nlohmann
-@since version 1.0.0
-*/
-namespace nlohmann
-{
-
-/*!
-@brief a class to store JSON values
-
-@tparam ObjectType type for JSON objects (`std::map` by default; will be used
-in @ref object_t)
-@tparam ArrayType type for JSON arrays (`std::vector` by default; will be used
-in @ref array_t)
-@tparam StringType type for JSON strings and object keys (`std::string` by
-default; will be used in @ref string_t)
-@tparam BooleanType type for JSON booleans (`bool` by default; will be used
-in @ref boolean_t)
-@tparam NumberIntegerType type for JSON integer numbers (`int64_t` by
-default; will be used in @ref number_integer_t)
-@tparam NumberUnsignedType type for JSON unsigned integer numbers (@c
-`uint64_t` by default; will be used in @ref number_unsigned_t)
-@tparam NumberFloatType type for JSON floating-point numbers (`double` by
-default; will be used in @ref number_float_t)
-@tparam AllocatorType type of the allocator to use (`std::allocator` by
-default)
-@tparam JSONSerializer the serializer to resolve internal calls to `to_json()`
-and `from_json()` (@ref adl_serializer by default)
-
-@requirement The class satisfies the following concept requirements:
-- Basic
- - [DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible):
- JSON values can be default constructed. The result will be a JSON null
- value.
- - [MoveConstructible](https://en.cppreference.com/w/cpp/named_req/MoveConstructible):
- A JSON value can be constructed from an rvalue argument.
- - [CopyConstructible](https://en.cppreference.com/w/cpp/named_req/CopyConstructible):
- A JSON value can be copy-constructed from an lvalue expression.
- - [MoveAssignable](https://en.cppreference.com/w/cpp/named_req/MoveAssignable):
- A JSON value van be assigned from an rvalue argument.
- - [CopyAssignable](https://en.cppreference.com/w/cpp/named_req/CopyAssignable):
- A JSON value can be copy-assigned from an lvalue expression.
- - [Destructible](https://en.cppreference.com/w/cpp/named_req/Destructible):
- JSON values can be destructed.
-- Layout
- - [StandardLayoutType](https://en.cppreference.com/w/cpp/named_req/StandardLayoutType):
- JSON values have
- [standard layout](https://en.cppreference.com/w/cpp/language/data_members#Standard_layout):
- All non-static data members are private and standard layout types, the
- class has no virtual functions or (virtual) base classes.
-- Library-wide
- - [EqualityComparable](https://en.cppreference.com/w/cpp/named_req/EqualityComparable):
- JSON values can be compared with `==`, see @ref
- operator==(const_reference,const_reference).
- - [LessThanComparable](https://en.cppreference.com/w/cpp/named_req/LessThanComparable):
- JSON values can be compared with `<`, see @ref
- operator<(const_reference,const_reference).
- - [Swappable](https://en.cppreference.com/w/cpp/named_req/Swappable):
- Any JSON lvalue or rvalue of can be swapped with any lvalue or rvalue of
- other compatible types, using unqualified function call @ref swap().
- - [NullablePointer](https://en.cppreference.com/w/cpp/named_req/NullablePointer):
- JSON values can be compared against `std::nullptr_t` objects which are used
- to model the `null` value.
-- Container
- - [Container](https://en.cppreference.com/w/cpp/named_req/Container):
- JSON values can be used like STL containers and provide iterator access.
- - [ReversibleContainer](https://en.cppreference.com/w/cpp/named_req/ReversibleContainer);
- JSON values can be used like STL containers and provide reverse iterator
- access.
-
-@invariant The member variables @a m_value and @a m_type have the following
-relationship:
-- If `m_type == value_t::object`, then `m_value.object != nullptr`.
-- If `m_type == value_t::array`, then `m_value.array != nullptr`.
-- If `m_type == value_t::string`, then `m_value.string != nullptr`.
-The invariants are checked by member function assert_invariant().
-
-@internal
-@note ObjectType trick from http://stackoverflow.com/a/9860911
-@endinternal
-
-@see [RFC 7159: The JavaScript Object Notation (JSON) Data Interchange
-Format](http://rfc7159.net/rfc7159)
-
-@since version 1.0.0
-
-@nosubgrouping
-*/
-NLOHMANN_BASIC_JSON_TPL_DECLARATION
-class basic_json
-{
- private:
- template<detail::value_t> friend struct detail::external_constructor;
- friend ::nlohmann::json_pointer<basic_json>;
- friend ::nlohmann::detail::parser<basic_json>;
- friend ::nlohmann::detail::serializer<basic_json>;
- template<typename BasicJsonType>
- friend class ::nlohmann::detail::iter_impl;
- template<typename BasicJsonType, typename CharType>
- friend class ::nlohmann::detail::binary_writer;
- template<typename BasicJsonType, typename SAX>
- friend class ::nlohmann::detail::binary_reader;
- template<typename BasicJsonType>
- friend class ::nlohmann::detail::json_sax_dom_parser;
- template<typename BasicJsonType>
- friend class ::nlohmann::detail::json_sax_dom_callback_parser;
-
- /// workaround type for MSVC
- using basic_json_t = NLOHMANN_BASIC_JSON_TPL;
-
- // convenience aliases for types residing in namespace detail;
- using lexer = ::nlohmann::detail::lexer<basic_json>;
- using parser = ::nlohmann::detail::parser<basic_json>;
-
- using primitive_iterator_t = ::nlohmann::detail::primitive_iterator_t;
- template<typename BasicJsonType>
- using internal_iterator = ::nlohmann::detail::internal_iterator<BasicJsonType>;
- template<typename BasicJsonType>
- using iter_impl = ::nlohmann::detail::iter_impl<BasicJsonType>;
- template<typename Iterator>
- using iteration_proxy = ::nlohmann::detail::iteration_proxy<Iterator>;
- template<typename Base> using json_reverse_iterator = ::nlohmann::detail::json_reverse_iterator<Base>;
-
- template<typename CharType>
- using output_adapter_t = ::nlohmann::detail::output_adapter_t<CharType>;
-
- using binary_reader = ::nlohmann::detail::binary_reader<basic_json>;
- template<typename CharType> using binary_writer = ::nlohmann::detail::binary_writer<basic_json, CharType>;
-
- using serializer = ::nlohmann::detail::serializer<basic_json>;
-
- public:
- using value_t = detail::value_t;
- /// JSON Pointer, see @ref nlohmann::json_pointer
- using json_pointer = ::nlohmann::json_pointer<basic_json>;
- template<typename T, typename SFINAE>
- using json_serializer = JSONSerializer<T, SFINAE>;
- /// how to treat decoding errors
- using error_handler_t = detail::error_handler_t;
- /// helper type for initializer lists of basic_json values
- using initializer_list_t = std::initializer_list<detail::json_ref<basic_json>>;
-
- using input_format_t = detail::input_format_t;
- /// SAX interface type, see @ref nlohmann::json_sax
- using json_sax_t = json_sax<basic_json>;
-
- ////////////////
- // exceptions //
- ////////////////
-
- /// @name exceptions
- /// Classes to implement user-defined exceptions.
- /// @{
-
- /// @copydoc detail::exception
- using exception = detail::exception;
- /// @copydoc detail::parse_error
- using parse_error = detail::parse_error;
- /// @copydoc detail::invalid_iterator
- using invalid_iterator = detail::invalid_iterator;
- /// @copydoc detail::type_error
- using type_error = detail::type_error;
- /// @copydoc detail::out_of_range
- using out_of_range = detail::out_of_range;
- /// @copydoc detail::other_error
- using other_error = detail::other_error;
-
- /// @}
-
-
- /////////////////////
- // container types //
- /////////////////////
-
- /// @name container types
- /// The canonic container types to use @ref basic_json like any other STL
- /// container.
- /// @{
-
- /// the type of elements in a basic_json container
- using value_type = basic_json;
-
- /// the type of an element reference
- using reference = value_type&;
- /// the type of an element const reference
- using const_reference = const value_type&;
-
- /// a type to represent differences between iterators
- using difference_type = std::ptrdiff_t;
- /// a type to represent container sizes
- using size_type = std::size_t;
-
- /// the allocator type
- using allocator_type = AllocatorType<basic_json>;
-
- /// the type of an element pointer
- using pointer = typename std::allocator_traits<allocator_type>::pointer;
- /// the type of an element const pointer
- using const_pointer = typename std::allocator_traits<allocator_type>::const_pointer;
-
- /// an iterator for a basic_json container
- using iterator = iter_impl<basic_json>;
- /// a const iterator for a basic_json container
- using const_iterator = iter_impl<const basic_json>;
- /// a reverse iterator for a basic_json container
- using reverse_iterator = json_reverse_iterator<typename basic_json::iterator>;
- /// a const reverse iterator for a basic_json container
- using const_reverse_iterator = json_reverse_iterator<typename basic_json::const_iterator>;
-
- /// @}
-
-
- /*!
- @brief returns the allocator associated with the container
- */
- static allocator_type get_allocator()
- {
- return allocator_type();
- }
-
- /*!
- @brief returns version information on the library
-
- This function returns a JSON object with information about the library,
- including the version number and information on the platform and compiler.
-
- @return JSON object holding version information
- key | description
- ----------- | ---------------
- `compiler` | Information on the used compiler. It is an object with the following keys: `c++` (the used C++ standard), `family` (the compiler family; possible values are `clang`, `icc`, `gcc`, `ilecpp`, `msvc`, `pgcpp`, `sunpro`, and `unknown`), and `version` (the compiler version).
- `copyright` | The copyright line for the library as string.
- `name` | The name of the library as string.
- `platform` | The used platform as string. Possible values are `win32`, `linux`, `apple`, `unix`, and `unknown`.
- `url` | The URL of the project as string.
- `version` | The version of the library. It is an object with the following keys: `major`, `minor`, and `patch` as defined by [Semantic Versioning](http://semver.org), and `string` (the version string).
-
- @liveexample{The following code shows an example output of the `meta()`
- function.,meta}
-
- @exceptionsafety Strong guarantee: if an exception is thrown, there are no
- changes to any JSON value.
-
- @complexity Constant.
-
- @since 2.1.0
- */
- JSON_NODISCARD
- static basic_json meta()
- {
- basic_json result;
-
- result["copyright"] = "(C) 2013-2017 Niels Lohmann";
- result["name"] = "JSON for Modern C++";
- result["url"] = "https://github.com/nlohmann/json";
- result["version"]["string"] =
- std::to_string(NLOHMANN_JSON_VERSION_MAJOR) + "." +
- std::to_string(NLOHMANN_JSON_VERSION_MINOR) + "." +
- std::to_string(NLOHMANN_JSON_VERSION_PATCH);
- result["version"]["major"] = NLOHMANN_JSON_VERSION_MAJOR;
- result["version"]["minor"] = NLOHMANN_JSON_VERSION_MINOR;
- result["version"]["patch"] = NLOHMANN_JSON_VERSION_PATCH;
-
-#ifdef _WIN32
- result["platform"] = "win32";
-#elif defined __linux__
- result["platform"] = "linux";
-#elif defined __APPLE__
- result["platform"] = "apple";
-#elif defined __unix__
- result["platform"] = "unix";
-#else
- result["platform"] = "unknown";
-#endif
-
-#if defined(__ICC) || defined(__INTEL_COMPILER)
- result["compiler"] = {{"family", "icc"}, {"version", __INTEL_COMPILER}};
-#elif defined(__clang__)
- result["compiler"] = {{"family", "clang"}, {"version", __clang_version__}};
-#elif defined(__GNUC__) || defined(__GNUG__)
- result["compiler"] = {{"family", "gcc"}, {"version", std::to_string(__GNUC__) + "." + std::to_string(__GNUC_MINOR__) + "." + std::to_string(__GNUC_PATCHLEVEL__)}};
-#elif defined(__HP_cc) || defined(__HP_aCC)
- result["compiler"] = "hp"
-#elif defined(__IBMCPP__)
- result["compiler"] = {{"family", "ilecpp"}, {"version", __IBMCPP__}};
-#elif defined(_MSC_VER)
- result["compiler"] = {{"family", "msvc"}, {"version", _MSC_VER}};
-#elif defined(__PGI)
- result["compiler"] = {{"family", "pgcpp"}, {"version", __PGI}};
-#elif defined(__SUNPRO_CC)
- result["compiler"] = {{"family", "sunpro"}, {"version", __SUNPRO_CC}};
-#else
- result["compiler"] = {{"family", "unknown"}, {"version", "unknown"}};
-#endif
-
-#ifdef __cplusplus
- result["compiler"]["c++"] = std::to_string(__cplusplus);
-#else
- result["compiler"]["c++"] = "unknown";
-#endif
- return result;
- }
-
-
- ///////////////////////////
- // JSON value data types //
- ///////////////////////////
-
- /// @name JSON value data types
- /// The data types to store a JSON value. These types are derived from
- /// the template arguments passed to class @ref basic_json.
- /// @{
-
-#if defined(JSON_HAS_CPP_14)
- // Use transparent comparator if possible, combined with perfect forwarding
- // on find() and count() calls prevents unnecessary string construction.
- using object_comparator_t = std::less<>;
-#else
- using object_comparator_t = std::less<StringType>;
-#endif
-
- /*!
- @brief a type for an object
-
- [RFC 7159](http://rfc7159.net/rfc7159) describes JSON objects as follows:
- > An object is an unordered collection of zero or more name/value pairs,
- > where a name is a string and a value is a string, number, boolean, null,
- > object, or array.
-
- To store objects in C++, a type is defined by the template parameters
- described below.
-
- @tparam ObjectType the container to store objects (e.g., `std::map` or
- `std::unordered_map`)
- @tparam StringType the type of the keys or names (e.g., `std::string`).
- The comparison function `std::less<StringType>` is used to order elements
- inside the container.
- @tparam AllocatorType the allocator to use for objects (e.g.,
- `std::allocator`)
-
- #### Default type
-
- With the default values for @a ObjectType (`std::map`), @a StringType
- (`std::string`), and @a AllocatorType (`std::allocator`), the default
- value for @a object_t is:
-
- @code {.cpp}
- std::map<
- std::string, // key_type
- basic_json, // value_type
- std::less<std::string>, // key_compare
- std::allocator<std::pair<const std::string, basic_json>> // allocator_type
- >
- @endcode
-
- #### Behavior
-
- The choice of @a object_t influences the behavior of the JSON class. With
- the default type, objects have the following behavior:
-
- - When all names are unique, objects will be interoperable in the sense
- that all software implementations receiving that object will agree on
- the name-value mappings.
- - When the names within an object are not unique, it is unspecified which
- one of the values for a given key will be chosen. For instance,
- `{"key": 2, "key": 1}` could be equal to either `{"key": 1}` or
- `{"key": 2}`.
- - Internally, name/value pairs are stored in lexicographical order of the
- names. Objects will also be serialized (see @ref dump) in this order.
- For instance, `{"b": 1, "a": 2}` and `{"a": 2, "b": 1}` will be stored
- and serialized as `{"a": 2, "b": 1}`.
- - When comparing objects, the order of the name/value pairs is irrelevant.
- This makes objects interoperable in the sense that they will not be
- affected by these differences. For instance, `{"b": 1, "a": 2}` and
- `{"a": 2, "b": 1}` will be treated as equal.
-
- #### Limits
-
- [RFC 7159](http://rfc7159.net/rfc7159) specifies:
- > An implementation may set limits on the maximum depth of nesting.
-
- In this class, the object's limit of nesting is not explicitly constrained.
- However, a maximum depth of nesting may be introduced by the compiler or
- runtime environment. A theoretical limit can be queried by calling the
- @ref max_size function of a JSON object.
-
- #### Storage
-
- Objects are stored as pointers in a @ref basic_json type. That is, for any
- access to object values, a pointer of type `object_t*` must be
- dereferenced.
-
- @sa @ref array_t -- type for an array value
-
- @since version 1.0.0
-
- @note The order name/value pairs are added to the object is *not*
- preserved by the library. Therefore, iterating an object may return
- name/value pairs in a different order than they were originally stored. In
- fact, keys will be traversed in alphabetical order as `std::map` with
- `std::less` is used by default. Please note this behavior conforms to [RFC
- 7159](http://rfc7159.net/rfc7159), because any order implements the
- specified "unordered" nature of JSON objects.
- */
- using object_t = ObjectType<StringType,
- basic_json,
- object_comparator_t,
- AllocatorType<std::pair<const StringType,
- basic_json>>>;
-
- /*!
- @brief a type for an array
-
- [RFC 7159](http://rfc7159.net/rfc7159) describes JSON arrays as follows:
- > An array is an ordered sequence of zero or more values.
-
- To store objects in C++, a type is defined by the template parameters
- explained below.
-
- @tparam ArrayType container type to store arrays (e.g., `std::vector` or
- `std::list`)
- @tparam AllocatorType allocator to use for arrays (e.g., `std::allocator`)
-
- #### Default type
-
- With the default values for @a ArrayType (`std::vector`) and @a
- AllocatorType (`std::allocator`), the default value for @a array_t is:
-
- @code {.cpp}
- std::vector<
- basic_json, // value_type
- std::allocator<basic_json> // allocator_type
- >
- @endcode
-
- #### Limits
-
- [RFC 7159](http://rfc7159.net/rfc7159) specifies:
- > An implementation may set limits on the maximum depth of nesting.
-
- In this class, the array's limit of nesting is not explicitly constrained.
- However, a maximum depth of nesting may be introduced by the compiler or
- runtime environment. A theoretical limit can be queried by calling the
- @ref max_size function of a JSON array.
-
- #### Storage
-
- Arrays are stored as pointers in a @ref basic_json type. That is, for any
- access to array values, a pointer of type `array_t*` must be dereferenced.
-
- @sa @ref object_t -- type for an object value
-
- @since version 1.0.0
- */
- using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
-
- /*!
- @brief a type for a string
-
- [RFC 7159](http://rfc7159.net/rfc7159) describes JSON strings as follows:
- > A string is a sequence of zero or more Unicode characters.
-
- To store objects in C++, a type is defined by the template parameter
- described below. Unicode values are split by the JSON class into
- byte-sized characters during deserialization.
-
- @tparam StringType the container to store strings (e.g., `std::string`).
- Note this container is used for keys/names in objects, see @ref object_t.
-
- #### Default type
-
- With the default values for @a StringType (`std::string`), the default
- value for @a string_t is:
-
- @code {.cpp}
- std::string
- @endcode
-
- #### Encoding
-
- Strings are stored in UTF-8 encoding. Therefore, functions like
- `std::string::size()` or `std::string::length()` return the number of
- bytes in the string rather than the number of characters or glyphs.
-
- #### String comparison
-
- [RFC 7159](http://rfc7159.net/rfc7159) states:
- > Software implementations are typically required to test names of object
- > members for equality. Implementations that transform the textual
- > representation into sequences of Unicode code units and then perform the
- > comparison numerically, code unit by code unit, are interoperable in the
- > sense that implementations will agree in all cases on equality or
- > inequality of two strings. For example, implementations that compare
- > strings with escaped characters unconverted may incorrectly find that
- > `"a\\b"` and `"a\u005Cb"` are not equal.
-
- This implementation is interoperable as it does compare strings code unit
- by code unit.
-
- #### Storage
-
- String values are stored as pointers in a @ref basic_json type. That is,
- for any access to string values, a pointer of type `string_t*` must be
- dereferenced.
-
- @since version 1.0.0
- */
- using string_t = StringType;
-
- /*!
- @brief a type for a boolean
-
- [RFC 7159](http://rfc7159.net/rfc7159) implicitly describes a boolean as a
- type which differentiates the two literals `true` and `false`.
-
- To store objects in C++, a type is defined by the template parameter @a
- BooleanType which chooses the type to use.
-
- #### Default type
-
- With the default values for @a BooleanType (`bool`), the default value for
- @a boolean_t is:
-
- @code {.cpp}
- bool
- @endcode
-
- #### Storage
-
- Boolean values are stored directly inside a @ref basic_json type.
-
- @since version 1.0.0
- */
- using boolean_t = BooleanType;
-
- /*!
- @brief a type for a number (integer)
-
- [RFC 7159](http://rfc7159.net/rfc7159) describes numbers as follows:
- > The representation of numbers is similar to that used in most
- > programming languages. A number is represented in base 10 using decimal
- > digits. It contains an integer component that may be prefixed with an
- > optional minus sign, which may be followed by a fraction part and/or an
- > exponent part. Leading zeros are not allowed. (...) Numeric values that
- > cannot be represented in the grammar below (such as Infinity and NaN)
- > are not permitted.
-
- This description includes both integer and floating-point numbers.
- However, C++ allows more precise storage if it is known whether the number
- is a signed integer, an unsigned integer or a floating-point number.
- Therefore, three different types, @ref number_integer_t, @ref
- number_unsigned_t and @ref number_float_t are used.
-
- To store integer numbers in C++, a type is defined by the template
- parameter @a NumberIntegerType which chooses the type to use.
-
- #### Default type
-
- With the default values for @a NumberIntegerType (`int64_t`), the default
- value for @a number_integer_t is:
-
- @code {.cpp}
- int64_t
- @endcode
-
- #### Default behavior
-
- - The restrictions about leading zeros is not enforced in C++. Instead,
- leading zeros in integer literals lead to an interpretation as octal
- number. Internally, the value will be stored as decimal number. For
- instance, the C++ integer literal `010` will be serialized to `8`.
- During deserialization, leading zeros yield an error.
- - Not-a-number (NaN) values will be serialized to `null`.
-
- #### Limits
-
- [RFC 7159](http://rfc7159.net/rfc7159) specifies:
- > An implementation may set limits on the range and precision of numbers.
-
- When the default type is used, the maximal integer number that can be
- stored is `9223372036854775807` (INT64_MAX) and the minimal integer number
- that can be stored is `-9223372036854775808` (INT64_MIN). Integer numbers
- that are out of range will yield over/underflow when used in a
- constructor. During deserialization, too large or small integer numbers
- will be automatically be stored as @ref number_unsigned_t or @ref
- number_float_t.
-
- [RFC 7159](http://rfc7159.net/rfc7159) further states:
- > Note that when such software is used, numbers that are integers and are
- > in the range \f$[-2^{53}+1, 2^{53}-1]\f$ are interoperable in the sense
- > that implementations will agree exactly on their numeric values.
-
- As this range is a subrange of the exactly supported range [INT64_MIN,
- INT64_MAX], this class's integer type is interoperable.
-
- #### Storage
-
- Integer number values are stored directly inside a @ref basic_json type.
-
- @sa @ref number_float_t -- type for number values (floating-point)
-
- @sa @ref number_unsigned_t -- type for number values (unsigned integer)
-
- @since version 1.0.0
- */
- using number_integer_t = NumberIntegerType;
-
- /*!
- @brief a type for a number (unsigned)
-
- [RFC 7159](http://rfc7159.net/rfc7159) describes numbers as follows:
- > The representation of numbers is similar to that used in most
- > programming languages. A number is represented in base 10 using decimal
- > digits. It contains an integer component that may be prefixed with an
- > optional minus sign, which may be followed by a fraction part and/or an
- > exponent part. Leading zeros are not allowed. (...) Numeric values that
- > cannot be represented in the grammar below (such as Infinity and NaN)
- > are not permitted.
-
- This description includes both integer and floating-point numbers.
- However, C++ allows more precise storage if it is known whether the number
- is a signed integer, an unsigned integer or a floating-point number.
- Therefore, three different types, @ref number_integer_t, @ref
- number_unsigned_t and @ref number_float_t are used.
-
- To store unsigned integer numbers in C++, a type is defined by the
- template parameter @a NumberUnsignedType which chooses the type to use.
-
- #### Default type
-
- With the default values for @a NumberUnsignedType (`uint64_t`), the
- default value for @a number_unsigned_t is:
-
- @code {.cpp}
- uint64_t
- @endcode
-
- #### Default behavior
-
- - The restrictions about leading zeros is not enforced in C++. Instead,
- leading zeros in integer literals lead to an interpretation as octal
- number. Internally, the value will be stored as decimal number. For
- instance, the C++ integer literal `010` will be serialized to `8`.
- During deserialization, leading zeros yield an error.
- - Not-a-number (NaN) values will be serialized to `null`.
-
- #### Limits
-
- [RFC 7159](http://rfc7159.net/rfc7159) specifies:
- > An implementation may set limits on the range and precision of numbers.
-
- When the default type is used, the maximal integer number that can be
- stored is `18446744073709551615` (UINT64_MAX) and the minimal integer
- number that can be stored is `0`. Integer numbers that are out of range
- will yield over/underflow when used in a constructor. During
- deserialization, too large or small integer numbers will be automatically
- be stored as @ref number_integer_t or @ref number_float_t.
-
- [RFC 7159](http://rfc7159.net/rfc7159) further states:
- > Note that when such software is used, numbers that are integers and are
- > in the range \f$[-2^{53}+1, 2^{53}-1]\f$ are interoperable in the sense
- > that implementations will agree exactly on their numeric values.
-
- As this range is a subrange (when considered in conjunction with the
- number_integer_t type) of the exactly supported range [0, UINT64_MAX],
- this class's integer type is interoperable.
-
- #### Storage
-
- Integer number values are stored directly inside a @ref basic_json type.
-
- @sa @ref number_float_t -- type for number values (floating-point)
- @sa @ref number_integer_t -- type for number values (integer)
-
- @since version 2.0.0
- */
- using number_unsigned_t = NumberUnsignedType;
-
- /*!
- @brief a type for a number (floating-point)
-
- [RFC 7159](http://rfc7159.net/rfc7159) describes numbers as follows:
- > The representation of numbers is similar to that used in most
- > programming languages. A number is represented in base 10 using decimal
- > digits. It contains an integer component that may be prefixed with an
- > optional minus sign, which may be followed by a fraction part and/or an
- > exponent part. Leading zeros are not allowed. (...) Numeric values that
- > cannot be represented in the grammar below (such as Infinity and NaN)
- > are not permitted.
-
- This description includes both integer and floating-point numbers.
- However, C++ allows more precise storage if it is known whether the number
- is a signed integer, an unsigned integer or a floating-point number.
- Therefore, three different types, @ref number_integer_t, @ref
- number_unsigned_t and @ref number_float_t are used.
-
- To store floating-point numbers in C++, a type is defined by the template
- parameter @a NumberFloatType which chooses the type to use.
-
- #### Default type
-
- With the default values for @a NumberFloatType (`double`), the default
- value for @a number_float_t is:
-
- @code {.cpp}
- double
- @endcode
-
- #### Default behavior
-
- - The restrictions about leading zeros is not enforced in C++. Instead,
- leading zeros in floating-point literals will be ignored. Internally,
- the value will be stored as decimal number. For instance, the C++
- floating-point literal `01.2` will be serialized to `1.2`. During
- deserialization, leading zeros yield an error.
- - Not-a-number (NaN) values will be serialized to `null`.
-
- #### Limits
-
- [RFC 7159](http://rfc7159.net/rfc7159) states:
- > This specification allows implementations to set limits on the range and
- > precision of numbers accepted. Since software that implements IEEE
- > 754-2008 binary64 (double precision) numbers is generally available and
- > widely used, good interoperability can be achieved by implementations
- > that expect no more precision or range than these provide, in the sense
- > that implementations will approximate JSON numbers within the expected
- > precision.
-
- This implementation does exactly follow this approach, as it uses double
- precision floating-point numbers. Note values smaller than
- `-1.79769313486232e+308` and values greater than `1.79769313486232e+308`
- will be stored as NaN internally and be serialized to `null`.
-
- #### Storage
-
- Floating-point number values are stored directly inside a @ref basic_json
- type.
-
- @sa @ref number_integer_t -- type for number values (integer)
-
- @sa @ref number_unsigned_t -- type for number values (unsigned integer)
-
- @since version 1.0.0
- */
- using number_float_t = NumberFloatType;
-
- /// @}
-
- private:
-
- /// helper for exception-safe object creation
- template<typename T, typename... Args>
- static T* create(Args&& ... args)
- {
- AllocatorType<T> alloc;
- using AllocatorTraits = std::allocator_traits<AllocatorType<T>>;
-
- auto deleter = [&](T * object)
- {
- AllocatorTraits::deallocate(alloc, object, 1);
- };
- std::unique_ptr<T, decltype(deleter)> object(AllocatorTraits::allocate(alloc, 1), deleter);
- AllocatorTraits::construct(alloc, object.get(), std::forward<Args>(args)...);
- assert(object != nullptr);
- return object.release();
- }
-
- ////////////////////////
- // JSON value storage //
- ////////////////////////
-
- /*!
- @brief a JSON value
-
- The actual storage for a JSON value of the @ref basic_json class. This
- union combines the different storage types for the JSON value types
- defined in @ref value_t.
-
- JSON type | value_t type | used type
- --------- | --------------- | ------------------------
- object | object | pointer to @ref object_t
- array | array | pointer to @ref array_t
- string | string | pointer to @ref string_t
- boolean | boolean | @ref boolean_t
- number | number_integer | @ref number_integer_t
- number | number_unsigned | @ref number_unsigned_t
- number | number_float | @ref number_float_t
- null | null | *no value is stored*
-
- @note Variable-length types (objects, arrays, and strings) are stored as
- pointers. The size of the union should not exceed 64 bits if the default
- value types are used.
-
- @since version 1.0.0
- */
- union json_value
- {
- /// object (stored with pointer to save storage)
- object_t* object;
- /// array (stored with pointer to save storage)
- array_t* array;
- /// string (stored with pointer to save storage)
- string_t* string;
- /// boolean
- boolean_t boolean;
- /// number (integer)
- number_integer_t number_integer;
- /// number (unsigned integer)
- number_unsigned_t number_unsigned;
- /// number (floating-point)
- number_float_t number_float;
-
- /// default constructor (for null values)
- json_value() = default;
- /// constructor for booleans
- json_value(boolean_t v) noexcept : boolean(v) {}
- /// constructor for numbers (integer)
- json_value(number_integer_t v) noexcept : number_integer(v) {}
- /// constructor for numbers (unsigned)
- json_value(number_unsigned_t v) noexcept : number_unsigned(v) {}
- /// constructor for numbers (floating-point)
- json_value(number_float_t v) noexcept : number_float(v) {}
- /// constructor for empty values of a given type
- json_value(value_t t)
- {
- switch (t)
- {
- case value_t::object:
- {
- object = create<object_t>();
- break;
- }
-
- case value_t::array:
- {
- array = create<array_t>();
- break;
- }
-
- case value_t::string:
- {
- string = create<string_t>("");
- break;
- }
-
- case value_t::boolean:
- {
- boolean = boolean_t(false);
- break;
- }
-
- case value_t::number_integer:
- {
- number_integer = number_integer_t(0);
- break;
- }
-
- case value_t::number_unsigned:
- {
- number_unsigned = number_unsigned_t(0);
- break;
- }
-
- case value_t::number_float:
- {
- number_float = number_float_t(0.0);
- break;
- }
-
- case value_t::null:
- {
- object = nullptr; // silence warning, see #821
- break;
- }
-
- default:
- {
- object = nullptr; // silence warning, see #821
- if (JSON_UNLIKELY(t == value_t::null))
- {
- JSON_THROW(other_error::create(500, "961c151d2e87f2686a955a9be24d316f1362bf21 3.6.1")); // LCOV_EXCL_LINE
- }
- break;
- }
- }
- }
-
- /// constructor for strings
- json_value(const string_t& value)
- {
- string = create<string_t>(value);
- }
-
- /// constructor for rvalue strings
- json_value(string_t&& value)
- {
- string = create<string_t>(std::move(value));
- }
-
- /// constructor for objects
- json_value(const object_t& value)
- {
- object = create<object_t>(value);
- }
-
- /// constructor for rvalue objects
- json_value(object_t&& value)
- {
- object = create<object_t>(std::move(value));
- }
-
- /// constructor for arrays
- json_value(const array_t& value)
- {
- array = create<array_t>(value);
- }
-
- /// constructor for rvalue arrays
- json_value(array_t&& value)
- {
- array = create<array_t>(std::move(value));
- }
-
- void destroy(value_t t) noexcept
- {
- switch (t)
- {
- case value_t::object:
- {
- AllocatorType<object_t> alloc;
- std::allocator_traits<decltype(alloc)>::destroy(alloc, object);
- std::allocator_traits<decltype(alloc)>::deallocate(alloc, object, 1);
- break;
- }
-
- case value_t::array:
- {
- AllocatorType<array_t> alloc;
- std::allocator_traits<decltype(alloc)>::destroy(alloc, array);
- std::allocator_traits<decltype(alloc)>::deallocate(alloc, array, 1);
- break;
- }
-
- case value_t::string:
- {
- AllocatorType<string_t> alloc;
- std::allocator_traits<decltype(alloc)>::destroy(alloc, string);
- std::allocator_traits<decltype(alloc)>::deallocate(alloc, string, 1);
- break;
- }
-
- default:
- {
- break;
- }
- }
- }
- };
-
- /*!
- @brief checks the class invariants
-
- This function asserts the class invariants. It needs to be called at the
- end of every constructor to make sure that created objects respect the
- invariant. Furthermore, it has to be called each time the type of a JSON
- value is changed, because the invariant expresses a relationship between
- @a m_type and @a m_value.
- */
- void assert_invariant() const noexcept
- {
- assert(m_type != value_t::object or m_value.object != nullptr);
- assert(m_type != value_t::array or m_value.array != nullptr);
- assert(m_type != value_t::string or m_value.string != nullptr);
- }
-
- public:
- //////////////////////////
- // JSON parser callback //
- //////////////////////////
-
- /*!
- @brief parser event types
-
- The parser callback distinguishes the following events:
- - `object_start`: the parser read `{` and started to process a JSON object
- - `key`: the parser read a key of a value in an object
- - `object_end`: the parser read `}` and finished processing a JSON object
- - `array_start`: the parser read `[` and started to process a JSON array
- - `array_end`: the parser read `]` and finished processing a JSON array
- - `value`: the parser finished reading a JSON value
-
- @image html callback_events.png "Example when certain parse events are triggered"
-
- @sa @ref parser_callback_t for more information and examples
- */
- using parse_event_t = typename parser::parse_event_t;
-
- /*!
- @brief per-element parser callback type
-
- With a parser callback function, the result of parsing a JSON text can be
- influenced. When passed to @ref parse, it is called on certain events
- (passed as @ref parse_event_t via parameter @a event) with a set recursion
- depth @a depth and context JSON value @a parsed. The return value of the
- callback function is a boolean indicating whether the element that emitted
- the callback shall be kept or not.
-
- We distinguish six scenarios (determined by the event type) in which the
- callback function can be called. The following table describes the values
- of the parameters @a depth, @a event, and @a parsed.
-
- parameter @a event | description | parameter @a depth | parameter @a parsed
- ------------------ | ----------- | ------------------ | -------------------
- parse_event_t::object_start | the parser read `{` and started to process a JSON object | depth of the parent of the JSON object | a JSON value with type discarded
- parse_event_t::key | the parser read a key of a value in an object | depth of the currently parsed JSON object | a JSON string containing the key
- parse_event_t::object_end | the parser read `}` and finished processing a JSON object | depth of the parent of the JSON object | the parsed JSON object
- parse_event_t::array_start | the parser read `[` and started to process a JSON array | depth of the parent of the JSON array | a JSON value with type discarded
- parse_event_t::array_end | the parser read `]` and finished processing a JSON array | depth of the parent of the JSON array | the parsed JSON array
- parse_event_t::value | the parser finished reading a JSON value | depth of the value | the parsed JSON value
-
- @image html callback_events.png "Example when certain parse events are triggered"
-
- Discarding a value (i.e., returning `false`) has different effects
- depending on the context in which function was called:
-
- - Discarded values in structured types are skipped. That is, the parser
- will behave as if the discarded value was never read.
- - In case a value outside a structured type is skipped, it is replaced
- with `null`. This case happens if the top-level element is skipped.
-
- @param[in] depth the depth of the recursion during parsing
-
- @param[in] event an event of type parse_event_t indicating the context in
- the callback function has been called
-
- @param[in,out] parsed the current intermediate parse result; note that
- writing to this value has no effect for parse_event_t::key events
-
- @return Whether the JSON value which called the function during parsing
- should be kept (`true`) or not (`false`). In the latter case, it is either
- skipped completely or replaced by an empty discarded object.
-
- @sa @ref parse for examples
-
- @since version 1.0.0
- */
- using parser_callback_t = typename parser::parser_callback_t;
-
- //////////////////
- // constructors //
- //////////////////
-
- /// @name constructors and destructors
- /// Constructors of class @ref basic_json, copy/move constructor, copy
- /// assignment, static functions creating objects, and the destructor.
- /// @{
-
- /*!
- @brief create an empty value with a given type
-
- Create an empty JSON value with a given type. The value will be default
- initialized with an empty value which depends on the type:
-
- Value type | initial value
- ----------- | -------------
- null | `null`
- boolean | `false`
- string | `""`
- number | `0`
- object | `{}`
- array | `[]`
-
- @param[in] v the type of the value to create
-
- @complexity Constant.
-
- @exceptionsafety Strong guarantee: if an exception is thrown, there are no
- changes to any JSON value.
-
- @liveexample{The following code shows the constructor for different @ref
- value_t values,basic_json__value_t}
-
- @sa @ref clear() -- restores the postcondition of this constructor
-
- @since version 1.0.0
- */
- basic_json(const value_t v)
- : m_type(v), m_value(v)
- {
- assert_invariant();
- }
-
- /*!
- @brief create a null object
-
- Create a `null` JSON value. It either takes a null pointer as parameter
- (explicitly creating `null`) or no parameter (implicitly creating `null`).
- The passed null pointer itself is not read -- it is only used to choose
- the right constructor.
-
- @complexity Constant.
-
- @exceptionsafety No-throw guarantee: this constructor never throws
- exceptions.
-
- @liveexample{The following code shows the constructor with and without a
- null pointer parameter.,basic_json__nullptr_t}
-
- @since version 1.0.0
- */
- basic_json(std::nullptr_t = nullptr) noexcept
- : basic_json(value_t::null)
- {
- assert_invariant();
- }
-
- /*!
- @brief create a JSON value
-
- This is a "catch all" constructor for all compatible JSON types; that is,
- types for which a `to_json()` method exists. The constructor forwards the
- parameter @a val to that method (to `json_serializer<U>::to_json` method
- with `U = uncvref_t<CompatibleType>`, to be exact).
-
- Template type @a CompatibleType includes, but is not limited to, the
- following types:
- - **arrays**: @ref array_t and all kinds of compatible containers such as
- `std::vector`, `std::deque`, `std::list`, `std::forward_list`,
- `std::array`, `std::valarray`, `std::set`, `std::unordered_set`,
- `std::multiset`, and `std::unordered_multiset` with a `value_type` from
- which a @ref basic_json value can be constructed.
- - **objects**: @ref object_t and all kinds of compatible associative
- containers such as `std::map`, `std::unordered_map`, `std::multimap`,
- and `std::unordered_multimap` with a `key_type` compatible to
- @ref string_t and a `value_type` from which a @ref basic_json value can
- be constructed.
- - **strings**: @ref string_t, string literals, and all compatible string
- containers can be used.
- - **numbers**: @ref number_integer_t, @ref number_unsigned_t,
- @ref number_float_t, and all convertible number types such as `int`,
- `size_t`, `int64_t`, `float` or `double` can be used.
- - **boolean**: @ref boolean_t / `bool` can be used.
-
- See the examples below.
-
- @tparam CompatibleType a type such that:
- - @a CompatibleType is not derived from `std::istream`,
- - @a CompatibleType is not @ref basic_json (to avoid hijacking copy/move
- constructors),
- - @a CompatibleType is not a different @ref basic_json type (i.e. with different template arguments)
- - @a CompatibleType is not a @ref basic_json nested type (e.g.,
- @ref json_pointer, @ref iterator, etc ...)
- - @ref @ref json_serializer<U> has a
- `to_json(basic_json_t&, CompatibleType&&)` method
-
- @tparam U = `uncvref_t<CompatibleType>`
-
- @param[in] val the value to be forwarded to the respective constructor
-
- @complexity Usually linear in the size of the passed @a val, also
- depending on the implementation of the called `to_json()`
- method.
-
- @exceptionsafety Depends on the called constructor. For types directly
- supported by the library (i.e., all types for which no `to_json()` function
- was provided), strong guarantee holds: if an exception is thrown, there are
- no changes to any JSON value.
-
- @liveexample{The following code shows the constructor with several
- compatible types.,basic_json__CompatibleType}
-
- @since version 2.1.0
- */
- template <typename CompatibleType,
- typename U = detail::uncvref_t<CompatibleType>,
- detail::enable_if_t<
- not detail::is_basic_json<U>::value and detail::is_compatible_type<basic_json_t, U>::value, int> = 0>
- basic_json(CompatibleType && val) noexcept(noexcept(
- JSONSerializer<U>::to_json(std::declval<basic_json_t&>(),
- std::forward<CompatibleType>(val))))
- {
- JSONSerializer<U>::to_json(*this, std::forward<CompatibleType>(val));
- assert_invariant();
- }
-
- /*!
- @brief create a JSON value from an existing one
-
- This is a constructor for existing @ref basic_json types.
- It does not hijack copy/move constructors, since the parameter has different
- template arguments than the current ones.
-
- The constructor tries to convert the internal @ref m_value of the parameter.
-
- @tparam BasicJsonType a type such that:
- - @a BasicJsonType is a @ref basic_json type.
- - @a BasicJsonType has different template arguments than @ref basic_json_t.
-
- @param[in] val the @ref basic_json value to be converted.
-
- @complexity Usually linear in the size of the passed @a val, also
- depending on the implementation of the called `to_json()`
- method.
-
- @exceptionsafety Depends on the called constructor. For types directly
- supported by the library (i.e., all types for which no `to_json()` function
- was provided), strong guarantee holds: if an exception is thrown, there are
- no changes to any JSON value.
-
- @since version 3.2.0
- */
- template <typename BasicJsonType,
- detail::enable_if_t<
- detail::is_basic_json<BasicJsonType>::value and not std::is_same<basic_json, BasicJsonType>::value, int> = 0>
- basic_json(const BasicJsonType& val)
- {
- using other_boolean_t = typename BasicJsonType::boolean_t;
- using other_number_float_t = typename BasicJsonType::number_float_t;
- using other_number_integer_t = typename BasicJsonType::number_integer_t;
- using other_number_unsigned_t = typename BasicJsonType::number_unsigned_t;
- using other_string_t = typename BasicJsonType::string_t;
- using other_object_t = typename BasicJsonType::object_t;
- using other_array_t = typename BasicJsonType::array_t;
-
- switch (val.type())
- {
- case value_t::boolean:
- JSONSerializer<other_boolean_t>::to_json(*this, val.template get<other_boolean_t>());
- break;
- case value_t::number_float:
- JSONSerializer<other_number_float_t>::to_json(*this, val.template get<other_number_float_t>());
- break;
- case value_t::number_integer:
- JSONSerializer<other_number_integer_t>::to_json(*this, val.template get<other_number_integer_t>());
- break;
- case value_t::number_unsigned:
- JSONSerializer<other_number_unsigned_t>::to_json(*this, val.template get<other_number_unsigned_t>());
- break;
- case value_t::string:
- JSONSerializer<other_string_t>::to_json(*this, val.template get_ref<const other_string_t&>());
- break;
- case value_t::object:
- JSONSerializer<other_object_t>::to_json(*this, val.template get_ref<const other_object_t&>());
- break;
- case value_t::array:
- JSONSerializer<other_array_t>::to_json(*this, val.template get_ref<const other_array_t&>());
- break;
- case value_t::null:
- *this = nullptr;
- break;
- case value_t::discarded:
- m_type = value_t::discarded;
- break;
- default: // LCOV_EXCL_LINE
- assert(false); // LCOV_EXCL_LINE
- }
- assert_invariant();
- }
-
- /*!
- @brief create a container (array or object) from an initializer list
-
- Creates a JSON value of type array or object from the passed initializer
- list @a init. In case @a type_deduction is `true` (default), the type of
- the JSON value to be created is deducted from the initializer list @a init
- according to the following rules:
-
- 1. If the list is empty, an empty JSON object value `{}` is created.
- 2. If the list consists of pairs whose first element is a string, a JSON
- object value is created where the first elements of the pairs are
- treated as keys and the second elements are as values.
- 3. In all other cases, an array is created.
-
- The rules aim to create the best fit between a C++ initializer list and
- JSON values. The rationale is as follows:
-
- 1. The empty initializer list is written as `{}` which is exactly an empty
- JSON object.
- 2. C++ has no way of describing mapped types other than to list a list of
- pairs. As JSON requires that keys must be of type string, rule 2 is the
- weakest constraint one can pose on initializer lists to interpret them
- as an object.
- 3. In all other cases, the initializer list could not be interpreted as
- JSON object type, so interpreting it as JSON array type is safe.
-
- With the rules described above, the following JSON values cannot be
- expressed by an initializer list:
-
- - the empty array (`[]`): use @ref array(initializer_list_t)
- with an empty initializer list in this case
- - arrays whose elements satisfy rule 2: use @ref
- array(initializer_list_t) with the same initializer list
- in this case
-
- @note When used without parentheses around an empty initializer list, @ref
- basic_json() is called instead of this function, yielding the JSON null
- value.
-
- @param[in] init initializer list with JSON values
-
- @param[in] type_deduction internal parameter; when set to `true`, the type
- of the JSON value is deducted from the initializer list @a init; when set
- to `false`, the type provided via @a manual_type is forced. This mode is
- used by the functions @ref array(initializer_list_t) and
- @ref object(initializer_list_t).
-
- @param[in] manual_type internal parameter; when @a type_deduction is set
- to `false`, the created JSON value will use the provided type (only @ref
- value_t::array and @ref value_t::object are valid); when @a type_deduction
- is set to `true`, this parameter has no effect
-
- @throw type_error.301 if @a type_deduction is `false`, @a manual_type is
- `value_t::object`, but @a init contains an element which is not a pair
- whose first element is a string. In this case, the constructor could not
- create an object. If @a type_deduction would have be `true`, an array
- would have been created. See @ref object(initializer_list_t)
- for an example.
-
- @complexity Linear in the size of the initializer list @a init.
-
- @exceptionsafety Strong guarantee: if an exception is thrown, there are no
- changes to any JSON value.
-
- @liveexample{The example below shows how JSON values are created from
- initializer lists.,basic_json__list_init_t}
-
- @sa @ref array(initializer_list_t) -- create a JSON array
- value from an initializer list
- @sa @ref object(initializer_list_t) -- create a JSON object
- value from an initializer list
-
- @since version 1.0.0
- */
- basic_json(initializer_list_t init,
- bool type_deduction = true,
- value_t manual_type = value_t::array)
- {
- // check if each element is an array with two elements whose first
- // element is a string
- bool is_an_object = std::all_of(init.begin(), init.end(),
- [](const detail::json_ref<basic_json>& element_ref)
- {
- return element_ref->is_array() and element_ref->size() == 2 and (*element_ref)[0].is_string();
- });
-
- // adjust type if type deduction is not wanted
- if (not type_deduction)
- {
- // if array is wanted, do not create an object though possible
- if (manual_type == value_t::array)
- {
- is_an_object = false;
- }
-
- // if object is wanted but impossible, throw an exception
- if (JSON_UNLIKELY(manual_type == value_t::object and not is_an_object))
- {
- JSON_THROW(type_error::create(301, "cannot create object from initializer list"));
- }
- }
-
- if (is_an_object)
- {
- // the initializer list is a list of pairs -> create object
- m_type = value_t::object;
- m_value = value_t::object;
-
- std::for_each(init.begin(), init.end(), [this](const detail::json_ref<basic_json>& element_ref)
- {
- auto element = element_ref.moved_or_copied();
- m_value.object->emplace(
- std::move(*((*element.m_value.array)[0].m_value.string)),
- std::move((*element.m_value.array)[1]));
- });
- }
- else
- {
- // the initializer list describes an array -> create array
- m_type = value_t::array;
- m_value.array = create<array_t>(init.begin(), init.end());
- }
-
- assert_invariant();
- }
-
- /*!
- @brief explicitly create an array from an initializer list
-
- Creates a JSON array value from a given initializer list. That is, given a
- list of values `a, b, c`, creates the JSON value `[a, b, c]`. If the
- initializer list is empty, the empty array `[]` is created.
-
- @note This function is only needed to express two edge cases that cannot
- be realized with the initializer list constructor (@ref
- basic_json(initializer_list_t, bool, value_t)). These cases
- are:
- 1. creating an array whose elements are all pairs whose first element is a
- string -- in this case, the initializer list constructor would create an
- object, taking the first elements as keys
- 2. creating an empty array -- passing the empty initializer list to the
- initializer list constructor yields an empty object
-
- @param[in] init initializer list with JSON values to create an array from
- (optional)
-
- @return JSON array value
-
- @complexity Linear in the size of @a init.
-
- @exceptionsafety Strong guarantee: if an exception is thrown, there are no
- changes to any JSON value.
-
- @liveexample{The following code shows an example for the `array`
- function.,array}
-
- @sa @ref basic_json(initializer_list_t, bool, value_t) --
- create a JSON value from an initializer list
- @sa @ref object(initializer_list_t) -- create a JSON object
- value from an initializer list
-
- @since version 1.0.0
- */
- JSON_NODISCARD
- static basic_json array(initializer_list_t init = {})
- {
- return basic_json(init, false, value_t::array);
- }
-
- /*!
- @brief explicitly create an object from an initializer list
-
- Creates a JSON object value from a given initializer list. The initializer
- lists elements must be pairs, and their first elements must be strings. If
- the initializer list is empty, the empty object `{}` is created.
-
- @note This function is only added for symmetry reasons. In contrast to the
- related function @ref array(initializer_list_t), there are
- no cases which can only be expressed by this function. That is, any
- initializer list @a init can also be passed to the initializer list
- constructor @ref basic_json(initializer_list_t, bool, value_t).
-
- @param[in] init initializer list to create an object from (optional)
-
- @return JSON object value
-
- @throw type_error.301 if @a init is not a list of pairs whose first
- elements are strings. In this case, no object can be created. When such a
- value is passed to @ref basic_json(initializer_list_t, bool, value_t),
- an array would have been created from the passed initializer list @a init.
- See example below.
-
- @complexity Linear in the size of @a init.
-
- @exceptionsafety Strong guarantee: if an exception is thrown, there are no
- changes to any JSON value.
-
- @liveexample{The following code shows an example for the `object`
- function.,object}
-
- @sa @ref basic_json(initializer_list_t, bool, value_t) --
- create a JSON value from an initializer list
- @sa @ref array(initializer_list_t) -- create a JSON array
- value from an initializer list
-
- @since version 1.0.0
- */
- JSON_NODISCARD
- static basic_json object(initializer_list_t init = {})
- {
- return basic_json(init, false, value_t::object);
- }
-
- /*!
- @brief construct an array with count copies of given value
-
- Constructs a JSON array value by creating @a cnt copies of a passed value.
- In case @a cnt is `0`, an empty array is created.
-
- @param[in] cnt the number of JSON copies of @a val to create
- @param[in] val the JSON value to copy
-
- @post `std::distance(begin(),end()) == cnt` holds.
-
- @complexity Linear in @a cnt.
-
- @exceptionsafety Strong guarantee: if an exception is thrown, there are no
- changes to any JSON value.
-
- @liveexample{The following code shows examples for the @ref
- basic_json(size_type\, const basic_json&)
- constructor.,basic_json__size_type_basic_json}
-
- @since version 1.0.0
- */
- basic_json(size_type cnt, const basic_json& val)
- : m_type(value_t::array)
- {
- m_value.array = create<array_t>(cnt, val);
- assert_invariant();
- }
-
- /*!
- @brief construct a JSON container given an iterator range
-
- Constructs the JSON value with the contents of the range `[first, last)`.
- The semantics depends on the different types a JSON value can have:
- - In case of a null type, invalid_iterator.206 is thrown.
- - In case of other primitive types (number, boolean, or string), @a first
- must be `begin()` and @a last must be `end()`. In this case, the value is
- copied. Otherwise, invalid_iterator.204 is thrown.
- - In case of structured types (array, object), the constructor behaves as
- similar versions for `std::vector` or `std::map`; that is, a JSON array
- or object is constructed from the values in the range.
-
- @tparam InputIT an input iterator type (@ref iterator or @ref
- const_iterator)
-
- @param[in] first begin of the range to copy from (included)
- @param[in] last end of the range to copy from (excluded)
-
- @pre Iterators @a first and @a last must be initialized. **This
- precondition is enforced with an assertion (see warning).** If
- assertions are switched off, a violation of this precondition yields
- undefined behavior.
-
- @pre Range `[first, last)` is valid. Usually, this precondition cannot be
- checked efficiently. Only certain edge cases are detected; see the
- description of the exceptions below. A violation of this precondition
- yields undefined behavior.
-
- @warning A precondition is enforced with a runtime assertion that will
- result in calling `std::abort` if this precondition is not met.
- Assertions can be disabled by defining `NDEBUG` at compile time.
- See https://en.cppreference.com/w/cpp/error/assert for more
- information.
-
- @throw invalid_iterator.201 if iterators @a first and @a last are not
- compatible (i.e., do not belong to the same JSON value). In this case,
- the range `[first, last)` is undefined.
- @throw invalid_iterator.204 if iterators @a first and @a last belong to a
- primitive type (number, boolean, or string), but @a first does not point
- to the first element any more. In this case, the range `[first, last)` is
- undefined. See example code below.
- @throw invalid_iterator.206 if iterators @a first and @a last belong to a
- null value. In this case, the range `[first, last)` is undefined.
-
- @complexity Linear in distance between @a first and @a last.
-
- @exceptionsafety Strong guarantee: if an exception is thrown, there are no
- changes to any JSON value.
-
- @liveexample{The example below shows several ways to create JSON values by
- specifying a subrange with iterators.,basic_json__InputIt_InputIt}
-
- @since version 1.0.0
- */
- template<class InputIT, typename std::enable_if<
- std::is_same<InputIT, typename basic_json_t::iterator>::value or
- std::is_same<InputIT, typename basic_json_t::const_iterator>::value, int>::type = 0>
- basic_json(InputIT first, InputIT last)
- {
- assert(first.m_object != nullptr);
- assert(last.m_object != nullptr);
-
- // make sure iterator fits the current value
- if (JSON_UNLIKELY(first.m_object != last.m_object))
- {
- JSON_THROW(invalid_iterator::create(201, "iterators are not compatible"));
- }
-
- // copy type from first iterator
- m_type = first.m_object->m_type;
-
- // check if iterator range is complete for primitive values
- switch (m_type)
- {
- case value_t::boolean:
- case value_t::number_float:
- case value_t::number_integer:
- case value_t::number_unsigned:
- case value_t::string:
- {
- if (JSON_UNLIKELY(not first.m_it.primitive_iterator.is_begin()
- or not last.m_it.primitive_iterator.is_end()))
- {
- JSON_THROW(invalid_iterator::create(204, "iterators out of range"));
- }
- break;
- }
-
- default:
- break;
- }
-
- switch (m_type)
- {
- case value_t::number_integer:
- {
- m_value.number_integer = first.m_object->m_value.number_integer;
- break;
- }
-
- case value_t::number_unsigned:
- {
- m_value.number_unsigned = first.m_object->m_value.number_unsigned;
- break;
- }
-
- case value_t::number_float:
- {
- m_value.number_float = first.m_object->m_value.number_float;
- break;
- }
-
- case value_t::boolean:
- {
- m_value.boolean = first.m_object->m_value.boolean;
- break;
- }
-
- case value_t::string:
- {
- m_value = *first.m_object->m_value.string;
- break;
- }
-
- case value_t::object:
- {
- m_value.object = create<object_t>(first.m_it.object_iterator,
- last.m_it.object_iterator);
- break;
- }
-
- case value_t::array:
- {
- m_value.array = create<array_t>(first.m_it.array_iterator,
- last.m_it.array_iterator);
- break;
- }
-
- default:
- JSON_THROW(invalid_iterator::create(206, "cannot construct with iterators from " +
- std::string(first.m_object->type_name())));
- }
-
- assert_invariant();
- }
-
-
- ///////////////////////////////////////
- // other constructors and destructor //
- ///////////////////////////////////////
-
- /// @private
- basic_json(const detail::json_ref<basic_json>& ref)
- : basic_json(ref.moved_or_copied())
- {}
-
- /*!
- @brief copy constructor
-
- Creates a copy of a given JSON value.
-
- @param[in] other the JSON value to copy
-
- @post `*this == other`
-
- @complexity Linear in the size of @a other.
-
- @exceptionsafety Strong guarantee: if an exception is thrown, there are no
- changes to any JSON value.
-
- @requirement This function helps `basic_json` satisfying the
- [Container](https://en.cppreference.com/w/cpp/named_req/Container)
- requirements:
- - The complexity is linear.
- - As postcondition, it holds: `other == basic_json(other)`.
-
- @liveexample{The following code shows an example for the copy
- constructor.,basic_json__basic_json}
-
- @since version 1.0.0
- */
- basic_json(const basic_json& other)
- : m_type(other.m_type)
- {
- // check of passed value is valid
- other.assert_invariant();
-
- switch (m_type)
- {
- case value_t::object:
- {
- m_value = *other.m_value.object;
- break;
- }
-
- case value_t::array:
- {
- m_value = *other.m_value.array;
- break;
- }
-
- case value_t::string:
- {
- m_value = *other.m_value.string;
- break;
- }
-
- case value_t::boolean:
- {
- m_value = other.m_value.boolean;
- break;
- }
-
- case value_t::number_integer:
- {
- m_value = other.m_value.number_integer;
- break;
- }
-
- case value_t::number_unsigned:
- {
- m_value = other.m_value.number_unsigned;
- break;
- }
-
- case value_t::number_float:
- {
- m_value = other.m_value.number_float;
- break;
- }
-
- default:
- break;
- }
-
- assert_invariant();
- }
-
- /*!
- @brief move constructor
-
- Move constructor. Constructs a JSON value with the contents of the given
- value @a other using move semantics. It "steals" the resources from @a
- other and leaves it as JSON null value.
-
- @param[in,out] other value to move to this object
-
- @post `*this` has the same value as @a other before the call.
- @post @a other is a JSON null value.
-
- @complexity Constant.
-
- @exceptionsafety No-throw guarantee: this constructor never throws
- exceptions.
-
- @requirement This function helps `basic_json` satisfying the
- [MoveConstructible](https://en.cppreference.com/w/cpp/named_req/MoveConstructible)
- requirements.
-
- @liveexample{The code below shows the move constructor explicitly called
- via std::move.,basic_json__moveconstructor}
-
- @since version 1.0.0
- */
- basic_json(basic_json&& other) noexcept
- : m_type(std::move(other.m_type)),
- m_value(std::move(other.m_value))
- {
- // check that passed value is valid
- other.assert_invariant();
-
- // invalidate payload
- other.m_type = value_t::null;
- other.m_value = {};
-
- assert_invariant();
- }
-
- /*!
- @brief copy assignment
-
- Copy assignment operator. Copies a JSON value via the "copy and swap"
- strategy: It is expressed in terms of the copy constructor, destructor,
- and the `swap()` member function.
-
- @param[in] other value to copy from
-
- @complexity Linear.
-
- @requirement This function helps `basic_json` satisfying the
- [Container](https://en.cppreference.com/w/cpp/named_req/Container)
- requirements:
- - The complexity is linear.
-
- @liveexample{The code below shows and example for the copy assignment. It
- creates a copy of value `a` which is then swapped with `b`. Finally\, the
- copy of `a` (which is the null value after the swap) is
- destroyed.,basic_json__copyassignment}
-
- @since version 1.0.0
- */
- basic_json& operator=(basic_json other) noexcept (
- std::is_nothrow_move_constructible<value_t>::value and
- std::is_nothrow_move_assignable<value_t>::value and
- std::is_nothrow_move_constructible<json_value>::value and
- std::is_nothrow_move_assignable<json_value>::value
- )
- {
- // check that passed value is valid
- other.assert_invariant();
-
- using std::swap;
- swap(m_type, other.m_type);
- swap(m_value, other.m_value);
-
- assert_invariant();
- return *this;
- }
-
- /*!
- @brief destructor
-
- Destroys the JSON value and frees all allocated memory.
-
- @complexity Linear.
-
- @requirement This function helps `basic_json` satisfying the
- [Container](https://en.cppreference.com/w/cpp/named_req/Container)
- requirements:
- - The complexity is linear.
- - All stored elements are destroyed and all memory is freed.
-
- @since version 1.0.0
- */
- ~basic_json() noexcept
- {
- assert_invariant();
- m_value.destroy(m_type);
- }
-
- /// @}
-
- public:
- ///////////////////////
- // object inspection //
- ///////////////////////
-
- /// @name object inspection
- /// Functions to inspect the type of a JSON value.
- /// @{
-
- /*!
- @brief serialization
-
- Serialization function for JSON values. The function tries to mimic
- Python's `json.dumps()` function, and currently supports its @a indent
- and @a ensure_ascii parameters.
-
- @param[in] indent If indent is nonnegative, then array elements and object
- members will be pretty-printed with that indent level. An indent level of
- `0` will only insert newlines. `-1` (the default) selects the most compact
- representation.
- @param[in] indent_char The character to use for indentation if @a indent is
- greater than `0`. The default is ` ` (space).
- @param[in] ensure_ascii If @a ensure_ascii is true, all non-ASCII characters
- in the output are escaped with `\uXXXX` sequences, and the result consists
- of ASCII characters only.
- @param[in] error_handler how to react on decoding errors; there are three
- possible values: `strict` (throws and exception in case a decoding error
- occurs; default), `replace` (replace invalid UTF-8 sequences with U+FFFD),
- and `ignore` (ignore invalid UTF-8 sequences during serialization).
-
- @return string containing the serialization of the JSON value
-
- @throw type_error.316 if a string stored inside the JSON value is not
- UTF-8 encoded
-
- @complexity Linear.
-
- @exceptionsafety Strong guarantee: if an exception is thrown, there are no
- changes in the JSON value.
-
- @liveexample{The following example shows the effect of different @a indent\,
- @a indent_char\, and @a ensure_ascii parameters to the result of the
- serialization.,dump}
-
- @see https://docs.python.org/2/library/json.html#json.dump
-
- @since version 1.0.0; indentation character @a indent_char, option
- @a ensure_ascii and exceptions added in version 3.0.0; error
- handlers added in version 3.4.0.
- */
- string_t dump(const int indent = -1,
- const char indent_char = ' ',
- const bool ensure_ascii = false,
- const error_handler_t error_handler = error_handler_t::strict) const
- {
- string_t result;
- serializer s(detail::output_adapter<char, string_t>(result), indent_char, error_handler);
-
- if (indent >= 0)
- {
- s.dump(*this, true, ensure_ascii, static_cast<unsigned int>(indent));
- }
- else
- {
- s.dump(*this, false, ensure_ascii, 0);
- }
-
- return result;
- }
-
- /*!
- @brief return the type of the JSON value (explicit)
-
- Return the type of the JSON value as a value from the @ref value_t
- enumeration.
-
- @return the type of the JSON value
- Value type | return value
- ------------------------- | -------------------------
- null | value_t::null
- boolean | value_t::boolean
- string | value_t::string
- number (integer) | value_t::number_integer
- number (unsigned integer) | value_t::number_unsigned
- number (floating-point) | value_t::number_float
- object | value_t::object
- array | value_t::array
- discarded | value_t::discarded
-
- @complexity Constant.
-
- @exceptionsafety No-throw guarantee: this member function never throws
- exceptions.
-
- @liveexample{The following code exemplifies `type()` for all JSON
- types.,type}
-
- @sa @ref operator value_t() -- return the type of the JSON value (implicit)
- @sa @ref type_name() -- return the type as string
-
- @since version 1.0.0
- */
- constexpr value_t type() const noexcept
- {
- return m_type;
- }
-
- /*!
- @brief return whether type is primitive
-
- This function returns true if and only if the JSON type is primitive
- (string, number, boolean, or null).
-
- @return `true` if type is primitive (string, number, boolean, or null),
- `false` otherwise.
-
- @complexity Constant.
-
- @exceptionsafety No-throw guarantee: this member function never throws
- exceptions.
-
- @liveexample{The following code exemplifies `is_primitive()` for all JSON
- types.,is_primitive}
-
- @sa @ref is_structured() -- returns whether JSON value is structured
- @sa @ref is_null() -- returns whether JSON value is `null`
- @sa @ref is_string() -- returns whether JSON value is a string
- @sa @ref is_boolean() -- returns whether JSON value is a boolean
- @sa @ref is_number() -- returns whether JSON value is a number
-
- @since version 1.0.0
- */
- constexpr bool is_primitive() const noexcept
- {
- return is_null() or is_string() or is_boolean() or is_number();
- }
-
- /*!
- @brief return whether type is structured
-
- This function returns true if and only if the JSON type is structured
- (array or object).
-
- @return `true` if type is structured (array or object), `false` otherwise.
-
- @complexity Constant.
-
- @exceptionsafety No-throw guarantee: this member function never throws
- exceptions.
-
- @liveexample{The following code exemplifies `is_structured()` for all JSON
- types.,is_structured}
-
- @sa @ref is_primitive() -- returns whether value is primitive
- @sa @ref is_array() -- returns whether value is an array
- @sa @ref is_object() -- returns whether value is an object
-
- @since version 1.0.0
- */
- constexpr bool is_structured() const noexcept
- {
- return is_array() or is_object();
- }
-
- /*!
- @brief return whether value is null
-
- This function returns true if and only if the JSON value is null.
-
- @return `true` if type is null, `false` otherwise.
-
- @complexity Constant.
-
- @exceptionsafety No-throw guarantee: this member function never throws
- exceptions.
-
- @liveexample{The following code exemplifies `is_null()` for all JSON
- types.,is_null}
-
- @since version 1.0.0
- */
- constexpr bool is_null() const noexcept
- {
- return m_type == value_t::null;
- }
-
- /*!
- @brief return whether value is a boolean
-
- This function returns true if and only if the JSON value is a boolean.
-
- @return `true` if type is boolean, `false` otherwise.
-
- @complexity Constant.
-
- @exceptionsafety No-throw guarantee: this member function never throws
- exceptions.
-
- @liveexample{The following code exemplifies `is_boolean()` for all JSON
- types.,is_boolean}
-
- @since version 1.0.0
- */
- constexpr bool is_boolean() const noexcept
- {
- return m_type == value_t::boolean;
- }
-
- /*!
- @brief return whether value is a number
-
- This function returns true if and only if the JSON value is a number. This
- includes both integer (signed and unsigned) and floating-point values.
-
- @return `true` if type is number (regardless whether integer, unsigned
- integer or floating-type), `false` otherwise.
-
- @complexity Constant.
-
- @exceptionsafety No-throw guarantee: this member function never throws
- exceptions.
-
- @liveexample{The following code exemplifies `is_number()` for all JSON
- types.,is_number}
-
- @sa @ref is_number_integer() -- check if value is an integer or unsigned
- integer number
- @sa @ref is_number_unsigned() -- check if value is an unsigned integer
- number
- @sa @ref is_number_float() -- check if value is a floating-point number
-
- @since version 1.0.0
- */
- constexpr bool is_number() const noexcept
- {
- return is_number_integer() or is_number_float();
- }
-
- /*!
- @brief return whether value is an integer number
-
- This function returns true if and only if the JSON value is a signed or
- unsigned integer number. This excludes floating-point values.
-
- @return `true` if type is an integer or unsigned integer number, `false`
- otherwise.
-
- @complexity Constant.
-
- @exceptionsafety No-throw guarantee: this member function never throws
- exceptions.
-
- @liveexample{The following code exemplifies `is_number_integer()` for all
- JSON types.,is_number_integer}
-
- @sa @ref is_number() -- check if value is a number
- @sa @ref is_number_unsigned() -- check if value is an unsigned integer
- number
- @sa @ref is_number_float() -- check if value is a floating-point number
-
- @since version 1.0.0
- */
- constexpr bool is_number_integer() const noexcept
- {
- return m_type == value_t::number_integer or m_type == value_t::number_unsigned;
- }
-
- /*!
- @brief return whether value is an unsigned integer number
-
- This function returns true if and only if the JSON value is an unsigned
- integer number. This excludes floating-point and signed integer values.
-
- @return `true` if type is an unsigned integer number, `false` otherwise.
-
- @complexity Constant.
-
- @exceptionsafety No-throw guarantee: this member function never throws
- exceptions.
-
- @liveexample{The following code exemplifies `is_number_unsigned()` for all
- JSON types.,is_number_unsigned}
-
- @sa @ref is_number() -- check if value is a number
- @sa @ref is_number_integer() -- check if value is an integer or unsigned
- integer number
- @sa @ref is_number_float() -- check if value is a floating-point number
-
- @since version 2.0.0
- */
- constexpr bool is_number_unsigned() const noexcept
- {
- return m_type == value_t::number_unsigned;
- }
-
- /*!
- @brief return whether value is a floating-point number
-
- This function returns true if and only if the JSON value is a
- floating-point number. This excludes signed and unsigned integer values.
-
- @return `true` if type is a floating-point number, `false` otherwise.
-
- @complexity Constant.
-
- @exceptionsafety No-throw guarantee: this member function never throws
- exceptions.
-
- @liveexample{The following code exemplifies `is_number_float()` for all
- JSON types.,is_number_float}
-
- @sa @ref is_number() -- check if value is number
- @sa @ref is_number_integer() -- check if value is an integer number
- @sa @ref is_number_unsigned() -- check if value is an unsigned integer
- number
-
- @since version 1.0.0
- */
- constexpr bool is_number_float() const noexcept
- {
- return m_type == value_t::number_float;
- }
-
- /*!
- @brief return whether value is an object
-
- This function returns true if and only if the JSON value is an object.
-
- @return `true` if type is object, `false` otherwise.
-
- @complexity Constant.
-
- @exceptionsafety No-throw guarantee: this member function never throws
- exceptions.
-
- @liveexample{The following code exemplifies `is_object()` for all JSON
- types.,is_object}
-
- @since version 1.0.0
- */
- constexpr bool is_object() const noexcept
- {
- return m_type == value_t::object;
- }
-
- /*!
- @brief return whether value is an array
-
- This function returns true if and only if the JSON value is an array.
-
- @return `true` if type is array, `false` otherwise.
-
- @complexity Constant.
-
- @exceptionsafety No-throw guarantee: this member function never throws
- exceptions.
-
- @liveexample{The following code exemplifies `is_array()` for all JSON
- types.,is_array}
-
- @since version 1.0.0
- */
- constexpr bool is_array() const noexcept
- {
- return m_type == value_t::array;
- }
-
- /*!
- @brief return whether value is a string
-
- This function returns true if and only if the JSON value is a string.
-
- @return `true` if type is string, `false` otherwise.
-
- @complexity Constant.
-
- @exceptionsafety No-throw guarantee: this member function never throws
- exceptions.
-
- @liveexample{The following code exemplifies `is_string()` for all JSON
- types.,is_string}
-
- @since version 1.0.0
- */
- constexpr bool is_string() const noexcept
- {
- return m_type == value_t::string;
- }
-
- /*!
- @brief return whether value is discarded
-
- This function returns true if and only if the JSON value was discarded
- during parsing with a callback function (see @ref parser_callback_t).
-
- @note This function will always be `false` for JSON values after parsing.
- That is, discarded values can only occur during parsing, but will be
- removed when inside a structured value or replaced by null in other cases.
-
- @return `true` if type is discarded, `false` otherwise.
-
- @complexity Constant.
-
- @exceptionsafety No-throw guarantee: this member function never throws
- exceptions.
-
- @liveexample{The following code exemplifies `is_discarded()` for all JSON
- types.,is_discarded}
-
- @since version 1.0.0
- */
- constexpr bool is_discarded() const noexcept
- {
- return m_type == value_t::discarded;
- }
-
- /*!
- @brief return the type of the JSON value (implicit)
-
- Implicitly return the type of the JSON value as a value from the @ref
- value_t enumeration.
-
- @return the type of the JSON value
-
- @complexity Constant.
-
- @exceptionsafety No-throw guarantee: this member function never throws
- exceptions.
-
- @liveexample{The following code exemplifies the @ref value_t operator for
- all JSON types.,operator__value_t}
-
- @sa @ref type() -- return the type of the JSON value (explicit)
- @sa @ref type_name() -- return the type as string
-
- @since version 1.0.0
- */
- constexpr operator value_t() const noexcept
- {
- return m_type;
- }
-
- /// @}
-
- private:
- //////////////////
- // value access //
- //////////////////
-
- /// get a boolean (explicit)
- boolean_t get_impl(boolean_t* /*unused*/) const
- {
- if (JSON_LIKELY(is_boolean()))
- {
- return m_value.boolean;
- }
-
- JSON_THROW(type_error::create(302, "type must be boolean, but is " + std::string(type_name())));
- }
-
- /// get a pointer to the value (object)
- object_t* get_impl_ptr(object_t* /*unused*/) noexcept
- {
- return is_object() ? m_value.object : nullptr;
- }
-
- /// get a pointer to the value (object)
- constexpr const object_t* get_impl_ptr(const object_t* /*unused*/) const noexcept
- {
- return is_object() ? m_value.object : nullptr;
- }
-
- /// get a pointer to the value (array)
- array_t* get_impl_ptr(array_t* /*unused*/) noexcept
- {
- return is_array() ? m_value.array : nullptr;
- }
-
- /// get a pointer to the value (array)
- constexpr const array_t* get_impl_ptr(const array_t* /*unused*/) const noexcept
- {
- return is_array() ? m_value.array : nullptr;
- }
-
- /// get a pointer to the value (string)
- string_t* get_impl_ptr(string_t* /*unused*/) noexcept
- {
- return is_string() ? m_value.string : nullptr;
- }
-
- /// get a pointer to the value (string)
- constexpr const string_t* get_impl_ptr(const string_t* /*unused*/) const noexcept
- {
- return is_string() ? m_value.string : nullptr;
- }
-
- /// get a pointer to the value (boolean)
- boolean_t* get_impl_ptr(boolean_t* /*unused*/) noexcept
- {
- return is_boolean() ? &m_value.boolean : nullptr;
- }
-
- /// get a pointer to the value (boolean)
- constexpr const boolean_t* get_impl_ptr(const boolean_t* /*unused*/) const noexcept
- {
- return is_boolean() ? &m_value.boolean : nullptr;
- }
-
- /// get a pointer to the value (integer number)
- number_integer_t* get_impl_ptr(number_integer_t* /*unused*/) noexcept
- {
- return is_number_integer() ? &m_value.number_integer : nullptr;
- }
-
- /// get a pointer to the value (integer number)
- constexpr const number_integer_t* get_impl_ptr(const number_integer_t* /*unused*/) const noexcept
- {
- return is_number_integer() ? &m_value.number_integer : nullptr;
- }
-
- /// get a pointer to the value (unsigned number)
- number_unsigned_t* get_impl_ptr(number_unsigned_t* /*unused*/) noexcept
- {
- return is_number_unsigned() ? &m_value.number_unsigned : nullptr;
- }
-
- /// get a pointer to the value (unsigned number)
- constexpr const number_unsigned_t* get_impl_ptr(const number_unsigned_t* /*unused*/) const noexcept
- {
- return is_number_unsigned() ? &m_value.number_unsigned : nullptr;
- }
-
- /// get a pointer to the value (floating-point number)
- number_float_t* get_impl_ptr(number_float_t* /*unused*/) noexcept
- {
- return is_number_float() ? &m_value.number_float : nullptr;
- }
-
- /// get a pointer to the value (floating-point number)
- constexpr const number_float_t* get_impl_ptr(const number_float_t* /*unused*/) const noexcept
- {
- return is_number_float() ? &m_value.number_float : nullptr;
- }
-
- /*!
- @brief helper function to implement get_ref()
-
- This function helps to implement get_ref() without code duplication for
- const and non-const overloads
-
- @tparam ThisType will be deduced as `basic_json` or `const basic_json`
-
- @throw type_error.303 if ReferenceType does not match underlying value
- type of the current JSON
- */
- template<typename ReferenceType, typename ThisType>
- static ReferenceType get_ref_impl(ThisType& obj)
- {
- // delegate the call to get_ptr<>()
- auto ptr = obj.template get_ptr<typename std::add_pointer<ReferenceType>::type>();
-
- if (JSON_LIKELY(ptr != nullptr))
- {
- return *ptr;
- }
-
- JSON_THROW(type_error::create(303, "incompatible ReferenceType for get_ref, actual type is " + std::string(obj.type_name())));
- }
-
- public:
- /// @name value access
- /// Direct access to the stored value of a JSON value.
- /// @{
-
- /*!
- @brief get special-case overload
-
- This overloads avoids a lot of template boilerplate, it can be seen as the
- identity method
-
- @tparam BasicJsonType == @ref basic_json
-
- @return a copy of *this
-
- @complexity Constant.
-
- @since version 2.1.0
- */
- template<typename BasicJsonType, detail::enable_if_t<
- std::is_same<typename std::remove_const<BasicJsonType>::type, basic_json_t>::value,
- int> = 0>
- basic_json get() const
- {
- return *this;
- }
-
- /*!
- @brief get special-case overload
-
- This overloads converts the current @ref basic_json in a different
- @ref basic_json type
-
- @tparam BasicJsonType == @ref basic_json
-
- @return a copy of *this, converted into @tparam BasicJsonType
-
- @complexity Depending on the implementation of the called `from_json()`
- method.
-
- @since version 3.2.0
- */
- template<typename BasicJsonType, detail::enable_if_t<
- not std::is_same<BasicJsonType, basic_json>::value and
- detail::is_basic_json<BasicJsonType>::value, int> = 0>
- BasicJsonType get() const
- {
- return *this;
- }
-
- /*!
- @brief get a value (explicit)
-
- Explicit type conversion between the JSON value and a compatible value
- which is [CopyConstructible](https://en.cppreference.com/w/cpp/named_req/CopyConstructible)
- and [DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible).
- The value is converted by calling the @ref json_serializer<ValueType>
- `from_json()` method.
-
- The function is equivalent to executing
- @code {.cpp}
- ValueType ret;
- JSONSerializer<ValueType>::from_json(*this, ret);
- return ret;
- @endcode
-
- This overloads is chosen if:
- - @a ValueType is not @ref basic_json,
- - @ref json_serializer<ValueType> has a `from_json()` method of the form
- `void from_json(const basic_json&, ValueType&)`, and
- - @ref json_serializer<ValueType> does not have a `from_json()` method of
- the form `ValueType from_json(const basic_json&)`
-
- @tparam ValueTypeCV the provided value type
- @tparam ValueType the returned value type
-
- @return copy of the JSON value, converted to @a ValueType
-
- @throw what @ref json_serializer<ValueType> `from_json()` method throws
-
- @liveexample{The example below shows several conversions from JSON values
- to other types. There a few things to note: (1) Floating-point numbers can
- be converted to integers\, (2) A JSON array can be converted to a standard
- `std::vector<short>`\, (3) A JSON object can be converted to C++
- associative containers such as `std::unordered_map<std::string\,
- json>`.,get__ValueType_const}
-
- @since version 2.1.0
- */
- template<typename ValueTypeCV, typename ValueType = detail::uncvref_t<ValueTypeCV>,
- detail::enable_if_t <
- not detail::is_basic_json<ValueType>::value and
- detail::has_from_json<basic_json_t, ValueType>::value and
- not detail::has_non_default_from_json<basic_json_t, ValueType>::value,
- int> = 0>
- ValueType get() const noexcept(noexcept(
- JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), std::declval<ValueType&>())))
- {
- // we cannot static_assert on ValueTypeCV being non-const, because
- // there is support for get<const basic_json_t>(), which is why we
- // still need the uncvref
- static_assert(not std::is_reference<ValueTypeCV>::value,
- "get() cannot be used with reference types, you might want to use get_ref()");
- static_assert(std::is_default_constructible<ValueType>::value,
- "types must be DefaultConstructible when used with get()");
-
- ValueType ret;
- JSONSerializer<ValueType>::from_json(*this, ret);
- return ret;
- }
-
- /*!
- @brief get a value (explicit); special case
-
- Explicit type conversion between the JSON value and a compatible value
- which is **not** [CopyConstructible](https://en.cppreference.com/w/cpp/named_req/CopyConstructible)
- and **not** [DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible).
- The value is converted by calling the @ref json_serializer<ValueType>
- `from_json()` method.
-
- The function is equivalent to executing
- @code {.cpp}
- return JSONSerializer<ValueTypeCV>::from_json(*this);
- @endcode
-
- This overloads is chosen if:
- - @a ValueType is not @ref basic_json and
- - @ref json_serializer<ValueType> has a `from_json()` method of the form
- `ValueType from_json(const basic_json&)`
-
- @note If @ref json_serializer<ValueType> has both overloads of
- `from_json()`, this one is chosen.
-
- @tparam ValueTypeCV the provided value type
- @tparam ValueType the returned value type
-
- @return copy of the JSON value, converted to @a ValueType
-
- @throw what @ref json_serializer<ValueType> `from_json()` method throws
-
- @since version 2.1.0
- */
- template<typename ValueTypeCV, typename ValueType = detail::uncvref_t<ValueTypeCV>,
- detail::enable_if_t<not std::is_same<basic_json_t, ValueType>::value and
- detail::has_non_default_from_json<basic_json_t, ValueType>::value,
- int> = 0>
- ValueType get() const noexcept(noexcept(
- JSONSerializer<ValueTypeCV>::from_json(std::declval<const basic_json_t&>())))
- {
- static_assert(not std::is_reference<ValueTypeCV>::value,
- "get() cannot be used with reference types, you might want to use get_ref()");
- return JSONSerializer<ValueTypeCV>::from_json(*this);
- }
-
- /*!
- @brief get a value (explicit)
-
- Explicit type conversion between the JSON value and a compatible value.
- The value is filled into the input parameter by calling the @ref json_serializer<ValueType>
- `from_json()` method.
-
- The function is equivalent to executing
- @code {.cpp}
- ValueType v;
- JSONSerializer<ValueType>::from_json(*this, v);
- @endcode
-
- This overloads is chosen if:
- - @a ValueType is not @ref basic_json,
- - @ref json_serializer<ValueType> has a `from_json()` method of the form
- `void from_json(const basic_json&, ValueType&)`, and
-
- @tparam ValueType the input parameter type.
-
- @return the input parameter, allowing chaining calls.
-
- @throw what @ref json_serializer<ValueType> `from_json()` method throws
-
- @liveexample{The example below shows several conversions from JSON values
- to other types. There a few things to note: (1) Floating-point numbers can
- be converted to integers\, (2) A JSON array can be converted to a standard
- `std::vector<short>`\, (3) A JSON object can be converted to C++
- associative containers such as `std::unordered_map<std::string\,
- json>`.,get_to}
-
- @since version 3.3.0
- */
- template<typename ValueType,
- detail::enable_if_t <
- not detail::is_basic_json<ValueType>::value and
- detail::has_from_json<basic_json_t, ValueType>::value,
- int> = 0>
- ValueType & get_to(ValueType& v) const noexcept(noexcept(
- JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), v)))
- {
- JSONSerializer<ValueType>::from_json(*this, v);
- return v;
- }
-
-
- /*!
- @brief get a pointer value (implicit)
-
- Implicit pointer access to the internally stored JSON value. No copies are
- made.
-
- @warning Writing data to the pointee of the result yields an undefined
- state.
-
- @tparam PointerType pointer type; must be a pointer to @ref array_t, @ref
- object_t, @ref string_t, @ref boolean_t, @ref number_integer_t,
- @ref number_unsigned_t, or @ref number_float_t. Enforced by a static
- assertion.
-
- @return pointer to the internally stored JSON value if the requested
- pointer type @a PointerType fits to the JSON value; `nullptr` otherwise
-
- @complexity Constant.
-
- @liveexample{The example below shows how pointers to internal values of a
- JSON value can be requested. Note that no type conversions are made and a
- `nullptr` is returned if the value and the requested pointer type does not
- match.,get_ptr}
-
- @since version 1.0.0
- */
- template<typename PointerType, typename std::enable_if<
- std::is_pointer<PointerType>::value, int>::type = 0>
- auto get_ptr() noexcept -> decltype(std::declval<basic_json_t&>().get_impl_ptr(std::declval<PointerType>()))
- {
- // delegate the call to get_impl_ptr<>()
- return get_impl_ptr(static_cast<PointerType>(nullptr));
- }
-
- /*!
- @brief get a pointer value (implicit)
- @copydoc get_ptr()
- */
- template<typename PointerType, typename std::enable_if<
- std::is_pointer<PointerType>::value and
- std::is_const<typename std::remove_pointer<PointerType>::type>::value, int>::type = 0>
- constexpr auto get_ptr() const noexcept -> decltype(std::declval<const basic_json_t&>().get_impl_ptr(std::declval<PointerType>()))
- {
- // delegate the call to get_impl_ptr<>() const
- return get_impl_ptr(static_cast<PointerType>(nullptr));
- }
-
- /*!
- @brief get a pointer value (explicit)
-
- Explicit pointer access to the internally stored JSON value. No copies are
- made.
-
- @warning The pointer becomes invalid if the underlying JSON object
- changes.
-
- @tparam PointerType pointer type; must be a pointer to @ref array_t, @ref
- object_t, @ref string_t, @ref boolean_t, @ref number_integer_t,
- @ref number_unsigned_t, or @ref number_float_t.
-
- @return pointer to the internally stored JSON value if the requested
- pointer type @a PointerType fits to the JSON value; `nullptr` otherwise
-
- @complexity Constant.
-
- @liveexample{The example below shows how pointers to internal values of a
- JSON value can be requested. Note that no type conversions are made and a
- `nullptr` is returned if the value and the requested pointer type does not
- match.,get__PointerType}
-
- @sa @ref get_ptr() for explicit pointer-member access
-
- @since version 1.0.0
- */
- template<typename PointerType, typename std::enable_if<
- std::is_pointer<PointerType>::value, int>::type = 0>
- auto get() noexcept -> decltype(std::declval<basic_json_t&>().template get_ptr<PointerType>())
- {
- // delegate the call to get_ptr
- return get_ptr<PointerType>();
- }
-
- /*!
- @brief get a pointer value (explicit)
- @copydoc get()
- */
- template<typename PointerType, typename std::enable_if<
- std::is_pointer<PointerType>::value, int>::type = 0>
- constexpr auto get() const noexcept -> decltype(std::declval<const basic_json_t&>().template get_ptr<PointerType>())
- {
- // delegate the call to get_ptr
- return get_ptr<PointerType>();
- }
-
- /*!
- @brief get a reference value (implicit)
-
- Implicit reference access to the internally stored JSON value. No copies
- are made.
-
- @warning Writing data to the referee of the result yields an undefined
- state.
-
- @tparam ReferenceType reference type; must be a reference to @ref array_t,
- @ref object_t, @ref string_t, @ref boolean_t, @ref number_integer_t, or
- @ref number_float_t. Enforced by static assertion.
-
- @return reference to the internally stored JSON value if the requested
- reference type @a ReferenceType fits to the JSON value; throws
- type_error.303 otherwise
-
- @throw type_error.303 in case passed type @a ReferenceType is incompatible
- with the stored JSON value; see example below
-
- @complexity Constant.
-
- @liveexample{The example shows several calls to `get_ref()`.,get_ref}
-
- @since version 1.1.0
- */
- template<typename ReferenceType, typename std::enable_if<
- std::is_reference<ReferenceType>::value, int>::type = 0>
- ReferenceType get_ref()
- {
- // delegate call to get_ref_impl
- return get_ref_impl<ReferenceType>(*this);
- }
-
- /*!
- @brief get a reference value (implicit)
- @copydoc get_ref()
- */
- template<typename ReferenceType, typename std::enable_if<
- std::is_reference<ReferenceType>::value and
- std::is_const<typename std::remove_reference<ReferenceType>::type>::value, int>::type = 0>
- ReferenceType get_ref() const
- {
- // delegate call to get_ref_impl
- return get_ref_impl<ReferenceType>(*this);
- }
-
- /*!
- @brief get a value (implicit)
-
- Implicit type conversion between the JSON value and a compatible value.
- The call is realized by calling @ref get() const.
-
- @tparam ValueType non-pointer type compatible to the JSON value, for
- instance `int` for JSON integer numbers, `bool` for JSON booleans, or
- `std::vector` types for JSON arrays. The character type of @ref string_t
- as well as an initializer list of this type is excluded to avoid
- ambiguities as these types implicitly convert to `std::string`.
-
- @return copy of the JSON value, converted to type @a ValueType
-
- @throw type_error.302 in case passed type @a ValueType is incompatible
- to the JSON value type (e.g., the JSON value is of type boolean, but a
- string is requested); see example below
-
- @complexity Linear in the size of the JSON value.
-
- @liveexample{The example below shows several conversions from JSON values
- to other types. There a few things to note: (1) Floating-point numbers can
- be converted to integers\, (2) A JSON array can be converted to a standard
- `std::vector<short>`\, (3) A JSON object can be converted to C++
- associative containers such as `std::unordered_map<std::string\,
- json>`.,operator__ValueType}
-
- @since version 1.0.0
- */
- template < typename ValueType, typename std::enable_if <
- not std::is_pointer<ValueType>::value and
- not std::is_same<ValueType, detail::json_ref<basic_json>>::value and
- not std::is_same<ValueType, typename string_t::value_type>::value and
- not detail::is_basic_json<ValueType>::value
-
-#ifndef _MSC_VER // fix for issue #167 operator<< ambiguity under VS2015
- and not std::is_same<ValueType, std::initializer_list<typename string_t::value_type>>::value
-#if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) and _MSC_VER <= 1914))
- and not std::is_same<ValueType, typename std::string_view>::value
-#endif
-#endif
- and detail::is_detected<detail::get_template_function, const basic_json_t&, ValueType>::value
- , int >::type = 0 >
- operator ValueType() const
- {
- // delegate the call to get<>() const
- return get<ValueType>();
- }
-
- /// @}
-
-
- ////////////////////
- // element access //
- ////////////////////
-
- /// @name element access
- /// Access to the JSON value.
- /// @{
-
- /*!
- @brief access specified array element with bounds checking
-
- Returns a reference to the element at specified location @a idx, with
- bounds checking.
-
- @param[in] idx index of the element to access
-
- @return reference to the element at index @a idx
-
- @throw type_error.304 if the JSON value is not an array; in this case,
- calling `at` with an index makes no sense. See example below.
- @throw out_of_range.401 if the index @a idx is out of range of the array;
- that is, `idx >= size()`. See example below.
-
- @exceptionsafety Strong guarantee: if an exception is thrown, there are no
- changes in the JSON value.
-
- @complexity Constant.
-
- @since version 1.0.0
-
- @liveexample{The example below shows how array elements can be read and
- written using `at()`. It also demonstrates the different exceptions that
- can be thrown.,at__size_type}
- */
- reference at(size_type idx)
- {
- // at only works for arrays
- if (JSON_LIKELY(is_array()))
- {
- JSON_TRY
- {
- return m_value.array->at(idx);
- }
- JSON_CATCH (std::out_of_range&)
- {
- // create better exception explanation
- JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range"));
- }
- }
- else
- {
- JSON_THROW(type_error::create(304, "cannot use at() with " + std::string(type_name())));
- }
- }
-
- /*!
- @brief access specified array element with bounds checking
-
- Returns a const reference to the element at specified location @a idx,
- with bounds checking.
-
- @param[in] idx index of the element to access
-
- @return const reference to the element at index @a idx
-
- @throw type_error.304 if the JSON value is not an array; in this case,
- calling `at` with an index makes no sense. See example below.
- @throw out_of_range.401 if the index @a idx is out of range of the array;
- that is, `idx >= size()`. See example below.
-
- @exceptionsafety Strong guarantee: if an exception is thrown, there are no
- changes in the JSON value.
-
- @complexity Constant.
-
- @since version 1.0.0
-
- @liveexample{The example below shows how array elements can be read using
- `at()`. It also demonstrates the different exceptions that can be thrown.,
- at__size_type_const}
- */
- const_reference at(size_type idx) const
- {
- // at only works for arrays
- if (JSON_LIKELY(is_array()))
- {
- JSON_TRY
- {
- return m_value.array->at(idx);
- }
- JSON_CATCH (std::out_of_range&)
- {
- // create better exception explanation
- JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range"));
- }
- }
- else
- {
- JSON_THROW(type_error::create(304, "cannot use at() with " + std::string(type_name())));
- }
- }
-
- /*!
- @brief access specified object element with bounds checking
-
- Returns a reference to the element at with specified key @a key, with
- bounds checking.
-
- @param[in] key key of the element to access
-
- @return reference to the element at key @a key
-
- @throw type_error.304 if the JSON value is not an object; in this case,
- calling `at` with a key makes no sense. See example below.
- @throw out_of_range.403 if the key @a key is is not stored in the object;
- that is, `find(key) == end()`. See example below.
-
- @exceptionsafety Strong guarantee: if an exception is thrown, there are no
- changes in the JSON value.
-
- @complexity Logarithmic in the size of the container.
-
- @sa @ref operator[](const typename object_t::key_type&) for unchecked
- access by reference
- @sa @ref value() for access by value with a default value
-
- @since version 1.0.0
-
- @liveexample{The example below shows how object elements can be read and
- written using `at()`. It also demonstrates the different exceptions that
- can be thrown.,at__object_t_key_type}
- */
- reference at(const typename object_t::key_type& key)
- {
- // at only works for objects
- if (JSON_LIKELY(is_object()))
- {
- JSON_TRY
- {
- return m_value.object->at(key);
- }
- JSON_CATCH (std::out_of_range&)
- {
- // create better exception explanation
- JSON_THROW(out_of_range::create(403, "key '" + key + "' not found"));
- }
- }
- else
- {
- JSON_THROW(type_error::create(304, "cannot use at() with " + std::string(type_name())));
- }
- }
-
- /*!
- @brief access specified object element with bounds checking
-
- Returns a const reference to the element at with specified key @a key,
- with bounds checking.
-
- @param[in] key key of the element to access
-
- @return const reference to the element at key @a key
-
- @throw type_error.304 if the JSON value is not an object; in this case,
- calling `at` with a key makes no sense. See example below.
- @throw out_of_range.403 if the key @a key is is not stored in the object;
- that is, `find(key) == end()`. See example below.
-
- @exceptionsafety Strong guarantee: if an exception is thrown, there are no
- changes in the JSON value.
-
- @complexity Logarithmic in the size of the container.
-
- @sa @ref operator[](const typename object_t::key_type&) for unchecked
- access by reference
- @sa @ref value() for access by value with a default value
-
- @since version 1.0.0
-
- @liveexample{The example below shows how object elements can be read using
- `at()`. It also demonstrates the different exceptions that can be thrown.,
- at__object_t_key_type_const}
- */
- const_reference at(const typename object_t::key_type& key) const
- {
- // at only works for objects
- if (JSON_LIKELY(is_object()))
- {
- JSON_TRY
- {
- return m_value.object->at(key);
- }
- JSON_CATCH (std::out_of_range&)
- {
- // create better exception explanation
- JSON_THROW(out_of_range::create(403, "key '" + key + "' not found"));
- }
- }
- else
- {
- JSON_THROW(type_error::create(304, "cannot use at() with " + std::string(type_name())));
- }
- }
-
- /*!
- @brief access specified array element
-
- Returns a reference to the element at specified location @a idx.
-
- @note If @a idx is beyond the range of the array (i.e., `idx >= size()`),
- then the array is silently filled up with `null` values to make `idx` a
- valid reference to the last stored element.
-
- @param[in] idx index of the element to access
-
- @return reference to the element at index @a idx
-
- @throw type_error.305 if the JSON value is not an array or null; in that
- cases, using the [] operator with an index makes no sense.
-
- @complexity Constant if @a idx is in the range of the array. Otherwise
- linear in `idx - size()`.
-
- @liveexample{The example below shows how array elements can be read and
- written using `[]` operator. Note the addition of `null`
- values.,operatorarray__size_type}
-
- @since version 1.0.0
- */
- reference operator[](size_type idx)
- {
- // implicitly convert null value to an empty array
- if (is_null())
- {
- m_type = value_t::array;
- m_value.array = create<array_t>();
- assert_invariant();
- }
-
- // operator[] only works for arrays
- if (JSON_LIKELY(is_array()))
- {
- // fill up array with null values if given idx is outside range
- if (idx >= m_value.array->size())
- {
- m_value.array->insert(m_value.array->end(),
- idx - m_value.array->size() + 1,
- basic_json());
- }
-
- return m_value.array->operator[](idx);
- }
-
- JSON_THROW(type_error::create(305, "cannot use operator[] with a numeric argument with " + std::string(type_name())));
- }
-
- /*!
- @brief access specified array element
-
- Returns a const reference to the element at specified location @a idx.
-
- @param[in] idx index of the element to access
-
- @return const reference to the element at index @a idx
-
- @throw type_error.305 if the JSON value is not an array; in that case,
- using the [] operator with an index makes no sense.
-
- @complexity Constant.
-
- @liveexample{The example below shows how array elements can be read using
- the `[]` operator.,operatorarray__size_type_const}
-
- @since version 1.0.0
- */
- const_reference operator[](size_type idx) const
- {
- // const operator[] only works for arrays
- if (JSON_LIKELY(is_array()))
- {
- return m_value.array->operator[](idx);
- }
-
- JSON_THROW(type_error::create(305, "cannot use operator[] with a numeric argument with " + std::string(type_name())));
- }
-
- /*!
- @brief access specified object element
-
- Returns a reference to the element at with specified key @a key.
-
- @note If @a key is not found in the object, then it is silently added to
- the object and filled with a `null` value to make `key` a valid reference.
- In case the value was `null` before, it is converted to an object.
-
- @param[in] key key of the element to access
-
- @return reference to the element at key @a key
-
- @throw type_error.305 if the JSON value is not an object or null; in that
- cases, using the [] operator with a key makes no sense.
-
- @complexity Logarithmic in the size of the container.
-
- @liveexample{The example below shows how object elements can be read and
- written using the `[]` operator.,operatorarray__key_type}
-
- @sa @ref at(const typename object_t::key_type&) for access by reference
- with range checking
- @sa @ref value() for access by value with a default value
-
- @since version 1.0.0
- */
- reference operator[](const typename object_t::key_type& key)
- {
- // implicitly convert null value to an empty object
- if (is_null())
- {
- m_type = value_t::object;
- m_value.object = create<object_t>();
- assert_invariant();
- }
-
- // operator[] only works for objects
- if (JSON_LIKELY(is_object()))
- {
- return m_value.object->operator[](key);
- }
-
- JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name())));
- }
-
- /*!
- @brief read-only access specified object element
-
- Returns a const reference to the element at with specified key @a key. No
- bounds checking is performed.
-
- @warning If the element with key @a key does not exist, the behavior is
- undefined.
-
- @param[in] key key of the element to access
-
- @return const reference to the element at key @a key
-
- @pre The element with key @a key must exist. **This precondition is
- enforced with an assertion.**
-
- @throw type_error.305 if the JSON value is not an object; in that case,
- using the [] operator with a key makes no sense.
-
- @complexity Logarithmic in the size of the container.
-
- @liveexample{The example below shows how object elements can be read using
- the `[]` operator.,operatorarray__key_type_const}
-
- @sa @ref at(const typename object_t::key_type&) for access by reference
- with range checking
- @sa @ref value() for access by value with a default value
-
- @since version 1.0.0
- */
- const_reference operator[](const typename object_t::key_type& key) const
- {
- // const operator[] only works for objects
- if (JSON_LIKELY(is_object()))
- {
- assert(m_value.object->find(key) != m_value.object->end());
- return m_value.object->find(key)->second;
- }
-
- JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name())));
- }
-
- /*!
- @brief access specified object element
-
- Returns a reference to the element at with specified key @a key.
-
- @note If @a key is not found in the object, then it is silently added to
- the object and filled with a `null` value to make `key` a valid reference.
- In case the value was `null` before, it is converted to an object.
-
- @param[in] key key of the element to access
-
- @return reference to the element at key @a key
-
- @throw type_error.305 if the JSON value is not an object or null; in that
- cases, using the [] operator with a key makes no sense.
-
- @complexity Logarithmic in the size of the container.
-
- @liveexample{The example below shows how object elements can be read and
- written using the `[]` operator.,operatorarray__key_type}
-
- @sa @ref at(const typename object_t::key_type&) for access by reference
- with range checking
- @sa @ref value() for access by value with a default value
-
- @since version 1.1.0
- */
- template<typename T>
- reference operator[](T* key)
- {
- // implicitly convert null to object
- if (is_null())
- {
- m_type = value_t::object;
- m_value = value_t::object;
- assert_invariant();
- }
-
- // at only works for objects
- if (JSON_LIKELY(is_object()))
- {
- return m_value.object->operator[](key);
- }
-
- JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name())));
- }
-
- /*!
- @brief read-only access specified object element
-
- Returns a const reference to the element at with specified key @a key. No
- bounds checking is performed.
-
- @warning If the element with key @a key does not exist, the behavior is
- undefined.
-
- @param[in] key key of the element to access
-
- @return const reference to the element at key @a key
-
- @pre The element with key @a key must exist. **This precondition is
- enforced with an assertion.**
-
- @throw type_error.305 if the JSON value is not an object; in that case,
- using the [] operator with a key makes no sense.
-
- @complexity Logarithmic in the size of the container.
-
- @liveexample{The example below shows how object elements can be read using
- the `[]` operator.,operatorarray__key_type_const}
-
- @sa @ref at(const typename object_t::key_type&) for access by reference
- with range checking
- @sa @ref value() for access by value with a default value
-
- @since version 1.1.0
- */
- template<typename T>
- const_reference operator[](T* key) const
- {
- // at only works for objects
- if (JSON_LIKELY(is_object()))
- {
- assert(m_value.object->find(key) != m_value.object->end());
- return m_value.object->find(key)->second;
- }
-
- JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name())));
- }
-
- /*!
- @brief access specified object element with default value
-
- Returns either a copy of an object's element at the specified key @a key
- or a given default value if no element with key @a key exists.
-
- The function is basically equivalent to executing
- @code {.cpp}
- try {
- return at(key);
- } catch(out_of_range) {
- return default_value;
- }
- @endcode
-
- @note Unlike @ref at(const typename object_t::key_type&), this function
- does not throw if the given key @a key was not found.
-
- @note Unlike @ref operator[](const typename object_t::key_type& key), this
- function does not implicitly add an element to the position defined by @a
- key. This function is furthermore also applicable to const objects.
-
- @param[in] key key of the element to access
- @param[in] default_value the value to return if @a key is not found
-
- @tparam ValueType type compatible to JSON values, for instance `int` for
- JSON integer numbers, `bool` for JSON booleans, or `std::vector` types for
- JSON arrays. Note the type of the expected value at @a key and the default
- value @a default_value must be compatible.
-
- @return copy of the element at key @a key or @a default_value if @a key
- is not found
-
- @throw type_error.306 if the JSON value is not an object; in that case,
- using `value()` with a key makes no sense.
-
- @complexity Logarithmic in the size of the container.
-
- @liveexample{The example below shows how object elements can be queried
- with a default value.,basic_json__value}
-
- @sa @ref at(const typename object_t::key_type&) for access by reference
- with range checking
- @sa @ref operator[](const typename object_t::key_type&) for unchecked
- access by reference
-
- @since version 1.0.0
- */
- template<class ValueType, typename std::enable_if<
- std::is_convertible<basic_json_t, ValueType>::value, int>::type = 0>
- ValueType value(const typename object_t::key_type& key, const ValueType& default_value) const
- {
- // at only works for objects
- if (JSON_LIKELY(is_object()))
- {
- // if key is found, return value and given default value otherwise
- const auto it = find(key);
- if (it != end())
- {
- return *it;
- }
-
- return default_value;
- }
-
- JSON_THROW(type_error::create(306, "cannot use value() with " + std::string(type_name())));
- }
-
- /*!
- @brief overload for a default value of type const char*
- @copydoc basic_json::value(const typename object_t::key_type&, const ValueType&) const
- */
- string_t value(const typename object_t::key_type& key, const char* default_value) const
- {
- return value(key, string_t(default_value));
- }
-
- /*!
- @brief access specified object element via JSON Pointer with default value
-
- Returns either a copy of an object's element at the specified key @a key
- or a given default value if no element with key @a key exists.
-
- The function is basically equivalent to executing
- @code {.cpp}
- try {
- return at(ptr);
- } catch(out_of_range) {
- return default_value;
- }
- @endcode
-
- @note Unlike @ref at(const json_pointer&), this function does not throw
- if the given key @a key was not found.
-
- @param[in] ptr a JSON pointer to the element to access
- @param[in] default_value the value to return if @a ptr found no value
-
- @tparam ValueType type compatible to JSON values, for instance `int` for
- JSON integer numbers, `bool` for JSON booleans, or `std::vector` types for
- JSON arrays. Note the type of the expected value at @a key and the default
- value @a default_value must be compatible.
-
- @return copy of the element at key @a key or @a default_value if @a key
- is not found
-
- @throw type_error.306 if the JSON value is not an object; in that case,
- using `value()` with a key makes no sense.
-
- @complexity Logarithmic in the size of the container.
-
- @liveexample{The example below shows how object elements can be queried
- with a default value.,basic_json__value_ptr}
-
- @sa @ref operator[](const json_pointer&) for unchecked access by reference
-
- @since version 2.0.2
- */
- template<class ValueType, typename std::enable_if<
- std::is_convertible<basic_json_t, ValueType>::value, int>::type = 0>
- ValueType value(const json_pointer& ptr, const ValueType& default_value) const
- {
- // at only works for objects
- if (JSON_LIKELY(is_object()))
- {
- // if pointer resolves a value, return it or use default value
- JSON_TRY
- {
- return ptr.get_checked(this);
- }
- JSON_INTERNAL_CATCH (out_of_range&)
- {
- return default_value;
- }
- }
-
- JSON_THROW(type_error::create(306, "cannot use value() with " + std::string(type_name())));
- }
-
- /*!
- @brief overload for a default value of type const char*
- @copydoc basic_json::value(const json_pointer&, ValueType) const
- */
- string_t value(const json_pointer& ptr, const char* default_value) const
- {
- return value(ptr, string_t(default_value));
- }
-
- /*!
- @brief access the first element
-
- Returns a reference to the first element in the container. For a JSON
- container `c`, the expression `c.front()` is equivalent to `*c.begin()`.
-
- @return In case of a structured type (array or object), a reference to the
- first element is returned. In case of number, string, or boolean values, a
- reference to the value is returned.
-
- @complexity Constant.
-
- @pre The JSON value must not be `null` (would throw `std::out_of_range`)
- or an empty array or object (undefined behavior, **guarded by
- assertions**).
- @post The JSON value remains unchanged.
-
- @throw invalid_iterator.214 when called on `null` value
-
- @liveexample{The following code shows an example for `front()`.,front}
-
- @sa @ref back() -- access the last element
-
- @since version 1.0.0
- */
- reference front()
- {
- return *begin();
- }
-
- /*!
- @copydoc basic_json::front()
- */
- const_reference front() const
- {
- return *cbegin();
- }
-
- /*!
- @brief access the last element
-
- Returns a reference to the last element in the container. For a JSON
- container `c`, the expression `c.back()` is equivalent to
- @code {.cpp}
- auto tmp = c.end();
- --tmp;
- return *tmp;
- @endcode
-
- @return In case of a structured type (array or object), a reference to the
- last element is returned. In case of number, string, or boolean values, a
- reference to the value is returned.
-
- @complexity Constant.
-
- @pre The JSON value must not be `null` (would throw `std::out_of_range`)
- or an empty array or object (undefined behavior, **guarded by
- assertions**).
- @post The JSON value remains unchanged.
-
- @throw invalid_iterator.214 when called on a `null` value. See example
- below.
-
- @liveexample{The following code shows an example for `back()`.,back}
-
- @sa @ref front() -- access the first element
-
- @since version 1.0.0
- */
- reference back()
- {
- auto tmp = end();
- --tmp;
- return *tmp;
- }
-
- /*!
- @copydoc basic_json::back()
- */
- const_reference back() const
- {
- auto tmp = cend();
- --tmp;
- return *tmp;
- }
-
- /*!
- @brief remove element given an iterator
-
- Removes the element specified by iterator @a pos. The iterator @a pos must
- be valid and dereferenceable. Thus the `end()` iterator (which is valid,
- but is not dereferenceable) cannot be used as a value for @a pos.
-
- If called on a primitive type other than `null`, the resulting JSON value
- will be `null`.
-
- @param[in] pos iterator to the element to remove
- @return Iterator following the last removed element. If the iterator @a
- pos refers to the last element, the `end()` iterator is returned.
-
- @tparam IteratorType an @ref iterator or @ref const_iterator
-
- @post Invalidates iterators and references at or after the point of the
- erase, including the `end()` iterator.
-
- @throw type_error.307 if called on a `null` value; example: `"cannot use
- erase() with null"`
- @throw invalid_iterator.202 if called on an iterator which does not belong
- to the current JSON value; example: `"iterator does not fit current
- value"`
- @throw invalid_iterator.205 if called on a primitive type with invalid
- iterator (i.e., any iterator which is not `begin()`); example: `"iterator
- out of range"`
-
- @complexity The complexity depends on the type:
- - objects: amortized constant
- - arrays: linear in distance between @a pos and the end of the container
- - strings: linear in the length of the string
- - other types: constant
-
- @liveexample{The example shows the result of `erase()` for different JSON
- types.,erase__IteratorType}
-
- @sa @ref erase(IteratorType, IteratorType) -- removes the elements in
- the given range
- @sa @ref erase(const typename object_t::key_type&) -- removes the element
- from an object at the given key
- @sa @ref erase(const size_type) -- removes the element from an array at
- the given index
-
- @since version 1.0.0
- */
- template<class IteratorType, typename std::enable_if<
- std::is_same<IteratorType, typename basic_json_t::iterator>::value or
- std::is_same<IteratorType, typename basic_json_t::const_iterator>::value, int>::type
- = 0>
- IteratorType erase(IteratorType pos)
- {
- // make sure iterator fits the current value
- if (JSON_UNLIKELY(this != pos.m_object))
- {
- JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value"));
- }
-
- IteratorType result = end();
-
- switch (m_type)
- {
- case value_t::boolean:
- case value_t::number_float:
- case value_t::number_integer:
- case value_t::number_unsigned:
- case value_t::string:
- {
- if (JSON_UNLIKELY(not pos.m_it.primitive_iterator.is_begin()))
- {
- JSON_THROW(invalid_iterator::create(205, "iterator out of range"));
- }
-
- if (is_string())
- {
- AllocatorType<string_t> alloc;
- std::allocator_traits<decltype(alloc)>::destroy(alloc, m_value.string);
- std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.string, 1);
- m_value.string = nullptr;
- }
-
- m_type = value_t::null;
- assert_invariant();
- break;
- }
-
- case value_t::object:
- {
- result.m_it.object_iterator = m_value.object->erase(pos.m_it.object_iterator);
- break;
- }
-
- case value_t::array:
- {
- result.m_it.array_iterator = m_value.array->erase(pos.m_it.array_iterator);
- break;
- }
-
- default:
- JSON_THROW(type_error::create(307, "cannot use erase() with " + std::string(type_name())));
- }
-
- return result;
- }
-
- /*!
- @brief remove elements given an iterator range
-
- Removes the element specified by the range `[first; last)`. The iterator
- @a first does not need to be dereferenceable if `first == last`: erasing
- an empty range is a no-op.
-
- If called on a primitive type other than `null`, the resulting JSON value
- will be `null`.
-
- @param[in] first iterator to the beginning of the range to remove
- @param[in] last iterator past the end of the range to remove
- @return Iterator following the last removed element. If the iterator @a
- second refers to the last element, the `end()` iterator is returned.
-
- @tparam IteratorType an @ref iterator or @ref const_iterator
-
- @post Invalidates iterators and references at or after the point of the
- erase, including the `end()` iterator.
-
- @throw type_error.307 if called on a `null` value; example: `"cannot use
- erase() with null"`
- @throw invalid_iterator.203 if called on iterators which does not belong
- to the current JSON value; example: `"iterators do not fit current value"`
- @throw invalid_iterator.204 if called on a primitive type with invalid
- iterators (i.e., if `first != begin()` and `last != end()`); example:
- `"iterators out of range"`
-
- @complexity The complexity depends on the type:
- - objects: `log(size()) + std::distance(first, last)`
- - arrays: linear in the distance between @a first and @a last, plus linear
- in the distance between @a last and end of the container
- - strings: linear in the length of the string
- - other types: constant
-
- @liveexample{The example shows the result of `erase()` for different JSON
- types.,erase__IteratorType_IteratorType}
-
- @sa @ref erase(IteratorType) -- removes the element at a given position
- @sa @ref erase(const typename object_t::key_type&) -- removes the element
- from an object at the given key
- @sa @ref erase(const size_type) -- removes the element from an array at
- the given index
-
- @since version 1.0.0
- */
- template<class IteratorType, typename std::enable_if<
- std::is_same<IteratorType, typename basic_json_t::iterator>::value or
- std::is_same<IteratorType, typename basic_json_t::const_iterator>::value, int>::type
- = 0>
- IteratorType erase(IteratorType first, IteratorType last)
- {
- // make sure iterator fits the current value
- if (JSON_UNLIKELY(this != first.m_object or this != last.m_object))
- {
- JSON_THROW(invalid_iterator::create(203, "iterators do not fit current value"));
- }
-
- IteratorType result = end();
-
- switch (m_type)
- {
- case value_t::boolean:
- case value_t::number_float:
- case value_t::number_integer:
- case value_t::number_unsigned:
- case value_t::string:
- {
- if (JSON_LIKELY(not first.m_it.primitive_iterator.is_begin()
- or not last.m_it.primitive_iterator.is_end()))
- {
- JSON_THROW(invalid_iterator::create(204, "iterators out of range"));
- }
-
- if (is_string())
- {
- AllocatorType<string_t> alloc;
- std::allocator_traits<decltype(alloc)>::destroy(alloc, m_value.string);
- std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.string, 1);
- m_value.string = nullptr;
- }
-
- m_type = value_t::null;
- assert_invariant();
- break;
- }
-
- case value_t::object:
- {
- result.m_it.object_iterator = m_value.object->erase(first.m_it.object_iterator,
- last.m_it.object_iterator);
- break;
- }
-
- case value_t::array:
- {
- result.m_it.array_iterator = m_value.array->erase(first.m_it.array_iterator,
- last.m_it.array_iterator);
- break;
- }
-
- default:
- JSON_THROW(type_error::create(307, "cannot use erase() with " + std::string(type_name())));
- }
-
- return result;
- }
-
- /*!
- @brief remove element from a JSON object given a key
-
- Removes elements from a JSON object with the key value @a key.
-
- @param[in] key value of the elements to remove
-
- @return Number of elements removed. If @a ObjectType is the default
- `std::map` type, the return value will always be `0` (@a key was not
- found) or `1` (@a key was found).
-
- @post References and iterators to the erased elements are invalidated.
- Other references and iterators are not affected.
-
- @throw type_error.307 when called on a type other than JSON object;
- example: `"cannot use erase() with null"`
-
- @complexity `log(size()) + count(key)`
-
- @liveexample{The example shows the effect of `erase()`.,erase__key_type}
-
- @sa @ref erase(IteratorType) -- removes the element at a given position
- @sa @ref erase(IteratorType, IteratorType) -- removes the elements in
- the given range
- @sa @ref erase(const size_type) -- removes the element from an array at
- the given index
-
- @since version 1.0.0
- */
- size_type erase(const typename object_t::key_type& key)
- {
- // this erase only works for objects
- if (JSON_LIKELY(is_object()))
- {
- return m_value.object->erase(key);
- }
-
- JSON_THROW(type_error::create(307, "cannot use erase() with " + std::string(type_name())));
- }
-
- /*!
- @brief remove element from a JSON array given an index
-
- Removes element from a JSON array at the index @a idx.
-
- @param[in] idx index of the element to remove
-
- @throw type_error.307 when called on a type other than JSON object;
- example: `"cannot use erase() with null"`
- @throw out_of_range.401 when `idx >= size()`; example: `"array index 17
- is out of range"`
-
- @complexity Linear in distance between @a idx and the end of the container.
-
- @liveexample{The example shows the effect of `erase()`.,erase__size_type}
-
- @sa @ref erase(IteratorType) -- removes the element at a given position
- @sa @ref erase(IteratorType, IteratorType) -- removes the elements in
- the given range
- @sa @ref erase(const typename object_t::key_type&) -- removes the element
- from an object at the given key
-
- @since version 1.0.0
- */
- void erase(const size_type idx)
- {
- // this erase only works for arrays
- if (JSON_LIKELY(is_array()))
- {
- if (JSON_UNLIKELY(idx >= size()))
- {
- JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range"));
- }
-
- m_value.array->erase(m_value.array->begin() + static_cast<difference_type>(idx));
- }
- else
- {
- JSON_THROW(type_error::create(307, "cannot use erase() with " + std::string(type_name())));
- }
- }
-
- /// @}
-
-
- ////////////
- // lookup //
- ////////////
-
- /// @name lookup
- /// @{
-
- /*!
- @brief find an element in a JSON object
-
- Finds an element in a JSON object with key equivalent to @a key. If the
- element is not found or the JSON value is not an object, end() is
- returned.
-
- @note This method always returns @ref end() when executed on a JSON type
- that is not an object.
-
- @param[in] key key value of the element to search for.
-
- @return Iterator to an element with key equivalent to @a key. If no such
- element is found or the JSON value is not an object, past-the-end (see
- @ref end()) iterator is returned.
-
- @complexity Logarithmic in the size of the JSON object.
-
- @liveexample{The example shows how `find()` is used.,find__key_type}
-
- @sa @ref contains(KeyT&&) const -- checks whether a key exists
-
- @since version 1.0.0
- */
- template<typename KeyT>
- iterator find(KeyT&& key)
- {
- auto result = end();
-
- if (is_object())
- {
- result.m_it.object_iterator = m_value.object->find(std::forward<KeyT>(key));
- }
-
- return result;
- }
-
- /*!
- @brief find an element in a JSON object
- @copydoc find(KeyT&&)
- */
- template<typename KeyT>
- const_iterator find(KeyT&& key) const
- {
- auto result = cend();
-
- if (is_object())
- {
- result.m_it.object_iterator = m_value.object->find(std::forward<KeyT>(key));
- }
-
- return result;
- }
-
- /*!
- @brief returns the number of occurrences of a key in a JSON object
-
- Returns the number of elements with key @a key. If ObjectType is the
- default `std::map` type, the return value will always be `0` (@a key was
- not found) or `1` (@a key was found).
-
- @note This method always returns `0` when executed on a JSON type that is
- not an object.
-
- @param[in] key key value of the element to count
-
- @return Number of elements with key @a key. If the JSON value is not an
- object, the return value will be `0`.
-
- @complexity Logarithmic in the size of the JSON object.
-
- @liveexample{The example shows how `count()` is used.,count}
-
- @since version 1.0.0
- */
- template<typename KeyT>
- size_type count(KeyT&& key) const
- {
- // return 0 for all nonobject types
- return is_object() ? m_value.object->count(std::forward<KeyT>(key)) : 0;
- }
-
- /*!
- @brief check the existence of an element in a JSON object
-
- Check whether an element exists in a JSON object with key equivalent to
- @a key. If the element is not found or the JSON value is not an object,
- false is returned.
-
- @note This method always returns false when executed on a JSON type
- that is not an object.
-
- @param[in] key key value to check its existence.
-
- @return true if an element with specified @a key exists. If no such
- element with such key is found or the JSON value is not an object,
- false is returned.
-
- @complexity Logarithmic in the size of the JSON object.
-
- @liveexample{The following code shows an example for `contains()`.,contains}
-
- @sa @ref find(KeyT&&) -- returns an iterator to an object element
-
- @since version 3.6.0
- */
- template<typename KeyT>
- bool contains(KeyT&& key) const
- {
- return is_object() and m_value.object->find(std::forward<KeyT>(key)) != m_value.object->end();
- }
-
- /// @}
-
-
- ///////////////
- // iterators //
- ///////////////
-
- /// @name iterators
- /// @{
-
- /*!
- @brief returns an iterator to the first element
-
- Returns an iterator to the first element.
-
- @image html range-begin-end.svg "Illustration from cppreference.com"
-
- @return iterator to the first element
-
- @complexity Constant.
-
- @requirement This function helps `basic_json` satisfying the
- [Container](https://en.cppreference.com/w/cpp/named_req/Container)
- requirements:
- - The complexity is constant.
-
- @liveexample{The following code shows an example for `begin()`.,begin}
-
- @sa @ref cbegin() -- returns a const iterator to the beginning
- @sa @ref end() -- returns an iterator to the end
- @sa @ref cend() -- returns a const iterator to the end
-
- @since version 1.0.0
- */
- iterator begin() noexcept
- {
- iterator result(this);
- result.set_begin();
- return result;
- }
-
- /*!
- @copydoc basic_json::cbegin()
- */
- const_iterator begin() const noexcept
- {
- return cbegin();
- }
-
- /*!
- @brief returns a const iterator to the first element
-
- Returns a const iterator to the first element.
-
- @image html range-begin-end.svg "Illustration from cppreference.com"
-
- @return const iterator to the first element
-
- @complexity Constant.
-
- @requirement This function helps `basic_json` satisfying the
- [Container](https://en.cppreference.com/w/cpp/named_req/Container)
- requirements:
- - The complexity is constant.
- - Has the semantics of `const_cast<const basic_json&>(*this).begin()`.
-
- @liveexample{The following code shows an example for `cbegin()`.,cbegin}
-
- @sa @ref begin() -- returns an iterator to the beginning
- @sa @ref end() -- returns an iterator to the end
- @sa @ref cend() -- returns a const iterator to the end
-
- @since version 1.0.0
- */
- const_iterator cbegin() const noexcept
- {
- const_iterator result(this);
- result.set_begin();
- return result;
- }
-
- /*!
- @brief returns an iterator to one past the last element
-
- Returns an iterator to one past the last element.
-
- @image html range-begin-end.svg "Illustration from cppreference.com"
-
- @return iterator one past the last element
-
- @complexity Constant.
-
- @requirement This function helps `basic_json` satisfying the
- [Container](https://en.cppreference.com/w/cpp/named_req/Container)
- requirements:
- - The complexity is constant.
-
- @liveexample{The following code shows an example for `end()`.,end}
-
- @sa @ref cend() -- returns a const iterator to the end
- @sa @ref begin() -- returns an iterator to the beginning
- @sa @ref cbegin() -- returns a const iterator to the beginning
-
- @since version 1.0.0
- */
- iterator end() noexcept
- {
- iterator result(this);
- result.set_end();
- return result;
- }
-
- /*!
- @copydoc basic_json::cend()
- */
- const_iterator end() const noexcept
- {
- return cend();
- }
-
- /*!
- @brief returns a const iterator to one past the last element
-
- Returns a const iterator to one past the last element.
-
- @image html range-begin-end.svg "Illustration from cppreference.com"
-
- @return const iterator one past the last element
-
- @complexity Constant.
-
- @requirement This function helps `basic_json` satisfying the
- [Container](https://en.cppreference.com/w/cpp/named_req/Container)
- requirements:
- - The complexity is constant.
- - Has the semantics of `const_cast<const basic_json&>(*this).end()`.
-
- @liveexample{The following code shows an example for `cend()`.,cend}
-
- @sa @ref end() -- returns an iterator to the end
- @sa @ref begin() -- returns an iterator to the beginning
- @sa @ref cbegin() -- returns a const iterator to the beginning
-
- @since version 1.0.0
- */
- const_iterator cend() const noexcept
- {
- const_iterator result(this);
- result.set_end();
- return result;
- }
-
- /*!
- @brief returns an iterator to the reverse-beginning
-
- Returns an iterator to the reverse-beginning; that is, the last element.
-
- @image html range-rbegin-rend.svg "Illustration from cppreference.com"
-
- @complexity Constant.
-
- @requirement This function helps `basic_json` satisfying the
- [ReversibleContainer](https://en.cppreference.com/w/cpp/named_req/ReversibleContainer)
- requirements:
- - The complexity is constant.
- - Has the semantics of `reverse_iterator(end())`.
-
- @liveexample{The following code shows an example for `rbegin()`.,rbegin}
-
- @sa @ref crbegin() -- returns a const reverse iterator to the beginning
- @sa @ref rend() -- returns a reverse iterator to the end
- @sa @ref crend() -- returns a const reverse iterator to the end
-
- @since version 1.0.0
- */
- reverse_iterator rbegin() noexcept
- {
- return reverse_iterator(end());
- }
-
- /*!
- @copydoc basic_json::crbegin()
- */
- const_reverse_iterator rbegin() const noexcept
- {
- return crbegin();
- }
-
- /*!
- @brief returns an iterator to the reverse-end
-
- Returns an iterator to the reverse-end; that is, one before the first
- element.
-
- @image html range-rbegin-rend.svg "Illustration from cppreference.com"
-
- @complexity Constant.
-
- @requirement This function helps `basic_json` satisfying the
- [ReversibleContainer](https://en.cppreference.com/w/cpp/named_req/ReversibleContainer)
- requirements:
- - The complexity is constant.
- - Has the semantics of `reverse_iterator(begin())`.
-
- @liveexample{The following code shows an example for `rend()`.,rend}
-
- @sa @ref crend() -- returns a const reverse iterator to the end
- @sa @ref rbegin() -- returns a reverse iterator to the beginning
- @sa @ref crbegin() -- returns a const reverse iterator to the beginning
-
- @since version 1.0.0
- */
- reverse_iterator rend() noexcept
- {
- return reverse_iterator(begin());
- }
-
- /*!
- @copydoc basic_json::crend()
- */
- const_reverse_iterator rend() const noexcept
- {
- return crend();
- }
-
- /*!
- @brief returns a const reverse iterator to the last element
-
- Returns a const iterator to the reverse-beginning; that is, the last
- element.
-
- @image html range-rbegin-rend.svg "Illustration from cppreference.com"
-
- @complexity Constant.
-
- @requirement This function helps `basic_json` satisfying the
- [ReversibleContainer](https://en.cppreference.com/w/cpp/named_req/ReversibleContainer)
- requirements:
- - The complexity is constant.
- - Has the semantics of `const_cast<const basic_json&>(*this).rbegin()`.
-
- @liveexample{The following code shows an example for `crbegin()`.,crbegin}
-
- @sa @ref rbegin() -- returns a reverse iterator to the beginning
- @sa @ref rend() -- returns a reverse iterator to the end
- @sa @ref crend() -- returns a const reverse iterator to the end
-
- @since version 1.0.0
- */
- const_reverse_iterator crbegin() const noexcept
- {
- return const_reverse_iterator(cend());
- }
-
- /*!
- @brief returns a const reverse iterator to one before the first
-
- Returns a const reverse iterator to the reverse-end; that is, one before
- the first element.
-
- @image html range-rbegin-rend.svg "Illustration from cppreference.com"
-
- @complexity Constant.
-
- @requirement This function helps `basic_json` satisfying the
- [ReversibleContainer](https://en.cppreference.com/w/cpp/named_req/ReversibleContainer)
- requirements:
- - The complexity is constant.
- - Has the semantics of `const_cast<const basic_json&>(*this).rend()`.
-
- @liveexample{The following code shows an example for `crend()`.,crend}
-
- @sa @ref rend() -- returns a reverse iterator to the end
- @sa @ref rbegin() -- returns a reverse iterator to the beginning
- @sa @ref crbegin() -- returns a const reverse iterator to the beginning
-
- @since version 1.0.0
- */
- const_reverse_iterator crend() const noexcept
- {
- return const_reverse_iterator(cbegin());
- }
-
- public:
- /*!
- @brief wrapper to access iterator member functions in range-based for
-
- This function allows to access @ref iterator::key() and @ref
- iterator::value() during range-based for loops. In these loops, a
- reference to the JSON values is returned, so there is no access to the
- underlying iterator.
-
- For loop without iterator_wrapper:
-
- @code{cpp}
- for (auto it = j_object.begin(); it != j_object.end(); ++it)
- {
- std::cout << "key: " << it.key() << ", value:" << it.value() << '\n';
- }
- @endcode
-
- Range-based for loop without iterator proxy:
-
- @code{cpp}
- for (auto it : j_object)
- {
- // "it" is of type json::reference and has no key() member
- std::cout << "value: " << it << '\n';
- }
- @endcode
-
- Range-based for loop with iterator proxy:
-
- @code{cpp}
- for (auto it : json::iterator_wrapper(j_object))
- {
- std::cout << "key: " << it.key() << ", value:" << it.value() << '\n';
- }
- @endcode
-
- @note When iterating over an array, `key()` will return the index of the
- element as string (see example).
-
- @param[in] ref reference to a JSON value
- @return iteration proxy object wrapping @a ref with an interface to use in
- range-based for loops
-
- @liveexample{The following code shows how the wrapper is used,iterator_wrapper}
-
- @exceptionsafety Strong guarantee: if an exception is thrown, there are no
- changes in the JSON value.
-
- @complexity Constant.
-
- @note The name of this function is not yet final and may change in the
- future.
-
- @deprecated This stream operator is deprecated and will be removed in
- future 4.0.0 of the library. Please use @ref items() instead;
- that is, replace `json::iterator_wrapper(j)` with `j.items()`.
- */
- JSON_DEPRECATED
- static iteration_proxy<iterator> iterator_wrapper(reference ref) noexcept
- {
- return ref.items();
- }
-
- /*!
- @copydoc iterator_wrapper(reference)
- */
- JSON_DEPRECATED
- static iteration_proxy<const_iterator> iterator_wrapper(const_reference ref) noexcept
- {
- return ref.items();
- }
-
- /*!
- @brief helper to access iterator member functions in range-based for
-
- This function allows to access @ref iterator::key() and @ref
- iterator::value() during range-based for loops. In these loops, a
- reference to the JSON values is returned, so there is no access to the
- underlying iterator.
-
- For loop without `items()` function:
-
- @code{cpp}
- for (auto it = j_object.begin(); it != j_object.end(); ++it)
- {
- std::cout << "key: " << it.key() << ", value:" << it.value() << '\n';
- }
- @endcode
-
- Range-based for loop without `items()` function:
-
- @code{cpp}
- for (auto it : j_object)
- {
- // "it" is of type json::reference and has no key() member
- std::cout << "value: " << it << '\n';
- }
- @endcode
-
- Range-based for loop with `items()` function:
-
- @code{cpp}
- for (auto& el : j_object.items())
- {
- std::cout << "key: " << el.key() << ", value:" << el.value() << '\n';
- }
- @endcode
-
- The `items()` function also allows to use
- [structured bindings](https://en.cppreference.com/w/cpp/language/structured_binding)
- (C++17):
-
- @code{cpp}
- for (auto& [key, val] : j_object.items())
- {
- std::cout << "key: " << key << ", value:" << val << '\n';
- }
- @endcode
-
- @note When iterating over an array, `key()` will return the index of the
- element as string (see example). For primitive types (e.g., numbers),
- `key()` returns an empty string.
-
- @return iteration proxy object wrapping @a ref with an interface to use in
- range-based for loops
-
- @liveexample{The following code shows how the function is used.,items}
-
- @exceptionsafety Strong guarantee: if an exception is thrown, there are no
- changes in the JSON value.
-
- @complexity Constant.
-
- @since version 3.1.0, structured bindings support since 3.5.0.
- */
- iteration_proxy<iterator> items() noexcept
- {
- return iteration_proxy<iterator>(*this);
- }
-
- /*!
- @copydoc items()
- */
- iteration_proxy<const_iterator> items() const noexcept
- {
- return iteration_proxy<const_iterator>(*this);
- }
-
- /// @}
-
-
- //////////////
- // capacity //
- //////////////
-
- /// @name capacity
- /// @{
-
- /*!
- @brief checks whether the container is empty.
-
- Checks if a JSON value has no elements (i.e. whether its @ref size is `0`).
-
- @return The return value depends on the different types and is
- defined as follows:
- Value type | return value
- ----------- | -------------
- null | `true`
- boolean | `false`
- string | `false`
- number | `false`
- object | result of function `object_t::empty()`
- array | result of function `array_t::empty()`
-
- @liveexample{The following code uses `empty()` to check if a JSON
- object contains any elements.,empty}
-
- @complexity Constant, as long as @ref array_t and @ref object_t satisfy
- the Container concept; that is, their `empty()` functions have constant
- complexity.
-
- @iterators No changes.
-
- @exceptionsafety No-throw guarantee: this function never throws exceptions.
-
- @note This function does not return whether a string stored as JSON value
- is empty - it returns whether the JSON container itself is empty which is
- false in the case of a string.
-
- @requirement This function helps `basic_json` satisfying the
- [Container](https://en.cppreference.com/w/cpp/named_req/Container)
- requirements:
- - The complexity is constant.
- - Has the semantics of `begin() == end()`.
-
- @sa @ref size() -- returns the number of elements
-
- @since version 1.0.0
- */
- bool empty() const noexcept
- {
- switch (m_type)
- {
- case value_t::null:
- {
- // null values are empty
- return true;
- }
-
- case value_t::array:
- {
- // delegate call to array_t::empty()
- return m_value.array->empty();
- }
-
- case value_t::object:
- {
- // delegate call to object_t::empty()
- return m_value.object->empty();
- }
-
- default:
- {
- // all other types are nonempty
- return false;
- }
- }
- }
-
- /*!
- @brief returns the number of elements
-
- Returns the number of elements in a JSON value.
-
- @return The return value depends on the different types and is
- defined as follows:
- Value type | return value
- ----------- | -------------
- null | `0`
- boolean | `1`
- string | `1`
- number | `1`
- object | result of function object_t::size()
- array | result of function array_t::size()
-
- @liveexample{The following code calls `size()` on the different value
- types.,size}
-
- @complexity Constant, as long as @ref array_t and @ref object_t satisfy
- the Container concept; that is, their size() functions have constant
- complexity.
-
- @iterators No changes.
-
- @exceptionsafety No-throw guarantee: this function never throws exceptions.
-
- @note This function does not return the length of a string stored as JSON
- value - it returns the number of elements in the JSON value which is 1 in
- the case of a string.
-
- @requirement This function helps `basic_json` satisfying the
- [Container](https://en.cppreference.com/w/cpp/named_req/Container)
- requirements:
- - The complexity is constant.
- - Has the semantics of `std::distance(begin(), end())`.
-
- @sa @ref empty() -- checks whether the container is empty
- @sa @ref max_size() -- returns the maximal number of elements
-
- @since version 1.0.0
- */
- size_type size() const noexcept
- {
- switch (m_type)
- {
- case value_t::null:
- {
- // null values are empty
- return 0;
- }
-
- case value_t::array:
- {
- // delegate call to array_t::size()
- return m_value.array->size();
- }
-
- case value_t::object:
- {
- // delegate call to object_t::size()
- return m_value.object->size();
- }
-
- default:
- {
- // all other types have size 1
- return 1;
- }
- }
- }
-
- /*!
- @brief returns the maximum possible number of elements
-
- Returns the maximum number of elements a JSON value is able to hold due to
- system or library implementation limitations, i.e. `std::distance(begin(),
- end())` for the JSON value.
-
- @return The return value depends on the different types and is
- defined as follows:
- Value type | return value
- ----------- | -------------
- null | `0` (same as `size()`)
- boolean | `1` (same as `size()`)
- string | `1` (same as `size()`)
- number | `1` (same as `size()`)
- object | result of function `object_t::max_size()`
- array | result of function `array_t::max_size()`
-
- @liveexample{The following code calls `max_size()` on the different value
- types. Note the output is implementation specific.,max_size}
-
- @complexity Constant, as long as @ref array_t and @ref object_t satisfy
- the Container concept; that is, their `max_size()` functions have constant
- complexity.
-
- @iterators No changes.
-
- @exceptionsafety No-throw guarantee: this function never throws exceptions.
-
- @requirement This function helps `basic_json` satisfying the
- [Container](https://en.cppreference.com/w/cpp/named_req/Container)
- requirements:
- - The complexity is constant.
- - Has the semantics of returning `b.size()` where `b` is the largest
- possible JSON value.
-
- @sa @ref size() -- returns the number of elements
-
- @since version 1.0.0
- */
- size_type max_size() const noexcept
- {
- switch (m_type)
- {
- case value_t::array:
- {
- // delegate call to array_t::max_size()
- return m_value.array->max_size();
- }
-
- case value_t::object:
- {
- // delegate call to object_t::max_size()
- return m_value.object->max_size();
- }
-
- default:
- {
- // all other types have max_size() == size()
- return size();
- }
- }
- }
-
- /// @}
-
-
- ///////////////
- // modifiers //
- ///////////////
-
- /// @name modifiers
- /// @{
-
- /*!
- @brief clears the contents
-
- Clears the content of a JSON value and resets it to the default value as
- if @ref basic_json(value_t) would have been called with the current value
- type from @ref type():
-
- Value type | initial value
- ----------- | -------------
- null | `null`
- boolean | `false`
- string | `""`
- number | `0`
- object | `{}`
- array | `[]`
-
- @post Has the same effect as calling
- @code {.cpp}
- *this = basic_json(type());
- @endcode
-
- @liveexample{The example below shows the effect of `clear()` to different
- JSON types.,clear}
-
- @complexity Linear in the size of the JSON value.
-
- @iterators All iterators, pointers and references related to this container
- are invalidated.
-
- @exceptionsafety No-throw guarantee: this function never throws exceptions.
-
- @sa @ref basic_json(value_t) -- constructor that creates an object with the
- same value than calling `clear()`
-
- @since version 1.0.0
- */
- void clear() noexcept
- {
- switch (m_type)
- {
- case value_t::number_integer:
- {
- m_value.number_integer = 0;
- break;
- }
-
- case value_t::number_unsigned:
- {
- m_value.number_unsigned = 0;
- break;
- }
-
- case value_t::number_float:
- {
- m_value.number_float = 0.0;
- break;
- }
-
- case value_t::boolean:
- {
- m_value.boolean = false;
- break;
- }
-
- case value_t::string:
- {
- m_value.string->clear();
- break;
- }
-
- case value_t::array:
- {
- m_value.array->clear();
- break;
- }
-
- case value_t::object:
- {
- m_value.object->clear();
- break;
- }
-
- default:
- break;
- }
- }
-
- /*!
- @brief add an object to an array
-
- Appends the given element @a val to the end of the JSON value. If the
- function is called on a JSON null value, an empty array is created before
- appending @a val.
-
- @param[in] val the value to add to the JSON array
-
- @throw type_error.308 when called on a type other than JSON array or
- null; example: `"cannot use push_back() with number"`
-
- @complexity Amortized constant.
-
- @liveexample{The example shows how `push_back()` and `+=` can be used to
- add elements to a JSON array. Note how the `null` value was silently
- converted to a JSON array.,push_back}
-
- @since version 1.0.0
- */
- void push_back(basic_json&& val)
- {
- // push_back only works for null objects or arrays
- if (JSON_UNLIKELY(not(is_null() or is_array())))
- {
- JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name())));
- }
-
- // transform null object into an array
- if (is_null())
- {
- m_type = value_t::array;
- m_value = value_t::array;
- assert_invariant();
- }
-
- // add element to array (move semantics)
- m_value.array->push_back(std::move(val));
- // invalidate object: mark it null so we do not call the destructor
- // cppcheck-suppress accessMoved
- val.m_type = value_t::null;
- }
-
- /*!
- @brief add an object to an array
- @copydoc push_back(basic_json&&)
- */
- reference operator+=(basic_json&& val)
- {
- push_back(std::move(val));
- return *this;
- }
-
- /*!
- @brief add an object to an array
- @copydoc push_back(basic_json&&)
- */
- void push_back(const basic_json& val)
- {
- // push_back only works for null objects or arrays
- if (JSON_UNLIKELY(not(is_null() or is_array())))
- {
- JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name())));
- }
-
- // transform null object into an array
- if (is_null())
- {
- m_type = value_t::array;
- m_value = value_t::array;
- assert_invariant();
- }
-
- // add element to array
- m_value.array->push_back(val);
- }
-
- /*!
- @brief add an object to an array
- @copydoc push_back(basic_json&&)
- */
- reference operator+=(const basic_json& val)
- {
- push_back(val);
- return *this;
- }
-
- /*!
- @brief add an object to an object
-
- Inserts the given element @a val to the JSON object. If the function is
- called on a JSON null value, an empty object is created before inserting
- @a val.
-
- @param[in] val the value to add to the JSON object
-
- @throw type_error.308 when called on a type other than JSON object or
- null; example: `"cannot use push_back() with number"`
-
- @complexity Logarithmic in the size of the container, O(log(`size()`)).
-
- @liveexample{The example shows how `push_back()` and `+=` can be used to
- add elements to a JSON object. Note how the `null` value was silently
- converted to a JSON object.,push_back__object_t__value}
-
- @since version 1.0.0
- */
- void push_back(const typename object_t::value_type& val)
- {
- // push_back only works for null objects or objects
- if (JSON_UNLIKELY(not(is_null() or is_object())))
- {
- JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name())));
- }
-
- // transform null object into an object
- if (is_null())
- {
- m_type = value_t::object;
- m_value = value_t::object;
- assert_invariant();
- }
-
- // add element to array
- m_value.object->insert(val);
- }
-
- /*!
- @brief add an object to an object
- @copydoc push_back(const typename object_t::value_type&)
- */
- reference operator+=(const typename object_t::value_type& val)
- {
- push_back(val);
- return *this;
- }
-
- /*!
- @brief add an object to an object
-
- This function allows to use `push_back` with an initializer list. In case
-
- 1. the current value is an object,
- 2. the initializer list @a init contains only two elements, and
- 3. the first element of @a init is a string,
-
- @a init is converted into an object element and added using
- @ref push_back(const typename object_t::value_type&). Otherwise, @a init
- is converted to a JSON value and added using @ref push_back(basic_json&&).
-
- @param[in] init an initializer list
-
- @complexity Linear in the size of the initializer list @a init.
-
- @note This function is required to resolve an ambiguous overload error,
- because pairs like `{"key", "value"}` can be both interpreted as
- `object_t::value_type` or `std::initializer_list<basic_json>`, see
- https://github.com/nlohmann/json/issues/235 for more information.
-
- @liveexample{The example shows how initializer lists are treated as
- objects when possible.,push_back__initializer_list}
- */
- void push_back(initializer_list_t init)
- {
- if (is_object() and init.size() == 2 and (*init.begin())->is_string())
- {
- basic_json&& key = init.begin()->moved_or_copied();
- push_back(typename object_t::value_type(
- std::move(key.get_ref<string_t&>()), (init.begin() + 1)->moved_or_copied()));
- }
- else
- {
- push_back(basic_json(init));
- }
- }
-
- /*!
- @brief add an object to an object
- @copydoc push_back(initializer_list_t)
- */
- reference operator+=(initializer_list_t init)
- {
- push_back(init);
- return *this;
- }
-
- /*!
- @brief add an object to an array
-
- Creates a JSON value from the passed parameters @a args to the end of the
- JSON value. If the function is called on a JSON null value, an empty array
- is created before appending the value created from @a args.
-
- @param[in] args arguments to forward to a constructor of @ref basic_json
- @tparam Args compatible types to create a @ref basic_json object
-
- @throw type_error.311 when called on a type other than JSON array or
- null; example: `"cannot use emplace_back() with number"`
-
- @complexity Amortized constant.
-
- @liveexample{The example shows how `push_back()` can be used to add
- elements to a JSON array. Note how the `null` value was silently converted
- to a JSON array.,emplace_back}
-
- @since version 2.0.8
- */
- template<class... Args>
- void emplace_back(Args&& ... args)
- {
- // emplace_back only works for null objects or arrays
- if (JSON_UNLIKELY(not(is_null() or is_array())))
- {
- JSON_THROW(type_error::create(311, "cannot use emplace_back() with " + std::string(type_name())));
- }
-
- // transform null object into an array
- if (is_null())
- {
- m_type = value_t::array;
- m_value = value_t::array;
- assert_invariant();
- }
-
- // add element to array (perfect forwarding)
- m_value.array->emplace_back(std::forward<Args>(args)...);
- }
-
- /*!
- @brief add an object to an object if key does not exist
-
- Inserts a new element into a JSON object constructed in-place with the
- given @a args if there is no element with the key in the container. If the
- function is called on a JSON null value, an empty object is created before
- appending the value created from @a args.
-
- @param[in] args arguments to forward to a constructor of @ref basic_json
- @tparam Args compatible types to create a @ref basic_json object
-
- @return a pair consisting of an iterator to the inserted element, or the
- already-existing element if no insertion happened, and a bool
- denoting whether the insertion took place.
-
- @throw type_error.311 when called on a type other than JSON object or
- null; example: `"cannot use emplace() with number"`
-
- @complexity Logarithmic in the size of the container, O(log(`size()`)).
-
- @liveexample{The example shows how `emplace()` can be used to add elements
- to a JSON object. Note how the `null` value was silently converted to a
- JSON object. Further note how no value is added if there was already one
- value stored with the same key.,emplace}
-
- @since version 2.0.8
- */
- template<class... Args>
- std::pair<iterator, bool> emplace(Args&& ... args)
- {
- // emplace only works for null objects or arrays
- if (JSON_UNLIKELY(not(is_null() or is_object())))
- {
- JSON_THROW(type_error::create(311, "cannot use emplace() with " + std::string(type_name())));
- }
-
- // transform null object into an object
- if (is_null())
- {
- m_type = value_t::object;
- m_value = value_t::object;
- assert_invariant();
- }
-
- // add element to array (perfect forwarding)
- auto res = m_value.object->emplace(std::forward<Args>(args)...);
- // create result iterator and set iterator to the result of emplace
- auto it = begin();
- it.m_it.object_iterator = res.first;
-
- // return pair of iterator and boolean
- return {it, res.second};
- }
-
- /// Helper for insertion of an iterator
- /// @note: This uses std::distance to support GCC 4.8,
- /// see https://github.com/nlohmann/json/pull/1257
- template<typename... Args>
- iterator insert_iterator(const_iterator pos, Args&& ... args)
- {
- iterator result(this);
- assert(m_value.array != nullptr);
-
- auto insert_pos = std::distance(m_value.array->begin(), pos.m_it.array_iterator);
- m_value.array->insert(pos.m_it.array_iterator, std::forward<Args>(args)...);
- result.m_it.array_iterator = m_value.array->begin() + insert_pos;
-
- // This could have been written as:
- // result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, cnt, val);
- // but the return value of insert is missing in GCC 4.8, so it is written this way instead.
-
- return result;
- }
-
- /*!
- @brief inserts element
-
- Inserts element @a val before iterator @a pos.
-
- @param[in] pos iterator before which the content will be inserted; may be
- the end() iterator
- @param[in] val element to insert
- @return iterator pointing to the inserted @a val.
-
- @throw type_error.309 if called on JSON values other than arrays;
- example: `"cannot use insert() with string"`
- @throw invalid_iterator.202 if @a pos is not an iterator of *this;
- example: `"iterator does not fit current value"`
-
- @complexity Constant plus linear in the distance between @a pos and end of
- the container.
-
- @liveexample{The example shows how `insert()` is used.,insert}
-
- @since version 1.0.0
- */
- iterator insert(const_iterator pos, const basic_json& val)
- {
- // insert only works for arrays
- if (JSON_LIKELY(is_array()))
- {
- // check if iterator pos fits to this JSON value
- if (JSON_UNLIKELY(pos.m_object != this))
- {
- JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value"));
- }
-
- // insert to array and return iterator
- return insert_iterator(pos, val);
- }
-
- JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name())));
- }
-
- /*!
- @brief inserts element
- @copydoc insert(const_iterator, const basic_json&)
- */
- iterator insert(const_iterator pos, basic_json&& val)
- {
- return insert(pos, val);
- }
-
- /*!
- @brief inserts elements
-
- Inserts @a cnt copies of @a val before iterator @a pos.
-
- @param[in] pos iterator before which the content will be inserted; may be
- the end() iterator
- @param[in] cnt number of copies of @a val to insert
- @param[in] val element to insert
- @return iterator pointing to the first element inserted, or @a pos if
- `cnt==0`
-
- @throw type_error.309 if called on JSON values other than arrays; example:
- `"cannot use insert() with string"`
- @throw invalid_iterator.202 if @a pos is not an iterator of *this;
- example: `"iterator does not fit current value"`
-
- @complexity Linear in @a cnt plus linear in the distance between @a pos
- and end of the container.
-
- @liveexample{The example shows how `insert()` is used.,insert__count}
-
- @since version 1.0.0
- */
- iterator insert(const_iterator pos, size_type cnt, const basic_json& val)
- {
- // insert only works for arrays
- if (JSON_LIKELY(is_array()))
- {
- // check if iterator pos fits to this JSON value
- if (JSON_UNLIKELY(pos.m_object != this))
- {
- JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value"));
- }
-
- // insert to array and return iterator
- return insert_iterator(pos, cnt, val);
- }
-
- JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name())));
- }
-
- /*!
- @brief inserts elements
-
- Inserts elements from range `[first, last)` before iterator @a pos.
-
- @param[in] pos iterator before which the content will be inserted; may be
- the end() iterator
- @param[in] first begin of the range of elements to insert
- @param[in] last end of the range of elements to insert
-
- @throw type_error.309 if called on JSON values other than arrays; example:
- `"cannot use insert() with string"`
- @throw invalid_iterator.202 if @a pos is not an iterator of *this;
- example: `"iterator does not fit current value"`
- @throw invalid_iterator.210 if @a first and @a last do not belong to the
- same JSON value; example: `"iterators do not fit"`
- @throw invalid_iterator.211 if @a first or @a last are iterators into
- container for which insert is called; example: `"passed iterators may not
- belong to container"`
-
- @return iterator pointing to the first element inserted, or @a pos if
- `first==last`
-
- @complexity Linear in `std::distance(first, last)` plus linear in the
- distance between @a pos and end of the container.
-
- @liveexample{The example shows how `insert()` is used.,insert__range}
-
- @since version 1.0.0
- */
- iterator insert(const_iterator pos, const_iterator first, const_iterator last)
- {
- // insert only works for arrays
- if (JSON_UNLIKELY(not is_array()))
- {
- JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name())));
- }
-
- // check if iterator pos fits to this JSON value
- if (JSON_UNLIKELY(pos.m_object != this))
- {
- JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value"));
- }
-
- // check if range iterators belong to the same JSON object
- if (JSON_UNLIKELY(first.m_object != last.m_object))
- {
- JSON_THROW(invalid_iterator::create(210, "iterators do not fit"));
- }
-
- if (JSON_UNLIKELY(first.m_object == this))
- {
- JSON_THROW(invalid_iterator::create(211, "passed iterators may not belong to container"));
- }
-
- // insert to array and return iterator
- return insert_iterator(pos, first.m_it.array_iterator, last.m_it.array_iterator);
- }
-
- /*!
- @brief inserts elements
-
- Inserts elements from initializer list @a ilist before iterator @a pos.
-
- @param[in] pos iterator before which the content will be inserted; may be
- the end() iterator
- @param[in] ilist initializer list to insert the values from
-
- @throw type_error.309 if called on JSON values other than arrays; example:
- `"cannot use insert() with string"`
- @throw invalid_iterator.202 if @a pos is not an iterator of *this;
- example: `"iterator does not fit current value"`
-
- @return iterator pointing to the first element inserted, or @a pos if
- `ilist` is empty
-
- @complexity Linear in `ilist.size()` plus linear in the distance between
- @a pos and end of the container.
-
- @liveexample{The example shows how `insert()` is used.,insert__ilist}
-
- @since version 1.0.0
- */
- iterator insert(const_iterator pos, initializer_list_t ilist)
- {
- // insert only works for arrays
- if (JSON_UNLIKELY(not is_array()))
- {
- JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name())));
- }
-
- // check if iterator pos fits to this JSON value
- if (JSON_UNLIKELY(pos.m_object != this))
- {
- JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value"));
- }
-
- // insert to array and return iterator
- return insert_iterator(pos, ilist.begin(), ilist.end());
- }
-
- /*!
- @brief inserts elements
-
- Inserts elements from range `[first, last)`.
-
- @param[in] first begin of the range of elements to insert
- @param[in] last end of the range of elements to insert
-
- @throw type_error.309 if called on JSON values other than objects; example:
- `"cannot use insert() with string"`
- @throw invalid_iterator.202 if iterator @a first or @a last does does not
- point to an object; example: `"iterators first and last must point to
- objects"`
- @throw invalid_iterator.210 if @a first and @a last do not belong to the
- same JSON value; example: `"iterators do not fit"`
-
- @complexity Logarithmic: `O(N*log(size() + N))`, where `N` is the number
- of elements to insert.
-
- @liveexample{The example shows how `insert()` is used.,insert__range_object}
-
- @since version 3.0.0
- */
- void insert(const_iterator first, const_iterator last)
- {
- // insert only works for objects
- if (JSON_UNLIKELY(not is_object()))
- {
- JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name())));
- }
-
- // check if range iterators belong to the same JSON object
- if (JSON_UNLIKELY(first.m_object != last.m_object))
- {
- JSON_THROW(invalid_iterator::create(210, "iterators do not fit"));
- }
-
- // passed iterators must belong to objects
- if (JSON_UNLIKELY(not first.m_object->is_object()))
- {
- JSON_THROW(invalid_iterator::create(202, "iterators first and last must point to objects"));
- }
-
- m_value.object->insert(first.m_it.object_iterator, last.m_it.object_iterator);
- }
-
- /*!
- @brief updates a JSON object from another object, overwriting existing keys
-
- Inserts all values from JSON object @a j and overwrites existing keys.
-
- @param[in] j JSON object to read values from
-
- @throw type_error.312 if called on JSON values other than objects; example:
- `"cannot use update() with string"`
-
- @complexity O(N*log(size() + N)), where N is the number of elements to
- insert.
-
- @liveexample{The example shows how `update()` is used.,update}
-
- @sa https://docs.python.org/3.6/library/stdtypes.html#dict.update
-
- @since version 3.0.0
- */
- void update(const_reference j)
- {
- // implicitly convert null value to an empty object
- if (is_null())
- {
- m_type = value_t::object;
- m_value.object = create<object_t>();
- assert_invariant();
- }
-
- if (JSON_UNLIKELY(not is_object()))
- {
- JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(type_name())));
- }
- if (JSON_UNLIKELY(not j.is_object()))
- {
- JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(j.type_name())));
- }
-
- for (auto it = j.cbegin(); it != j.cend(); ++it)
- {
- m_value.object->operator[](it.key()) = it.value();
- }
- }
-
- /*!
- @brief updates a JSON object from another object, overwriting existing keys
-
- Inserts all values from from range `[first, last)` and overwrites existing
- keys.
-
- @param[in] first begin of the range of elements to insert
- @param[in] last end of the range of elements to insert
-
- @throw type_error.312 if called on JSON values other than objects; example:
- `"cannot use update() with string"`
- @throw invalid_iterator.202 if iterator @a first or @a last does does not
- point to an object; example: `"iterators first and last must point to
- objects"`
- @throw invalid_iterator.210 if @a first and @a last do not belong to the
- same JSON value; example: `"iterators do not fit"`
-
- @complexity O(N*log(size() + N)), where N is the number of elements to
- insert.
-
- @liveexample{The example shows how `update()` is used__range.,update}
-
- @sa https://docs.python.org/3.6/library/stdtypes.html#dict.update
-
- @since version 3.0.0
- */
- void update(const_iterator first, const_iterator last)
- {
- // implicitly convert null value to an empty object
- if (is_null())
- {
- m_type = value_t::object;
- m_value.object = create<object_t>();
- assert_invariant();
- }
-
- if (JSON_UNLIKELY(not is_object()))
- {
- JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(type_name())));
- }
-
- // check if range iterators belong to the same JSON object
- if (JSON_UNLIKELY(first.m_object != last.m_object))
- {
- JSON_THROW(invalid_iterator::create(210, "iterators do not fit"));
- }
-
- // passed iterators must belong to objects
- if (JSON_UNLIKELY(not first.m_object->is_object()
- or not last.m_object->is_object()))
- {
- JSON_THROW(invalid_iterator::create(202, "iterators first and last must point to objects"));
- }
-
- for (auto it = first; it != last; ++it)
- {
- m_value.object->operator[](it.key()) = it.value();
- }
- }
-
- /*!
- @brief exchanges the values
-
- Exchanges the contents of the JSON value with those of @a other. Does not
- invoke any move, copy, or swap operations on individual elements. All
- iterators and references remain valid. The past-the-end iterator is
- invalidated.
-
- @param[in,out] other JSON value to exchange the contents with
-
- @complexity Constant.
-
- @liveexample{The example below shows how JSON values can be swapped with
- `swap()`.,swap__reference}
-
- @since version 1.0.0
- */
- void swap(reference other) noexcept (
- std::is_nothrow_move_constructible<value_t>::value and
- std::is_nothrow_move_assignable<value_t>::value and
- std::is_nothrow_move_constructible<json_value>::value and
- std::is_nothrow_move_assignable<json_value>::value
- )
- {
- std::swap(m_type, other.m_type);
- std::swap(m_value, other.m_value);
- assert_invariant();
- }
-
- /*!
- @brief exchanges the values
-
- Exchanges the contents of a JSON array with those of @a other. Does not
- invoke any move, copy, or swap operations on individual elements. All
- iterators and references remain valid. The past-the-end iterator is
- invalidated.
-
- @param[in,out] other array to exchange the contents with
-
- @throw type_error.310 when JSON value is not an array; example: `"cannot
- use swap() with string"`
-
- @complexity Constant.
-
- @liveexample{The example below shows how arrays can be swapped with
- `swap()`.,swap__array_t}
-
- @since version 1.0.0
- */
- void swap(array_t& other)
- {
- // swap only works for arrays
- if (JSON_LIKELY(is_array()))
- {
- std::swap(*(m_value.array), other);
- }
- else
- {
- JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name())));
- }
- }
-
- /*!
- @brief exchanges the values
-
- Exchanges the contents of a JSON object with those of @a other. Does not
- invoke any move, copy, or swap operations on individual elements. All
- iterators and references remain valid. The past-the-end iterator is
- invalidated.
-
- @param[in,out] other object to exchange the contents with
-
- @throw type_error.310 when JSON value is not an object; example:
- `"cannot use swap() with string"`
-
- @complexity Constant.
-
- @liveexample{The example below shows how objects can be swapped with
- `swap()`.,swap__object_t}
-
- @since version 1.0.0
- */
- void swap(object_t& other)
- {
- // swap only works for objects
- if (JSON_LIKELY(is_object()))
- {
- std::swap(*(m_value.object), other);
- }
- else
- {
- JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name())));
- }
- }
-
- /*!
- @brief exchanges the values
-
- Exchanges the contents of a JSON string with those of @a other. Does not
- invoke any move, copy, or swap operations on individual elements. All
- iterators and references remain valid. The past-the-end iterator is
- invalidated.
-
- @param[in,out] other string to exchange the contents with
-
- @throw type_error.310 when JSON value is not a string; example: `"cannot
- use swap() with boolean"`
-
- @complexity Constant.
-
- @liveexample{The example below shows how strings can be swapped with
- `swap()`.,swap__string_t}
-
- @since version 1.0.0
- */
- void swap(string_t& other)
- {
- // swap only works for strings
- if (JSON_LIKELY(is_string()))
- {
- std::swap(*(m_value.string), other);
- }
- else
- {
- JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name())));
- }
- }
-
- /// @}
-
- public:
- //////////////////////////////////////////
- // lexicographical comparison operators //
- //////////////////////////////////////////
-
- /// @name lexicographical comparison operators
- /// @{
-
- /*!
- @brief comparison: equal
-
- Compares two JSON values for equality according to the following rules:
- - Two JSON values are equal if (1) they are from the same type and (2)
- their stored values are the same according to their respective
- `operator==`.
- - Integer and floating-point numbers are automatically converted before
- comparison. Note than two NaN values are always treated as unequal.
- - Two JSON null values are equal.
-
- @note Floating-point inside JSON values numbers are compared with
- `json::number_float_t::operator==` which is `double::operator==` by
- default. To compare floating-point while respecting an epsilon, an alternative
- [comparison function](https://github.com/mariokonrad/marnav/blob/master/src/marnav/math/floatingpoint.hpp#L34-#L39)
- could be used, for instance
- @code {.cpp}
- template<typename T, typename = typename std::enable_if<std::is_floating_point<T>::value, T>::type>
- inline bool is_same(T a, T b, T epsilon = std::numeric_limits<T>::epsilon()) noexcept
- {
- return std::abs(a - b) <= epsilon;
- }
- @endcode
-
- @note NaN values never compare equal to themselves or to other NaN values.
-
- @param[in] lhs first JSON value to consider
- @param[in] rhs second JSON value to consider
- @return whether the values @a lhs and @a rhs are equal
-
- @exceptionsafety No-throw guarantee: this function never throws exceptions.
-
- @complexity Linear.
-
- @liveexample{The example demonstrates comparing several JSON
- types.,operator__equal}
-
- @since version 1.0.0
- */
- friend bool operator==(const_reference lhs, const_reference rhs) noexcept
- {
- const auto lhs_type = lhs.type();
- const auto rhs_type = rhs.type();
-
- if (lhs_type == rhs_type)
- {
- switch (lhs_type)
- {
- case value_t::array:
- return *lhs.m_value.array == *rhs.m_value.array;
-
- case value_t::object:
- return *lhs.m_value.object == *rhs.m_value.object;
-
- case value_t::null:
- return true;
-
- case value_t::string:
- return *lhs.m_value.string == *rhs.m_value.string;
-
- case value_t::boolean:
- return lhs.m_value.boolean == rhs.m_value.boolean;
-
- case value_t::number_integer:
- return lhs.m_value.number_integer == rhs.m_value.number_integer;
-
- case value_t::number_unsigned:
- return lhs.m_value.number_unsigned == rhs.m_value.number_unsigned;
-
- case value_t::number_float:
- return lhs.m_value.number_float == rhs.m_value.number_float;
-
- default:
- return false;
- }
- }
- else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_float)
- {
- return static_cast<number_float_t>(lhs.m_value.number_integer) == rhs.m_value.number_float;
- }
- else if (lhs_type == value_t::number_float and rhs_type == value_t::number_integer)
- {
- return lhs.m_value.number_float == static_cast<number_float_t>(rhs.m_value.number_integer);
- }
- else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_float)
- {
- return static_cast<number_float_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_float;
- }
- else if (lhs_type == value_t::number_float and rhs_type == value_t::number_unsigned)
- {
- return lhs.m_value.number_float == static_cast<number_float_t>(rhs.m_value.number_unsigned);
- }
- else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_integer)
- {
- return static_cast<number_integer_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_integer;
- }
- else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_unsigned)
- {
- return lhs.m_value.number_integer == static_cast<number_integer_t>(rhs.m_value.number_unsigned);
- }
-
- return false;
- }
-
- /*!
- @brief comparison: equal
- @copydoc operator==(const_reference, const_reference)
- */
- template<typename ScalarType, typename std::enable_if<
- std::is_scalar<ScalarType>::value, int>::type = 0>
- friend bool operator==(const_reference lhs, const ScalarType rhs) noexcept
- {
- return lhs == basic_json(rhs);
- }
-
- /*!
- @brief comparison: equal
- @copydoc operator==(const_reference, const_reference)
- */
- template<typename ScalarType, typename std::enable_if<
- std::is_scalar<ScalarType>::value, int>::type = 0>
- friend bool operator==(const ScalarType lhs, const_reference rhs) noexcept
- {
- return basic_json(lhs) == rhs;
- }
-
- /*!
- @brief comparison: not equal
-
- Compares two JSON values for inequality by calculating `not (lhs == rhs)`.
-
- @param[in] lhs first JSON value to consider
- @param[in] rhs second JSON value to consider
- @return whether the values @a lhs and @a rhs are not equal
-
- @complexity Linear.
-
- @exceptionsafety No-throw guarantee: this function never throws exceptions.
-
- @liveexample{The example demonstrates comparing several JSON
- types.,operator__notequal}
-
- @since version 1.0.0
- */
- friend bool operator!=(const_reference lhs, const_reference rhs) noexcept
- {
- return not (lhs == rhs);
- }
-
- /*!
- @brief comparison: not equal
- @copydoc operator!=(const_reference, const_reference)
- */
- template<typename ScalarType, typename std::enable_if<
- std::is_scalar<ScalarType>::value, int>::type = 0>
- friend bool operator!=(const_reference lhs, const ScalarType rhs) noexcept
- {
- return lhs != basic_json(rhs);
- }
-
- /*!
- @brief comparison: not equal
- @copydoc operator!=(const_reference, const_reference)
- */
- template<typename ScalarType, typename std::enable_if<
- std::is_scalar<ScalarType>::value, int>::type = 0>
- friend bool operator!=(const ScalarType lhs, const_reference rhs) noexcept
- {
- return basic_json(lhs) != rhs;
- }
-
- /*!
- @brief comparison: less than
-
- Compares whether one JSON value @a lhs is less than another JSON value @a
- rhs according to the following rules:
- - If @a lhs and @a rhs have the same type, the values are compared using
- the default `<` operator.
- - Integer and floating-point numbers are automatically converted before
- comparison
- - In case @a lhs and @a rhs have different types, the values are ignored
- and the order of the types is considered, see
- @ref operator<(const value_t, const value_t).
-
- @param[in] lhs first JSON value to consider
- @param[in] rhs second JSON value to consider
- @return whether @a lhs is less than @a rhs
-
- @complexity Linear.
-
- @exceptionsafety No-throw guarantee: this function never throws exceptions.
-
- @liveexample{The example demonstrates comparing several JSON
- types.,operator__less}
-
- @since version 1.0.0
- */
- friend bool operator<(const_reference lhs, const_reference rhs) noexcept
- {
- const auto lhs_type = lhs.type();
- const auto rhs_type = rhs.type();
-
- if (lhs_type == rhs_type)
- {
- switch (lhs_type)
- {
- case value_t::array:
- // note parentheses are necessary, see
- // https://github.com/nlohmann/json/issues/1530
- return (*lhs.m_value.array) < (*rhs.m_value.array);
-
- case value_t::object:
- return *lhs.m_value.object < *rhs.m_value.object;
-
- case value_t::null:
- return false;
-
- case value_t::string:
- return *lhs.m_value.string < *rhs.m_value.string;
-
- case value_t::boolean:
- return lhs.m_value.boolean < rhs.m_value.boolean;
-
- case value_t::number_integer:
- return lhs.m_value.number_integer < rhs.m_value.number_integer;
-
- case value_t::number_unsigned:
- return lhs.m_value.number_unsigned < rhs.m_value.number_unsigned;
-
- case value_t::number_float:
- return lhs.m_value.number_float < rhs.m_value.number_float;
-
- default:
- return false;
- }
- }
- else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_float)
- {
- return static_cast<number_float_t>(lhs.m_value.number_integer) < rhs.m_value.number_float;
- }
- else if (lhs_type == value_t::number_float and rhs_type == value_t::number_integer)
- {
- return lhs.m_value.number_float < static_cast<number_float_t>(rhs.m_value.number_integer);
- }
- else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_float)
- {
- return static_cast<number_float_t>(lhs.m_value.number_unsigned) < rhs.m_value.number_float;
- }
- else if (lhs_type == value_t::number_float and rhs_type == value_t::number_unsigned)
- {
- return lhs.m_value.number_float < static_cast<number_float_t>(rhs.m_value.number_unsigned);
- }
- else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_unsigned)
- {
- return lhs.m_value.number_integer < static_cast<number_integer_t>(rhs.m_value.number_unsigned);
- }
- else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_integer)
- {
- return static_cast<number_integer_t>(lhs.m_value.number_unsigned) < rhs.m_value.number_integer;
- }
-
- // We only reach this line if we cannot compare values. In that case,
- // we compare types. Note we have to call the operator explicitly,
- // because MSVC has problems otherwise.
- return operator<(lhs_type, rhs_type);
- }
-
- /*!
- @brief comparison: less than
- @copydoc operator<(const_reference, const_reference)
- */
- template<typename ScalarType, typename std::enable_if<
- std::is_scalar<ScalarType>::value, int>::type = 0>
- friend bool operator<(const_reference lhs, const ScalarType rhs) noexcept
- {
- return lhs < basic_json(rhs);
- }
-
- /*!
- @brief comparison: less than
- @copydoc operator<(const_reference, const_reference)
- */
- template<typename ScalarType, typename std::enable_if<
- std::is_scalar<ScalarType>::value, int>::type = 0>
- friend bool operator<(const ScalarType lhs, const_reference rhs) noexcept
- {
- return basic_json(lhs) < rhs;
- }
-
- /*!
- @brief comparison: less than or equal
-
- Compares whether one JSON value @a lhs is less than or equal to another
- JSON value by calculating `not (rhs < lhs)`.
-
- @param[in] lhs first JSON value to consider
- @param[in] rhs second JSON value to consider
- @return whether @a lhs is less than or equal to @a rhs
-
- @complexity Linear.
-
- @exceptionsafety No-throw guarantee: this function never throws exceptions.
-
- @liveexample{The example demonstrates comparing several JSON
- types.,operator__greater}
-
- @since version 1.0.0
- */
- friend bool operator<=(const_reference lhs, const_reference rhs) noexcept
- {
- return not (rhs < lhs);
- }
-
- /*!
- @brief comparison: less than or equal
- @copydoc operator<=(const_reference, const_reference)
- */
- template<typename ScalarType, typename std::enable_if<
- std::is_scalar<ScalarType>::value, int>::type = 0>
- friend bool operator<=(const_reference lhs, const ScalarType rhs) noexcept
- {
- return lhs <= basic_json(rhs);
- }
-
- /*!
- @brief comparison: less than or equal
- @copydoc operator<=(const_reference, const_reference)
- */
- template<typename ScalarType, typename std::enable_if<
- std::is_scalar<ScalarType>::value, int>::type = 0>
- friend bool operator<=(const ScalarType lhs, const_reference rhs) noexcept
- {
- return basic_json(lhs) <= rhs;
- }
-
- /*!
- @brief comparison: greater than
-
- Compares whether one JSON value @a lhs is greater than another
- JSON value by calculating `not (lhs <= rhs)`.
-
- @param[in] lhs first JSON value to consider
- @param[in] rhs second JSON value to consider
- @return whether @a lhs is greater than to @a rhs
-
- @complexity Linear.
-
- @exceptionsafety No-throw guarantee: this function never throws exceptions.
-
- @liveexample{The example demonstrates comparing several JSON
- types.,operator__lessequal}
-
- @since version 1.0.0
- */
- friend bool operator>(const_reference lhs, const_reference rhs) noexcept
- {
- return not (lhs <= rhs);
- }
-
- /*!
- @brief comparison: greater than
- @copydoc operator>(const_reference, const_reference)
- */
- template<typename ScalarType, typename std::enable_if<
- std::is_scalar<ScalarType>::value, int>::type = 0>
- friend bool operator>(const_reference lhs, const ScalarType rhs) noexcept
- {
- return lhs > basic_json(rhs);
- }
-
- /*!
- @brief comparison: greater than
- @copydoc operator>(const_reference, const_reference)
- */
- template<typename ScalarType, typename std::enable_if<
- std::is_scalar<ScalarType>::value, int>::type = 0>
- friend bool operator>(const ScalarType lhs, const_reference rhs) noexcept
- {
- return basic_json(lhs) > rhs;
- }
-
- /*!
- @brief comparison: greater than or equal
-
- Compares whether one JSON value @a lhs is greater than or equal to another
- JSON value by calculating `not (lhs < rhs)`.
-
- @param[in] lhs first JSON value to consider
- @param[in] rhs second JSON value to consider
- @return whether @a lhs is greater than or equal to @a rhs
-
- @complexity Linear.
-
- @exceptionsafety No-throw guarantee: this function never throws exceptions.
-
- @liveexample{The example demonstrates comparing several JSON
- types.,operator__greaterequal}
-
- @since version 1.0.0
- */
- friend bool operator>=(const_reference lhs, const_reference rhs) noexcept
- {
- return not (lhs < rhs);
- }
-
- /*!
- @brief comparison: greater than or equal
- @copydoc operator>=(const_reference, const_reference)
- */
- template<typename ScalarType, typename std::enable_if<
- std::is_scalar<ScalarType>::value, int>::type = 0>
- friend bool operator>=(const_reference lhs, const ScalarType rhs) noexcept
- {
- return lhs >= basic_json(rhs);
- }
-
- /*!
- @brief comparison: greater than or equal
- @copydoc operator>=(const_reference, const_reference)
- */
- template<typename ScalarType, typename std::enable_if<
- std::is_scalar<ScalarType>::value, int>::type = 0>
- friend bool operator>=(const ScalarType lhs, const_reference rhs) noexcept
- {
- return basic_json(lhs) >= rhs;
- }
-
- /// @}
-
- ///////////////////
- // serialization //
- ///////////////////
-
- /// @name serialization
- /// @{
-
- /*!
- @brief serialize to stream
-
- Serialize the given JSON value @a j to the output stream @a o. The JSON
- value will be serialized using the @ref dump member function.
-
- - The indentation of the output can be controlled with the member variable
- `width` of the output stream @a o. For instance, using the manipulator
- `std::setw(4)` on @a o sets the indentation level to `4` and the
- serialization result is the same as calling `dump(4)`.
-
- - The indentation character can be controlled with the member variable
- `fill` of the output stream @a o. For instance, the manipulator
- `std::setfill('\\t')` sets indentation to use a tab character rather than
- the default space character.
-
- @param[in,out] o stream to serialize to
- @param[in] j JSON value to serialize
-
- @return the stream @a o
-
- @throw type_error.316 if a string stored inside the JSON value is not
- UTF-8 encoded
-
- @complexity Linear.
-
- @liveexample{The example below shows the serialization with different
- parameters to `width` to adjust the indentation level.,operator_serialize}
-
- @since version 1.0.0; indentation character added in version 3.0.0
- */
- friend std::ostream& operator<<(std::ostream& o, const basic_json& j)
- {
- // read width member and use it as indentation parameter if nonzero
- const bool pretty_print = o.width() > 0;
- const auto indentation = pretty_print ? o.width() : 0;
-
- // reset width to 0 for subsequent calls to this stream
- o.width(0);
-
- // do the actual serialization
- serializer s(detail::output_adapter<char>(o), o.fill());
- s.dump(j, pretty_print, false, static_cast<unsigned int>(indentation));
- return o;
- }
-
- /*!
- @brief serialize to stream
- @deprecated This stream operator is deprecated and will be removed in
- future 4.0.0 of the library. Please use
- @ref operator<<(std::ostream&, const basic_json&)
- instead; that is, replace calls like `j >> o;` with `o << j;`.
- @since version 1.0.0; deprecated since version 3.0.0
- */
- JSON_DEPRECATED
- friend std::ostream& operator>>(const basic_json& j, std::ostream& o)
- {
- return o << j;
- }
-
- /// @}
-
-
- /////////////////////
- // deserialization //
- /////////////////////
-
- /// @name deserialization
- /// @{
-
- /*!
- @brief deserialize from a compatible input
-
- This function reads from a compatible input. Examples are:
- - an array of 1-byte values
- - strings with character/literal type with size of 1 byte
- - input streams
- - container with contiguous storage of 1-byte values. Compatible container
- types include `std::vector`, `std::string`, `std::array`,
- `std::valarray`, and `std::initializer_list`. Furthermore, C-style
- arrays can be used with `std::begin()`/`std::end()`. User-defined
- containers can be used as long as they implement random-access iterators
- and a contiguous storage.
-
- @pre Each element of the container has a size of 1 byte. Violating this
- precondition yields undefined behavior. **This precondition is enforced
- with a static assertion.**
-
- @pre The container storage is contiguous. Violating this precondition
- yields undefined behavior. **This precondition is enforced with an
- assertion.**
-
- @warning There is no way to enforce all preconditions at compile-time. If
- the function is called with a noncompliant container and with
- assertions switched off, the behavior is undefined and will most
- likely yield segmentation violation.
-
- @param[in] i input to read from
- @param[in] cb a parser callback function of type @ref parser_callback_t
- which is used to control the deserialization by filtering unwanted values
- (optional)
- @param[in] allow_exceptions whether to throw exceptions in case of a
- parse error (optional, true by default)
-
- @return deserialized JSON value; in case of a parse error and
- @a allow_exceptions set to `false`, the return value will be
- value_t::discarded.
-
- @throw parse_error.101 if a parse error occurs; example: `""unexpected end
- of input; expected string literal""`
- @throw parse_error.102 if to_unicode fails or surrogate error
- @throw parse_error.103 if to_unicode fails
-
- @complexity Linear in the length of the input. The parser is a predictive
- LL(1) parser. The complexity can be higher if the parser callback function
- @a cb has a super-linear complexity.
-
- @note A UTF-8 byte order mark is silently ignored.
-
- @liveexample{The example below demonstrates the `parse()` function reading
- from an array.,parse__array__parser_callback_t}
-
- @liveexample{The example below demonstrates the `parse()` function with
- and without callback function.,parse__string__parser_callback_t}
-
- @liveexample{The example below demonstrates the `parse()` function with
- and without callback function.,parse__istream__parser_callback_t}
-
- @liveexample{The example below demonstrates the `parse()` function reading
- from a contiguous container.,parse__contiguouscontainer__parser_callback_t}
-
- @since version 2.0.3 (contiguous containers)
- */
- JSON_NODISCARD
- static basic_json parse(detail::input_adapter&& i,
- const parser_callback_t cb = nullptr,
- const bool allow_exceptions = true)
- {
- basic_json result;
- parser(i, cb, allow_exceptions).parse(true, result);
- return result;
- }
-
- static bool accept(detail::input_adapter&& i)
- {
- return parser(i).accept(true);
- }
-
- /*!
- @brief generate SAX events
-
- The SAX event lister must follow the interface of @ref json_sax.
-
- This function reads from a compatible input. Examples are:
- - an array of 1-byte values
- - strings with character/literal type with size of 1 byte
- - input streams
- - container with contiguous storage of 1-byte values. Compatible container
- types include `std::vector`, `std::string`, `std::array`,
- `std::valarray`, and `std::initializer_list`. Furthermore, C-style
- arrays can be used with `std::begin()`/`std::end()`. User-defined
- containers can be used as long as they implement random-access iterators
- and a contiguous storage.
-
- @pre Each element of the container has a size of 1 byte. Violating this
- precondition yields undefined behavior. **This precondition is enforced
- with a static assertion.**
-
- @pre The container storage is contiguous. Violating this precondition
- yields undefined behavior. **This precondition is enforced with an
- assertion.**
-
- @warning There is no way to enforce all preconditions at compile-time. If
- the function is called with a noncompliant container and with
- assertions switched off, the behavior is undefined and will most
- likely yield segmentation violation.
-
- @param[in] i input to read from
- @param[in,out] sax SAX event listener
- @param[in] format the format to parse (JSON, CBOR, MessagePack, or UBJSON)
- @param[in] strict whether the input has to be consumed completely
-
- @return return value of the last processed SAX event
-
- @throw parse_error.101 if a parse error occurs; example: `""unexpected end
- of input; expected string literal""`
- @throw parse_error.102 if to_unicode fails or surrogate error
- @throw parse_error.103 if to_unicode fails
-
- @complexity Linear in the length of the input. The parser is a predictive
- LL(1) parser. The complexity can be higher if the SAX consumer @a sax has
- a super-linear complexity.
-
- @note A UTF-8 byte order mark is silently ignored.
-
- @liveexample{The example below demonstrates the `sax_parse()` function
- reading from string and processing the events with a user-defined SAX
- event consumer.,sax_parse}
-
- @since version 3.2.0
- */
- template <typename SAX>
- static bool sax_parse(detail::input_adapter&& i, SAX* sax,
- input_format_t format = input_format_t::json,
- const bool strict = true)
- {
- assert(sax);
- return format == input_format_t::json
- ? parser(std::move(i)).sax_parse(sax, strict)
- : detail::binary_reader<basic_json, SAX>(std::move(i)).sax_parse(format, sax, strict);
- }
-
- /*!
- @brief deserialize from an iterator range with contiguous storage
-
- This function reads from an iterator range of a container with contiguous
- storage of 1-byte values. Compatible container types include
- `std::vector`, `std::string`, `std::array`, `std::valarray`, and
- `std::initializer_list`. Furthermore, C-style arrays can be used with
- `std::begin()`/`std::end()`. User-defined containers can be used as long
- as they implement random-access iterators and a contiguous storage.
-
- @pre The iterator range is contiguous. Violating this precondition yields
- undefined behavior. **This precondition is enforced with an assertion.**
- @pre Each element in the range has a size of 1 byte. Violating this
- precondition yields undefined behavior. **This precondition is enforced
- with a static assertion.**
-
- @warning There is no way to enforce all preconditions at compile-time. If
- the function is called with noncompliant iterators and with
- assertions switched off, the behavior is undefined and will most
- likely yield segmentation violation.
-
- @tparam IteratorType iterator of container with contiguous storage
- @param[in] first begin of the range to parse (included)
- @param[in] last end of the range to parse (excluded)
- @param[in] cb a parser callback function of type @ref parser_callback_t
- which is used to control the deserialization by filtering unwanted values
- (optional)
- @param[in] allow_exceptions whether to throw exceptions in case of a
- parse error (optional, true by default)
-
- @return deserialized JSON value; in case of a parse error and
- @a allow_exceptions set to `false`, the return value will be
- value_t::discarded.
-
- @throw parse_error.101 in case of an unexpected token
- @throw parse_error.102 if to_unicode fails or surrogate error
- @throw parse_error.103 if to_unicode fails
-
- @complexity Linear in the length of the input. The parser is a predictive
- LL(1) parser. The complexity can be higher if the parser callback function
- @a cb has a super-linear complexity.
-
- @note A UTF-8 byte order mark is silently ignored.
-
- @liveexample{The example below demonstrates the `parse()` function reading
- from an iterator range.,parse__iteratortype__parser_callback_t}
-
- @since version 2.0.3
- */
- template<class IteratorType, typename std::enable_if<
- std::is_base_of<
- std::random_access_iterator_tag,
- typename std::iterator_traits<IteratorType>::iterator_category>::value, int>::type = 0>
- static basic_json parse(IteratorType first, IteratorType last,
- const parser_callback_t cb = nullptr,
- const bool allow_exceptions = true)
- {
- basic_json result;
- parser(detail::input_adapter(first, last), cb, allow_exceptions).parse(true, result);
- return result;
- }
-
- template<class IteratorType, typename std::enable_if<
- std::is_base_of<
- std::random_access_iterator_tag,
- typename std::iterator_traits<IteratorType>::iterator_category>::value, int>::type = 0>
- static bool accept(IteratorType first, IteratorType last)
- {
- return parser(detail::input_adapter(first, last)).accept(true);
- }
-
- template<class IteratorType, class SAX, typename std::enable_if<
- std::is_base_of<
- std::random_access_iterator_tag,
- typename std::iterator_traits<IteratorType>::iterator_category>::value, int>::type = 0>
- static bool sax_parse(IteratorType first, IteratorType last, SAX* sax)
- {
- return parser(detail::input_adapter(first, last)).sax_parse(sax);
- }
-
- /*!
- @brief deserialize from stream
- @deprecated This stream operator is deprecated and will be removed in
- version 4.0.0 of the library. Please use
- @ref operator>>(std::istream&, basic_json&)
- instead; that is, replace calls like `j << i;` with `i >> j;`.
- @since version 1.0.0; deprecated since version 3.0.0
- */
- JSON_DEPRECATED
- friend std::istream& operator<<(basic_json& j, std::istream& i)
- {
- return operator>>(i, j);
- }
-
- /*!
- @brief deserialize from stream
-
- Deserializes an input stream to a JSON value.
-
- @param[in,out] i input stream to read a serialized JSON value from
- @param[in,out] j JSON value to write the deserialized input to
-
- @throw parse_error.101 in case of an unexpected token
- @throw parse_error.102 if to_unicode fails or surrogate error
- @throw parse_error.103 if to_unicode fails
-
- @complexity Linear in the length of the input. The parser is a predictive
- LL(1) parser.
-
- @note A UTF-8 byte order mark is silently ignored.
-
- @liveexample{The example below shows how a JSON value is constructed by
- reading a serialization from a stream.,operator_deserialize}
-
- @sa parse(std::istream&, const parser_callback_t) for a variant with a
- parser callback function to filter values while parsing
-
- @since version 1.0.0
- */
- friend std::istream& operator>>(std::istream& i, basic_json& j)
- {
- parser(detail::input_adapter(i)).parse(false, j);
- return i;
- }
-
- /// @}
-
- ///////////////////////////
- // convenience functions //
- ///////////////////////////
-
- /*!
- @brief return the type as string
-
- Returns the type name as string to be used in error messages - usually to
- indicate that a function was called on a wrong JSON type.
-
- @return a string representation of a the @a m_type member:
- Value type | return value
- ----------- | -------------
- null | `"null"`
- boolean | `"boolean"`
- string | `"string"`
- number | `"number"` (for all number types)
- object | `"object"`
- array | `"array"`
- discarded | `"discarded"`
-
- @exceptionsafety No-throw guarantee: this function never throws exceptions.
-
- @complexity Constant.
-
- @liveexample{The following code exemplifies `type_name()` for all JSON
- types.,type_name}
-
- @sa @ref type() -- return the type of the JSON value
- @sa @ref operator value_t() -- return the type of the JSON value (implicit)
-
- @since version 1.0.0, public since 2.1.0, `const char*` and `noexcept`
- since 3.0.0
- */
- const char* type_name() const noexcept
- {
- {
- switch (m_type)
- {
- case value_t::null:
- return "null";
- case value_t::object:
- return "object";
- case value_t::array:
- return "array";
- case value_t::string:
- return "string";
- case value_t::boolean:
- return "boolean";
- case value_t::discarded:
- return "discarded";
- default:
- return "number";
- }
- }
- }
-
-
- private:
- //////////////////////
- // member variables //
- //////////////////////
-
- /// the type of the current element
- value_t m_type = value_t::null;
-
- /// the value of the current element
- json_value m_value = {};
-
- //////////////////////////////////////////
- // binary serialization/deserialization //
- //////////////////////////////////////////
-
- /// @name binary serialization/deserialization support
- /// @{
-
- public:
- /*!
- @brief create a CBOR serialization of a given JSON value
-
- Serializes a given JSON value @a j to a byte vector using the CBOR (Concise
- Binary Object Representation) serialization format. CBOR is a binary
- serialization format which aims to be more compact than JSON itself, yet
- more efficient to parse.
-
- The library uses the following mapping from JSON values types to
- CBOR types according to the CBOR specification (RFC 7049):
-
- JSON value type | value/range | CBOR type | first byte
- --------------- | ------------------------------------------ | ---------------------------------- | ---------------
- null | `null` | Null | 0xF6
- boolean | `true` | True | 0xF5
- boolean | `false` | False | 0xF4
- number_integer | -9223372036854775808..-2147483649 | Negative integer (8 bytes follow) | 0x3B
- number_integer | -2147483648..-32769 | Negative integer (4 bytes follow) | 0x3A
- number_integer | -32768..-129 | Negative integer (2 bytes follow) | 0x39
- number_integer | -128..-25 | Negative integer (1 byte follow) | 0x38
- number_integer | -24..-1 | Negative integer | 0x20..0x37
- number_integer | 0..23 | Integer | 0x00..0x17
- number_integer | 24..255 | Unsigned integer (1 byte follow) | 0x18
- number_integer | 256..65535 | Unsigned integer (2 bytes follow) | 0x19
- number_integer | 65536..4294967295 | Unsigned integer (4 bytes follow) | 0x1A
- number_integer | 4294967296..18446744073709551615 | Unsigned integer (8 bytes follow) | 0x1B
- number_unsigned | 0..23 | Integer | 0x00..0x17
- number_unsigned | 24..255 | Unsigned integer (1 byte follow) | 0x18
- number_unsigned | 256..65535 | Unsigned integer (2 bytes follow) | 0x19
- number_unsigned | 65536..4294967295 | Unsigned integer (4 bytes follow) | 0x1A
- number_unsigned | 4294967296..18446744073709551615 | Unsigned integer (8 bytes follow) | 0x1B
- number_float | *any value* | Double-Precision Float | 0xFB
- string | *length*: 0..23 | UTF-8 string | 0x60..0x77
- string | *length*: 23..255 | UTF-8 string (1 byte follow) | 0x78
- string | *length*: 256..65535 | UTF-8 string (2 bytes follow) | 0x79
- string | *length*: 65536..4294967295 | UTF-8 string (4 bytes follow) | 0x7A
- string | *length*: 4294967296..18446744073709551615 | UTF-8 string (8 bytes follow) | 0x7B
- array | *size*: 0..23 | array | 0x80..0x97
- array | *size*: 23..255 | array (1 byte follow) | 0x98
- array | *size*: 256..65535 | array (2 bytes follow) | 0x99
- array | *size*: 65536..4294967295 | array (4 bytes follow) | 0x9A
- array | *size*: 4294967296..18446744073709551615 | array (8 bytes follow) | 0x9B
- object | *size*: 0..23 | map | 0xA0..0xB7
- object | *size*: 23..255 | map (1 byte follow) | 0xB8
- object | *size*: 256..65535 | map (2 bytes follow) | 0xB9
- object | *size*: 65536..4294967295 | map (4 bytes follow) | 0xBA
- object | *size*: 4294967296..18446744073709551615 | map (8 bytes follow) | 0xBB
-
- @note The mapping is **complete** in the sense that any JSON value type
- can be converted to a CBOR value.
-
- @note If NaN or Infinity are stored inside a JSON number, they are
- serialized properly. This behavior differs from the @ref dump()
- function which serializes NaN or Infinity to `null`.
-
- @note The following CBOR types are not used in the conversion:
- - byte strings (0x40..0x5F)
- - UTF-8 strings terminated by "break" (0x7F)
- - arrays terminated by "break" (0x9F)
- - maps terminated by "break" (0xBF)
- - date/time (0xC0..0xC1)
- - bignum (0xC2..0xC3)
- - decimal fraction (0xC4)
- - bigfloat (0xC5)
- - tagged items (0xC6..0xD4, 0xD8..0xDB)
- - expected conversions (0xD5..0xD7)
- - simple values (0xE0..0xF3, 0xF8)
- - undefined (0xF7)
- - half and single-precision floats (0xF9-0xFA)
- - break (0xFF)
-
- @param[in] j JSON value to serialize
- @return MessagePack serialization as byte vector
-
- @complexity Linear in the size of the JSON value @a j.
-
- @liveexample{The example shows the serialization of a JSON value to a byte
- vector in CBOR format.,to_cbor}
-
- @sa http://cbor.io
- @sa @ref from_cbor(detail::input_adapter&&, const bool, const bool) for the
- analogous deserialization
- @sa @ref to_msgpack(const basic_json&) for the related MessagePack format
- @sa @ref to_ubjson(const basic_json&, const bool, const bool) for the
- related UBJSON format
-
- @since version 2.0.9
- */
- static std::vector<uint8_t> to_cbor(const basic_json& j)
- {
- std::vector<uint8_t> result;
- to_cbor(j, result);
- return result;
- }
-
- static void to_cbor(const basic_json& j, detail::output_adapter<uint8_t> o)
- {
- binary_writer<uint8_t>(o).write_cbor(j);
- }
-
- static void to_cbor(const basic_json& j, detail::output_adapter<char> o)
- {
- binary_writer<char>(o).write_cbor(j);
- }
-
- /*!
- @brief create a MessagePack serialization of a given JSON value
-
- Serializes a given JSON value @a j to a byte vector using the MessagePack
- serialization format. MessagePack is a binary serialization format which
- aims to be more compact than JSON itself, yet more efficient to parse.
-
- The library uses the following mapping from JSON values types to
- MessagePack types according to the MessagePack specification:
-
- JSON value type | value/range | MessagePack type | first byte
- --------------- | --------------------------------- | ---------------- | ----------
- null | `null` | nil | 0xC0
- boolean | `true` | true | 0xC3
- boolean | `false` | false | 0xC2
- number_integer | -9223372036854775808..-2147483649 | int64 | 0xD3
- number_integer | -2147483648..-32769 | int32 | 0xD2
- number_integer | -32768..-129 | int16 | 0xD1
- number_integer | -128..-33 | int8 | 0xD0
- number_integer | -32..-1 | negative fixint | 0xE0..0xFF
- number_integer | 0..127 | positive fixint | 0x00..0x7F
- number_integer | 128..255 | uint 8 | 0xCC
- number_integer | 256..65535 | uint 16 | 0xCD
- number_integer | 65536..4294967295 | uint 32 | 0xCE
- number_integer | 4294967296..18446744073709551615 | uint 64 | 0xCF
- number_unsigned | 0..127 | positive fixint | 0x00..0x7F
- number_unsigned | 128..255 | uint 8 | 0xCC
- number_unsigned | 256..65535 | uint 16 | 0xCD
- number_unsigned | 65536..4294967295 | uint 32 | 0xCE
- number_unsigned | 4294967296..18446744073709551615 | uint 64 | 0xCF
- number_float | *any value* | float 64 | 0xCB
- string | *length*: 0..31 | fixstr | 0xA0..0xBF
- string | *length*: 32..255 | str 8 | 0xD9
- string | *length*: 256..65535 | str 16 | 0xDA
- string | *length*: 65536..4294967295 | str 32 | 0xDB
- array | *size*: 0..15 | fixarray | 0x90..0x9F
- array | *size*: 16..65535 | array 16 | 0xDC
- array | *size*: 65536..4294967295 | array 32 | 0xDD
- object | *size*: 0..15 | fix map | 0x80..0x8F
- object | *size*: 16..65535 | map 16 | 0xDE
- object | *size*: 65536..4294967295 | map 32 | 0xDF
-
- @note The mapping is **complete** in the sense that any JSON value type
- can be converted to a MessagePack value.
-
- @note The following values can **not** be converted to a MessagePack value:
- - strings with more than 4294967295 bytes
- - arrays with more than 4294967295 elements
- - objects with more than 4294967295 elements
-
- @note The following MessagePack types are not used in the conversion:
- - bin 8 - bin 32 (0xC4..0xC6)
- - ext 8 - ext 32 (0xC7..0xC9)
- - float 32 (0xCA)
- - fixext 1 - fixext 16 (0xD4..0xD8)
-
- @note Any MessagePack output created @ref to_msgpack can be successfully
- parsed by @ref from_msgpack.
-
- @note If NaN or Infinity are stored inside a JSON number, they are
- serialized properly. This behavior differs from the @ref dump()
- function which serializes NaN or Infinity to `null`.
-
- @param[in] j JSON value to serialize
- @return MessagePack serialization as byte vector
-
- @complexity Linear in the size of the JSON value @a j.
-
- @liveexample{The example shows the serialization of a JSON value to a byte
- vector in MessagePack format.,to_msgpack}
-
- @sa http://msgpack.org
- @sa @ref from_msgpack for the analogous deserialization
- @sa @ref to_cbor(const basic_json& for the related CBOR format
- @sa @ref to_ubjson(const basic_json&, const bool, const bool) for the
- related UBJSON format
-
- @since version 2.0.9
- */
- static std::vector<uint8_t> to_msgpack(const basic_json& j)
- {
- std::vector<uint8_t> result;
- to_msgpack(j, result);
- return result;
- }
-
- static void to_msgpack(const basic_json& j, detail::output_adapter<uint8_t> o)
- {
- binary_writer<uint8_t>(o).write_msgpack(j);
- }
-
- static void to_msgpack(const basic_json& j, detail::output_adapter<char> o)
- {
- binary_writer<char>(o).write_msgpack(j);
- }
-
- /*!
- @brief create a UBJSON serialization of a given JSON value
-
- Serializes a given JSON value @a j to a byte vector using the UBJSON
- (Universal Binary JSON) serialization format. UBJSON aims to be more compact
- than JSON itself, yet more efficient to parse.
-
- The library uses the following mapping from JSON values types to
- UBJSON types according to the UBJSON specification:
-
- JSON value type | value/range | UBJSON type | marker
- --------------- | --------------------------------- | ----------- | ------
- null | `null` | null | `Z`
- boolean | `true` | true | `T`
- boolean | `false` | false | `F`
- number_integer | -9223372036854775808..-2147483649 | int64 | `L`
- number_integer | -2147483648..-32769 | int32 | `l`
- number_integer | -32768..-129 | int16 | `I`
- number_integer | -128..127 | int8 | `i`
- number_integer | 128..255 | uint8 | `U`
- number_integer | 256..32767 | int16 | `I`
- number_integer | 32768..2147483647 | int32 | `l`
- number_integer | 2147483648..9223372036854775807 | int64 | `L`
- number_unsigned | 0..127 | int8 | `i`
- number_unsigned | 128..255 | uint8 | `U`
- number_unsigned | 256..32767 | int16 | `I`
- number_unsigned | 32768..2147483647 | int32 | `l`
- number_unsigned | 2147483648..9223372036854775807 | int64 | `L`
- number_float | *any value* | float64 | `D`
- string | *with shortest length indicator* | string | `S`
- array | *see notes on optimized format* | array | `[`
- object | *see notes on optimized format* | map | `{`
-
- @note The mapping is **complete** in the sense that any JSON value type
- can be converted to a UBJSON value.
-
- @note The following values can **not** be converted to a UBJSON value:
- - strings with more than 9223372036854775807 bytes (theoretical)
- - unsigned integer numbers above 9223372036854775807
-
- @note The following markers are not used in the conversion:
- - `Z`: no-op values are not created.
- - `C`: single-byte strings are serialized with `S` markers.
-
- @note Any UBJSON output created @ref to_ubjson can be successfully parsed
- by @ref from_ubjson.
-
- @note If NaN or Infinity are stored inside a JSON number, they are
- serialized properly. This behavior differs from the @ref dump()
- function which serializes NaN or Infinity to `null`.
-
- @note The optimized formats for containers are supported: Parameter
- @a use_size adds size information to the beginning of a container and
- removes the closing marker. Parameter @a use_type further checks
- whether all elements of a container have the same type and adds the
- type marker to the beginning of the container. The @a use_type
- parameter must only be used together with @a use_size = true. Note
- that @a use_size = true alone may result in larger representations -
- the benefit of this parameter is that the receiving side is
- immediately informed on the number of elements of the container.
-
- @param[in] j JSON value to serialize
- @param[in] use_size whether to add size annotations to container types
- @param[in] use_type whether to add type annotations to container types
- (must be combined with @a use_size = true)
- @return UBJSON serialization as byte vector
-
- @complexity Linear in the size of the JSON value @a j.
-
- @liveexample{The example shows the serialization of a JSON value to a byte
- vector in UBJSON format.,to_ubjson}
-
- @sa http://ubjson.org
- @sa @ref from_ubjson(detail::input_adapter&&, const bool, const bool) for the
- analogous deserialization
- @sa @ref to_cbor(const basic_json& for the related CBOR format
- @sa @ref to_msgpack(const basic_json&) for the related MessagePack format
-
- @since version 3.1.0
- */
- static std::vector<uint8_t> to_ubjson(const basic_json& j,
- const bool use_size = false,
- const bool use_type = false)
- {
- std::vector<uint8_t> result;
- to_ubjson(j, result, use_size, use_type);
- return result;
- }
-
- static void to_ubjson(const basic_json& j, detail::output_adapter<uint8_t> o,
- const bool use_size = false, const bool use_type = false)
- {
- binary_writer<uint8_t>(o).write_ubjson(j, use_size, use_type);
- }
-
- static void to_ubjson(const basic_json& j, detail::output_adapter<char> o,
- const bool use_size = false, const bool use_type = false)
- {
- binary_writer<char>(o).write_ubjson(j, use_size, use_type);
- }
-
-
- /*!
- @brief Serializes the given JSON object `j` to BSON and returns a vector
- containing the corresponding BSON-representation.
-
- BSON (Binary JSON) is a binary format in which zero or more ordered key/value pairs are
- stored as a single entity (a so-called document).
-
- The library uses the following mapping from JSON values types to BSON types:
-
- JSON value type | value/range | BSON type | marker
- --------------- | --------------------------------- | ----------- | ------
- null | `null` | null | 0x0A
- boolean | `true`, `false` | boolean | 0x08
- number_integer | -9223372036854775808..-2147483649 | int64 | 0x12
- number_integer | -2147483648..2147483647 | int32 | 0x10
- number_integer | 2147483648..9223372036854775807 | int64 | 0x12
- number_unsigned | 0..2147483647 | int32 | 0x10
- number_unsigned | 2147483648..9223372036854775807 | int64 | 0x12
- number_unsigned | 9223372036854775808..18446744073709551615| -- | --
- number_float | *any value* | double | 0x01
- string | *any value* | string | 0x02
- array | *any value* | document | 0x04
- object | *any value* | document | 0x03
-
- @warning The mapping is **incomplete**, since only JSON-objects (and things
- contained therein) can be serialized to BSON.
- Also, integers larger than 9223372036854775807 cannot be serialized to BSON,
- and the keys may not contain U+0000, since they are serialized a
- zero-terminated c-strings.
-
- @throw out_of_range.407 if `j.is_number_unsigned() && j.get<std::uint64_t>() > 9223372036854775807`
- @throw out_of_range.409 if a key in `j` contains a NULL (U+0000)
- @throw type_error.317 if `!j.is_object()`
-
- @pre The input `j` is required to be an object: `j.is_object() == true`.
-
- @note Any BSON output created via @ref to_bson can be successfully parsed
- by @ref from_bson.
-
- @param[in] j JSON value to serialize
- @return BSON serialization as byte vector
-
- @complexity Linear in the size of the JSON value @a j.
-
- @liveexample{The example shows the serialization of a JSON value to a byte
- vector in BSON format.,to_bson}
-
- @sa http://bsonspec.org/spec.html
- @sa @ref from_bson(detail::input_adapter&&, const bool strict) for the
- analogous deserialization
- @sa @ref to_ubjson(const basic_json&, const bool, const bool) for the
- related UBJSON format
- @sa @ref to_cbor(const basic_json&) for the related CBOR format
- @sa @ref to_msgpack(const basic_json&) for the related MessagePack format
- */
- static std::vector<uint8_t> to_bson(const basic_json& j)
- {
- std::vector<uint8_t> result;
- to_bson(j, result);
- return result;
- }
-
- /*!
- @brief Serializes the given JSON object `j` to BSON and forwards the
- corresponding BSON-representation to the given output_adapter `o`.
- @param j The JSON object to convert to BSON.
- @param o The output adapter that receives the binary BSON representation.
- @pre The input `j` shall be an object: `j.is_object() == true`
- @sa @ref to_bson(const basic_json&)
- */
- static void to_bson(const basic_json& j, detail::output_adapter<uint8_t> o)
- {
- binary_writer<uint8_t>(o).write_bson(j);
- }
-
- /*!
- @copydoc to_bson(const basic_json&, detail::output_adapter<uint8_t>)
- */
- static void to_bson(const basic_json& j, detail::output_adapter<char> o)
- {
- binary_writer<char>(o).write_bson(j);
- }
-
-
- /*!
- @brief create a JSON value from an input in CBOR format
-
- Deserializes a given input @a i to a JSON value using the CBOR (Concise
- Binary Object Representation) serialization format.
-
- The library maps CBOR types to JSON value types as follows:
-
- CBOR type | JSON value type | first byte
- ---------------------- | --------------- | ----------
- Integer | number_unsigned | 0x00..0x17
- Unsigned integer | number_unsigned | 0x18
- Unsigned integer | number_unsigned | 0x19
- Unsigned integer | number_unsigned | 0x1A
- Unsigned integer | number_unsigned | 0x1B
- Negative integer | number_integer | 0x20..0x37
- Negative integer | number_integer | 0x38
- Negative integer | number_integer | 0x39
- Negative integer | number_integer | 0x3A
- Negative integer | number_integer | 0x3B
- Negative integer | number_integer | 0x40..0x57
- UTF-8 string | string | 0x60..0x77
- UTF-8 string | string | 0x78
- UTF-8 string | string | 0x79
- UTF-8 string | string | 0x7A
- UTF-8 string | string | 0x7B
- UTF-8 string | string | 0x7F
- array | array | 0x80..0x97
- array | array | 0x98
- array | array | 0x99
- array | array | 0x9A
- array | array | 0x9B
- array | array | 0x9F
- map | object | 0xA0..0xB7
- map | object | 0xB8
- map | object | 0xB9
- map | object | 0xBA
- map | object | 0xBB
- map | object | 0xBF
- False | `false` | 0xF4
- True | `true` | 0xF5
- Null | `null` | 0xF6
- Half-Precision Float | number_float | 0xF9
- Single-Precision Float | number_float | 0xFA
- Double-Precision Float | number_float | 0xFB
-
- @warning The mapping is **incomplete** in the sense that not all CBOR
- types can be converted to a JSON value. The following CBOR types
- are not supported and will yield parse errors (parse_error.112):
- - byte strings (0x40..0x5F)
- - date/time (0xC0..0xC1)
- - bignum (0xC2..0xC3)
- - decimal fraction (0xC4)
- - bigfloat (0xC5)
- - tagged items (0xC6..0xD4, 0xD8..0xDB)
- - expected conversions (0xD5..0xD7)
- - simple values (0xE0..0xF3, 0xF8)
- - undefined (0xF7)
-
- @warning CBOR allows map keys of any type, whereas JSON only allows
- strings as keys in object values. Therefore, CBOR maps with keys
- other than UTF-8 strings are rejected (parse_error.113).
-
- @note Any CBOR output created @ref to_cbor can be successfully parsed by
- @ref from_cbor.
-
- @param[in] i an input in CBOR format convertible to an input adapter
- @param[in] strict whether to expect the input to be consumed until EOF
- (true by default)
- @param[in] allow_exceptions whether to throw exceptions in case of a
- parse error (optional, true by default)
-
- @return deserialized JSON value; in case of a parse error and
- @a allow_exceptions set to `false`, the return value will be
- value_t::discarded.
-
- @throw parse_error.110 if the given input ends prematurely or the end of
- file was not reached when @a strict was set to true
- @throw parse_error.112 if unsupported features from CBOR were
- used in the given input @a v or if the input is not valid CBOR
- @throw parse_error.113 if a string was expected as map key, but not found
-
- @complexity Linear in the size of the input @a i.
-
- @liveexample{The example shows the deserialization of a byte vector in CBOR
- format to a JSON value.,from_cbor}
-
- @sa http://cbor.io
- @sa @ref to_cbor(const basic_json&) for the analogous serialization
- @sa @ref from_msgpack(detail::input_adapter&&, const bool, const bool) for the
- related MessagePack format
- @sa @ref from_ubjson(detail::input_adapter&&, const bool, const bool) for the
- related UBJSON format
-
- @since version 2.0.9; parameter @a start_index since 2.1.1; changed to
- consume input adapters, removed start_index parameter, and added
- @a strict parameter since 3.0.0; added @a allow_exceptions parameter
- since 3.2.0
- */
- JSON_NODISCARD
- static basic_json from_cbor(detail::input_adapter&& i,
- const bool strict = true,
- const bool allow_exceptions = true)
- {
- basic_json result;
- detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
- const bool res = binary_reader(detail::input_adapter(i)).sax_parse(input_format_t::cbor, &sdp, strict);
- return res ? result : basic_json(value_t::discarded);
- }
-
- /*!
- @copydoc from_cbor(detail::input_adapter&&, const bool, const bool)
- */
- template<typename A1, typename A2,
- detail::enable_if_t<std::is_constructible<detail::input_adapter, A1, A2>::value, int> = 0>
- JSON_NODISCARD
- static basic_json from_cbor(A1 && a1, A2 && a2,
- const bool strict = true,
- const bool allow_exceptions = true)
- {
- basic_json result;
- detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
- const bool res = binary_reader(detail::input_adapter(std::forward<A1>(a1), std::forward<A2>(a2))).sax_parse(input_format_t::cbor, &sdp, strict);
- return res ? result : basic_json(value_t::discarded);
- }
-
- /*!
- @brief create a JSON value from an input in MessagePack format
-
- Deserializes a given input @a i to a JSON value using the MessagePack
- serialization format.
-
- The library maps MessagePack types to JSON value types as follows:
-
- MessagePack type | JSON value type | first byte
- ---------------- | --------------- | ----------
- positive fixint | number_unsigned | 0x00..0x7F
- fixmap | object | 0x80..0x8F
- fixarray | array | 0x90..0x9F
- fixstr | string | 0xA0..0xBF
- nil | `null` | 0xC0
- false | `false` | 0xC2
- true | `true` | 0xC3
- float 32 | number_float | 0xCA
- float 64 | number_float | 0xCB
- uint 8 | number_unsigned | 0xCC
- uint 16 | number_unsigned | 0xCD
- uint 32 | number_unsigned | 0xCE
- uint 64 | number_unsigned | 0xCF
- int 8 | number_integer | 0xD0
- int 16 | number_integer | 0xD1
- int 32 | number_integer | 0xD2
- int 64 | number_integer | 0xD3
- str 8 | string | 0xD9
- str 16 | string | 0xDA
- str 32 | string | 0xDB
- array 16 | array | 0xDC
- array 32 | array | 0xDD
- map 16 | object | 0xDE
- map 32 | object | 0xDF
- negative fixint | number_integer | 0xE0-0xFF
-
- @warning The mapping is **incomplete** in the sense that not all
- MessagePack types can be converted to a JSON value. The following
- MessagePack types are not supported and will yield parse errors:
- - bin 8 - bin 32 (0xC4..0xC6)
- - ext 8 - ext 32 (0xC7..0xC9)
- - fixext 1 - fixext 16 (0xD4..0xD8)
-
- @note Any MessagePack output created @ref to_msgpack can be successfully
- parsed by @ref from_msgpack.
-
- @param[in] i an input in MessagePack format convertible to an input
- adapter
- @param[in] strict whether to expect the input to be consumed until EOF
- (true by default)
- @param[in] allow_exceptions whether to throw exceptions in case of a
- parse error (optional, true by default)
-
- @return deserialized JSON value; in case of a parse error and
- @a allow_exceptions set to `false`, the return value will be
- value_t::discarded.
-
- @throw parse_error.110 if the given input ends prematurely or the end of
- file was not reached when @a strict was set to true
- @throw parse_error.112 if unsupported features from MessagePack were
- used in the given input @a i or if the input is not valid MessagePack
- @throw parse_error.113 if a string was expected as map key, but not found
-
- @complexity Linear in the size of the input @a i.
-
- @liveexample{The example shows the deserialization of a byte vector in
- MessagePack format to a JSON value.,from_msgpack}
-
- @sa http://msgpack.org
- @sa @ref to_msgpack(const basic_json&) for the analogous serialization
- @sa @ref from_cbor(detail::input_adapter&&, const bool, const bool) for the
- related CBOR format
- @sa @ref from_ubjson(detail::input_adapter&&, const bool, const bool) for
- the related UBJSON format
- @sa @ref from_bson(detail::input_adapter&&, const bool, const bool) for
- the related BSON format
-
- @since version 2.0.9; parameter @a start_index since 2.1.1; changed to
- consume input adapters, removed start_index parameter, and added
- @a strict parameter since 3.0.0; added @a allow_exceptions parameter
- since 3.2.0
- */
- JSON_NODISCARD
- static basic_json from_msgpack(detail::input_adapter&& i,
- const bool strict = true,
- const bool allow_exceptions = true)
- {
- basic_json result;
- detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
- const bool res = binary_reader(detail::input_adapter(i)).sax_parse(input_format_t::msgpack, &sdp, strict);
- return res ? result : basic_json(value_t::discarded);
- }
-
- /*!
- @copydoc from_msgpack(detail::input_adapter&&, const bool, const bool)
- */
- template<typename A1, typename A2,
- detail::enable_if_t<std::is_constructible<detail::input_adapter, A1, A2>::value, int> = 0>
- JSON_NODISCARD
- static basic_json from_msgpack(A1 && a1, A2 && a2,
- const bool strict = true,
- const bool allow_exceptions = true)
- {
- basic_json result;
- detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
- const bool res = binary_reader(detail::input_adapter(std::forward<A1>(a1), std::forward<A2>(a2))).sax_parse(input_format_t::msgpack, &sdp, strict);
- return res ? result : basic_json(value_t::discarded);
- }
-
- /*!
- @brief create a JSON value from an input in UBJSON format
-
- Deserializes a given input @a i to a JSON value using the UBJSON (Universal
- Binary JSON) serialization format.
-
- The library maps UBJSON types to JSON value types as follows:
-
- UBJSON type | JSON value type | marker
- ----------- | --------------------------------------- | ------
- no-op | *no value, next value is read* | `N`
- null | `null` | `Z`
- false | `false` | `F`
- true | `true` | `T`
- float32 | number_float | `d`
- float64 | number_float | `D`
- uint8 | number_unsigned | `U`
- int8 | number_integer | `i`
- int16 | number_integer | `I`
- int32 | number_integer | `l`
- int64 | number_integer | `L`
- string | string | `S`
- char | string | `C`
- array | array (optimized values are supported) | `[`
- object | object (optimized values are supported) | `{`
-
- @note The mapping is **complete** in the sense that any UBJSON value can
- be converted to a JSON value.
-
- @param[in] i an input in UBJSON format convertible to an input adapter
- @param[in] strict whether to expect the input to be consumed until EOF
- (true by default)
- @param[in] allow_exceptions whether to throw exceptions in case of a
- parse error (optional, true by default)
-
- @return deserialized JSON value; in case of a parse error and
- @a allow_exceptions set to `false`, the return value will be
- value_t::discarded.
-
- @throw parse_error.110 if the given input ends prematurely or the end of
- file was not reached when @a strict was set to true
- @throw parse_error.112 if a parse error occurs
- @throw parse_error.113 if a string could not be parsed successfully
-
- @complexity Linear in the size of the input @a i.
-
- @liveexample{The example shows the deserialization of a byte vector in
- UBJSON format to a JSON value.,from_ubjson}
-
- @sa http://ubjson.org
- @sa @ref to_ubjson(const basic_json&, const bool, const bool) for the
- analogous serialization
- @sa @ref from_cbor(detail::input_adapter&&, const bool, const bool) for the
- related CBOR format
- @sa @ref from_msgpack(detail::input_adapter&&, const bool, const bool) for
- the related MessagePack format
- @sa @ref from_bson(detail::input_adapter&&, const bool, const bool) for
- the related BSON format
-
- @since version 3.1.0; added @a allow_exceptions parameter since 3.2.0
- */
- JSON_NODISCARD
- static basic_json from_ubjson(detail::input_adapter&& i,
- const bool strict = true,
- const bool allow_exceptions = true)
- {
- basic_json result;
- detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
- const bool res = binary_reader(detail::input_adapter(i)).sax_parse(input_format_t::ubjson, &sdp, strict);
- return res ? result : basic_json(value_t::discarded);
- }
-
- /*!
- @copydoc from_ubjson(detail::input_adapter&&, const bool, const bool)
- */
- template<typename A1, typename A2,
- detail::enable_if_t<std::is_constructible<detail::input_adapter, A1, A2>::value, int> = 0>
- JSON_NODISCARD
- static basic_json from_ubjson(A1 && a1, A2 && a2,
- const bool strict = true,
- const bool allow_exceptions = true)
- {
- basic_json result;
- detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
- const bool res = binary_reader(detail::input_adapter(std::forward<A1>(a1), std::forward<A2>(a2))).sax_parse(input_format_t::ubjson, &sdp, strict);
- return res ? result : basic_json(value_t::discarded);
- }
-
- /*!
- @brief Create a JSON value from an input in BSON format
-
- Deserializes a given input @a i to a JSON value using the BSON (Binary JSON)
- serialization format.
-
- The library maps BSON record types to JSON value types as follows:
-
- BSON type | BSON marker byte | JSON value type
- --------------- | ---------------- | ---------------------------
- double | 0x01 | number_float
- string | 0x02 | string
- document | 0x03 | object
- array | 0x04 | array
- binary | 0x05 | still unsupported
- undefined | 0x06 | still unsupported
- ObjectId | 0x07 | still unsupported
- boolean | 0x08 | boolean
- UTC Date-Time | 0x09 | still unsupported
- null | 0x0A | null
- Regular Expr. | 0x0B | still unsupported
- DB Pointer | 0x0C | still unsupported
- JavaScript Code | 0x0D | still unsupported
- Symbol | 0x0E | still unsupported
- JavaScript Code | 0x0F | still unsupported
- int32 | 0x10 | number_integer
- Timestamp | 0x11 | still unsupported
- 128-bit decimal float | 0x13 | still unsupported
- Max Key | 0x7F | still unsupported
- Min Key | 0xFF | still unsupported
-
- @warning The mapping is **incomplete**. The unsupported mappings
- are indicated in the table above.
-
- @param[in] i an input in BSON format convertible to an input adapter
- @param[in] strict whether to expect the input to be consumed until EOF
- (true by default)
- @param[in] allow_exceptions whether to throw exceptions in case of a
- parse error (optional, true by default)
-
- @return deserialized JSON value; in case of a parse error and
- @a allow_exceptions set to `false`, the return value will be
- value_t::discarded.
-
- @throw parse_error.114 if an unsupported BSON record type is encountered
-
- @complexity Linear in the size of the input @a i.
-
- @liveexample{The example shows the deserialization of a byte vector in
- BSON format to a JSON value.,from_bson}
-
- @sa http://bsonspec.org/spec.html
- @sa @ref to_bson(const basic_json&) for the analogous serialization
- @sa @ref from_cbor(detail::input_adapter&&, const bool, const bool) for the
- related CBOR format
- @sa @ref from_msgpack(detail::input_adapter&&, const bool, const bool) for
- the related MessagePack format
- @sa @ref from_ubjson(detail::input_adapter&&, const bool, const bool) for the
- related UBJSON format
- */
- JSON_NODISCARD
- static basic_json from_bson(detail::input_adapter&& i,
- const bool strict = true,
- const bool allow_exceptions = true)
- {
- basic_json result;
- detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
- const bool res = binary_reader(detail::input_adapter(i)).sax_parse(input_format_t::bson, &sdp, strict);
- return res ? result : basic_json(value_t::discarded);
- }
-
- /*!
- @copydoc from_bson(detail::input_adapter&&, const bool, const bool)
- */
- template<typename A1, typename A2,
- detail::enable_if_t<std::is_constructible<detail::input_adapter, A1, A2>::value, int> = 0>
- JSON_NODISCARD
- static basic_json from_bson(A1 && a1, A2 && a2,
- const bool strict = true,
- const bool allow_exceptions = true)
- {
- basic_json result;
- detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
- const bool res = binary_reader(detail::input_adapter(std::forward<A1>(a1), std::forward<A2>(a2))).sax_parse(input_format_t::bson, &sdp, strict);
- return res ? result : basic_json(value_t::discarded);
- }
-
-
-
- /// @}
-
- //////////////////////////
- // JSON Pointer support //
- //////////////////////////
-
- /// @name JSON Pointer functions
- /// @{
-
- /*!
- @brief access specified element via JSON Pointer
-
- Uses a JSON pointer to retrieve a reference to the respective JSON value.
- No bound checking is performed. Similar to @ref operator[](const typename
- object_t::key_type&), `null` values are created in arrays and objects if
- necessary.
-
- In particular:
- - If the JSON pointer points to an object key that does not exist, it
- is created an filled with a `null` value before a reference to it
- is returned.
- - If the JSON pointer points to an array index that does not exist, it
- is created an filled with a `null` value before a reference to it
- is returned. All indices between the current maximum and the given
- index are also filled with `null`.
- - The special value `-` is treated as a synonym for the index past the
- end.
-
- @param[in] ptr a JSON pointer
-
- @return reference to the element pointed to by @a ptr
-
- @complexity Constant.
-
- @throw parse_error.106 if an array index begins with '0'
- @throw parse_error.109 if an array index was not a number
- @throw out_of_range.404 if the JSON pointer can not be resolved
-
- @liveexample{The behavior is shown in the example.,operatorjson_pointer}
-
- @since version 2.0.0
- */
- reference operator[](const json_pointer& ptr)
- {
- return ptr.get_unchecked(this);
- }
-
- /*!
- @brief access specified element via JSON Pointer
-
- Uses a JSON pointer to retrieve a reference to the respective JSON value.
- No bound checking is performed. The function does not change the JSON
- value; no `null` values are created. In particular, the the special value
- `-` yields an exception.
-
- @param[in] ptr JSON pointer to the desired element
-
- @return const reference to the element pointed to by @a ptr
-
- @complexity Constant.
-
- @throw parse_error.106 if an array index begins with '0'
- @throw parse_error.109 if an array index was not a number
- @throw out_of_range.402 if the array index '-' is used
- @throw out_of_range.404 if the JSON pointer can not be resolved
-
- @liveexample{The behavior is shown in the example.,operatorjson_pointer_const}
-
- @since version 2.0.0
- */
- const_reference operator[](const json_pointer& ptr) const
- {
- return ptr.get_unchecked(this);
- }
-
- /*!
- @brief access specified element via JSON Pointer
-
- Returns a reference to the element at with specified JSON pointer @a ptr,
- with bounds checking.
-
- @param[in] ptr JSON pointer to the desired element
-
- @return reference to the element pointed to by @a ptr
-
- @throw parse_error.106 if an array index in the passed JSON pointer @a ptr
- begins with '0'. See example below.
-
- @throw parse_error.109 if an array index in the passed JSON pointer @a ptr
- is not a number. See example below.
-
- @throw out_of_range.401 if an array index in the passed JSON pointer @a ptr
- is out of range. See example below.
-
- @throw out_of_range.402 if the array index '-' is used in the passed JSON
- pointer @a ptr. As `at` provides checked access (and no elements are
- implicitly inserted), the index '-' is always invalid. See example below.
-
- @throw out_of_range.403 if the JSON pointer describes a key of an object
- which cannot be found. See example below.
-
- @throw out_of_range.404 if the JSON pointer @a ptr can not be resolved.
- See example below.
-
- @exceptionsafety Strong guarantee: if an exception is thrown, there are no
- changes in the JSON value.
-
- @complexity Constant.
-
- @since version 2.0.0
-
- @liveexample{The behavior is shown in the example.,at_json_pointer}
- */
- reference at(const json_pointer& ptr)
- {
- return ptr.get_checked(this);
- }
-
- /*!
- @brief access specified element via JSON Pointer
-
- Returns a const reference to the element at with specified JSON pointer @a
- ptr, with bounds checking.
-
- @param[in] ptr JSON pointer to the desired element
-
- @return reference to the element pointed to by @a ptr
-
- @throw parse_error.106 if an array index in the passed JSON pointer @a ptr
- begins with '0'. See example below.
-
- @throw parse_error.109 if an array index in the passed JSON pointer @a ptr
- is not a number. See example below.
-
- @throw out_of_range.401 if an array index in the passed JSON pointer @a ptr
- is out of range. See example below.
-
- @throw out_of_range.402 if the array index '-' is used in the passed JSON
- pointer @a ptr. As `at` provides checked access (and no elements are
- implicitly inserted), the index '-' is always invalid. See example below.
-
- @throw out_of_range.403 if the JSON pointer describes a key of an object
- which cannot be found. See example below.
-
- @throw out_of_range.404 if the JSON pointer @a ptr can not be resolved.
- See example below.
-
- @exceptionsafety Strong guarantee: if an exception is thrown, there are no
- changes in the JSON value.
-
- @complexity Constant.
-
- @since version 2.0.0
-
- @liveexample{The behavior is shown in the example.,at_json_pointer_const}
- */
- const_reference at(const json_pointer& ptr) const
- {
- return ptr.get_checked(this);
- }
-
- /*!
- @brief return flattened JSON value
-
- The function creates a JSON object whose keys are JSON pointers (see [RFC
- 6901](https://tools.ietf.org/html/rfc6901)) and whose values are all
- primitive. The original JSON value can be restored using the @ref
- unflatten() function.
-
- @return an object that maps JSON pointers to primitive values
-
- @note Empty objects and arrays are flattened to `null` and will not be
- reconstructed correctly by the @ref unflatten() function.
-
- @complexity Linear in the size the JSON value.
-
- @liveexample{The following code shows how a JSON object is flattened to an
- object whose keys consist of JSON pointers.,flatten}
-
- @sa @ref unflatten() for the reverse function
-
- @since version 2.0.0
- */
- basic_json flatten() const
- {
- basic_json result(value_t::object);
- json_pointer::flatten("", *this, result);
- return result;
- }
-
- /*!
- @brief unflatten a previously flattened JSON value
-
- The function restores the arbitrary nesting of a JSON value that has been
- flattened before using the @ref flatten() function. The JSON value must
- meet certain constraints:
- 1. The value must be an object.
- 2. The keys must be JSON pointers (see
- [RFC 6901](https://tools.ietf.org/html/rfc6901))
- 3. The mapped values must be primitive JSON types.
-
- @return the original JSON from a flattened version
-
- @note Empty objects and arrays are flattened by @ref flatten() to `null`
- values and can not unflattened to their original type. Apart from
- this example, for a JSON value `j`, the following is always true:
- `j == j.flatten().unflatten()`.
-
- @complexity Linear in the size the JSON value.
-
- @throw type_error.314 if value is not an object
- @throw type_error.315 if object values are not primitive
-
- @liveexample{The following code shows how a flattened JSON object is
- unflattened into the original nested JSON object.,unflatten}
-
- @sa @ref flatten() for the reverse function
-
- @since version 2.0.0
- */
- basic_json unflatten() const
- {
- return json_pointer::unflatten(*this);
- }
-
- /// @}
-
- //////////////////////////
- // JSON Patch functions //
- //////////////////////////
-
- /// @name JSON Patch functions
- /// @{
-
- /*!
- @brief applies a JSON patch
-
- [JSON Patch](http://jsonpatch.com) defines a JSON document structure for
- expressing a sequence of operations to apply to a JSON) document. With
- this function, a JSON Patch is applied to the current JSON value by
- executing all operations from the patch.
-
- @param[in] json_patch JSON patch document
- @return patched document
-
- @note The application of a patch is atomic: Either all operations succeed
- and the patched document is returned or an exception is thrown. In
- any case, the original value is not changed: the patch is applied
- to a copy of the value.
-
- @throw parse_error.104 if the JSON patch does not consist of an array of
- objects
-
- @throw parse_error.105 if the JSON patch is malformed (e.g., mandatory
- attributes are missing); example: `"operation add must have member path"`
-
- @throw out_of_range.401 if an array index is out of range.
-
- @throw out_of_range.403 if a JSON pointer inside the patch could not be
- resolved successfully in the current JSON value; example: `"key baz not
- found"`
-
- @throw out_of_range.405 if JSON pointer has no parent ("add", "remove",
- "move")
-
- @throw other_error.501 if "test" operation was unsuccessful
-
- @complexity Linear in the size of the JSON value and the length of the
- JSON patch. As usually only a fraction of the JSON value is affected by
- the patch, the complexity can usually be neglected.
-
- @liveexample{The following code shows how a JSON patch is applied to a
- value.,patch}
-
- @sa @ref diff -- create a JSON patch by comparing two JSON values
-
- @sa [RFC 6902 (JSON Patch)](https://tools.ietf.org/html/rfc6902)
- @sa [RFC 6901 (JSON Pointer)](https://tools.ietf.org/html/rfc6901)
-
- @since version 2.0.0
- */
- basic_json patch(const basic_json& json_patch) const
- {
- // make a working copy to apply the patch to
- basic_json result = *this;
-
- // the valid JSON Patch operations
- enum class patch_operations {add, remove, replace, move, copy, test, invalid};
-
- const auto get_op = [](const std::string & op)
- {
- if (op == "add")
- {
- return patch_operations::add;
- }
- if (op == "remove")
- {
- return patch_operations::remove;
- }
- if (op == "replace")
- {
- return patch_operations::replace;
- }
- if (op == "move")
- {
- return patch_operations::move;
- }
- if (op == "copy")
- {
- return patch_operations::copy;
- }
- if (op == "test")
- {
- return patch_operations::test;
- }
-
- return patch_operations::invalid;
- };
-
- // wrapper for "add" operation; add value at ptr
- const auto operation_add = [&result](json_pointer & ptr, basic_json val)
- {
- // adding to the root of the target document means replacing it
- if (ptr.empty())
- {
- result = val;
- return;
- }
-
- // make sure the top element of the pointer exists
- json_pointer top_pointer = ptr.top();
- if (top_pointer != ptr)
- {
- result.at(top_pointer);
- }
-
- // get reference to parent of JSON pointer ptr
- const auto last_path = ptr.back();
- ptr.pop_back();
- basic_json& parent = result[ptr];
-
- switch (parent.m_type)
- {
- case value_t::null:
- case value_t::object:
- {
- // use operator[] to add value
- parent[last_path] = val;
- break;
- }
-
- case value_t::array:
- {
- if (last_path == "-")
- {
- // special case: append to back
- parent.push_back(val);
- }
- else
- {
- const auto idx = json_pointer::array_index(last_path);
- if (JSON_UNLIKELY(static_cast<size_type>(idx) > parent.size()))
- {
- // avoid undefined behavior
- JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range"));
- }
-
- // default case: insert add offset
- parent.insert(parent.begin() + static_cast<difference_type>(idx), val);
- }
- break;
- }
-
- // if there exists a parent it cannot be primitive
- default: // LCOV_EXCL_LINE
- assert(false); // LCOV_EXCL_LINE
- }
- };
-
- // wrapper for "remove" operation; remove value at ptr
- const auto operation_remove = [&result](json_pointer & ptr)
- {
- // get reference to parent of JSON pointer ptr
- const auto last_path = ptr.back();
- ptr.pop_back();
- basic_json& parent = result.at(ptr);
-
- // remove child
- if (parent.is_object())
- {
- // perform range check
- auto it = parent.find(last_path);
- if (JSON_LIKELY(it != parent.end()))
- {
- parent.erase(it);
- }
- else
- {
- JSON_THROW(out_of_range::create(403, "key '" + last_path + "' not found"));
- }
- }
- else if (parent.is_array())
- {
- // note erase performs range check
- parent.erase(static_cast<size_type>(json_pointer::array_index(last_path)));
- }
- };
-
- // type check: top level value must be an array
- if (JSON_UNLIKELY(not json_patch.is_array()))
- {
- JSON_THROW(parse_error::create(104, 0, "JSON patch must be an array of objects"));
- }
-
- // iterate and apply the operations
- for (const auto& val : json_patch)
- {
- // wrapper to get a value for an operation
- const auto get_value = [&val](const std::string & op,
- const std::string & member,
- bool string_type) -> basic_json &
- {
- // find value
- auto it = val.m_value.object->find(member);
-
- // context-sensitive error message
- const auto error_msg = (op == "op") ? "operation" : "operation '" + op + "'";
-
- // check if desired value is present
- if (JSON_UNLIKELY(it == val.m_value.object->end()))
- {
- JSON_THROW(parse_error::create(105, 0, error_msg + " must have member '" + member + "'"));
- }
-
- // check if result is of type string
- if (JSON_UNLIKELY(string_type and not it->second.is_string()))
- {
- JSON_THROW(parse_error::create(105, 0, error_msg + " must have string member '" + member + "'"));
- }
-
- // no error: return value
- return it->second;
- };
-
- // type check: every element of the array must be an object
- if (JSON_UNLIKELY(not val.is_object()))
- {
- JSON_THROW(parse_error::create(104, 0, "JSON patch must be an array of objects"));
- }
-
- // collect mandatory members
- const std::string op = get_value("op", "op", true);
- const std::string path = get_value(op, "path", true);
- json_pointer ptr(path);
-
- switch (get_op(op))
- {
- case patch_operations::add:
- {
- operation_add(ptr, get_value("add", "value", false));
- break;
- }
-
- case patch_operations::remove:
- {
- operation_remove(ptr);
- break;
- }
-
- case patch_operations::replace:
- {
- // the "path" location must exist - use at()
- result.at(ptr) = get_value("replace", "value", false);
- break;
- }
-
- case patch_operations::move:
- {
- const std::string from_path = get_value("move", "from", true);
- json_pointer from_ptr(from_path);
-
- // the "from" location must exist - use at()
- basic_json v = result.at(from_ptr);
-
- // The move operation is functionally identical to a
- // "remove" operation on the "from" location, followed
- // immediately by an "add" operation at the target
- // location with the value that was just removed.
- operation_remove(from_ptr);
- operation_add(ptr, v);
- break;
- }
-
- case patch_operations::copy:
- {
- const std::string from_path = get_value("copy", "from", true);
- const json_pointer from_ptr(from_path);
-
- // the "from" location must exist - use at()
- basic_json v = result.at(from_ptr);
-
- // The copy is functionally identical to an "add"
- // operation at the target location using the value
- // specified in the "from" member.
- operation_add(ptr, v);
- break;
- }
-
- case patch_operations::test:
- {
- bool success = false;
- JSON_TRY
- {
- // check if "value" matches the one at "path"
- // the "path" location must exist - use at()
- success = (result.at(ptr) == get_value("test", "value", false));
- }
- JSON_INTERNAL_CATCH (out_of_range&)
- {
- // ignore out of range errors: success remains false
- }
-
- // throw an exception if test fails
- if (JSON_UNLIKELY(not success))
- {
- JSON_THROW(other_error::create(501, "unsuccessful: " + val.dump()));
- }
-
- break;
- }
-
- default:
- {
- // op must be "add", "remove", "replace", "move", "copy", or
- // "test"
- JSON_THROW(parse_error::create(105, 0, "operation value '" + op + "' is invalid"));
- }
- }
- }
-
- return result;
- }
-
- /*!
- @brief creates a diff as a JSON patch
-
- Creates a [JSON Patch](http://jsonpatch.com) so that value @a source can
- be changed into the value @a target by calling @ref patch function.
-
- @invariant For two JSON values @a source and @a target, the following code
- yields always `true`:
- @code {.cpp}
- source.patch(diff(source, target)) == target;
- @endcode
-
- @note Currently, only `remove`, `add`, and `replace` operations are
- generated.
-
- @param[in] source JSON value to compare from
- @param[in] target JSON value to compare against
- @param[in] path helper value to create JSON pointers
-
- @return a JSON patch to convert the @a source to @a target
-
- @complexity Linear in the lengths of @a source and @a target.
-
- @liveexample{The following code shows how a JSON patch is created as a
- diff for two JSON values.,diff}
-
- @sa @ref patch -- apply a JSON patch
- @sa @ref merge_patch -- apply a JSON Merge Patch
-
- @sa [RFC 6902 (JSON Patch)](https://tools.ietf.org/html/rfc6902)
-
- @since version 2.0.0
- */
- JSON_NODISCARD
- static basic_json diff(const basic_json& source, const basic_json& target,
- const std::string& path = "")
- {
- // the patch
- basic_json result(value_t::array);
-
- // if the values are the same, return empty patch
- if (source == target)
- {
- return result;
- }
-
- if (source.type() != target.type())
- {
- // different types: replace value
- result.push_back(
- {
- {"op", "replace"}, {"path", path}, {"value", target}
- });
- return result;
- }
-
- switch (source.type())
- {
- case value_t::array:
- {
- // first pass: traverse common elements
- std::size_t i = 0;
- while (i < source.size() and i < target.size())
- {
- // recursive call to compare array values at index i
- auto temp_diff = diff(source[i], target[i], path + "/" + std::to_string(i));
- result.insert(result.end(), temp_diff.begin(), temp_diff.end());
- ++i;
- }
-
- // i now reached the end of at least one array
- // in a second pass, traverse the remaining elements
-
- // remove my remaining elements
- const auto end_index = static_cast<difference_type>(result.size());
- while (i < source.size())
- {
- // add operations in reverse order to avoid invalid
- // indices
- result.insert(result.begin() + end_index, object(
- {
- {"op", "remove"},
- {"path", path + "/" + std::to_string(i)}
- }));
- ++i;
- }
-
- // add other remaining elements
- while (i < target.size())
- {
- result.push_back(
- {
- {"op", "add"},
- {"path", path + "/" + std::to_string(i)},
- {"value", target[i]}
- });
- ++i;
- }
-
- break;
- }
-
- case value_t::object:
- {
- // first pass: traverse this object's elements
- for (auto it = source.cbegin(); it != source.cend(); ++it)
- {
- // escape the key name to be used in a JSON patch
- const auto key = json_pointer::escape(it.key());
-
- if (target.find(it.key()) != target.end())
- {
- // recursive call to compare object values at key it
- auto temp_diff = diff(it.value(), target[it.key()], path + "/" + key);
- result.insert(result.end(), temp_diff.begin(), temp_diff.end());
- }
- else
- {
- // found a key that is not in o -> remove it
- result.push_back(object(
- {
- {"op", "remove"}, {"path", path + "/" + key}
- }));
- }
- }
-
- // second pass: traverse other object's elements
- for (auto it = target.cbegin(); it != target.cend(); ++it)
- {
- if (source.find(it.key()) == source.end())
- {
- // found a key that is not in this -> add it
- const auto key = json_pointer::escape(it.key());
- result.push_back(
- {
- {"op", "add"}, {"path", path + "/" + key},
- {"value", it.value()}
- });
- }
- }
-
- break;
- }
-
- default:
- {
- // both primitive type: replace value
- result.push_back(
- {
- {"op", "replace"}, {"path", path}, {"value", target}
- });
- break;
- }
- }
-
- return result;
- }
-
- /// @}
-
- ////////////////////////////////
- // JSON Merge Patch functions //
- ////////////////////////////////
-
- /// @name JSON Merge Patch functions
- /// @{
-
- /*!
- @brief applies a JSON Merge Patch
-
- The merge patch format is primarily intended for use with the HTTP PATCH
- method as a means of describing a set of modifications to a target
- resource's content. This function applies a merge patch to the current
- JSON value.
-
- The function implements the following algorithm from Section 2 of
- [RFC 7396 (JSON Merge Patch)](https://tools.ietf.org/html/rfc7396):
-
- ```
- define MergePatch(Target, Patch):
- if Patch is an Object:
- if Target is not an Object:
- Target = {} // Ignore the contents and set it to an empty Object
- for each Name/Value pair in Patch:
- if Value is null:
- if Name exists in Target:
- remove the Name/Value pair from Target
- else:
- Target[Name] = MergePatch(Target[Name], Value)
- return Target
- else:
- return Patch
- ```
-
- Thereby, `Target` is the current object; that is, the patch is applied to
- the current value.
-
- @param[in] apply_patch the patch to apply
-
- @complexity Linear in the lengths of @a patch.
-
- @liveexample{The following code shows how a JSON Merge Patch is applied to
- a JSON document.,merge_patch}
-
- @sa @ref patch -- apply a JSON patch
- @sa [RFC 7396 (JSON Merge Patch)](https://tools.ietf.org/html/rfc7396)
-
- @since version 3.0.0
- */
- void merge_patch(const basic_json& apply_patch)
- {
- if (apply_patch.is_object())
- {
- if (not is_object())
- {
- *this = object();
- }
- for (auto it = apply_patch.begin(); it != apply_patch.end(); ++it)
- {
- if (it.value().is_null())
- {
- erase(it.key());
- }
- else
- {
- operator[](it.key()).merge_patch(it.value());
- }
- }
- }
- else
- {
- *this = apply_patch;
- }
- }
-
- /// @}
-};
-} // namespace nlohmann
-
-///////////////////////
-// nonmember support //
-///////////////////////
-
-// specialization of std::swap, and std::hash
-namespace std
-{
-
-/// hash value for JSON objects
-template<>
-struct hash<nlohmann::json>
-{
- /*!
- @brief return a hash value for a JSON object
-
- @since version 1.0.0
- */
- std::size_t operator()(const nlohmann::json& j) const
- {
- // a naive hashing via the string representation
- const auto& h = hash<nlohmann::json::string_t>();
- return h(j.dump());
- }
-};
-
-/// specialization for std::less<value_t>
-/// @note: do not remove the space after '<',
-/// see https://github.com/nlohmann/json/pull/679
-template<>
-struct less< ::nlohmann::detail::value_t>
-{
- /*!
- @brief compare two value_t enum values
- @since version 3.0.0
- */
- bool operator()(nlohmann::detail::value_t lhs,
- nlohmann::detail::value_t rhs) const noexcept
- {
- return nlohmann::detail::operator<(lhs, rhs);
- }
-};
-
-/*!
-@brief exchanges the values of two JSON objects
-
-@since version 1.0.0
-*/
-template<>
-inline void swap<nlohmann::json>(nlohmann::json& j1, nlohmann::json& j2) noexcept(
- is_nothrow_move_constructible<nlohmann::json>::value and
- is_nothrow_move_assignable<nlohmann::json>::value
-)
-{
- j1.swap(j2);
-}
-
-} // namespace std
-
-/*!
-@brief user-defined string literal for JSON values
-
-This operator implements a user-defined string literal for JSON objects. It
-can be used by adding `"_json"` to a string literal and returns a JSON object
-if no parse error occurred.
-
-@param[in] s a string representation of a JSON object
-@param[in] n the length of string @a s
-@return a JSON object
-
-@since version 1.0.0
-*/
-inline nlohmann::json operator "" _json(const char* s, std::size_t n)
-{
- return nlohmann::json::parse(s, s + n);
-}
-
-/*!
-@brief user-defined string literal for JSON pointer
-
-This operator implements a user-defined string literal for JSON Pointers. It
-can be used by adding `"_json_pointer"` to a string literal and returns a JSON pointer
-object if no parse error occurred.
-
-@param[in] s a string representation of a JSON Pointer
-@param[in] n the length of string @a s
-@return a JSON pointer object
-
-@since version 2.0.0
-*/
-inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std::size_t n)
-{
- return nlohmann::json::json_pointer(std::string(s, n));
-}
-
-// #include <nlohmann/detail/macro_unscope.hpp>
-
-
-// restore GCC/clang diagnostic settings
-#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
- #pragma GCC diagnostic pop
-#endif
-#if defined(__clang__)
- #pragma GCC diagnostic pop
-#endif
-
-// clean up
-#undef JSON_INTERNAL_CATCH
-#undef JSON_CATCH
-#undef JSON_THROW
-#undef JSON_TRY
-#undef JSON_LIKELY
-#undef JSON_UNLIKELY
-#undef JSON_DEPRECATED
-#undef JSON_NODISCARD
-#undef JSON_HAS_CPP_14
-#undef JSON_HAS_CPP_17
-#undef NLOHMANN_BASIC_JSON_TPL_DECLARATION
-#undef NLOHMANN_BASIC_JSON_TPL
-
-
-#endif // INCLUDE_NLOHMANN_JSON_HPP_
+/*
+ __ _____ _____ _____
+ __| | __| | | | JSON for Modern C++
+| | |__ | | | | | | version 3.6.1
+|_____|_____|_____|_|___| https://github.com/nlohmann/json
+
+Licensed under the MIT License <http://opensource.org/licenses/MIT>.
+SPDX-License-Identifier: MIT
+Copyright (c) 2013-2019 Niels Lohmann <http://nlohmann.me>.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*/
+
+#ifndef INCLUDE_NLOHMANN_JSON_HPP_
+#define INCLUDE_NLOHMANN_JSON_HPP_
+
+#define NLOHMANN_JSON_VERSION_MAJOR 3
+#define NLOHMANN_JSON_VERSION_MINOR 6
+#define NLOHMANN_JSON_VERSION_PATCH 1
+
+#include <algorithm> // all_of, find, for_each
+#include <cassert> // assert
+#include <ciso646> // and, not, or
+#include <cstddef> // nullptr_t, ptrdiff_t, size_t
+#include <functional> // hash, less
+#include <initializer_list> // initializer_list
+#include <iosfwd> // istream, ostream
+#include <iterator> // random_access_iterator_tag
+#include <memory> // unique_ptr
+#include <numeric> // accumulate
+#include <string> // string, stoi, to_string
+#include <utility> // declval, forward, move, pair, swap
+#include <vector> // vector
+
+// #include <nlohmann/adl_serializer.hpp>
+
+
+#include <utility>
+
+// #include <nlohmann/detail/conversions/from_json.hpp>
+
+
+#include <algorithm> // transform
+#include <array> // array
+#include <ciso646> // and, not
+#include <forward_list> // forward_list
+#include <iterator> // inserter, front_inserter, end
+#include <map> // map
+#include <string> // string
+#include <tuple> // tuple, make_tuple
+#include <type_traits> // is_arithmetic, is_same, is_enum, underlying_type, is_convertible
+#include <unordered_map> // unordered_map
+#include <utility> // pair, declval
+#include <valarray> // valarray
+
+// #include <nlohmann/detail/exceptions.hpp>
+
+
+#include <exception> // exception
+#include <stdexcept> // runtime_error
+#include <string> // to_string
+
+// #include <nlohmann/detail/input/position_t.hpp>
+
+
+#include <cstddef> // size_t
+
+namespace nlohmann
+{
+namespace detail
+{
+/// struct to capture the start position of the current token
+struct position_t
+{
+ /// the total number of characters read
+ std::size_t chars_read_total = 0;
+ /// the number of characters read in the current line
+ std::size_t chars_read_current_line = 0;
+ /// the number of lines read
+ std::size_t lines_read = 0;
+
+ /// conversion to size_t to preserve SAX interface
+ constexpr operator size_t() const
+ {
+ return chars_read_total;
+ }
+};
+
+} // namespace detail
+} // namespace nlohmann
+
+
+namespace nlohmann
+{
+namespace detail
+{
+////////////////
+// exceptions //
+////////////////
+
+/*!
+@brief general exception of the @ref basic_json class
+
+This class is an extension of `std::exception` objects with a member @a id for
+exception ids. It is used as the base class for all exceptions thrown by the
+@ref basic_json class. This class can hence be used as "wildcard" to catch
+exceptions.
+
+Subclasses:
+- @ref parse_error for exceptions indicating a parse error
+- @ref invalid_iterator for exceptions indicating errors with iterators
+- @ref type_error for exceptions indicating executing a member function with
+ a wrong type
+- @ref out_of_range for exceptions indicating access out of the defined range
+- @ref other_error for exceptions indicating other library errors
+
+@internal
+@note To have nothrow-copy-constructible exceptions, we internally use
+ `std::runtime_error` which can cope with arbitrary-length error messages.
+ Intermediate strings are built with static functions and then passed to
+ the actual constructor.
+@endinternal
+
+@liveexample{The following code shows how arbitrary library exceptions can be
+caught.,exception}
+
+@since version 3.0.0
+*/
+class exception : public std::exception
+{
+ public:
+ /// returns the explanatory string
+ const char* what() const noexcept override
+ {
+ return m.what();
+ }
+
+ /// the id of the exception
+ const int id;
+
+ protected:
+ exception(int id_, const char* what_arg) : id(id_), m(what_arg) {}
+
+ static std::string name(const std::string& ename, int id_)
+ {
+ return "[json.exception." + ename + "." + std::to_string(id_) + "] ";
+ }
+
+ private:
+ /// an exception object as storage for error messages
+ std::runtime_error m;
+};
+
+/*!
+@brief exception indicating a parse error
+
+This exception is thrown by the library when a parse error occurs. Parse errors
+can occur during the deserialization of JSON text, CBOR, MessagePack, as well
+as when using JSON Patch.
+
+Member @a byte holds the byte index of the last read character in the input
+file.
+
+Exceptions have ids 1xx.
+
+name / id | example message | description
+------------------------------ | --------------- | -------------------------
+json.exception.parse_error.101 | parse error at 2: unexpected end of input; expected string literal | This error indicates a syntax error while deserializing a JSON text. The error message describes that an unexpected token (character) was encountered, and the member @a byte indicates the error position.
+json.exception.parse_error.102 | parse error at 14: missing or wrong low surrogate | JSON uses the `\uxxxx` format to describe Unicode characters. Code points above above 0xFFFF are split into two `\uxxxx` entries ("surrogate pairs"). This error indicates that the surrogate pair is incomplete or contains an invalid code point.
+json.exception.parse_error.103 | parse error: code points above 0x10FFFF are invalid | Unicode supports code points up to 0x10FFFF. Code points above 0x10FFFF are invalid.
+json.exception.parse_error.104 | parse error: JSON patch must be an array of objects | [RFC 6902](https://tools.ietf.org/html/rfc6902) requires a JSON Patch document to be a JSON document that represents an array of objects.
+json.exception.parse_error.105 | parse error: operation must have string member 'op' | An operation of a JSON Patch document must contain exactly one "op" member, whose value indicates the operation to perform. Its value must be one of "add", "remove", "replace", "move", "copy", or "test"; other values are errors.
+json.exception.parse_error.106 | parse error: array index '01' must not begin with '0' | An array index in a JSON Pointer ([RFC 6901](https://tools.ietf.org/html/rfc6901)) may be `0` or any number without a leading `0`.
+json.exception.parse_error.107 | parse error: JSON pointer must be empty or begin with '/' - was: 'foo' | A JSON Pointer must be a Unicode string containing a sequence of zero or more reference tokens, each prefixed by a `/` character.
+json.exception.parse_error.108 | parse error: escape character '~' must be followed with '0' or '1' | In a JSON Pointer, only `~0` and `~1` are valid escape sequences.
+json.exception.parse_error.109 | parse error: array index 'one' is not a number | A JSON Pointer array index must be a number.
+json.exception.parse_error.110 | parse error at 1: cannot read 2 bytes from vector | When parsing CBOR or MessagePack, the byte vector ends before the complete value has been read.
+json.exception.parse_error.112 | parse error at 1: error reading CBOR; last byte: 0xF8 | Not all types of CBOR or MessagePack are supported. This exception occurs if an unsupported byte was read.
+json.exception.parse_error.113 | parse error at 2: expected a CBOR string; last byte: 0x98 | While parsing a map key, a value that is not a string has been read.
+json.exception.parse_error.114 | parse error: Unsupported BSON record type 0x0F | The parsing of the corresponding BSON record type is not implemented (yet).
+
+@note For an input with n bytes, 1 is the index of the first character and n+1
+ is the index of the terminating null byte or the end of file. This also
+ holds true when reading a byte vector (CBOR or MessagePack).
+
+@liveexample{The following code shows how a `parse_error` exception can be
+caught.,parse_error}
+
+@sa - @ref exception for the base class of the library exceptions
+@sa - @ref invalid_iterator for exceptions indicating errors with iterators
+@sa - @ref type_error for exceptions indicating executing a member function with
+ a wrong type
+@sa - @ref out_of_range for exceptions indicating access out of the defined range
+@sa - @ref other_error for exceptions indicating other library errors
+
+@since version 3.0.0
+*/
+class parse_error : public exception
+{
+ public:
+ /*!
+ @brief create a parse error exception
+ @param[in] id_ the id of the exception
+ @param[in] pos the position where the error occurred (or with
+ chars_read_total=0 if the position cannot be
+ determined)
+ @param[in] what_arg the explanatory string
+ @return parse_error object
+ */
+ static parse_error create(int id_, const position_t& pos, const std::string& what_arg)
+ {
+ std::string w = exception::name("parse_error", id_) + "parse error" +
+ position_string(pos) + ": " + what_arg;
+ return parse_error(id_, pos.chars_read_total, w.c_str());
+ }
+
+ static parse_error create(int id_, std::size_t byte_, const std::string& what_arg)
+ {
+ std::string w = exception::name("parse_error", id_) + "parse error" +
+ (byte_ != 0 ? (" at byte " + std::to_string(byte_)) : "") +
+ ": " + what_arg;
+ return parse_error(id_, byte_, w.c_str());
+ }
+
+ /*!
+ @brief byte index of the parse error
+
+ The byte index of the last read character in the input file.
+
+ @note For an input with n bytes, 1 is the index of the first character and
+ n+1 is the index of the terminating null byte or the end of file.
+ This also holds true when reading a byte vector (CBOR or MessagePack).
+ */
+ const std::size_t byte;
+
+ private:
+ parse_error(int id_, std::size_t byte_, const char* what_arg)
+ : exception(id_, what_arg), byte(byte_) {}
+
+ static std::string position_string(const position_t& pos)
+ {
+ return " at line " + std::to_string(pos.lines_read + 1) +
+ ", column " + std::to_string(pos.chars_read_current_line);
+ }
+};
+
+/*!
+@brief exception indicating errors with iterators
+
+This exception is thrown if iterators passed to a library function do not match
+the expected semantics.
+
+Exceptions have ids 2xx.
+
+name / id | example message | description
+----------------------------------- | --------------- | -------------------------
+json.exception.invalid_iterator.201 | iterators are not compatible | The iterators passed to constructor @ref basic_json(InputIT first, InputIT last) are not compatible, meaning they do not belong to the same container. Therefore, the range (@a first, @a last) is invalid.
+json.exception.invalid_iterator.202 | iterator does not fit current value | In an erase or insert function, the passed iterator @a pos does not belong to the JSON value for which the function was called. It hence does not define a valid position for the deletion/insertion.
+json.exception.invalid_iterator.203 | iterators do not fit current value | Either iterator passed to function @ref erase(IteratorType first, IteratorType last) does not belong to the JSON value from which values shall be erased. It hence does not define a valid range to delete values from.
+json.exception.invalid_iterator.204 | iterators out of range | When an iterator range for a primitive type (number, boolean, or string) is passed to a constructor or an erase function, this range has to be exactly (@ref begin(), @ref end()), because this is the only way the single stored value is expressed. All other ranges are invalid.
+json.exception.invalid_iterator.205 | iterator out of range | When an iterator for a primitive type (number, boolean, or string) is passed to an erase function, the iterator has to be the @ref begin() iterator, because it is the only way to address the stored value. All other iterators are invalid.
+json.exception.invalid_iterator.206 | cannot construct with iterators from null | The iterators passed to constructor @ref basic_json(InputIT first, InputIT last) belong to a JSON null value and hence to not define a valid range.
+json.exception.invalid_iterator.207 | cannot use key() for non-object iterators | The key() member function can only be used on iterators belonging to a JSON object, because other types do not have a concept of a key.
+json.exception.invalid_iterator.208 | cannot use operator[] for object iterators | The operator[] to specify a concrete offset cannot be used on iterators belonging to a JSON object, because JSON objects are unordered.
+json.exception.invalid_iterator.209 | cannot use offsets with object iterators | The offset operators (+, -, +=, -=) cannot be used on iterators belonging to a JSON object, because JSON objects are unordered.
+json.exception.invalid_iterator.210 | iterators do not fit | The iterator range passed to the insert function are not compatible, meaning they do not belong to the same container. Therefore, the range (@a first, @a last) is invalid.
+json.exception.invalid_iterator.211 | passed iterators may not belong to container | The iterator range passed to the insert function must not be a subrange of the container to insert to.
+json.exception.invalid_iterator.212 | cannot compare iterators of different containers | When two iterators are compared, they must belong to the same container.
+json.exception.invalid_iterator.213 | cannot compare order of object iterators | The order of object iterators cannot be compared, because JSON objects are unordered.
+json.exception.invalid_iterator.214 | cannot get value | Cannot get value for iterator: Either the iterator belongs to a null value or it is an iterator to a primitive type (number, boolean, or string), but the iterator is different to @ref begin().
+
+@liveexample{The following code shows how an `invalid_iterator` exception can be
+caught.,invalid_iterator}
+
+@sa - @ref exception for the base class of the library exceptions
+@sa - @ref parse_error for exceptions indicating a parse error
+@sa - @ref type_error for exceptions indicating executing a member function with
+ a wrong type
+@sa - @ref out_of_range for exceptions indicating access out of the defined range
+@sa - @ref other_error for exceptions indicating other library errors
+
+@since version 3.0.0
+*/
+class invalid_iterator : public exception
+{
+ public:
+ static invalid_iterator create(int id_, const std::string& what_arg)
+ {
+ std::string w = exception::name("invalid_iterator", id_) + what_arg;
+ return invalid_iterator(id_, w.c_str());
+ }
+
+ private:
+ invalid_iterator(int id_, const char* what_arg)
+ : exception(id_, what_arg) {}
+};
+
+/*!
+@brief exception indicating executing a member function with a wrong type
+
+This exception is thrown in case of a type error; that is, a library function is
+executed on a JSON value whose type does not match the expected semantics.
+
+Exceptions have ids 3xx.
+
+name / id | example message | description
+----------------------------- | --------------- | -------------------------
+json.exception.type_error.301 | cannot create object from initializer list | To create an object from an initializer list, the initializer list must consist only of a list of pairs whose first element is a string. When this constraint is violated, an array is created instead.
+json.exception.type_error.302 | type must be object, but is array | During implicit or explicit value conversion, the JSON type must be compatible to the target type. For instance, a JSON string can only be converted into string types, but not into numbers or boolean types.
+json.exception.type_error.303 | incompatible ReferenceType for get_ref, actual type is object | To retrieve a reference to a value stored in a @ref basic_json object with @ref get_ref, the type of the reference must match the value type. For instance, for a JSON array, the @a ReferenceType must be @ref array_t &.
+json.exception.type_error.304 | cannot use at() with string | The @ref at() member functions can only be executed for certain JSON types.
+json.exception.type_error.305 | cannot use operator[] with string | The @ref operator[] member functions can only be executed for certain JSON types.
+json.exception.type_error.306 | cannot use value() with string | The @ref value() member functions can only be executed for certain JSON types.
+json.exception.type_error.307 | cannot use erase() with string | The @ref erase() member functions can only be executed for certain JSON types.
+json.exception.type_error.308 | cannot use push_back() with string | The @ref push_back() and @ref operator+= member functions can only be executed for certain JSON types.
+json.exception.type_error.309 | cannot use insert() with | The @ref insert() member functions can only be executed for certain JSON types.
+json.exception.type_error.310 | cannot use swap() with number | The @ref swap() member functions can only be executed for certain JSON types.
+json.exception.type_error.311 | cannot use emplace_back() with string | The @ref emplace_back() member function can only be executed for certain JSON types.
+json.exception.type_error.312 | cannot use update() with string | The @ref update() member functions can only be executed for certain JSON types.
+json.exception.type_error.313 | invalid value to unflatten | The @ref unflatten function converts an object whose keys are JSON Pointers back into an arbitrary nested JSON value. The JSON Pointers must not overlap, because then the resulting value would not be well defined.
+json.exception.type_error.314 | only objects can be unflattened | The @ref unflatten function only works for an object whose keys are JSON Pointers.
+json.exception.type_error.315 | values in object must be primitive | The @ref unflatten function only works for an object whose keys are JSON Pointers and whose values are primitive.
+json.exception.type_error.316 | invalid UTF-8 byte at index 10: 0x7E | The @ref dump function only works with UTF-8 encoded strings; that is, if you assign a `std::string` to a JSON value, make sure it is UTF-8 encoded. |
+json.exception.type_error.317 | JSON value cannot be serialized to requested format | The dynamic type of the object cannot be represented in the requested serialization format (e.g. a raw `true` or `null` JSON object cannot be serialized to BSON) |
+
+@liveexample{The following code shows how a `type_error` exception can be
+caught.,type_error}
+
+@sa - @ref exception for the base class of the library exceptions
+@sa - @ref parse_error for exceptions indicating a parse error
+@sa - @ref invalid_iterator for exceptions indicating errors with iterators
+@sa - @ref out_of_range for exceptions indicating access out of the defined range
+@sa - @ref other_error for exceptions indicating other library errors
+
+@since version 3.0.0
+*/
+class type_error : public exception
+{
+ public:
+ static type_error create(int id_, const std::string& what_arg)
+ {
+ std::string w = exception::name("type_error", id_) + what_arg;
+ return type_error(id_, w.c_str());
+ }
+
+ private:
+ type_error(int id_, const char* what_arg) : exception(id_, what_arg) {}
+};
+
+/*!
+@brief exception indicating access out of the defined range
+
+This exception is thrown in case a library function is called on an input
+parameter that exceeds the expected range, for instance in case of array
+indices or nonexisting object keys.
+
+Exceptions have ids 4xx.
+
+name / id | example message | description
+------------------------------- | --------------- | -------------------------
+json.exception.out_of_range.401 | array index 3 is out of range | The provided array index @a i is larger than @a size-1.
+json.exception.out_of_range.402 | array index '-' (3) is out of range | The special array index `-` in a JSON Pointer never describes a valid element of the array, but the index past the end. That is, it can only be used to add elements at this position, but not to read it.
+json.exception.out_of_range.403 | key 'foo' not found | The provided key was not found in the JSON object.
+json.exception.out_of_range.404 | unresolved reference token 'foo' | A reference token in a JSON Pointer could not be resolved.
+json.exception.out_of_range.405 | JSON pointer has no parent | The JSON Patch operations 'remove' and 'add' can not be applied to the root element of the JSON value.
+json.exception.out_of_range.406 | number overflow parsing '10E1000' | A parsed number could not be stored as without changing it to NaN or INF.
+json.exception.out_of_range.407 | number overflow serializing '9223372036854775808' | UBJSON and BSON only support integer numbers up to 9223372036854775807. |
+json.exception.out_of_range.408 | excessive array size: 8658170730974374167 | The size (following `#`) of an UBJSON array or object exceeds the maximal capacity. |
+json.exception.out_of_range.409 | BSON key cannot contain code point U+0000 (at byte 2) | Key identifiers to be serialized to BSON cannot contain code point U+0000, since the key is stored as zero-terminated c-string |
+
+@liveexample{The following code shows how an `out_of_range` exception can be
+caught.,out_of_range}
+
+@sa - @ref exception for the base class of the library exceptions
+@sa - @ref parse_error for exceptions indicating a parse error
+@sa - @ref invalid_iterator for exceptions indicating errors with iterators
+@sa - @ref type_error for exceptions indicating executing a member function with
+ a wrong type
+@sa - @ref other_error for exceptions indicating other library errors
+
+@since version 3.0.0
+*/
+class out_of_range : public exception
+{
+ public:
+ static out_of_range create(int id_, const std::string& what_arg)
+ {
+ std::string w = exception::name("out_of_range", id_) + what_arg;
+ return out_of_range(id_, w.c_str());
+ }
+
+ private:
+ out_of_range(int id_, const char* what_arg) : exception(id_, what_arg) {}
+};
+
+/*!
+@brief exception indicating other library errors
+
+This exception is thrown in case of errors that cannot be classified with the
+other exception types.
+
+Exceptions have ids 5xx.
+
+name / id | example message | description
+------------------------------ | --------------- | -------------------------
+json.exception.other_error.501 | unsuccessful: {"op":"test","path":"/baz", "value":"bar"} | A JSON Patch operation 'test' failed. The unsuccessful operation is also printed.
+
+@sa - @ref exception for the base class of the library exceptions
+@sa - @ref parse_error for exceptions indicating a parse error
+@sa - @ref invalid_iterator for exceptions indicating errors with iterators
+@sa - @ref type_error for exceptions indicating executing a member function with
+ a wrong type
+@sa - @ref out_of_range for exceptions indicating access out of the defined range
+
+@liveexample{The following code shows how an `other_error` exception can be
+caught.,other_error}
+
+@since version 3.0.0
+*/
+class other_error : public exception
+{
+ public:
+ static other_error create(int id_, const std::string& what_arg)
+ {
+ std::string w = exception::name("other_error", id_) + what_arg;
+ return other_error(id_, w.c_str());
+ }
+
+ private:
+ other_error(int id_, const char* what_arg) : exception(id_, what_arg) {}
+};
+} // namespace detail
+} // namespace nlohmann
+
+// #include <nlohmann/detail/macro_scope.hpp>
+
+
+#include <utility> // pair
+
+// This file contains all internal macro definitions
+// You MUST include macro_unscope.hpp at the end of json.hpp to undef all of them
+
+// exclude unsupported compilers
+#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK)
+ #if defined(__clang__)
+ #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400
+ #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers"
+ #endif
+ #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER))
+ #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800
+ #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers"
+ #endif
+ #endif
+#endif
+
+// disable float-equal warnings on GCC/clang
+#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
+ #pragma GCC diagnostic push
+ #pragma GCC diagnostic ignored "-Wfloat-equal"
+#endif
+
+// disable documentation warnings on clang
+#if defined(__clang__)
+ #pragma GCC diagnostic push
+ #pragma GCC diagnostic ignored "-Wdocumentation"
+#endif
+
+// allow for portable deprecation warnings
+#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
+ #define JSON_DEPRECATED __attribute__((deprecated))
+#elif defined(_MSC_VER)
+ #define JSON_DEPRECATED __declspec(deprecated)
+#else
+ #define JSON_DEPRECATED
+#endif
+
+// allow for portable nodiscard warnings
+#if defined(__has_cpp_attribute)
+ #if __has_cpp_attribute(nodiscard)
+ #define JSON_NODISCARD [[nodiscard]]
+ #elif __has_cpp_attribute(gnu::warn_unused_result)
+ #define JSON_NODISCARD [[gnu::warn_unused_result]]
+ #else
+ #define JSON_NODISCARD
+ #endif
+#else
+ #define JSON_NODISCARD
+#endif
+
+// allow to disable exceptions
+#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION)
+ #define JSON_THROW(exception) throw exception
+ #define JSON_TRY try
+ #define JSON_CATCH(exception) catch(exception)
+ #define JSON_INTERNAL_CATCH(exception) catch(exception)
+#else
+ #include <cstdlib>
+ #define JSON_THROW(exception) std::abort()
+ #define JSON_TRY if(true)
+ #define JSON_CATCH(exception) if(false)
+ #define JSON_INTERNAL_CATCH(exception) if(false)
+#endif
+
+// override exception macros
+#if defined(JSON_THROW_USER)
+ #undef JSON_THROW
+ #define JSON_THROW JSON_THROW_USER
+#endif
+#if defined(JSON_TRY_USER)
+ #undef JSON_TRY
+ #define JSON_TRY JSON_TRY_USER
+#endif
+#if defined(JSON_CATCH_USER)
+ #undef JSON_CATCH
+ #define JSON_CATCH JSON_CATCH_USER
+ #undef JSON_INTERNAL_CATCH
+ #define JSON_INTERNAL_CATCH JSON_CATCH_USER
+#endif
+#if defined(JSON_INTERNAL_CATCH_USER)
+ #undef JSON_INTERNAL_CATCH
+ #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER
+#endif
+
+// manual branch prediction
+#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
+ #define JSON_LIKELY(x) __builtin_expect(x, 1)
+ #define JSON_UNLIKELY(x) __builtin_expect(x, 0)
+#else
+ #define JSON_LIKELY(x) x
+ #define JSON_UNLIKELY(x) x
+#endif
+
+// C++ language standard detection
+#if (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464
+ #define JSON_HAS_CPP_17
+ #define JSON_HAS_CPP_14
+#elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
+ #define JSON_HAS_CPP_14
+#endif
+
+/*!
+@brief macro to briefly define a mapping between an enum and JSON
+@def NLOHMANN_JSON_SERIALIZE_ENUM
+@since version 3.4.0
+*/
+#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \
+ template<typename BasicJsonType> \
+ inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \
+ { \
+ static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
+ static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
+ auto it = std::find_if(std::begin(m), std::end(m), \
+ [e](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
+ { \
+ return ej_pair.first == e; \
+ }); \
+ j = ((it != std::end(m)) ? it : std::begin(m))->second; \
+ } \
+ template<typename BasicJsonType> \
+ inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \
+ { \
+ static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
+ static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
+ auto it = std::find_if(std::begin(m), std::end(m), \
+ [j](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
+ { \
+ return ej_pair.second == j; \
+ }); \
+ e = ((it != std::end(m)) ? it : std::begin(m))->first; \
+ }
+
+// Ugly macros to avoid uglier copy-paste when specializing basic_json. They
+// may be removed in the future once the class is split.
+
+#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \
+ template<template<typename, typename, typename...> class ObjectType, \
+ template<typename, typename...> class ArrayType, \
+ class StringType, class BooleanType, class NumberIntegerType, \
+ class NumberUnsignedType, class NumberFloatType, \
+ template<typename> class AllocatorType, \
+ template<typename, typename = void> class JSONSerializer>
+
+#define NLOHMANN_BASIC_JSON_TPL \
+ basic_json<ObjectType, ArrayType, StringType, BooleanType, \
+ NumberIntegerType, NumberUnsignedType, NumberFloatType, \
+ AllocatorType, JSONSerializer>
+
+// #include <nlohmann/detail/meta/cpp_future.hpp>
+
+
+#include <ciso646> // not
+#include <cstddef> // size_t
+#include <type_traits> // conditional, enable_if, false_type, integral_constant, is_constructible, is_integral, is_same, remove_cv, remove_reference, true_type
+
+namespace nlohmann
+{
+namespace detail
+{
+// alias templates to reduce boilerplate
+template<bool B, typename T = void>
+using enable_if_t = typename std::enable_if<B, T>::type;
+
+template<typename T>
+using uncvref_t = typename std::remove_cv<typename std::remove_reference<T>::type>::type;
+
+// implementation of C++14 index_sequence and affiliates
+// source: https://stackoverflow.com/a/32223343
+template<std::size_t... Ints>
+struct index_sequence
+{
+ using type = index_sequence;
+ using value_type = std::size_t;
+ static constexpr std::size_t size() noexcept
+ {
+ return sizeof...(Ints);
+ }
+};
+
+template<class Sequence1, class Sequence2>
+struct merge_and_renumber;
+
+template<std::size_t... I1, std::size_t... I2>
+struct merge_and_renumber<index_sequence<I1...>, index_sequence<I2...>>
+ : index_sequence < I1..., (sizeof...(I1) + I2)... > {};
+
+template<std::size_t N>
+struct make_index_sequence
+ : merge_and_renumber < typename make_index_sequence < N / 2 >::type,
+ typename make_index_sequence < N - N / 2 >::type > {};
+
+template<> struct make_index_sequence<0> : index_sequence<> {};
+template<> struct make_index_sequence<1> : index_sequence<0> {};
+
+template<typename... Ts>
+using index_sequence_for = make_index_sequence<sizeof...(Ts)>;
+
+// dispatch utility (taken from ranges-v3)
+template<unsigned N> struct priority_tag : priority_tag < N - 1 > {};
+template<> struct priority_tag<0> {};
+
+// taken from ranges-v3
+template<typename T>
+struct static_const
+{
+ static constexpr T value{};
+};
+
+template<typename T>
+constexpr T static_const<T>::value;
+} // namespace detail
+} // namespace nlohmann
+
+// #include <nlohmann/detail/meta/type_traits.hpp>
+
+
+#include <ciso646> // not
+#include <limits> // numeric_limits
+#include <type_traits> // false_type, is_constructible, is_integral, is_same, true_type
+#include <utility> // declval
+
+// #include <nlohmann/detail/iterators/iterator_traits.hpp>
+
+
+#include <iterator> // random_access_iterator_tag
+
+// #include <nlohmann/detail/meta/void_t.hpp>
+
+
+namespace nlohmann
+{
+namespace detail
+{
+template <typename ...Ts> struct make_void
+{
+ using type = void;
+};
+template <typename ...Ts> using void_t = typename make_void<Ts...>::type;
+} // namespace detail
+} // namespace nlohmann
+
+// #include <nlohmann/detail/meta/cpp_future.hpp>
+
+
+namespace nlohmann
+{
+namespace detail
+{
+template <typename It, typename = void>
+struct iterator_types {};
+
+template <typename It>
+struct iterator_types <
+ It,
+ void_t<typename It::difference_type, typename It::value_type, typename It::pointer,
+ typename It::reference, typename It::iterator_category >>
+{
+ using difference_type = typename It::difference_type;
+ using value_type = typename It::value_type;
+ using pointer = typename It::pointer;
+ using reference = typename It::reference;
+ using iterator_category = typename It::iterator_category;
+};
+
+// This is required as some compilers implement std::iterator_traits in a way that
+// doesn't work with SFINAE. See https://github.com/nlohmann/json/issues/1341.
+template <typename T, typename = void>
+struct iterator_traits
+{
+};
+
+template <typename T>
+struct iterator_traits < T, enable_if_t < !std::is_pointer<T>::value >>
+ : iterator_types<T>
+{
+};
+
+template <typename T>
+struct iterator_traits<T*, enable_if_t<std::is_object<T>::value>>
+{
+ using iterator_category = std::random_access_iterator_tag;
+ using value_type = T;
+ using difference_type = ptrdiff_t;
+ using pointer = T*;
+ using reference = T&;
+};
+} // namespace detail
+} // namespace nlohmann
+
+// #include <nlohmann/detail/macro_scope.hpp>
+
+// #include <nlohmann/detail/meta/cpp_future.hpp>
+
+// #include <nlohmann/detail/meta/detected.hpp>
+
+
+#include <type_traits>
+
+// #include <nlohmann/detail/meta/void_t.hpp>
+
+
+// http://en.cppreference.com/w/cpp/experimental/is_detected
+namespace nlohmann
+{
+namespace detail
+{
+struct nonesuch
+{
+ nonesuch() = delete;
+ ~nonesuch() = delete;
+ nonesuch(nonesuch const&) = delete;
+ nonesuch(nonesuch const&&) = delete;
+ void operator=(nonesuch const&) = delete;
+ void operator=(nonesuch&&) = delete;
+};
+
+template <class Default,
+ class AlwaysVoid,
+ template <class...> class Op,
+ class... Args>
+struct detector
+{
+ using value_t = std::false_type;
+ using type = Default;
+};
+
+template <class Default, template <class...> class Op, class... Args>
+struct detector<Default, void_t<Op<Args...>>, Op, Args...>
+{
+ using value_t = std::true_type;
+ using type = Op<Args...>;
+};
+
+template <template <class...> class Op, class... Args>
+using is_detected = typename detector<nonesuch, void, Op, Args...>::value_t;
+
+template <template <class...> class Op, class... Args>
+using detected_t = typename detector<nonesuch, void, Op, Args...>::type;
+
+template <class Default, template <class...> class Op, class... Args>
+using detected_or = detector<Default, void, Op, Args...>;
+
+template <class Default, template <class...> class Op, class... Args>
+using detected_or_t = typename detected_or<Default, Op, Args...>::type;
+
+template <class Expected, template <class...> class Op, class... Args>
+using is_detected_exact = std::is_same<Expected, detected_t<Op, Args...>>;
+
+template <class To, template <class...> class Op, class... Args>
+using is_detected_convertible =
+ std::is_convertible<detected_t<Op, Args...>, To>;
+} // namespace detail
+} // namespace nlohmann
+
+// #include <nlohmann/json_fwd.hpp>
+#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
+#define INCLUDE_NLOHMANN_JSON_FWD_HPP_
+
+#include <cstdint> // int64_t, uint64_t
+#include <map> // map
+#include <memory> // allocator
+#include <string> // string
+#include <vector> // vector
+
+/*!
+@brief namespace for Niels Lohmann
+@see https://github.com/nlohmann
+@since version 1.0.0
+*/
+namespace nlohmann
+{
+/*!
+@brief default JSONSerializer template argument
+
+This serializer ignores the template arguments and uses ADL
+([argument-dependent lookup](https://en.cppreference.com/w/cpp/language/adl))
+for serialization.
+*/
+template<typename T = void, typename SFINAE = void>
+struct adl_serializer;
+
+template<template<typename U, typename V, typename... Args> class ObjectType =
+ std::map,
+ template<typename U, typename... Args> class ArrayType = std::vector,
+ class StringType = std::string, class BooleanType = bool,
+ class NumberIntegerType = std::int64_t,
+ class NumberUnsignedType = std::uint64_t,
+ class NumberFloatType = double,
+ template<typename U> class AllocatorType = std::allocator,
+ template<typename T, typename SFINAE = void> class JSONSerializer =
+ adl_serializer>
+class basic_json;
+
+/*!
+@brief JSON Pointer
+
+A JSON pointer defines a string syntax for identifying a specific value
+within a JSON document. It can be used with functions `at` and
+`operator[]`. Furthermore, JSON pointers are the base for JSON patches.
+
+@sa [RFC 6901](https://tools.ietf.org/html/rfc6901)
+
+@since version 2.0.0
+*/
+template<typename BasicJsonType>
+class json_pointer;
+
+/*!
+@brief default JSON class
+
+This type is the default specialization of the @ref basic_json class which
+uses the standard template types.
+
+@since version 1.0.0
+*/
+using json = basic_json<>;
+} // namespace nlohmann
+
+#endif // INCLUDE_NLOHMANN_JSON_FWD_HPP_
+
+
+namespace nlohmann
+{
+/*!
+@brief detail namespace with internal helper functions
+
+This namespace collects functions that should not be exposed,
+implementations of some @ref basic_json methods, and meta-programming helpers.
+
+@since version 2.1.0
+*/
+namespace detail
+{
+/////////////
+// helpers //
+/////////////
+
+// Note to maintainers:
+//
+// Every trait in this file expects a non CV-qualified type.
+// The only exceptions are in the 'aliases for detected' section
+// (i.e. those of the form: decltype(T::member_function(std::declval<T>())))
+//
+// In this case, T has to be properly CV-qualified to constraint the function arguments
+// (e.g. to_json(BasicJsonType&, const T&))
+
+template<typename> struct is_basic_json : std::false_type {};
+
+NLOHMANN_BASIC_JSON_TPL_DECLARATION
+struct is_basic_json<NLOHMANN_BASIC_JSON_TPL> : std::true_type {};
+
+//////////////////////////
+// aliases for detected //
+//////////////////////////
+
+template <typename T>
+using mapped_type_t = typename T::mapped_type;
+
+template <typename T>
+using key_type_t = typename T::key_type;
+
+template <typename T>
+using value_type_t = typename T::value_type;
+
+template <typename T>
+using difference_type_t = typename T::difference_type;
+
+template <typename T>
+using pointer_t = typename T::pointer;
+
+template <typename T>
+using reference_t = typename T::reference;
+
+template <typename T>
+using iterator_category_t = typename T::iterator_category;
+
+template <typename T>
+using iterator_t = typename T::iterator;
+
+template <typename T, typename... Args>
+using to_json_function = decltype(T::to_json(std::declval<Args>()...));
+
+template <typename T, typename... Args>
+using from_json_function = decltype(T::from_json(std::declval<Args>()...));
+
+template <typename T, typename U>
+using get_template_function = decltype(std::declval<T>().template get<U>());
+
+// trait checking if JSONSerializer<T>::from_json(json const&, udt&) exists
+template <typename BasicJsonType, typename T, typename = void>
+struct has_from_json : std::false_type {};
+
+template <typename BasicJsonType, typename T>
+struct has_from_json<BasicJsonType, T,
+ enable_if_t<not is_basic_json<T>::value>>
+{
+ using serializer = typename BasicJsonType::template json_serializer<T, void>;
+
+ static constexpr bool value =
+ is_detected_exact<void, from_json_function, serializer,
+ const BasicJsonType&, T&>::value;
+};
+
+// This trait checks if JSONSerializer<T>::from_json(json const&) exists
+// this overload is used for non-default-constructible user-defined-types
+template <typename BasicJsonType, typename T, typename = void>
+struct has_non_default_from_json : std::false_type {};
+
+template<typename BasicJsonType, typename T>
+struct has_non_default_from_json<BasicJsonType, T, enable_if_t<not is_basic_json<T>::value>>
+{
+ using serializer = typename BasicJsonType::template json_serializer<T, void>;
+
+ static constexpr bool value =
+ is_detected_exact<T, from_json_function, serializer,
+ const BasicJsonType&>::value;
+};
+
+// This trait checks if BasicJsonType::json_serializer<T>::to_json exists
+// Do not evaluate the trait when T is a basic_json type, to avoid template instantiation infinite recursion.
+template <typename BasicJsonType, typename T, typename = void>
+struct has_to_json : std::false_type {};
+
+template <typename BasicJsonType, typename T>
+struct has_to_json<BasicJsonType, T, enable_if_t<not is_basic_json<T>::value>>
+{
+ using serializer = typename BasicJsonType::template json_serializer<T, void>;
+
+ static constexpr bool value =
+ is_detected_exact<void, to_json_function, serializer, BasicJsonType&,
+ T>::value;
+};
+
+
+///////////////////
+// is_ functions //
+///////////////////
+
+template <typename T, typename = void>
+struct is_iterator_traits : std::false_type {};
+
+template <typename T>
+struct is_iterator_traits<iterator_traits<T>>
+{
+ private:
+ using traits = iterator_traits<T>;
+
+ public:
+ static constexpr auto value =
+ is_detected<value_type_t, traits>::value &&
+ is_detected<difference_type_t, traits>::value &&
+ is_detected<pointer_t, traits>::value &&
+ is_detected<iterator_category_t, traits>::value &&
+ is_detected<reference_t, traits>::value;
+};
+
+// source: https://stackoverflow.com/a/37193089/4116453
+
+template <typename T, typename = void>
+struct is_complete_type : std::false_type {};
+
+template <typename T>
+struct is_complete_type<T, decltype(void(sizeof(T)))> : std::true_type {};
+
+template <typename BasicJsonType, typename CompatibleObjectType,
+ typename = void>
+struct is_compatible_object_type_impl : std::false_type {};
+
+template <typename BasicJsonType, typename CompatibleObjectType>
+struct is_compatible_object_type_impl <
+ BasicJsonType, CompatibleObjectType,
+ enable_if_t<is_detected<mapped_type_t, CompatibleObjectType>::value and
+ is_detected<key_type_t, CompatibleObjectType>::value >>
+{
+
+ using object_t = typename BasicJsonType::object_t;
+
+ // macOS's is_constructible does not play well with nonesuch...
+ static constexpr bool value =
+ std::is_constructible<typename object_t::key_type,
+ typename CompatibleObjectType::key_type>::value and
+ std::is_constructible<typename object_t::mapped_type,
+ typename CompatibleObjectType::mapped_type>::value;
+};
+
+template <typename BasicJsonType, typename CompatibleObjectType>
+struct is_compatible_object_type
+ : is_compatible_object_type_impl<BasicJsonType, CompatibleObjectType> {};
+
+template <typename BasicJsonType, typename ConstructibleObjectType,
+ typename = void>
+struct is_constructible_object_type_impl : std::false_type {};
+
+template <typename BasicJsonType, typename ConstructibleObjectType>
+struct is_constructible_object_type_impl <
+ BasicJsonType, ConstructibleObjectType,
+ enable_if_t<is_detected<mapped_type_t, ConstructibleObjectType>::value and
+ is_detected<key_type_t, ConstructibleObjectType>::value >>
+{
+ using object_t = typename BasicJsonType::object_t;
+
+ static constexpr bool value =
+ (std::is_constructible<typename ConstructibleObjectType::key_type, typename object_t::key_type>::value and
+ std::is_same<typename object_t::mapped_type, typename ConstructibleObjectType::mapped_type>::value) or
+ (has_from_json<BasicJsonType, typename ConstructibleObjectType::mapped_type>::value or
+ has_non_default_from_json<BasicJsonType, typename ConstructibleObjectType::mapped_type >::value);
+};
+
+template <typename BasicJsonType, typename ConstructibleObjectType>
+struct is_constructible_object_type
+ : is_constructible_object_type_impl<BasicJsonType,
+ ConstructibleObjectType> {};
+
+template <typename BasicJsonType, typename CompatibleStringType,
+ typename = void>
+struct is_compatible_string_type_impl : std::false_type {};
+
+template <typename BasicJsonType, typename CompatibleStringType>
+struct is_compatible_string_type_impl <
+ BasicJsonType, CompatibleStringType,
+ enable_if_t<is_detected_exact<typename BasicJsonType::string_t::value_type,
+ value_type_t, CompatibleStringType>::value >>
+{
+ static constexpr auto value =
+ std::is_constructible<typename BasicJsonType::string_t, CompatibleStringType>::value;
+};
+
+template <typename BasicJsonType, typename ConstructibleStringType>
+struct is_compatible_string_type
+ : is_compatible_string_type_impl<BasicJsonType, ConstructibleStringType> {};
+
+template <typename BasicJsonType, typename ConstructibleStringType,
+ typename = void>
+struct is_constructible_string_type_impl : std::false_type {};
+
+template <typename BasicJsonType, typename ConstructibleStringType>
+struct is_constructible_string_type_impl <
+ BasicJsonType, ConstructibleStringType,
+ enable_if_t<is_detected_exact<typename BasicJsonType::string_t::value_type,
+ value_type_t, ConstructibleStringType>::value >>
+{
+ static constexpr auto value =
+ std::is_constructible<ConstructibleStringType,
+ typename BasicJsonType::string_t>::value;
+};
+
+template <typename BasicJsonType, typename ConstructibleStringType>
+struct is_constructible_string_type
+ : is_constructible_string_type_impl<BasicJsonType, ConstructibleStringType> {};
+
+template <typename BasicJsonType, typename CompatibleArrayType, typename = void>
+struct is_compatible_array_type_impl : std::false_type {};
+
+template <typename BasicJsonType, typename CompatibleArrayType>
+struct is_compatible_array_type_impl <
+ BasicJsonType, CompatibleArrayType,
+ enable_if_t<is_detected<value_type_t, CompatibleArrayType>::value and
+ is_detected<iterator_t, CompatibleArrayType>::value and
+// This is needed because json_reverse_iterator has a ::iterator type...
+// Therefore it is detected as a CompatibleArrayType.
+// The real fix would be to have an Iterable concept.
+ not is_iterator_traits<
+ iterator_traits<CompatibleArrayType>>::value >>
+{
+ static constexpr bool value =
+ std::is_constructible<BasicJsonType,
+ typename CompatibleArrayType::value_type>::value;
+};
+
+template <typename BasicJsonType, typename CompatibleArrayType>
+struct is_compatible_array_type
+ : is_compatible_array_type_impl<BasicJsonType, CompatibleArrayType> {};
+
+template <typename BasicJsonType, typename ConstructibleArrayType, typename = void>
+struct is_constructible_array_type_impl : std::false_type {};
+
+template <typename BasicJsonType, typename ConstructibleArrayType>
+struct is_constructible_array_type_impl <
+ BasicJsonType, ConstructibleArrayType,
+ enable_if_t<std::is_same<ConstructibleArrayType,
+ typename BasicJsonType::value_type>::value >>
+ : std::true_type {};
+
+template <typename BasicJsonType, typename ConstructibleArrayType>
+struct is_constructible_array_type_impl <
+ BasicJsonType, ConstructibleArrayType,
+ enable_if_t<not std::is_same<ConstructibleArrayType,
+ typename BasicJsonType::value_type>::value and
+ is_detected<value_type_t, ConstructibleArrayType>::value and
+ is_detected<iterator_t, ConstructibleArrayType>::value and
+ is_complete_type<
+ detected_t<value_type_t, ConstructibleArrayType>>::value >>
+{
+ static constexpr bool value =
+ // This is needed because json_reverse_iterator has a ::iterator type,
+ // furthermore, std::back_insert_iterator (and other iterators) have a base class `iterator`...
+ // Therefore it is detected as a ConstructibleArrayType.
+ // The real fix would be to have an Iterable concept.
+ not is_iterator_traits <
+ iterator_traits<ConstructibleArrayType >>::value and
+
+ (std::is_same<typename ConstructibleArrayType::value_type, typename BasicJsonType::array_t::value_type>::value or
+ has_from_json<BasicJsonType,
+ typename ConstructibleArrayType::value_type>::value or
+ has_non_default_from_json <
+ BasicJsonType, typename ConstructibleArrayType::value_type >::value);
+};
+
+template <typename BasicJsonType, typename ConstructibleArrayType>
+struct is_constructible_array_type
+ : is_constructible_array_type_impl<BasicJsonType, ConstructibleArrayType> {};
+
+template <typename RealIntegerType, typename CompatibleNumberIntegerType,
+ typename = void>
+struct is_compatible_integer_type_impl : std::false_type {};
+
+template <typename RealIntegerType, typename CompatibleNumberIntegerType>
+struct is_compatible_integer_type_impl <
+ RealIntegerType, CompatibleNumberIntegerType,
+ enable_if_t<std::is_integral<RealIntegerType>::value and
+ std::is_integral<CompatibleNumberIntegerType>::value and
+ not std::is_same<bool, CompatibleNumberIntegerType>::value >>
+{
+ // is there an assert somewhere on overflows?
+ using RealLimits = std::numeric_limits<RealIntegerType>;
+ using CompatibleLimits = std::numeric_limits<CompatibleNumberIntegerType>;
+
+ static constexpr auto value =
+ std::is_constructible<RealIntegerType,
+ CompatibleNumberIntegerType>::value and
+ CompatibleLimits::is_integer and
+ RealLimits::is_signed == CompatibleLimits::is_signed;
+};
+
+template <typename RealIntegerType, typename CompatibleNumberIntegerType>
+struct is_compatible_integer_type
+ : is_compatible_integer_type_impl<RealIntegerType,
+ CompatibleNumberIntegerType> {};
+
+template <typename BasicJsonType, typename CompatibleType, typename = void>
+struct is_compatible_type_impl: std::false_type {};
+
+template <typename BasicJsonType, typename CompatibleType>
+struct is_compatible_type_impl <
+ BasicJsonType, CompatibleType,
+ enable_if_t<is_complete_type<CompatibleType>::value >>
+{
+ static constexpr bool value =
+ has_to_json<BasicJsonType, CompatibleType>::value;
+};
+
+template <typename BasicJsonType, typename CompatibleType>
+struct is_compatible_type
+ : is_compatible_type_impl<BasicJsonType, CompatibleType> {};
+} // namespace detail
+} // namespace nlohmann
+
+// #include <nlohmann/detail/value_t.hpp>
+
+
+#include <array> // array
+#include <ciso646> // and
+#include <cstddef> // size_t
+#include <cstdint> // uint8_t
+#include <string> // string
+
+namespace nlohmann
+{
+namespace detail
+{
+///////////////////////////
+// JSON type enumeration //
+///////////////////////////
+
+/*!
+@brief the JSON type enumeration
+
+This enumeration collects the different JSON types. It is internally used to
+distinguish the stored values, and the functions @ref basic_json::is_null(),
+@ref basic_json::is_object(), @ref basic_json::is_array(),
+@ref basic_json::is_string(), @ref basic_json::is_boolean(),
+@ref basic_json::is_number() (with @ref basic_json::is_number_integer(),
+@ref basic_json::is_number_unsigned(), and @ref basic_json::is_number_float()),
+@ref basic_json::is_discarded(), @ref basic_json::is_primitive(), and
+@ref basic_json::is_structured() rely on it.
+
+@note There are three enumeration entries (number_integer, number_unsigned, and
+number_float), because the library distinguishes these three types for numbers:
+@ref basic_json::number_unsigned_t is used for unsigned integers,
+@ref basic_json::number_integer_t is used for signed integers, and
+@ref basic_json::number_float_t is used for floating-point numbers or to
+approximate integers which do not fit in the limits of their respective type.
+
+@sa @ref basic_json::basic_json(const value_t value_type) -- create a JSON
+value with the default value for a given type
+
+@since version 1.0.0
+*/
+enum class value_t : std::uint8_t
+{
+ null, ///< null value
+ object, ///< object (unordered set of name/value pairs)
+ array, ///< array (ordered collection of values)
+ string, ///< string value
+ boolean, ///< boolean value
+ number_integer, ///< number value (signed integer)
+ number_unsigned, ///< number value (unsigned integer)
+ number_float, ///< number value (floating-point)
+ discarded ///< discarded by the the parser callback function
+};
+
+/*!
+@brief comparison operator for JSON types
+
+Returns an ordering that is similar to Python:
+- order: null < boolean < number < object < array < string
+- furthermore, each type is not smaller than itself
+- discarded values are not comparable
+
+@since version 1.0.0
+*/
+inline bool operator<(const value_t lhs, const value_t rhs) noexcept
+{
+ static constexpr std::array<std::uint8_t, 8> order = {{
+ 0 /* null */, 3 /* object */, 4 /* array */, 5 /* string */,
+ 1 /* boolean */, 2 /* integer */, 2 /* unsigned */, 2 /* float */
+ }
+ };
+
+ const auto l_index = static_cast<std::size_t>(lhs);
+ const auto r_index = static_cast<std::size_t>(rhs);
+ return l_index < order.size() and r_index < order.size() and order[l_index] < order[r_index];
+}
+} // namespace detail
+} // namespace nlohmann
+
+
+namespace nlohmann
+{
+namespace detail
+{
+template<typename BasicJsonType>
+void from_json(const BasicJsonType& j, typename std::nullptr_t& n)
+{
+ if (JSON_UNLIKELY(not j.is_null()))
+ {
+ JSON_THROW(type_error::create(302, "type must be null, but is " + std::string(j.type_name())));
+ }
+ n = nullptr;
+}
+
+// overloads for basic_json template parameters
+template<typename BasicJsonType, typename ArithmeticType,
+ enable_if_t<std::is_arithmetic<ArithmeticType>::value and
+ not std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
+ int> = 0>
+void get_arithmetic_value(const BasicJsonType& j, ArithmeticType& val)
+{
+ switch (static_cast<value_t>(j))
+ {
+ case value_t::number_unsigned:
+ {
+ val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
+ break;
+ }
+ case value_t::number_integer:
+ {
+ val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
+ break;
+ }
+ case value_t::number_float:
+ {
+ val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
+ break;
+ }
+
+ default:
+ JSON_THROW(type_error::create(302, "type must be number, but is " + std::string(j.type_name())));
+ }
+}
+
+template<typename BasicJsonType>
+void from_json(const BasicJsonType& j, typename BasicJsonType::boolean_t& b)
+{
+ if (JSON_UNLIKELY(not j.is_boolean()))
+ {
+ JSON_THROW(type_error::create(302, "type must be boolean, but is " + std::string(j.type_name())));
+ }
+ b = *j.template get_ptr<const typename BasicJsonType::boolean_t*>();
+}
+
+template<typename BasicJsonType>
+void from_json(const BasicJsonType& j, typename BasicJsonType::string_t& s)
+{
+ if (JSON_UNLIKELY(not j.is_string()))
+ {
+ JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name())));
+ }
+ s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
+}
+
+template <
+ typename BasicJsonType, typename ConstructibleStringType,
+ enable_if_t <
+ is_constructible_string_type<BasicJsonType, ConstructibleStringType>::value and
+ not std::is_same<typename BasicJsonType::string_t,
+ ConstructibleStringType>::value,
+ int > = 0 >
+void from_json(const BasicJsonType& j, ConstructibleStringType& s)
+{
+ if (JSON_UNLIKELY(not j.is_string()))
+ {
+ JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name())));
+ }
+
+ s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
+}
+
+template<typename BasicJsonType>
+void from_json(const BasicJsonType& j, typename BasicJsonType::number_float_t& val)
+{
+ get_arithmetic_value(j, val);
+}
+
+template<typename BasicJsonType>
+void from_json(const BasicJsonType& j, typename BasicJsonType::number_unsigned_t& val)
+{
+ get_arithmetic_value(j, val);
+}
+
+template<typename BasicJsonType>
+void from_json(const BasicJsonType& j, typename BasicJsonType::number_integer_t& val)
+{
+ get_arithmetic_value(j, val);
+}
+
+template<typename BasicJsonType, typename EnumType,
+ enable_if_t<std::is_enum<EnumType>::value, int> = 0>
+void from_json(const BasicJsonType& j, EnumType& e)
+{
+ typename std::underlying_type<EnumType>::type val;
+ get_arithmetic_value(j, val);
+ e = static_cast<EnumType>(val);
+}
+
+// forward_list doesn't have an insert method
+template<typename BasicJsonType, typename T, typename Allocator,
+ enable_if_t<std::is_convertible<BasicJsonType, T>::value, int> = 0>
+void from_json(const BasicJsonType& j, std::forward_list<T, Allocator>& l)
+{
+ if (JSON_UNLIKELY(not j.is_array()))
+ {
+ JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name())));
+ }
+ std::transform(j.rbegin(), j.rend(),
+ std::front_inserter(l), [](const BasicJsonType & i)
+ {
+ return i.template get<T>();
+ });
+}
+
+// valarray doesn't have an insert method
+template<typename BasicJsonType, typename T,
+ enable_if_t<std::is_convertible<BasicJsonType, T>::value, int> = 0>
+void from_json(const BasicJsonType& j, std::valarray<T>& l)
+{
+ if (JSON_UNLIKELY(not j.is_array()))
+ {
+ JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name())));
+ }
+ l.resize(j.size());
+ std::copy(j.m_value.array->begin(), j.m_value.array->end(), std::begin(l));
+}
+
+template<typename BasicJsonType>
+void from_json_array_impl(const BasicJsonType& j, typename BasicJsonType::array_t& arr, priority_tag<3> /*unused*/)
+{
+ arr = *j.template get_ptr<const typename BasicJsonType::array_t*>();
+}
+
+template <typename BasicJsonType, typename T, std::size_t N>
+auto from_json_array_impl(const BasicJsonType& j, std::array<T, N>& arr,
+ priority_tag<2> /*unused*/)
+-> decltype(j.template get<T>(), void())
+{
+ for (std::size_t i = 0; i < N; ++i)
+ {
+ arr[i] = j.at(i).template get<T>();
+ }
+}
+
+template<typename BasicJsonType, typename ConstructibleArrayType>
+auto from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, priority_tag<1> /*unused*/)
+-> decltype(
+ arr.reserve(std::declval<typename ConstructibleArrayType::size_type>()),
+ j.template get<typename ConstructibleArrayType::value_type>(),
+ void())
+{
+ using std::end;
+
+ arr.reserve(j.size());
+ std::transform(j.begin(), j.end(),
+ std::inserter(arr, end(arr)), [](const BasicJsonType & i)
+ {
+ // get<BasicJsonType>() returns *this, this won't call a from_json
+ // method when value_type is BasicJsonType
+ return i.template get<typename ConstructibleArrayType::value_type>();
+ });
+}
+
+template <typename BasicJsonType, typename ConstructibleArrayType>
+void from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr,
+ priority_tag<0> /*unused*/)
+{
+ using std::end;
+
+ std::transform(
+ j.begin(), j.end(), std::inserter(arr, end(arr)),
+ [](const BasicJsonType & i)
+ {
+ // get<BasicJsonType>() returns *this, this won't call a from_json
+ // method when value_type is BasicJsonType
+ return i.template get<typename ConstructibleArrayType::value_type>();
+ });
+}
+
+template <typename BasicJsonType, typename ConstructibleArrayType,
+ enable_if_t <
+ is_constructible_array_type<BasicJsonType, ConstructibleArrayType>::value and
+ not is_constructible_object_type<BasicJsonType, ConstructibleArrayType>::value and
+ not is_constructible_string_type<BasicJsonType, ConstructibleArrayType>::value and
+ not is_basic_json<ConstructibleArrayType>::value,
+ int > = 0 >
+
+auto from_json(const BasicJsonType& j, ConstructibleArrayType& arr)
+-> decltype(from_json_array_impl(j, arr, priority_tag<3> {}),
+j.template get<typename ConstructibleArrayType::value_type>(),
+void())
+{
+ if (JSON_UNLIKELY(not j.is_array()))
+ {
+ JSON_THROW(type_error::create(302, "type must be array, but is " +
+ std::string(j.type_name())));
+ }
+
+ from_json_array_impl(j, arr, priority_tag<3> {});
+}
+
+template<typename BasicJsonType, typename ConstructibleObjectType,
+ enable_if_t<is_constructible_object_type<BasicJsonType, ConstructibleObjectType>::value, int> = 0>
+void from_json(const BasicJsonType& j, ConstructibleObjectType& obj)
+{
+ if (JSON_UNLIKELY(not j.is_object()))
+ {
+ JSON_THROW(type_error::create(302, "type must be object, but is " + std::string(j.type_name())));
+ }
+
+ auto inner_object = j.template get_ptr<const typename BasicJsonType::object_t*>();
+ using value_type = typename ConstructibleObjectType::value_type;
+ std::transform(
+ inner_object->begin(), inner_object->end(),
+ std::inserter(obj, obj.begin()),
+ [](typename BasicJsonType::object_t::value_type const & p)
+ {
+ return value_type(p.first, p.second.template get<typename ConstructibleObjectType::mapped_type>());
+ });
+}
+
+// overload for arithmetic types, not chosen for basic_json template arguments
+// (BooleanType, etc..); note: Is it really necessary to provide explicit
+// overloads for boolean_t etc. in case of a custom BooleanType which is not
+// an arithmetic type?
+template<typename BasicJsonType, typename ArithmeticType,
+ enable_if_t <
+ std::is_arithmetic<ArithmeticType>::value and
+ not std::is_same<ArithmeticType, typename BasicJsonType::number_unsigned_t>::value and
+ not std::is_same<ArithmeticType, typename BasicJsonType::number_integer_t>::value and
+ not std::is_same<ArithmeticType, typename BasicJsonType::number_float_t>::value and
+ not std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
+ int> = 0>
+void from_json(const BasicJsonType& j, ArithmeticType& val)
+{
+ switch (static_cast<value_t>(j))
+ {
+ case value_t::number_unsigned:
+ {
+ val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
+ break;
+ }
+ case value_t::number_integer:
+ {
+ val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
+ break;
+ }
+ case value_t::number_float:
+ {
+ val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
+ break;
+ }
+ case value_t::boolean:
+ {
+ val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::boolean_t*>());
+ break;
+ }
+
+ default:
+ JSON_THROW(type_error::create(302, "type must be number, but is " + std::string(j.type_name())));
+ }
+}
+
+template<typename BasicJsonType, typename A1, typename A2>
+void from_json(const BasicJsonType& j, std::pair<A1, A2>& p)
+{
+ p = {j.at(0).template get<A1>(), j.at(1).template get<A2>()};
+}
+
+template<typename BasicJsonType, typename Tuple, std::size_t... Idx>
+void from_json_tuple_impl(const BasicJsonType& j, Tuple& t, index_sequence<Idx...> /*unused*/)
+{
+ t = std::make_tuple(j.at(Idx).template get<typename std::tuple_element<Idx, Tuple>::type>()...);
+}
+
+template<typename BasicJsonType, typename... Args>
+void from_json(const BasicJsonType& j, std::tuple<Args...>& t)
+{
+ from_json_tuple_impl(j, t, index_sequence_for<Args...> {});
+}
+
+template <typename BasicJsonType, typename Key, typename Value, typename Compare, typename Allocator,
+ typename = enable_if_t<not std::is_constructible<
+ typename BasicJsonType::string_t, Key>::value>>
+void from_json(const BasicJsonType& j, std::map<Key, Value, Compare, Allocator>& m)
+{
+ if (JSON_UNLIKELY(not j.is_array()))
+ {
+ JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name())));
+ }
+ for (const auto& p : j)
+ {
+ if (JSON_UNLIKELY(not p.is_array()))
+ {
+ JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(p.type_name())));
+ }
+ m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
+ }
+}
+
+template <typename BasicJsonType, typename Key, typename Value, typename Hash, typename KeyEqual, typename Allocator,
+ typename = enable_if_t<not std::is_constructible<
+ typename BasicJsonType::string_t, Key>::value>>
+void from_json(const BasicJsonType& j, std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>& m)
+{
+ if (JSON_UNLIKELY(not j.is_array()))
+ {
+ JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name())));
+ }
+ for (const auto& p : j)
+ {
+ if (JSON_UNLIKELY(not p.is_array()))
+ {
+ JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(p.type_name())));
+ }
+ m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
+ }
+}
+
+struct from_json_fn
+{
+ template<typename BasicJsonType, typename T>
+ auto operator()(const BasicJsonType& j, T& val) const
+ noexcept(noexcept(from_json(j, val)))
+ -> decltype(from_json(j, val), void())
+ {
+ return from_json(j, val);
+ }
+};
+} // namespace detail
+
+/// namespace to hold default `from_json` function
+/// to see why this is required:
+/// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4381.html
+namespace
+{
+constexpr const auto& from_json = detail::static_const<detail::from_json_fn>::value;
+} // namespace
+} // namespace nlohmann
+
+// #include <nlohmann/detail/conversions/to_json.hpp>
+
+
+#include <algorithm> // copy
+#include <ciso646> // or, and, not
+#include <iterator> // begin, end
+#include <string> // string
+#include <tuple> // tuple, get
+#include <type_traits> // is_same, is_constructible, is_floating_point, is_enum, underlying_type
+#include <utility> // move, forward, declval, pair
+#include <valarray> // valarray
+#include <vector> // vector
+
+// #include <nlohmann/detail/iterators/iteration_proxy.hpp>
+
+
+#include <cstddef> // size_t
+#include <iterator> // input_iterator_tag
+#include <string> // string, to_string
+#include <tuple> // tuple_size, get, tuple_element
+
+// #include <nlohmann/detail/meta/type_traits.hpp>
+
+// #include <nlohmann/detail/value_t.hpp>
+
+
+namespace nlohmann
+{
+namespace detail
+{
+template <typename IteratorType> class iteration_proxy_value
+{
+ public:
+ using difference_type = std::ptrdiff_t;
+ using value_type = iteration_proxy_value;
+ using pointer = value_type * ;
+ using reference = value_type & ;
+ using iterator_category = std::input_iterator_tag;
+
+ private:
+ /// the iterator
+ IteratorType anchor;
+ /// an index for arrays (used to create key names)
+ std::size_t array_index = 0;
+ /// last stringified array index
+ mutable std::size_t array_index_last = 0;
+ /// a string representation of the array index
+ mutable std::string array_index_str = "0";
+ /// an empty string (to return a reference for primitive values)
+ const std::string empty_str = "";
+
+ public:
+ explicit iteration_proxy_value(IteratorType it) noexcept : anchor(it) {}
+
+ /// dereference operator (needed for range-based for)
+ iteration_proxy_value& operator*()
+ {
+ return *this;
+ }
+
+ /// increment operator (needed for range-based for)
+ iteration_proxy_value& operator++()
+ {
+ ++anchor;
+ ++array_index;
+
+ return *this;
+ }
+
+ /// equality operator (needed for InputIterator)
+ bool operator==(const iteration_proxy_value& o) const
+ {
+ return anchor == o.anchor;
+ }
+
+ /// inequality operator (needed for range-based for)
+ bool operator!=(const iteration_proxy_value& o) const
+ {
+ return anchor != o.anchor;
+ }
+
+ /// return key of the iterator
+ const std::string& key() const
+ {
+ assert(anchor.m_object != nullptr);
+
+ switch (anchor.m_object->type())
+ {
+ // use integer array index as key
+ case value_t::array:
+ {
+ if (array_index != array_index_last)
+ {
+ array_index_str = std::to_string(array_index);
+ array_index_last = array_index;
+ }
+ return array_index_str;
+ }
+
+ // use key from the object
+ case value_t::object:
+ return anchor.key();
+
+ // use an empty key for all primitive types
+ default:
+ return empty_str;
+ }
+ }
+
+ /// return value of the iterator
+ typename IteratorType::reference value() const
+ {
+ return anchor.value();
+ }
+};
+
+/// proxy class for the items() function
+template<typename IteratorType> class iteration_proxy
+{
+ private:
+ /// the container to iterate
+ typename IteratorType::reference container;
+
+ public:
+ /// construct iteration proxy from a container
+ explicit iteration_proxy(typename IteratorType::reference cont) noexcept
+ : container(cont) {}
+
+ /// return iterator begin (needed for range-based for)
+ iteration_proxy_value<IteratorType> begin() noexcept
+ {
+ return iteration_proxy_value<IteratorType>(container.begin());
+ }
+
+ /// return iterator end (needed for range-based for)
+ iteration_proxy_value<IteratorType> end() noexcept
+ {
+ return iteration_proxy_value<IteratorType>(container.end());
+ }
+};
+// Structured Bindings Support
+// For further reference see https://blog.tartanllama.xyz/structured-bindings/
+// And see https://github.com/nlohmann/json/pull/1391
+template <std::size_t N, typename IteratorType, enable_if_t<N == 0, int> = 0>
+auto get(const nlohmann::detail::iteration_proxy_value<IteratorType>& i) -> decltype(i.key())
+{
+ return i.key();
+}
+// Structured Bindings Support
+// For further reference see https://blog.tartanllama.xyz/structured-bindings/
+// And see https://github.com/nlohmann/json/pull/1391
+template <std::size_t N, typename IteratorType, enable_if_t<N == 1, int> = 0>
+auto get(const nlohmann::detail::iteration_proxy_value<IteratorType>& i) -> decltype(i.value())
+{
+ return i.value();
+}
+} // namespace detail
+} // namespace nlohmann
+
+// The Addition to the STD Namespace is required to add
+// Structured Bindings Support to the iteration_proxy_value class
+// For further reference see https://blog.tartanllama.xyz/structured-bindings/
+// And see https://github.com/nlohmann/json/pull/1391
+namespace std
+{
+#if defined(__clang__)
+ // Fix: https://github.com/nlohmann/json/issues/1401
+ #pragma clang diagnostic push
+ #pragma clang diagnostic ignored "-Wmismatched-tags"
+#endif
+template <typename IteratorType>
+class tuple_size<::nlohmann::detail::iteration_proxy_value<IteratorType>>
+ : public std::integral_constant<std::size_t, 2> {};
+
+template <std::size_t N, typename IteratorType>
+class tuple_element<N, ::nlohmann::detail::iteration_proxy_value<IteratorType >>
+{
+ public:
+ using type = decltype(
+ get<N>(std::declval <
+ ::nlohmann::detail::iteration_proxy_value<IteratorType >> ()));
+};
+#if defined(__clang__)
+ #pragma clang diagnostic pop
+#endif
+} // namespace std
+
+// #include <nlohmann/detail/meta/cpp_future.hpp>
+
+// #include <nlohmann/detail/meta/type_traits.hpp>
+
+// #include <nlohmann/detail/value_t.hpp>
+
+
+namespace nlohmann
+{
+namespace detail
+{
+//////////////////
+// constructors //
+//////////////////
+
+template<value_t> struct external_constructor;
+
+template<>
+struct external_constructor<value_t::boolean>
+{
+ template<typename BasicJsonType>
+ static void construct(BasicJsonType& j, typename BasicJsonType::boolean_t b) noexcept
+ {
+ j.m_type = value_t::boolean;
+ j.m_value = b;
+ j.assert_invariant();
+ }
+};
+
+template<>
+struct external_constructor<value_t::string>
+{
+ template<typename BasicJsonType>
+ static void construct(BasicJsonType& j, const typename BasicJsonType::string_t& s)
+ {
+ j.m_type = value_t::string;
+ j.m_value = s;
+ j.assert_invariant();
+ }
+
+ template<typename BasicJsonType>
+ static void construct(BasicJsonType& j, typename BasicJsonType::string_t&& s)
+ {
+ j.m_type = value_t::string;
+ j.m_value = std::move(s);
+ j.assert_invariant();
+ }
+
+ template<typename BasicJsonType, typename CompatibleStringType,
+ enable_if_t<not std::is_same<CompatibleStringType, typename BasicJsonType::string_t>::value,
+ int> = 0>
+ static void construct(BasicJsonType& j, const CompatibleStringType& str)
+ {
+ j.m_type = value_t::string;
+ j.m_value.string = j.template create<typename BasicJsonType::string_t>(str);
+ j.assert_invariant();
+ }
+};
+
+template<>
+struct external_constructor<value_t::number_float>
+{
+ template<typename BasicJsonType>
+ static void construct(BasicJsonType& j, typename BasicJsonType::number_float_t val) noexcept
+ {
+ j.m_type = value_t::number_float;
+ j.m_value = val;
+ j.assert_invariant();
+ }
+};
+
+template<>
+struct external_constructor<value_t::number_unsigned>
+{
+ template<typename BasicJsonType>
+ static void construct(BasicJsonType& j, typename BasicJsonType::number_unsigned_t val) noexcept
+ {
+ j.m_type = value_t::number_unsigned;
+ j.m_value = val;
+ j.assert_invariant();
+ }
+};
+
+template<>
+struct external_constructor<value_t::number_integer>
+{
+ template<typename BasicJsonType>
+ static void construct(BasicJsonType& j, typename BasicJsonType::number_integer_t val) noexcept
+ {
+ j.m_type = value_t::number_integer;
+ j.m_value = val;
+ j.assert_invariant();
+ }
+};
+
+template<>
+struct external_constructor<value_t::array>
+{
+ template<typename BasicJsonType>
+ static void construct(BasicJsonType& j, const typename BasicJsonType::array_t& arr)
+ {
+ j.m_type = value_t::array;
+ j.m_value = arr;
+ j.assert_invariant();
+ }
+
+ template<typename BasicJsonType>
+ static void construct(BasicJsonType& j, typename BasicJsonType::array_t&& arr)
+ {
+ j.m_type = value_t::array;
+ j.m_value = std::move(arr);
+ j.assert_invariant();
+ }
+
+ template<typename BasicJsonType, typename CompatibleArrayType,
+ enable_if_t<not std::is_same<CompatibleArrayType, typename BasicJsonType::array_t>::value,
+ int> = 0>
+ static void construct(BasicJsonType& j, const CompatibleArrayType& arr)
+ {
+ using std::begin;
+ using std::end;
+ j.m_type = value_t::array;
+ j.m_value.array = j.template create<typename BasicJsonType::array_t>(begin(arr), end(arr));
+ j.assert_invariant();
+ }
+
+ template<typename BasicJsonType>
+ static void construct(BasicJsonType& j, const std::vector<bool>& arr)
+ {
+ j.m_type = value_t::array;
+ j.m_value = value_t::array;
+ j.m_value.array->reserve(arr.size());
+ for (const bool x : arr)
+ {
+ j.m_value.array->push_back(x);
+ }
+ j.assert_invariant();
+ }
+
+ template<typename BasicJsonType, typename T,
+ enable_if_t<std::is_convertible<T, BasicJsonType>::value, int> = 0>
+ static void construct(BasicJsonType& j, const std::valarray<T>& arr)
+ {
+ j.m_type = value_t::array;
+ j.m_value = value_t::array;
+ j.m_value.array->resize(arr.size());
+ std::copy(std::begin(arr), std::end(arr), j.m_value.array->begin());
+ j.assert_invariant();
+ }
+};
+
+template<>
+struct external_constructor<value_t::object>
+{
+ template<typename BasicJsonType>
+ static void construct(BasicJsonType& j, const typename BasicJsonType::object_t& obj)
+ {
+ j.m_type = value_t::object;
+ j.m_value = obj;
+ j.assert_invariant();
+ }
+
+ template<typename BasicJsonType>
+ static void construct(BasicJsonType& j, typename BasicJsonType::object_t&& obj)
+ {
+ j.m_type = value_t::object;
+ j.m_value = std::move(obj);
+ j.assert_invariant();
+ }
+
+ template<typename BasicJsonType, typename CompatibleObjectType,
+ enable_if_t<not std::is_same<CompatibleObjectType, typename BasicJsonType::object_t>::value, int> = 0>
+ static void construct(BasicJsonType& j, const CompatibleObjectType& obj)
+ {
+ using std::begin;
+ using std::end;
+
+ j.m_type = value_t::object;
+ j.m_value.object = j.template create<typename BasicJsonType::object_t>(begin(obj), end(obj));
+ j.assert_invariant();
+ }
+};
+
+/////////////
+// to_json //
+/////////////
+
+template<typename BasicJsonType, typename T,
+ enable_if_t<std::is_same<T, typename BasicJsonType::boolean_t>::value, int> = 0>
+void to_json(BasicJsonType& j, T b) noexcept
+{
+ external_constructor<value_t::boolean>::construct(j, b);
+}
+
+template<typename BasicJsonType, typename CompatibleString,
+ enable_if_t<std::is_constructible<typename BasicJsonType::string_t, CompatibleString>::value, int> = 0>
+void to_json(BasicJsonType& j, const CompatibleString& s)
+{
+ external_constructor<value_t::string>::construct(j, s);
+}
+
+template<typename BasicJsonType>
+void to_json(BasicJsonType& j, typename BasicJsonType::string_t&& s)
+{
+ external_constructor<value_t::string>::construct(j, std::move(s));
+}
+
+template<typename BasicJsonType, typename FloatType,
+ enable_if_t<std::is_floating_point<FloatType>::value, int> = 0>
+void to_json(BasicJsonType& j, FloatType val) noexcept
+{
+ external_constructor<value_t::number_float>::construct(j, static_cast<typename BasicJsonType::number_float_t>(val));
+}
+
+template<typename BasicJsonType, typename CompatibleNumberUnsignedType,
+ enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_unsigned_t, CompatibleNumberUnsignedType>::value, int> = 0>
+void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val) noexcept
+{
+ external_constructor<value_t::number_unsigned>::construct(j, static_cast<typename BasicJsonType::number_unsigned_t>(val));
+}
+
+template<typename BasicJsonType, typename CompatibleNumberIntegerType,
+ enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_integer_t, CompatibleNumberIntegerType>::value, int> = 0>
+void to_json(BasicJsonType& j, CompatibleNumberIntegerType val) noexcept
+{
+ external_constructor<value_t::number_integer>::construct(j, static_cast<typename BasicJsonType::number_integer_t>(val));
+}
+
+template<typename BasicJsonType, typename EnumType,
+ enable_if_t<std::is_enum<EnumType>::value, int> = 0>
+void to_json(BasicJsonType& j, EnumType e) noexcept
+{
+ using underlying_type = typename std::underlying_type<EnumType>::type;
+ external_constructor<value_t::number_integer>::construct(j, static_cast<underlying_type>(e));
+}
+
+template<typename BasicJsonType>
+void to_json(BasicJsonType& j, const std::vector<bool>& e)
+{
+ external_constructor<value_t::array>::construct(j, e);
+}
+
+template <typename BasicJsonType, typename CompatibleArrayType,
+ enable_if_t<is_compatible_array_type<BasicJsonType,
+ CompatibleArrayType>::value and
+ not is_compatible_object_type<
+ BasicJsonType, CompatibleArrayType>::value and
+ not is_compatible_string_type<BasicJsonType, CompatibleArrayType>::value and
+ not is_basic_json<CompatibleArrayType>::value,
+ int> = 0>
+void to_json(BasicJsonType& j, const CompatibleArrayType& arr)
+{
+ external_constructor<value_t::array>::construct(j, arr);
+}
+
+template<typename BasicJsonType, typename T,
+ enable_if_t<std::is_convertible<T, BasicJsonType>::value, int> = 0>
+void to_json(BasicJsonType& j, const std::valarray<T>& arr)
+{
+ external_constructor<value_t::array>::construct(j, std::move(arr));
+}
+
+template<typename BasicJsonType>
+void to_json(BasicJsonType& j, typename BasicJsonType::array_t&& arr)
+{
+ external_constructor<value_t::array>::construct(j, std::move(arr));
+}
+
+template<typename BasicJsonType, typename CompatibleObjectType,
+ enable_if_t<is_compatible_object_type<BasicJsonType, CompatibleObjectType>::value and not is_basic_json<CompatibleObjectType>::value, int> = 0>
+void to_json(BasicJsonType& j, const CompatibleObjectType& obj)
+{
+ external_constructor<value_t::object>::construct(j, obj);
+}
+
+template<typename BasicJsonType>
+void to_json(BasicJsonType& j, typename BasicJsonType::object_t&& obj)
+{
+ external_constructor<value_t::object>::construct(j, std::move(obj));
+}
+
+template <
+ typename BasicJsonType, typename T, std::size_t N,
+ enable_if_t<not std::is_constructible<typename BasicJsonType::string_t,
+ const T(&)[N]>::value,
+ int> = 0 >
+void to_json(BasicJsonType& j, const T(&arr)[N])
+{
+ external_constructor<value_t::array>::construct(j, arr);
+}
+
+template<typename BasicJsonType, typename... Args>
+void to_json(BasicJsonType& j, const std::pair<Args...>& p)
+{
+ j = { p.first, p.second };
+}
+
+// for https://github.com/nlohmann/json/pull/1134
+template < typename BasicJsonType, typename T,
+ enable_if_t<std::is_same<T, iteration_proxy_value<typename BasicJsonType::iterator>>::value, int> = 0>
+void to_json(BasicJsonType& j, const T& b)
+{
+ j = { {b.key(), b.value()} };
+}
+
+template<typename BasicJsonType, typename Tuple, std::size_t... Idx>
+void to_json_tuple_impl(BasicJsonType& j, const Tuple& t, index_sequence<Idx...> /*unused*/)
+{
+ j = { std::get<Idx>(t)... };
+}
+
+template<typename BasicJsonType, typename... Args>
+void to_json(BasicJsonType& j, const std::tuple<Args...>& t)
+{
+ to_json_tuple_impl(j, t, index_sequence_for<Args...> {});
+}
+
+struct to_json_fn
+{
+ template<typename BasicJsonType, typename T>
+ auto operator()(BasicJsonType& j, T&& val) const noexcept(noexcept(to_json(j, std::forward<T>(val))))
+ -> decltype(to_json(j, std::forward<T>(val)), void())
+ {
+ return to_json(j, std::forward<T>(val));
+ }
+};
+} // namespace detail
+
+/// namespace to hold default `to_json` function
+namespace
+{
+constexpr const auto& to_json = detail::static_const<detail::to_json_fn>::value;
+} // namespace
+} // namespace nlohmann
+
+
+namespace nlohmann
+{
+
+template<typename, typename>
+struct adl_serializer
+{
+ /*!
+ @brief convert a JSON value to any value type
+
+ This function is usually called by the `get()` function of the
+ @ref basic_json class (either explicit or via conversion operators).
+
+ @param[in] j JSON value to read from
+ @param[in,out] val value to write to
+ */
+ template<typename BasicJsonType, typename ValueType>
+ static auto from_json(BasicJsonType&& j, ValueType& val) noexcept(
+ noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), val)))
+ -> decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), val), void())
+ {
+ ::nlohmann::from_json(std::forward<BasicJsonType>(j), val);
+ }
+
+ /*!
+ @brief convert any value type to a JSON value
+
+ This function is usually called by the constructors of the @ref basic_json
+ class.
+
+ @param[in,out] j JSON value to write to
+ @param[in] val value to read from
+ */
+ template <typename BasicJsonType, typename ValueType>
+ static auto to_json(BasicJsonType& j, ValueType&& val) noexcept(
+ noexcept(::nlohmann::to_json(j, std::forward<ValueType>(val))))
+ -> decltype(::nlohmann::to_json(j, std::forward<ValueType>(val)), void())
+ {
+ ::nlohmann::to_json(j, std::forward<ValueType>(val));
+ }
+};
+
+} // namespace nlohmann
+
+// #include <nlohmann/detail/conversions/from_json.hpp>
+
+// #include <nlohmann/detail/conversions/to_json.hpp>
+
+// #include <nlohmann/detail/exceptions.hpp>
+
+// #include <nlohmann/detail/input/binary_reader.hpp>
+
+
+#include <algorithm> // generate_n
+#include <array> // array
+#include <cassert> // assert
+#include <cmath> // ldexp
+#include <cstddef> // size_t
+#include <cstdint> // uint8_t, uint16_t, uint32_t, uint64_t
+#include <cstdio> // snprintf
+#include <cstring> // memcpy
+#include <iterator> // back_inserter
+#include <limits> // numeric_limits
+#include <string> // char_traits, string
+#include <utility> // make_pair, move
+
+// #include <nlohmann/detail/exceptions.hpp>
+
+// #include <nlohmann/detail/input/input_adapters.hpp>
+
+
+#include <array> // array
+#include <cassert> // assert
+#include <cstddef> // size_t
+#include <cstdio> //FILE *
+#include <cstring> // strlen
+#include <istream> // istream
+#include <iterator> // begin, end, iterator_traits, random_access_iterator_tag, distance, next
+#include <memory> // shared_ptr, make_shared, addressof
+#include <numeric> // accumulate
+#include <string> // string, char_traits
+#include <type_traits> // enable_if, is_base_of, is_pointer, is_integral, remove_pointer
+#include <utility> // pair, declval
+
+// #include <nlohmann/detail/iterators/iterator_traits.hpp>
+
+// #include <nlohmann/detail/macro_scope.hpp>
+
+
+namespace nlohmann
+{
+namespace detail
+{
+/// the supported input formats
+enum class input_format_t { json, cbor, msgpack, ubjson, bson };
+
+////////////////////
+// input adapters //
+////////////////////
+
+/*!
+@brief abstract input adapter interface
+
+Produces a stream of std::char_traits<char>::int_type characters from a
+std::istream, a buffer, or some other input type. Accepts the return of
+exactly one non-EOF character for future input. The int_type characters
+returned consist of all valid char values as positive values (typically
+unsigned char), plus an EOF value outside that range, specified by the value
+of the function std::char_traits<char>::eof(). This value is typically -1, but
+could be any arbitrary value which is not a valid char value.
+*/
+struct input_adapter_protocol
+{
+ /// get a character [0,255] or std::char_traits<char>::eof().
+ virtual std::char_traits<char>::int_type get_character() = 0;
+ virtual ~input_adapter_protocol() = default;
+};
+
+/// a type to simplify interfaces
+using input_adapter_t = std::shared_ptr<input_adapter_protocol>;
+
+/*!
+Input adapter for stdio file access. This adapter read only 1 byte and do not use any
+ buffer. This adapter is a very low level adapter.
+*/
+class file_input_adapter : public input_adapter_protocol
+{
+ public:
+ explicit file_input_adapter(std::FILE* f) noexcept
+ : m_file(f)
+ {}
+
+ // make class move-only
+ file_input_adapter(const file_input_adapter&) = delete;
+ file_input_adapter(file_input_adapter&&) = default;
+ file_input_adapter& operator=(const file_input_adapter&) = delete;
+ file_input_adapter& operator=(file_input_adapter&&) = default;
+ ~file_input_adapter() override = default;
+
+ std::char_traits<char>::int_type get_character() noexcept override
+ {
+ return std::fgetc(m_file);
+ }
+
+ private:
+ /// the file pointer to read from
+ std::FILE* m_file;
+};
+
+
+/*!
+Input adapter for a (caching) istream. Ignores a UFT Byte Order Mark at
+beginning of input. Does not support changing the underlying std::streambuf
+in mid-input. Maintains underlying std::istream and std::streambuf to support
+subsequent use of standard std::istream operations to process any input
+characters following those used in parsing the JSON input. Clears the
+std::istream flags; any input errors (e.g., EOF) will be detected by the first
+subsequent call for input from the std::istream.
+*/
+class input_stream_adapter : public input_adapter_protocol
+{
+ public:
+ ~input_stream_adapter() override
+ {
+ // clear stream flags; we use underlying streambuf I/O, do not
+ // maintain ifstream flags, except eof
+ is.clear(is.rdstate() & std::ios::eofbit);
+ }
+
+ explicit input_stream_adapter(std::istream& i)
+ : is(i), sb(*i.rdbuf())
+ {}
+
+ // delete because of pointer members
+ input_stream_adapter(const input_stream_adapter&) = delete;
+ input_stream_adapter& operator=(input_stream_adapter&) = delete;
+ input_stream_adapter(input_stream_adapter&&) = delete;
+ input_stream_adapter& operator=(input_stream_adapter&&) = delete;
+
+ // std::istream/std::streambuf use std::char_traits<char>::to_int_type, to
+ // ensure that std::char_traits<char>::eof() and the character 0xFF do not
+ // end up as the same value, eg. 0xFFFFFFFF.
+ std::char_traits<char>::int_type get_character() override
+ {
+ auto res = sb.sbumpc();
+ // set eof manually, as we don't use the istream interface.
+ if (res == EOF)
+ {
+ is.clear(is.rdstate() | std::ios::eofbit);
+ }
+ return res;
+ }
+
+ private:
+ /// the associated input stream
+ std::istream& is;
+ std::streambuf& sb;
+};
+
+/// input adapter for buffer input
+class input_buffer_adapter : public input_adapter_protocol
+{
+ public:
+ input_buffer_adapter(const char* b, const std::size_t l) noexcept
+ : cursor(b), limit(b + l)
+ {}
+
+ // delete because of pointer members
+ input_buffer_adapter(const input_buffer_adapter&) = delete;
+ input_buffer_adapter& operator=(input_buffer_adapter&) = delete;
+ input_buffer_adapter(input_buffer_adapter&&) = delete;
+ input_buffer_adapter& operator=(input_buffer_adapter&&) = delete;
+ ~input_buffer_adapter() override = default;
+
+ std::char_traits<char>::int_type get_character() noexcept override
+ {
+ if (JSON_LIKELY(cursor < limit))
+ {
+ return std::char_traits<char>::to_int_type(*(cursor++));
+ }
+
+ return std::char_traits<char>::eof();
+ }
+
+ private:
+ /// pointer to the current character
+ const char* cursor;
+ /// pointer past the last character
+ const char* const limit;
+};
+
+template<typename WideStringType, size_t T>
+struct wide_string_input_helper
+{
+ // UTF-32
+ static void fill_buffer(const WideStringType& str,
+ size_t& current_wchar,
+ std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
+ size_t& utf8_bytes_index,
+ size_t& utf8_bytes_filled)
+ {
+ utf8_bytes_index = 0;
+
+ if (current_wchar == str.size())
+ {
+ utf8_bytes[0] = std::char_traits<char>::eof();
+ utf8_bytes_filled = 1;
+ }
+ else
+ {
+ // get the current character
+ const auto wc = static_cast<unsigned int>(str[current_wchar++]);
+
+ // UTF-32 to UTF-8 encoding
+ if (wc < 0x80)
+ {
+ utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(wc);
+ utf8_bytes_filled = 1;
+ }
+ else if (wc <= 0x7FF)
+ {
+ utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xC0u | ((wc >> 6u) & 0x1Fu));
+ utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | (wc & 0x3Fu));
+ utf8_bytes_filled = 2;
+ }
+ else if (wc <= 0xFFFF)
+ {
+ utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xE0u | ((wc >> 12u) & 0x0Fu));
+ utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | ((wc >> 6u) & 0x3Fu));
+ utf8_bytes[2] = static_cast<std::char_traits<char>::int_type>(0x80u | (wc & 0x3Fu));
+ utf8_bytes_filled = 3;
+ }
+ else if (wc <= 0x10FFFF)
+ {
+ utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xF0u | ((wc >> 18u) & 0x07u));
+ utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | ((wc >> 12u) & 0x3Fu));
+ utf8_bytes[2] = static_cast<std::char_traits<char>::int_type>(0x80u | ((wc >> 6u) & 0x3Fu));
+ utf8_bytes[3] = static_cast<std::char_traits<char>::int_type>(0x80u | (wc & 0x3Fu));
+ utf8_bytes_filled = 4;
+ }
+ else
+ {
+ // unknown character
+ utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(wc);
+ utf8_bytes_filled = 1;
+ }
+ }
+ }
+};
+
+template<typename WideStringType>
+struct wide_string_input_helper<WideStringType, 2>
+{
+ // UTF-16
+ static void fill_buffer(const WideStringType& str,
+ size_t& current_wchar,
+ std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
+ size_t& utf8_bytes_index,
+ size_t& utf8_bytes_filled)
+ {
+ utf8_bytes_index = 0;
+
+ if (current_wchar == str.size())
+ {
+ utf8_bytes[0] = std::char_traits<char>::eof();
+ utf8_bytes_filled = 1;
+ }
+ else
+ {
+ // get the current character
+ const auto wc = static_cast<unsigned int>(str[current_wchar++]);
+
+ // UTF-16 to UTF-8 encoding
+ if (wc < 0x80)
+ {
+ utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(wc);
+ utf8_bytes_filled = 1;
+ }
+ else if (wc <= 0x7FF)
+ {
+ utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xC0u | ((wc >> 6u)));
+ utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | (wc & 0x3Fu));
+ utf8_bytes_filled = 2;
+ }
+ else if (0xD800 > wc or wc >= 0xE000)
+ {
+ utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xE0u | ((wc >> 12u)));
+ utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | ((wc >> 6u) & 0x3Fu));
+ utf8_bytes[2] = static_cast<std::char_traits<char>::int_type>(0x80u | (wc & 0x3Fu));
+ utf8_bytes_filled = 3;
+ }
+ else
+ {
+ if (current_wchar < str.size())
+ {
+ const auto wc2 = static_cast<unsigned int>(str[current_wchar++]);
+ const auto charcode = 0x10000u + (((wc & 0x3FFu) << 10u) | (wc2 & 0x3FFu));
+ utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xF0u | (charcode >> 18u));
+ utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | ((charcode >> 12u) & 0x3Fu));
+ utf8_bytes[2] = static_cast<std::char_traits<char>::int_type>(0x80u | ((charcode >> 6u) & 0x3Fu));
+ utf8_bytes[3] = static_cast<std::char_traits<char>::int_type>(0x80u | (charcode & 0x3Fu));
+ utf8_bytes_filled = 4;
+ }
+ else
+ {
+ // unknown character
+ ++current_wchar;
+ utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(wc);
+ utf8_bytes_filled = 1;
+ }
+ }
+ }
+ }
+};
+
+template<typename WideStringType>
+class wide_string_input_adapter : public input_adapter_protocol
+{
+ public:
+ explicit wide_string_input_adapter(const WideStringType& w) noexcept
+ : str(w)
+ {}
+
+ std::char_traits<char>::int_type get_character() noexcept override
+ {
+ // check if buffer needs to be filled
+ if (utf8_bytes_index == utf8_bytes_filled)
+ {
+ fill_buffer<sizeof(typename WideStringType::value_type)>();
+
+ assert(utf8_bytes_filled > 0);
+ assert(utf8_bytes_index == 0);
+ }
+
+ // use buffer
+ assert(utf8_bytes_filled > 0);
+ assert(utf8_bytes_index < utf8_bytes_filled);
+ return utf8_bytes[utf8_bytes_index++];
+ }
+
+ private:
+ template<size_t T>
+ void fill_buffer()
+ {
+ wide_string_input_helper<WideStringType, T>::fill_buffer(str, current_wchar, utf8_bytes, utf8_bytes_index, utf8_bytes_filled);
+ }
+
+ /// the wstring to process
+ const WideStringType& str;
+
+ /// index of the current wchar in str
+ std::size_t current_wchar = 0;
+
+ /// a buffer for UTF-8 bytes
+ std::array<std::char_traits<char>::int_type, 4> utf8_bytes = {{0, 0, 0, 0}};
+
+ /// index to the utf8_codes array for the next valid byte
+ std::size_t utf8_bytes_index = 0;
+ /// number of valid bytes in the utf8_codes array
+ std::size_t utf8_bytes_filled = 0;
+};
+
+class input_adapter
+{
+ public:
+ // native support
+ input_adapter(std::FILE* file)
+ : ia(std::make_shared<file_input_adapter>(file)) {}
+ /// input adapter for input stream
+ input_adapter(std::istream& i)
+ : ia(std::make_shared<input_stream_adapter>(i)) {}
+
+ /// input adapter for input stream
+ input_adapter(std::istream&& i)
+ : ia(std::make_shared<input_stream_adapter>(i)) {}
+
+ input_adapter(const std::wstring& ws)
+ : ia(std::make_shared<wide_string_input_adapter<std::wstring>>(ws)) {}
+
+ input_adapter(const std::u16string& ws)
+ : ia(std::make_shared<wide_string_input_adapter<std::u16string>>(ws)) {}
+
+ input_adapter(const std::u32string& ws)
+ : ia(std::make_shared<wide_string_input_adapter<std::u32string>>(ws)) {}
+
+ /// input adapter for buffer
+ template<typename CharT,
+ typename std::enable_if<
+ std::is_pointer<CharT>::value and
+ std::is_integral<typename std::remove_pointer<CharT>::type>::value and
+ sizeof(typename std::remove_pointer<CharT>::type) == 1,
+ int>::type = 0>
+ input_adapter(CharT b, std::size_t l)
+ : ia(std::make_shared<input_buffer_adapter>(reinterpret_cast<const char*>(b), l)) {}
+
+ // derived support
+
+ /// input adapter for string literal
+ template<typename CharT,
+ typename std::enable_if<
+ std::is_pointer<CharT>::value and
+ std::is_integral<typename std::remove_pointer<CharT>::type>::value and
+ sizeof(typename std::remove_pointer<CharT>::type) == 1,
+ int>::type = 0>
+ input_adapter(CharT b)
+ : input_adapter(reinterpret_cast<const char*>(b),
+ std::strlen(reinterpret_cast<const char*>(b))) {}
+
+ /// input adapter for iterator range with contiguous storage
+ template<class IteratorType,
+ typename std::enable_if<
+ std::is_same<typename iterator_traits<IteratorType>::iterator_category, std::random_access_iterator_tag>::value,
+ int>::type = 0>
+ input_adapter(IteratorType first, IteratorType last)
+ {
+#ifndef NDEBUG
+ // assertion to check that the iterator range is indeed contiguous,
+ // see http://stackoverflow.com/a/35008842/266378 for more discussion
+ const auto is_contiguous = std::accumulate(
+ first, last, std::pair<bool, int>(true, 0),
+ [&first](std::pair<bool, int> res, decltype(*first) val)
+ {
+ res.first &= (val == *(std::next(std::addressof(*first), res.second++)));
+ return res;
+ }).first;
+ assert(is_contiguous);
+#endif
+
+ // assertion to check that each element is 1 byte long
+ static_assert(
+ sizeof(typename iterator_traits<IteratorType>::value_type) == 1,
+ "each element in the iterator range must have the size of 1 byte");
+
+ const auto len = static_cast<size_t>(std::distance(first, last));
+ if (JSON_LIKELY(len > 0))
+ {
+ // there is at least one element: use the address of first
+ ia = std::make_shared<input_buffer_adapter>(reinterpret_cast<const char*>(&(*first)), len);
+ }
+ else
+ {
+ // the address of first cannot be used: use nullptr
+ ia = std::make_shared<input_buffer_adapter>(nullptr, len);
+ }
+ }
+
+ /// input adapter for array
+ template<class T, std::size_t N>
+ input_adapter(T (&array)[N])
+ : input_adapter(std::begin(array), std::end(array)) {}
+
+ /// input adapter for contiguous container
+ template<class ContiguousContainer, typename
+ std::enable_if<not std::is_pointer<ContiguousContainer>::value and
+ std::is_base_of<std::random_access_iterator_tag, typename iterator_traits<decltype(std::begin(std::declval<ContiguousContainer const>()))>::iterator_category>::value,
+ int>::type = 0>
+ input_adapter(const ContiguousContainer& c)
+ : input_adapter(std::begin(c), std::end(c)) {}
+
+ operator input_adapter_t()
+ {
+ return ia;
+ }
+
+ private:
+ /// the actual adapter
+ input_adapter_t ia = nullptr;
+};
+} // namespace detail
+} // namespace nlohmann
+
+// #include <nlohmann/detail/input/json_sax.hpp>
+
+
+#include <cassert> // assert
+#include <cstddef>
+#include <string> // string
+#include <utility> // move
+#include <vector> // vector
+
+// #include <nlohmann/detail/exceptions.hpp>
+
+// #include <nlohmann/detail/macro_scope.hpp>
+
+
+namespace nlohmann
+{
+
+/*!
+@brief SAX interface
+
+This class describes the SAX interface used by @ref nlohmann::json::sax_parse.
+Each function is called in different situations while the input is parsed. The
+boolean return value informs the parser whether to continue processing the
+input.
+*/
+template<typename BasicJsonType>
+struct json_sax
+{
+ /// type for (signed) integers
+ using number_integer_t = typename BasicJsonType::number_integer_t;
+ /// type for unsigned integers
+ using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
+ /// type for floating-point numbers
+ using number_float_t = typename BasicJsonType::number_float_t;
+ /// type for strings
+ using string_t = typename BasicJsonType::string_t;
+
+ /*!
+ @brief a null value was read
+ @return whether parsing should proceed
+ */
+ virtual bool null() = 0;
+
+ /*!
+ @brief a boolean value was read
+ @param[in] val boolean value
+ @return whether parsing should proceed
+ */
+ virtual bool boolean(bool val) = 0;
+
+ /*!
+ @brief an integer number was read
+ @param[in] val integer value
+ @return whether parsing should proceed
+ */
+ virtual bool number_integer(number_integer_t val) = 0;
+
+ /*!
+ @brief an unsigned integer number was read
+ @param[in] val unsigned integer value
+ @return whether parsing should proceed
+ */
+ virtual bool number_unsigned(number_unsigned_t val) = 0;
+
+ /*!
+ @brief an floating-point number was read
+ @param[in] val floating-point value
+ @param[in] s raw token value
+ @return whether parsing should proceed
+ */
+ virtual bool number_float(number_float_t val, const string_t& s) = 0;
+
+ /*!
+ @brief a string was read
+ @param[in] val string value
+ @return whether parsing should proceed
+ @note It is safe to move the passed string.
+ */
+ virtual bool string(string_t& val) = 0;
+
+ /*!
+ @brief the beginning of an object was read
+ @param[in] elements number of object elements or -1 if unknown
+ @return whether parsing should proceed
+ @note binary formats may report the number of elements
+ */
+ virtual bool start_object(std::size_t elements) = 0;
+
+ /*!
+ @brief an object key was read
+ @param[in] val object key
+ @return whether parsing should proceed
+ @note It is safe to move the passed string.
+ */
+ virtual bool key(string_t& val) = 0;
+
+ /*!
+ @brief the end of an object was read
+ @return whether parsing should proceed
+ */
+ virtual bool end_object() = 0;
+
+ /*!
+ @brief the beginning of an array was read
+ @param[in] elements number of array elements or -1 if unknown
+ @return whether parsing should proceed
+ @note binary formats may report the number of elements
+ */
+ virtual bool start_array(std::size_t elements) = 0;
+
+ /*!
+ @brief the end of an array was read
+ @return whether parsing should proceed
+ */
+ virtual bool end_array() = 0;
+
+ /*!
+ @brief a parse error occurred
+ @param[in] position the position in the input where the error occurs
+ @param[in] last_token the last read token
+ @param[in] ex an exception object describing the error
+ @return whether parsing should proceed (must return false)
+ */
+ virtual bool parse_error(std::size_t position,
+ const std::string& last_token,
+ const detail::exception& ex) = 0;
+
+ virtual ~json_sax() = default;
+};
+
+
+namespace detail
+{
+/*!
+@brief SAX implementation to create a JSON value from SAX events
+
+This class implements the @ref json_sax interface and processes the SAX events
+to create a JSON value which makes it basically a DOM parser. The structure or
+hierarchy of the JSON value is managed by the stack `ref_stack` which contains
+a pointer to the respective array or object for each recursion depth.
+
+After successful parsing, the value that is passed by reference to the
+constructor contains the parsed value.
+
+@tparam BasicJsonType the JSON type
+*/
+template<typename BasicJsonType>
+class json_sax_dom_parser
+{
+ public:
+ using number_integer_t = typename BasicJsonType::number_integer_t;
+ using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
+ using number_float_t = typename BasicJsonType::number_float_t;
+ using string_t = typename BasicJsonType::string_t;
+
+ /*!
+ @param[in, out] r reference to a JSON value that is manipulated while
+ parsing
+ @param[in] allow_exceptions_ whether parse errors yield exceptions
+ */
+ explicit json_sax_dom_parser(BasicJsonType& r, const bool allow_exceptions_ = true)
+ : root(r), allow_exceptions(allow_exceptions_)
+ {}
+
+ // make class move-only
+ json_sax_dom_parser(const json_sax_dom_parser&) = delete;
+ json_sax_dom_parser(json_sax_dom_parser&&) = default;
+ json_sax_dom_parser& operator=(const json_sax_dom_parser&) = delete;
+ json_sax_dom_parser& operator=(json_sax_dom_parser&&) = default;
+ ~json_sax_dom_parser() = default;
+
+ bool null()
+ {
+ handle_value(nullptr);
+ return true;
+ }
+
+ bool boolean(bool val)
+ {
+ handle_value(val);
+ return true;
+ }
+
+ bool number_integer(number_integer_t val)
+ {
+ handle_value(val);
+ return true;
+ }
+
+ bool number_unsigned(number_unsigned_t val)
+ {
+ handle_value(val);
+ return true;
+ }
+
+ bool number_float(number_float_t val, const string_t& /*unused*/)
+ {
+ handle_value(val);
+ return true;
+ }
+
+ bool string(string_t& val)
+ {
+ handle_value(val);
+ return true;
+ }
+
+ bool start_object(std::size_t len)
+ {
+ ref_stack.push_back(handle_value(BasicJsonType::value_t::object));
+
+ if (JSON_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size()))
+ {
+ JSON_THROW(out_of_range::create(408,
+ "excessive object size: " + std::to_string(len)));
+ }
+
+ return true;
+ }
+
+ bool key(string_t& val)
+ {
+ // add null at given key and store the reference for later
+ object_element = &(ref_stack.back()->m_value.object->operator[](val));
+ return true;
+ }
+
+ bool end_object()
+ {
+ ref_stack.pop_back();
+ return true;
+ }
+
+ bool start_array(std::size_t len)
+ {
+ ref_stack.push_back(handle_value(BasicJsonType::value_t::array));
+
+ if (JSON_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size()))
+ {
+ JSON_THROW(out_of_range::create(408,
+ "excessive array size: " + std::to_string(len)));
+ }
+
+ return true;
+ }
+
+ bool end_array()
+ {
+ ref_stack.pop_back();
+ return true;
+ }
+
+ bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/,
+ const detail::exception& ex)
+ {
+ errored = true;
+ if (allow_exceptions)
+ {
+ // determine the proper exception type from the id
+ switch ((ex.id / 100) % 100)
+ {
+ case 1:
+ JSON_THROW(*static_cast<const detail::parse_error*>(&ex));
+ case 4:
+ JSON_THROW(*static_cast<const detail::out_of_range*>(&ex));
+ // LCOV_EXCL_START
+ case 2:
+ JSON_THROW(*static_cast<const detail::invalid_iterator*>(&ex));
+ case 3:
+ JSON_THROW(*static_cast<const detail::type_error*>(&ex));
+ case 5:
+ JSON_THROW(*static_cast<const detail::other_error*>(&ex));
+ default:
+ assert(false);
+ // LCOV_EXCL_STOP
+ }
+ }
+ return false;
+ }
+
+ constexpr bool is_errored() const
+ {
+ return errored;
+ }
+
+ private:
+ /*!
+ @invariant If the ref stack is empty, then the passed value will be the new
+ root.
+ @invariant If the ref stack contains a value, then it is an array or an
+ object to which we can add elements
+ */
+ template<typename Value>
+ BasicJsonType* handle_value(Value&& v)
+ {
+ if (ref_stack.empty())
+ {
+ root = BasicJsonType(std::forward<Value>(v));
+ return &root;
+ }
+
+ assert(ref_stack.back()->is_array() or ref_stack.back()->is_object());
+
+ if (ref_stack.back()->is_array())
+ {
+ ref_stack.back()->m_value.array->emplace_back(std::forward<Value>(v));
+ return &(ref_stack.back()->m_value.array->back());
+ }
+
+ assert(ref_stack.back()->is_object());
+ assert(object_element);
+ *object_element = BasicJsonType(std::forward<Value>(v));
+ return object_element;
+ }
+
+ /// the parsed JSON value
+ BasicJsonType& root;
+ /// stack to model hierarchy of values
+ std::vector<BasicJsonType*> ref_stack {};
+ /// helper to hold the reference for the next object element
+ BasicJsonType* object_element = nullptr;
+ /// whether a syntax error occurred
+ bool errored = false;
+ /// whether to throw exceptions in case of errors
+ const bool allow_exceptions = true;
+};
+
+template<typename BasicJsonType>
+class json_sax_dom_callback_parser
+{
+ public:
+ using number_integer_t = typename BasicJsonType::number_integer_t;
+ using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
+ using number_float_t = typename BasicJsonType::number_float_t;
+ using string_t = typename BasicJsonType::string_t;
+ using parser_callback_t = typename BasicJsonType::parser_callback_t;
+ using parse_event_t = typename BasicJsonType::parse_event_t;
+
+ json_sax_dom_callback_parser(BasicJsonType& r,
+ const parser_callback_t cb,
+ const bool allow_exceptions_ = true)
+ : root(r), callback(cb), allow_exceptions(allow_exceptions_)
+ {
+ keep_stack.push_back(true);
+ }
+
+ // make class move-only
+ json_sax_dom_callback_parser(const json_sax_dom_callback_parser&) = delete;
+ json_sax_dom_callback_parser(json_sax_dom_callback_parser&&) = default;
+ json_sax_dom_callback_parser& operator=(const json_sax_dom_callback_parser&) = delete;
+ json_sax_dom_callback_parser& operator=(json_sax_dom_callback_parser&&) = default;
+ ~json_sax_dom_callback_parser() = default;
+
+ bool null()
+ {
+ handle_value(nullptr);
+ return true;
+ }
+
+ bool boolean(bool val)
+ {
+ handle_value(val);
+ return true;
+ }
+
+ bool number_integer(number_integer_t val)
+ {
+ handle_value(val);
+ return true;
+ }
+
+ bool number_unsigned(number_unsigned_t val)
+ {
+ handle_value(val);
+ return true;
+ }
+
+ bool number_float(number_float_t val, const string_t& /*unused*/)
+ {
+ handle_value(val);
+ return true;
+ }
+
+ bool string(string_t& val)
+ {
+ handle_value(val);
+ return true;
+ }
+
+ bool start_object(std::size_t len)
+ {
+ // check callback for object start
+ const bool keep = callback(static_cast<int>(ref_stack.size()), parse_event_t::object_start, discarded);
+ keep_stack.push_back(keep);
+
+ auto val = handle_value(BasicJsonType::value_t::object, true);
+ ref_stack.push_back(val.second);
+
+ // check object limit
+ if (ref_stack.back() and JSON_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size()))
+ {
+ JSON_THROW(out_of_range::create(408, "excessive object size: " + std::to_string(len)));
+ }
+
+ return true;
+ }
+
+ bool key(string_t& val)
+ {
+ BasicJsonType k = BasicJsonType(val);
+
+ // check callback for key
+ const bool keep = callback(static_cast<int>(ref_stack.size()), parse_event_t::key, k);
+ key_keep_stack.push_back(keep);
+
+ // add discarded value at given key and store the reference for later
+ if (keep and ref_stack.back())
+ {
+ object_element = &(ref_stack.back()->m_value.object->operator[](val) = discarded);
+ }
+
+ return true;
+ }
+
+ bool end_object()
+ {
+ if (ref_stack.back() and not callback(static_cast<int>(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back()))
+ {
+ // discard object
+ *ref_stack.back() = discarded;
+ }
+
+ assert(not ref_stack.empty());
+ assert(not keep_stack.empty());
+ ref_stack.pop_back();
+ keep_stack.pop_back();
+
+ if (not ref_stack.empty() and ref_stack.back() and ref_stack.back()->is_object())
+ {
+ // remove discarded value
+ for (auto it = ref_stack.back()->begin(); it != ref_stack.back()->end(); ++it)
+ {
+ if (it->is_discarded())
+ {
+ ref_stack.back()->erase(it);
+ break;
+ }
+ }
+ }
+
+ return true;
+ }
+
+ bool start_array(std::size_t len)
+ {
+ const bool keep = callback(static_cast<int>(ref_stack.size()), parse_event_t::array_start, discarded);
+ keep_stack.push_back(keep);
+
+ auto val = handle_value(BasicJsonType::value_t::array, true);
+ ref_stack.push_back(val.second);
+
+ // check array limit
+ if (ref_stack.back() and JSON_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size()))
+ {
+ JSON_THROW(out_of_range::create(408, "excessive array size: " + std::to_string(len)));
+ }
+
+ return true;
+ }
+
+ bool end_array()
+ {
+ bool keep = true;
+
+ if (ref_stack.back())
+ {
+ keep = callback(static_cast<int>(ref_stack.size()) - 1, parse_event_t::array_end, *ref_stack.back());
+ if (not keep)
+ {
+ // discard array
+ *ref_stack.back() = discarded;
+ }
+ }
+
+ assert(not ref_stack.empty());
+ assert(not keep_stack.empty());
+ ref_stack.pop_back();
+ keep_stack.pop_back();
+
+ // remove discarded value
+ if (not keep and not ref_stack.empty() and ref_stack.back()->is_array())
+ {
+ ref_stack.back()->m_value.array->pop_back();
+ }
+
+ return true;
+ }
+
+ bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/,
+ const detail::exception& ex)
+ {
+ errored = true;
+ if (allow_exceptions)
+ {
+ // determine the proper exception type from the id
+ switch ((ex.id / 100) % 100)
+ {
+ case 1:
+ JSON_THROW(*static_cast<const detail::parse_error*>(&ex));
+ case 4:
+ JSON_THROW(*static_cast<const detail::out_of_range*>(&ex));
+ // LCOV_EXCL_START
+ case 2:
+ JSON_THROW(*static_cast<const detail::invalid_iterator*>(&ex));
+ case 3:
+ JSON_THROW(*static_cast<const detail::type_error*>(&ex));
+ case 5:
+ JSON_THROW(*static_cast<const detail::other_error*>(&ex));
+ default:
+ assert(false);
+ // LCOV_EXCL_STOP
+ }
+ }
+ return false;
+ }
+
+ constexpr bool is_errored() const
+ {
+ return errored;
+ }
+
+ private:
+ /*!
+ @param[in] v value to add to the JSON value we build during parsing
+ @param[in] skip_callback whether we should skip calling the callback
+ function; this is required after start_array() and
+ start_object() SAX events, because otherwise we would call the
+ callback function with an empty array or object, respectively.
+
+ @invariant If the ref stack is empty, then the passed value will be the new
+ root.
+ @invariant If the ref stack contains a value, then it is an array or an
+ object to which we can add elements
+
+ @return pair of boolean (whether value should be kept) and pointer (to the
+ passed value in the ref_stack hierarchy; nullptr if not kept)
+ */
+ template<typename Value>
+ std::pair<bool, BasicJsonType*> handle_value(Value&& v, const bool skip_callback = false)
+ {
+ assert(not keep_stack.empty());
+
+ // do not handle this value if we know it would be added to a discarded
+ // container
+ if (not keep_stack.back())
+ {
+ return {false, nullptr};
+ }
+
+ // create value
+ auto value = BasicJsonType(std::forward<Value>(v));
+
+ // check callback
+ const bool keep = skip_callback or callback(static_cast<int>(ref_stack.size()), parse_event_t::value, value);
+
+ // do not handle this value if we just learnt it shall be discarded
+ if (not keep)
+ {
+ return {false, nullptr};
+ }
+
+ if (ref_stack.empty())
+ {
+ root = std::move(value);
+ return {true, &root};
+ }
+
+ // skip this value if we already decided to skip the parent
+ // (https://github.com/nlohmann/json/issues/971#issuecomment-413678360)
+ if (not ref_stack.back())
+ {
+ return {false, nullptr};
+ }
+
+ // we now only expect arrays and objects
+ assert(ref_stack.back()->is_array() or ref_stack.back()->is_object());
+
+ // array
+ if (ref_stack.back()->is_array())
+ {
+ ref_stack.back()->m_value.array->push_back(std::move(value));
+ return {true, &(ref_stack.back()->m_value.array->back())};
+ }
+
+ // object
+ assert(ref_stack.back()->is_object());
+ // check if we should store an element for the current key
+ assert(not key_keep_stack.empty());
+ const bool store_element = key_keep_stack.back();
+ key_keep_stack.pop_back();
+
+ if (not store_element)
+ {
+ return {false, nullptr};
+ }
+
+ assert(object_element);
+ *object_element = std::move(value);
+ return {true, object_element};
+ }
+
+ /// the parsed JSON value
+ BasicJsonType& root;
+ /// stack to model hierarchy of values
+ std::vector<BasicJsonType*> ref_stack {};
+ /// stack to manage which values to keep
+ std::vector<bool> keep_stack {};
+ /// stack to manage which object keys to keep
+ std::vector<bool> key_keep_stack {};
+ /// helper to hold the reference for the next object element
+ BasicJsonType* object_element = nullptr;
+ /// whether a syntax error occurred
+ bool errored = false;
+ /// callback function
+ const parser_callback_t callback = nullptr;
+ /// whether to throw exceptions in case of errors
+ const bool allow_exceptions = true;
+ /// a discarded value for the callback
+ BasicJsonType discarded = BasicJsonType::value_t::discarded;
+};
+
+template<typename BasicJsonType>
+class json_sax_acceptor
+{
+ public:
+ using number_integer_t = typename BasicJsonType::number_integer_t;
+ using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
+ using number_float_t = typename BasicJsonType::number_float_t;
+ using string_t = typename BasicJsonType::string_t;
+
+ bool null()
+ {
+ return true;
+ }
+
+ bool boolean(bool /*unused*/)
+ {
+ return true;
+ }
+
+ bool number_integer(number_integer_t /*unused*/)
+ {
+ return true;
+ }
+
+ bool number_unsigned(number_unsigned_t /*unused*/)
+ {
+ return true;
+ }
+
+ bool number_float(number_float_t /*unused*/, const string_t& /*unused*/)
+ {
+ return true;
+ }
+
+ bool string(string_t& /*unused*/)
+ {
+ return true;
+ }
+
+ bool start_object(std::size_t /*unused*/ = std::size_t(-1))
+ {
+ return true;
+ }
+
+ bool key(string_t& /*unused*/)
+ {
+ return true;
+ }
+
+ bool end_object()
+ {
+ return true;
+ }
+
+ bool start_array(std::size_t /*unused*/ = std::size_t(-1))
+ {
+ return true;
+ }
+
+ bool end_array()
+ {
+ return true;
+ }
+
+ bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, const detail::exception& /*unused*/)
+ {
+ return false;
+ }
+};
+} // namespace detail
+
+} // namespace nlohmann
+
+// #include <nlohmann/detail/macro_scope.hpp>
+
+// #include <nlohmann/detail/meta/is_sax.hpp>
+
+
+#include <cstdint> // size_t
+#include <utility> // declval
+#include <string> // string
+
+// #include <nlohmann/detail/meta/detected.hpp>
+
+// #include <nlohmann/detail/meta/type_traits.hpp>
+
+
+namespace nlohmann
+{
+namespace detail
+{
+template <typename T>
+using null_function_t = decltype(std::declval<T&>().null());
+
+template <typename T>
+using boolean_function_t =
+ decltype(std::declval<T&>().boolean(std::declval<bool>()));
+
+template <typename T, typename Integer>
+using number_integer_function_t =
+ decltype(std::declval<T&>().number_integer(std::declval<Integer>()));
+
+template <typename T, typename Unsigned>
+using number_unsigned_function_t =
+ decltype(std::declval<T&>().number_unsigned(std::declval<Unsigned>()));
+
+template <typename T, typename Float, typename String>
+using number_float_function_t = decltype(std::declval<T&>().number_float(
+ std::declval<Float>(), std::declval<const String&>()));
+
+template <typename T, typename String>
+using string_function_t =
+ decltype(std::declval<T&>().string(std::declval<String&>()));
+
+template <typename T>
+using start_object_function_t =
+ decltype(std::declval<T&>().start_object(std::declval<std::size_t>()));
+
+template <typename T, typename String>
+using key_function_t =
+ decltype(std::declval<T&>().key(std::declval<String&>()));
+
+template <typename T>
+using end_object_function_t = decltype(std::declval<T&>().end_object());
+
+template <typename T>
+using start_array_function_t =
+ decltype(std::declval<T&>().start_array(std::declval<std::size_t>()));
+
+template <typename T>
+using end_array_function_t = decltype(std::declval<T&>().end_array());
+
+template <typename T, typename Exception>
+using parse_error_function_t = decltype(std::declval<T&>().parse_error(
+ std::declval<std::size_t>(), std::declval<const std::string&>(),
+ std::declval<const Exception&>()));
+
+template <typename SAX, typename BasicJsonType>
+struct is_sax
+{
+ private:
+ static_assert(is_basic_json<BasicJsonType>::value,
+ "BasicJsonType must be of type basic_json<...>");
+
+ using number_integer_t = typename BasicJsonType::number_integer_t;
+ using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
+ using number_float_t = typename BasicJsonType::number_float_t;
+ using string_t = typename BasicJsonType::string_t;
+ using exception_t = typename BasicJsonType::exception;
+
+ public:
+ static constexpr bool value =
+ is_detected_exact<bool, null_function_t, SAX>::value &&
+ is_detected_exact<bool, boolean_function_t, SAX>::value &&
+ is_detected_exact<bool, number_integer_function_t, SAX,
+ number_integer_t>::value &&
+ is_detected_exact<bool, number_unsigned_function_t, SAX,
+ number_unsigned_t>::value &&
+ is_detected_exact<bool, number_float_function_t, SAX, number_float_t,
+ string_t>::value &&
+ is_detected_exact<bool, string_function_t, SAX, string_t>::value &&
+ is_detected_exact<bool, start_object_function_t, SAX>::value &&
+ is_detected_exact<bool, key_function_t, SAX, string_t>::value &&
+ is_detected_exact<bool, end_object_function_t, SAX>::value &&
+ is_detected_exact<bool, start_array_function_t, SAX>::value &&
+ is_detected_exact<bool, end_array_function_t, SAX>::value &&
+ is_detected_exact<bool, parse_error_function_t, SAX, exception_t>::value;
+};
+
+template <typename SAX, typename BasicJsonType>
+struct is_sax_static_asserts
+{
+ private:
+ static_assert(is_basic_json<BasicJsonType>::value,
+ "BasicJsonType must be of type basic_json<...>");
+
+ using number_integer_t = typename BasicJsonType::number_integer_t;
+ using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
+ using number_float_t = typename BasicJsonType::number_float_t;
+ using string_t = typename BasicJsonType::string_t;
+ using exception_t = typename BasicJsonType::exception;
+
+ public:
+ static_assert(is_detected_exact<bool, null_function_t, SAX>::value,
+ "Missing/invalid function: bool null()");
+ static_assert(is_detected_exact<bool, boolean_function_t, SAX>::value,
+ "Missing/invalid function: bool boolean(bool)");
+ static_assert(is_detected_exact<bool, boolean_function_t, SAX>::value,
+ "Missing/invalid function: bool boolean(bool)");
+ static_assert(
+ is_detected_exact<bool, number_integer_function_t, SAX,
+ number_integer_t>::value,
+ "Missing/invalid function: bool number_integer(number_integer_t)");
+ static_assert(
+ is_detected_exact<bool, number_unsigned_function_t, SAX,
+ number_unsigned_t>::value,
+ "Missing/invalid function: bool number_unsigned(number_unsigned_t)");
+ static_assert(is_detected_exact<bool, number_float_function_t, SAX,
+ number_float_t, string_t>::value,
+ "Missing/invalid function: bool number_float(number_float_t, const string_t&)");
+ static_assert(
+ is_detected_exact<bool, string_function_t, SAX, string_t>::value,
+ "Missing/invalid function: bool string(string_t&)");
+ static_assert(is_detected_exact<bool, start_object_function_t, SAX>::value,
+ "Missing/invalid function: bool start_object(std::size_t)");
+ static_assert(is_detected_exact<bool, key_function_t, SAX, string_t>::value,
+ "Missing/invalid function: bool key(string_t&)");
+ static_assert(is_detected_exact<bool, end_object_function_t, SAX>::value,
+ "Missing/invalid function: bool end_object()");
+ static_assert(is_detected_exact<bool, start_array_function_t, SAX>::value,
+ "Missing/invalid function: bool start_array(std::size_t)");
+ static_assert(is_detected_exact<bool, end_array_function_t, SAX>::value,
+ "Missing/invalid function: bool end_array()");
+ static_assert(
+ is_detected_exact<bool, parse_error_function_t, SAX, exception_t>::value,
+ "Missing/invalid function: bool parse_error(std::size_t, const "
+ "std::string&, const exception&)");
+};
+} // namespace detail
+} // namespace nlohmann
+
+// #include <nlohmann/detail/value_t.hpp>
+
+
+namespace nlohmann
+{
+namespace detail
+{
+///////////////////
+// binary reader //
+///////////////////
+
+/*!
+@brief deserialization of CBOR, MessagePack, and UBJSON values
+*/
+template<typename BasicJsonType, typename SAX = json_sax_dom_parser<BasicJsonType>>
+class binary_reader
+{
+ using number_integer_t = typename BasicJsonType::number_integer_t;
+ using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
+ using number_float_t = typename BasicJsonType::number_float_t;
+ using string_t = typename BasicJsonType::string_t;
+ using json_sax_t = SAX;
+
+ public:
+ /*!
+ @brief create a binary reader
+
+ @param[in] adapter input adapter to read from
+ */
+ explicit binary_reader(input_adapter_t adapter) : ia(std::move(adapter))
+ {
+ (void)detail::is_sax_static_asserts<SAX, BasicJsonType> {};
+ assert(ia);
+ }
+
+ // make class move-only
+ binary_reader(const binary_reader&) = delete;
+ binary_reader(binary_reader&&) = default;
+ binary_reader& operator=(const binary_reader&) = delete;
+ binary_reader& operator=(binary_reader&&) = default;
+ ~binary_reader() = default;
+
+ /*!
+ @param[in] format the binary format to parse
+ @param[in] sax_ a SAX event processor
+ @param[in] strict whether to expect the input to be consumed completed
+
+ @return
+ */
+ bool sax_parse(const input_format_t format,
+ json_sax_t* sax_,
+ const bool strict = true)
+ {
+ sax = sax_;
+ bool result = false;
+
+ switch (format)
+ {
+ case input_format_t::bson:
+ result = parse_bson_internal();
+ break;
+
+ case input_format_t::cbor:
+ result = parse_cbor_internal();
+ break;
+
+ case input_format_t::msgpack:
+ result = parse_msgpack_internal();
+ break;
+
+ case input_format_t::ubjson:
+ result = parse_ubjson_internal();
+ break;
+
+ default: // LCOV_EXCL_LINE
+ assert(false); // LCOV_EXCL_LINE
+ }
+
+ // strict mode: next byte must be EOF
+ if (result and strict)
+ {
+ if (format == input_format_t::ubjson)
+ {
+ get_ignore_noop();
+ }
+ else
+ {
+ get();
+ }
+
+ if (JSON_UNLIKELY(current != std::char_traits<char>::eof()))
+ {
+ return sax->parse_error(chars_read, get_token_string(),
+ parse_error::create(110, chars_read, exception_message(format, "expected end of input; last byte: 0x" + get_token_string(), "value")));
+ }
+ }
+
+ return result;
+ }
+
+ /*!
+ @brief determine system byte order
+
+ @return true if and only if system's byte order is little endian
+
+ @note from http://stackoverflow.com/a/1001328/266378
+ */
+ static constexpr bool little_endianess(int num = 1) noexcept
+ {
+ return *reinterpret_cast<char*>(&num) == 1;
+ }
+
+ private:
+ //////////
+ // BSON //
+ //////////
+
+ /*!
+ @brief Reads in a BSON-object and passes it to the SAX-parser.
+ @return whether a valid BSON-value was passed to the SAX parser
+ */
+ bool parse_bson_internal()
+ {
+ std::int32_t document_size;
+ get_number<std::int32_t, true>(input_format_t::bson, document_size);
+
+ if (JSON_UNLIKELY(not sax->start_object(std::size_t(-1))))
+ {
+ return false;
+ }
+
+ if (JSON_UNLIKELY(not parse_bson_element_list(/*is_array*/false)))
+ {
+ return false;
+ }
+
+ return sax->end_object();
+ }
+
+ /*!
+ @brief Parses a C-style string from the BSON input.
+ @param[in, out] result A reference to the string variable where the read
+ string is to be stored.
+ @return `true` if the \x00-byte indicating the end of the string was
+ encountered before the EOF; false` indicates an unexpected EOF.
+ */
+ bool get_bson_cstr(string_t& result)
+ {
+ auto out = std::back_inserter(result);
+ while (true)
+ {
+ get();
+ if (JSON_UNLIKELY(not unexpect_eof(input_format_t::bson, "cstring")))
+ {
+ return false;
+ }
+ if (current == 0x00)
+ {
+ return true;
+ }
+ *out++ = static_cast<char>(current);
+ }
+
+ return true;
+ }
+
+ /*!
+ @brief Parses a zero-terminated string of length @a len from the BSON
+ input.
+ @param[in] len The length (including the zero-byte at the end) of the
+ string to be read.
+ @param[in, out] result A reference to the string variable where the read
+ string is to be stored.
+ @tparam NumberType The type of the length @a len
+ @pre len >= 1
+ @return `true` if the string was successfully parsed
+ */
+ template<typename NumberType>
+ bool get_bson_string(const NumberType len, string_t& result)
+ {
+ if (JSON_UNLIKELY(len < 1))
+ {
+ auto last_token = get_token_string();
+ return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::bson, "string length must be at least 1, is " + std::to_string(len), "string")));
+ }
+
+ return get_string(input_format_t::bson, len - static_cast<NumberType>(1), result) and get() != std::char_traits<char>::eof();
+ }
+
+ /*!
+ @brief Read a BSON document element of the given @a element_type.
+ @param[in] element_type The BSON element type, c.f. http://bsonspec.org/spec.html
+ @param[in] element_type_parse_position The position in the input stream,
+ where the `element_type` was read.
+ @warning Not all BSON element types are supported yet. An unsupported
+ @a element_type will give rise to a parse_error.114:
+ Unsupported BSON record type 0x...
+ @return whether a valid BSON-object/array was passed to the SAX parser
+ */
+ bool parse_bson_element_internal(const int element_type,
+ const std::size_t element_type_parse_position)
+ {
+ switch (element_type)
+ {
+ case 0x01: // double
+ {
+ double number;
+ return get_number<double, true>(input_format_t::bson, number) and sax->number_float(static_cast<number_float_t>(number), "");
+ }
+
+ case 0x02: // string
+ {
+ std::int32_t len;
+ string_t value;
+ return get_number<std::int32_t, true>(input_format_t::bson, len) and get_bson_string(len, value) and sax->string(value);
+ }
+
+ case 0x03: // object
+ {
+ return parse_bson_internal();
+ }
+
+ case 0x04: // array
+ {
+ return parse_bson_array();
+ }
+
+ case 0x08: // boolean
+ {
+ return sax->boolean(get() != 0);
+ }
+
+ case 0x0A: // null
+ {
+ return sax->null();
+ }
+
+ case 0x10: // int32
+ {
+ std::int32_t value;
+ return get_number<std::int32_t, true>(input_format_t::bson, value) and sax->number_integer(value);
+ }
+
+ case 0x12: // int64
+ {
+ std::int64_t value;
+ return get_number<std::int64_t, true>(input_format_t::bson, value) and sax->number_integer(value);
+ }
+
+ default: // anything else not supported (yet)
+ {
+ std::array<char, 3> cr{{}};
+ (std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast<unsigned char>(element_type));
+ return sax->parse_error(element_type_parse_position, std::string(cr.data()), parse_error::create(114, element_type_parse_position, "Unsupported BSON record type 0x" + std::string(cr.data())));
+ }
+ }
+ }
+
+ /*!
+ @brief Read a BSON element list (as specified in the BSON-spec)
+
+ The same binary layout is used for objects and arrays, hence it must be
+ indicated with the argument @a is_array which one is expected
+ (true --> array, false --> object).
+
+ @param[in] is_array Determines if the element list being read is to be
+ treated as an object (@a is_array == false), or as an
+ array (@a is_array == true).
+ @return whether a valid BSON-object/array was passed to the SAX parser
+ */
+ bool parse_bson_element_list(const bool is_array)
+ {
+ string_t key;
+ while (int element_type = get())
+ {
+ if (JSON_UNLIKELY(not unexpect_eof(input_format_t::bson, "element list")))
+ {
+ return false;
+ }
+
+ const std::size_t element_type_parse_position = chars_read;
+ if (JSON_UNLIKELY(not get_bson_cstr(key)))
+ {
+ return false;
+ }
+
+ if (not is_array and not sax->key(key))
+ {
+ return false;
+ }
+
+ if (JSON_UNLIKELY(not parse_bson_element_internal(element_type, element_type_parse_position)))
+ {
+ return false;
+ }
+
+ // get_bson_cstr only appends
+ key.clear();
+ }
+
+ return true;
+ }
+
+ /*!
+ @brief Reads an array from the BSON input and passes it to the SAX-parser.
+ @return whether a valid BSON-array was passed to the SAX parser
+ */
+ bool parse_bson_array()
+ {
+ std::int32_t document_size;
+ get_number<std::int32_t, true>(input_format_t::bson, document_size);
+
+ if (JSON_UNLIKELY(not sax->start_array(std::size_t(-1))))
+ {
+ return false;
+ }
+
+ if (JSON_UNLIKELY(not parse_bson_element_list(/*is_array*/true)))
+ {
+ return false;
+ }
+
+ return sax->end_array();
+ }
+
+ //////////
+ // CBOR //
+ //////////
+
+ /*!
+ @param[in] get_char whether a new character should be retrieved from the
+ input (true, default) or whether the last read
+ character should be considered instead
+
+ @return whether a valid CBOR value was passed to the SAX parser
+ */
+ bool parse_cbor_internal(const bool get_char = true)
+ {
+ switch (get_char ? get() : current)
+ {
+ // EOF
+ case std::char_traits<char>::eof():
+ return unexpect_eof(input_format_t::cbor, "value");
+
+ // Integer 0x00..0x17 (0..23)
+ case 0x00:
+ case 0x01:
+ case 0x02:
+ case 0x03:
+ case 0x04:
+ case 0x05:
+ case 0x06:
+ case 0x07:
+ case 0x08:
+ case 0x09:
+ case 0x0A:
+ case 0x0B:
+ case 0x0C:
+ case 0x0D:
+ case 0x0E:
+ case 0x0F:
+ case 0x10:
+ case 0x11:
+ case 0x12:
+ case 0x13:
+ case 0x14:
+ case 0x15:
+ case 0x16:
+ case 0x17:
+ return sax->number_unsigned(static_cast<number_unsigned_t>(current));
+
+ case 0x18: // Unsigned integer (one-byte uint8_t follows)
+ {
+ std::uint8_t number;
+ return get_number(input_format_t::cbor, number) and sax->number_unsigned(number);
+ }
+
+ case 0x19: // Unsigned integer (two-byte uint16_t follows)
+ {
+ std::uint16_t number;
+ return get_number(input_format_t::cbor, number) and sax->number_unsigned(number);
+ }
+
+ case 0x1A: // Unsigned integer (four-byte uint32_t follows)
+ {
+ std::uint32_t number;
+ return get_number(input_format_t::cbor, number) and sax->number_unsigned(number);
+ }
+
+ case 0x1B: // Unsigned integer (eight-byte uint64_t follows)
+ {
+ std::uint64_t number;
+ return get_number(input_format_t::cbor, number) and sax->number_unsigned(number);
+ }
+
+ // Negative integer -1-0x00..-1-0x17 (-1..-24)
+ case 0x20:
+ case 0x21:
+ case 0x22:
+ case 0x23:
+ case 0x24:
+ case 0x25:
+ case 0x26:
+ case 0x27:
+ case 0x28:
+ case 0x29:
+ case 0x2A:
+ case 0x2B:
+ case 0x2C:
+ case 0x2D:
+ case 0x2E:
+ case 0x2F:
+ case 0x30:
+ case 0x31:
+ case 0x32:
+ case 0x33:
+ case 0x34:
+ case 0x35:
+ case 0x36:
+ case 0x37:
+ return sax->number_integer(static_cast<std::int8_t>(0x20 - 1 - current));
+
+ case 0x38: // Negative integer (one-byte uint8_t follows)
+ {
+ std::uint8_t number;
+ return get_number(input_format_t::cbor, number) and sax->number_integer(static_cast<number_integer_t>(-1) - number);
+ }
+
+ case 0x39: // Negative integer -1-n (two-byte uint16_t follows)
+ {
+ std::uint16_t number;
+ return get_number(input_format_t::cbor, number) and sax->number_integer(static_cast<number_integer_t>(-1) - number);
+ }
+
+ case 0x3A: // Negative integer -1-n (four-byte uint32_t follows)
+ {
+ std::uint32_t number;
+ return get_number(input_format_t::cbor, number) and sax->number_integer(static_cast<number_integer_t>(-1) - number);
+ }
+
+ case 0x3B: // Negative integer -1-n (eight-byte uint64_t follows)
+ {
+ std::uint64_t number;
+ return get_number(input_format_t::cbor, number) and sax->number_integer(static_cast<number_integer_t>(-1)
+ - static_cast<number_integer_t>(number));
+ }
+
+ // UTF-8 string (0x00..0x17 bytes follow)
+ case 0x60:
+ case 0x61:
+ case 0x62:
+ case 0x63:
+ case 0x64:
+ case 0x65:
+ case 0x66:
+ case 0x67:
+ case 0x68:
+ case 0x69:
+ case 0x6A:
+ case 0x6B:
+ case 0x6C:
+ case 0x6D:
+ case 0x6E:
+ case 0x6F:
+ case 0x70:
+ case 0x71:
+ case 0x72:
+ case 0x73:
+ case 0x74:
+ case 0x75:
+ case 0x76:
+ case 0x77:
+ case 0x78: // UTF-8 string (one-byte uint8_t for n follows)
+ case 0x79: // UTF-8 string (two-byte uint16_t for n follow)
+ case 0x7A: // UTF-8 string (four-byte uint32_t for n follow)
+ case 0x7B: // UTF-8 string (eight-byte uint64_t for n follow)
+ case 0x7F: // UTF-8 string (indefinite length)
+ {
+ string_t s;
+ return get_cbor_string(s) and sax->string(s);
+ }
+
+ // array (0x00..0x17 data items follow)
+ case 0x80:
+ case 0x81:
+ case 0x82:
+ case 0x83:
+ case 0x84:
+ case 0x85:
+ case 0x86:
+ case 0x87:
+ case 0x88:
+ case 0x89:
+ case 0x8A:
+ case 0x8B:
+ case 0x8C:
+ case 0x8D:
+ case 0x8E:
+ case 0x8F:
+ case 0x90:
+ case 0x91:
+ case 0x92:
+ case 0x93:
+ case 0x94:
+ case 0x95:
+ case 0x96:
+ case 0x97:
+ return get_cbor_array(static_cast<std::size_t>(static_cast<unsigned int>(current) & 0x1Fu));
+
+ case 0x98: // array (one-byte uint8_t for n follows)
+ {
+ std::uint8_t len;
+ return get_number(input_format_t::cbor, len) and get_cbor_array(static_cast<std::size_t>(len));
+ }
+
+ case 0x99: // array (two-byte uint16_t for n follow)
+ {
+ std::uint16_t len;
+ return get_number(input_format_t::cbor, len) and get_cbor_array(static_cast<std::size_t>(len));
+ }
+
+ case 0x9A: // array (four-byte uint32_t for n follow)
+ {
+ std::uint32_t len;
+ return get_number(input_format_t::cbor, len) and get_cbor_array(static_cast<std::size_t>(len));
+ }
+
+ case 0x9B: // array (eight-byte uint64_t for n follow)
+ {
+ std::uint64_t len;
+ return get_number(input_format_t::cbor, len) and get_cbor_array(static_cast<std::size_t>(len));
+ }
+
+ case 0x9F: // array (indefinite length)
+ return get_cbor_array(std::size_t(-1));
+
+ // map (0x00..0x17 pairs of data items follow)
+ case 0xA0:
+ case 0xA1:
+ case 0xA2:
+ case 0xA3:
+ case 0xA4:
+ case 0xA5:
+ case 0xA6:
+ case 0xA7:
+ case 0xA8:
+ case 0xA9:
+ case 0xAA:
+ case 0xAB:
+ case 0xAC:
+ case 0xAD:
+ case 0xAE:
+ case 0xAF:
+ case 0xB0:
+ case 0xB1:
+ case 0xB2:
+ case 0xB3:
+ case 0xB4:
+ case 0xB5:
+ case 0xB6:
+ case 0xB7:
+ return get_cbor_object(static_cast<std::size_t>(static_cast<unsigned int>(current) & 0x1Fu));
+
+ case 0xB8: // map (one-byte uint8_t for n follows)
+ {
+ std::uint8_t len;
+ return get_number(input_format_t::cbor, len) and get_cbor_object(static_cast<std::size_t>(len));
+ }
+
+ case 0xB9: // map (two-byte uint16_t for n follow)
+ {
+ std::uint16_t len;
+ return get_number(input_format_t::cbor, len) and get_cbor_object(static_cast<std::size_t>(len));
+ }
+
+ case 0xBA: // map (four-byte uint32_t for n follow)
+ {
+ std::uint32_t len;
+ return get_number(input_format_t::cbor, len) and get_cbor_object(static_cast<std::size_t>(len));
+ }
+
+ case 0xBB: // map (eight-byte uint64_t for n follow)
+ {
+ std::uint64_t len;
+ return get_number(input_format_t::cbor, len) and get_cbor_object(static_cast<std::size_t>(len));
+ }
+
+ case 0xBF: // map (indefinite length)
+ return get_cbor_object(std::size_t(-1));
+
+ case 0xF4: // false
+ return sax->boolean(false);
+
+ case 0xF5: // true
+ return sax->boolean(true);
+
+ case 0xF6: // null
+ return sax->null();
+
+ case 0xF9: // Half-Precision Float (two-byte IEEE 754)
+ {
+ const int byte1_raw = get();
+ if (JSON_UNLIKELY(not unexpect_eof(input_format_t::cbor, "number")))
+ {
+ return false;
+ }
+ const int byte2_raw = get();
+ if (JSON_UNLIKELY(not unexpect_eof(input_format_t::cbor, "number")))
+ {
+ return false;
+ }
+
+ const auto byte1 = static_cast<unsigned char>(byte1_raw);
+ const auto byte2 = static_cast<unsigned char>(byte2_raw);
+
+ // code from RFC 7049, Appendix D, Figure 3:
+ // As half-precision floating-point numbers were only added
+ // to IEEE 754 in 2008, today's programming platforms often
+ // still only have limited support for them. It is very
+ // easy to include at least decoding support for them even
+ // without such support. An example of a small decoder for
+ // half-precision floating-point numbers in the C language
+ // is shown in Fig. 3.
+ const auto half = static_cast<unsigned int>((byte1 << 8u) + byte2);
+ const double val = [&half]
+ {
+ const int exp = (half >> 10u) & 0x1Fu;
+ const unsigned int mant = half & 0x3FFu;
+ assert(0 <= exp and exp <= 32);
+ assert(0 <= mant and mant <= 1024);
+ switch (exp)
+ {
+ case 0:
+ return std::ldexp(mant, -24);
+ case 31:
+ return (mant == 0)
+ ? std::numeric_limits<double>::infinity()
+ : std::numeric_limits<double>::quiet_NaN();
+ default:
+ return std::ldexp(mant + 1024, exp - 25);
+ }
+ }();
+ return sax->number_float((half & 0x8000u) != 0
+ ? static_cast<number_float_t>(-val)
+ : static_cast<number_float_t>(val), "");
+ }
+
+ case 0xFA: // Single-Precision Float (four-byte IEEE 754)
+ {
+ float number;
+ return get_number(input_format_t::cbor, number) and sax->number_float(static_cast<number_float_t>(number), "");
+ }
+
+ case 0xFB: // Double-Precision Float (eight-byte IEEE 754)
+ {
+ double number;
+ return get_number(input_format_t::cbor, number) and sax->number_float(static_cast<number_float_t>(number), "");
+ }
+
+ default: // anything else (0xFF is handled inside the other types)
+ {
+ auto last_token = get_token_string();
+ return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::cbor, "invalid byte: 0x" + last_token, "value")));
+ }
+ }
+ }
+
+ /*!
+ @brief reads a CBOR string
+
+ This function first reads starting bytes to determine the expected
+ string length and then copies this number of bytes into a string.
+ Additionally, CBOR's strings with indefinite lengths are supported.
+
+ @param[out] result created string
+
+ @return whether string creation completed
+ */
+ bool get_cbor_string(string_t& result)
+ {
+ if (JSON_UNLIKELY(not unexpect_eof(input_format_t::cbor, "string")))
+ {
+ return false;
+ }
+
+ switch (current)
+ {
+ // UTF-8 string (0x00..0x17 bytes follow)
+ case 0x60:
+ case 0x61:
+ case 0x62:
+ case 0x63:
+ case 0x64:
+ case 0x65:
+ case 0x66:
+ case 0x67:
+ case 0x68:
+ case 0x69:
+ case 0x6A:
+ case 0x6B:
+ case 0x6C:
+ case 0x6D:
+ case 0x6E:
+ case 0x6F:
+ case 0x70:
+ case 0x71:
+ case 0x72:
+ case 0x73:
+ case 0x74:
+ case 0x75:
+ case 0x76:
+ case 0x77:
+ {
+ return get_string(input_format_t::cbor, static_cast<unsigned int>(current) & 0x1Fu, result);
+ }
+
+ case 0x78: // UTF-8 string (one-byte uint8_t for n follows)
+ {
+ std::uint8_t len;
+ return get_number(input_format_t::cbor, len) and get_string(input_format_t::cbor, len, result);
+ }
+
+ case 0x79: // UTF-8 string (two-byte uint16_t for n follow)
+ {
+ std::uint16_t len;
+ return get_number(input_format_t::cbor, len) and get_string(input_format_t::cbor, len, result);
+ }
+
+ case 0x7A: // UTF-8 string (four-byte uint32_t for n follow)
+ {
+ std::uint32_t len;
+ return get_number(input_format_t::cbor, len) and get_string(input_format_t::cbor, len, result);
+ }
+
+ case 0x7B: // UTF-8 string (eight-byte uint64_t for n follow)
+ {
+ std::uint64_t len;
+ return get_number(input_format_t::cbor, len) and get_string(input_format_t::cbor, len, result);
+ }
+
+ case 0x7F: // UTF-8 string (indefinite length)
+ {
+ while (get() != 0xFF)
+ {
+ string_t chunk;
+ if (not get_cbor_string(chunk))
+ {
+ return false;
+ }
+ result.append(chunk);
+ }
+ return true;
+ }
+
+ default:
+ {
+ auto last_token = get_token_string();
+ return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::cbor, "expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x" + last_token, "string")));
+ }
+ }
+ }
+
+ /*!
+ @param[in] len the length of the array or std::size_t(-1) for an
+ array of indefinite size
+ @return whether array creation completed
+ */
+ bool get_cbor_array(const std::size_t len)
+ {
+ if (JSON_UNLIKELY(not sax->start_array(len)))
+ {
+ return false;
+ }
+
+ if (len != std::size_t(-1))
+ {
+ for (std::size_t i = 0; i < len; ++i)
+ {
+ if (JSON_UNLIKELY(not parse_cbor_internal()))
+ {
+ return false;
+ }
+ }
+ }
+ else
+ {
+ while (get() != 0xFF)
+ {
+ if (JSON_UNLIKELY(not parse_cbor_internal(false)))
+ {
+ return false;
+ }
+ }
+ }
+
+ return sax->end_array();
+ }
+
+ /*!
+ @param[in] len the length of the object or std::size_t(-1) for an
+ object of indefinite size
+ @return whether object creation completed
+ */
+ bool get_cbor_object(const std::size_t len)
+ {
+ if (JSON_UNLIKELY(not sax->start_object(len)))
+ {
+ return false;
+ }
+
+ string_t key;
+ if (len != std::size_t(-1))
+ {
+ for (std::size_t i = 0; i < len; ++i)
+ {
+ get();
+ if (JSON_UNLIKELY(not get_cbor_string(key) or not sax->key(key)))
+ {
+ return false;
+ }
+
+ if (JSON_UNLIKELY(not parse_cbor_internal()))
+ {
+ return false;
+ }
+ key.clear();
+ }
+ }
+ else
+ {
+ while (get() != 0xFF)
+ {
+ if (JSON_UNLIKELY(not get_cbor_string(key) or not sax->key(key)))
+ {
+ return false;
+ }
+
+ if (JSON_UNLIKELY(not parse_cbor_internal()))
+ {
+ return false;
+ }
+ key.clear();
+ }
+ }
+
+ return sax->end_object();
+ }
+
+ /////////////
+ // MsgPack //
+ /////////////
+
+ /*!
+ @return whether a valid MessagePack value was passed to the SAX parser
+ */
+ bool parse_msgpack_internal()
+ {
+ switch (get())
+ {
+ // EOF
+ case std::char_traits<char>::eof():
+ return unexpect_eof(input_format_t::msgpack, "value");
+
+ // positive fixint
+ case 0x00:
+ case 0x01:
+ case 0x02:
+ case 0x03:
+ case 0x04:
+ case 0x05:
+ case 0x06:
+ case 0x07:
+ case 0x08:
+ case 0x09:
+ case 0x0A:
+ case 0x0B:
+ case 0x0C:
+ case 0x0D:
+ case 0x0E:
+ case 0x0F:
+ case 0x10:
+ case 0x11:
+ case 0x12:
+ case 0x13:
+ case 0x14:
+ case 0x15:
+ case 0x16:
+ case 0x17:
+ case 0x18:
+ case 0x19:
+ case 0x1A:
+ case 0x1B:
+ case 0x1C:
+ case 0x1D:
+ case 0x1E:
+ case 0x1F:
+ case 0x20:
+ case 0x21:
+ case 0x22:
+ case 0x23:
+ case 0x24:
+ case 0x25:
+ case 0x26:
+ case 0x27:
+ case 0x28:
+ case 0x29:
+ case 0x2A:
+ case 0x2B:
+ case 0x2C:
+ case 0x2D:
+ case 0x2E:
+ case 0x2F:
+ case 0x30:
+ case 0x31:
+ case 0x32:
+ case 0x33:
+ case 0x34:
+ case 0x35:
+ case 0x36:
+ case 0x37:
+ case 0x38:
+ case 0x39:
+ case 0x3A:
+ case 0x3B:
+ case 0x3C:
+ case 0x3D:
+ case 0x3E:
+ case 0x3F:
+ case 0x40:
+ case 0x41:
+ case 0x42:
+ case 0x43:
+ case 0x44:
+ case 0x45:
+ case 0x46:
+ case 0x47:
+ case 0x48:
+ case 0x49:
+ case 0x4A:
+ case 0x4B:
+ case 0x4C:
+ case 0x4D:
+ case 0x4E:
+ case 0x4F:
+ case 0x50:
+ case 0x51:
+ case 0x52:
+ case 0x53:
+ case 0x54:
+ case 0x55:
+ case 0x56:
+ case 0x57:
+ case 0x58:
+ case 0x59:
+ case 0x5A:
+ case 0x5B:
+ case 0x5C:
+ case 0x5D:
+ case 0x5E:
+ case 0x5F:
+ case 0x60:
+ case 0x61:
+ case 0x62:
+ case 0x63:
+ case 0x64:
+ case 0x65:
+ case 0x66:
+ case 0x67:
+ case 0x68:
+ case 0x69:
+ case 0x6A:
+ case 0x6B:
+ case 0x6C:
+ case 0x6D:
+ case 0x6E:
+ case 0x6F:
+ case 0x70:
+ case 0x71:
+ case 0x72:
+ case 0x73:
+ case 0x74:
+ case 0x75:
+ case 0x76:
+ case 0x77:
+ case 0x78:
+ case 0x79:
+ case 0x7A:
+ case 0x7B:
+ case 0x7C:
+ case 0x7D:
+ case 0x7E:
+ case 0x7F:
+ return sax->number_unsigned(static_cast<number_unsigned_t>(current));
+
+ // fixmap
+ case 0x80:
+ case 0x81:
+ case 0x82:
+ case 0x83:
+ case 0x84:
+ case 0x85:
+ case 0x86:
+ case 0x87:
+ case 0x88:
+ case 0x89:
+ case 0x8A:
+ case 0x8B:
+ case 0x8C:
+ case 0x8D:
+ case 0x8E:
+ case 0x8F:
+ return get_msgpack_object(static_cast<std::size_t>(static_cast<unsigned int>(current) & 0x0Fu));
+
+ // fixarray
+ case 0x90:
+ case 0x91:
+ case 0x92:
+ case 0x93:
+ case 0x94:
+ case 0x95:
+ case 0x96:
+ case 0x97:
+ case 0x98:
+ case 0x99:
+ case 0x9A:
+ case 0x9B:
+ case 0x9C:
+ case 0x9D:
+ case 0x9E:
+ case 0x9F:
+ return get_msgpack_array(static_cast<std::size_t>(static_cast<unsigned int>(current) & 0x0Fu));
+
+ // fixstr
+ case 0xA0:
+ case 0xA1:
+ case 0xA2:
+ case 0xA3:
+ case 0xA4:
+ case 0xA5:
+ case 0xA6:
+ case 0xA7:
+ case 0xA8:
+ case 0xA9:
+ case 0xAA:
+ case 0xAB:
+ case 0xAC:
+ case 0xAD:
+ case 0xAE:
+ case 0xAF:
+ case 0xB0:
+ case 0xB1:
+ case 0xB2:
+ case 0xB3:
+ case 0xB4:
+ case 0xB5:
+ case 0xB6:
+ case 0xB7:
+ case 0xB8:
+ case 0xB9:
+ case 0xBA:
+ case 0xBB:
+ case 0xBC:
+ case 0xBD:
+ case 0xBE:
+ case 0xBF:
+ {
+ string_t s;
+ return get_msgpack_string(s) and sax->string(s);
+ }
+
+ case 0xC0: // nil
+ return sax->null();
+
+ case 0xC2: // false
+ return sax->boolean(false);
+
+ case 0xC3: // true
+ return sax->boolean(true);
+
+ case 0xCA: // float 32
+ {
+ float number;
+ return get_number(input_format_t::msgpack, number) and sax->number_float(static_cast<number_float_t>(number), "");
+ }
+
+ case 0xCB: // float 64
+ {
+ double number;
+ return get_number(input_format_t::msgpack, number) and sax->number_float(static_cast<number_float_t>(number), "");
+ }
+
+ case 0xCC: // uint 8
+ {
+ std::uint8_t number;
+ return get_number(input_format_t::msgpack, number) and sax->number_unsigned(number);
+ }
+
+ case 0xCD: // uint 16
+ {
+ std::uint16_t number;
+ return get_number(input_format_t::msgpack, number) and sax->number_unsigned(number);
+ }
+
+ case 0xCE: // uint 32
+ {
+ std::uint32_t number;
+ return get_number(input_format_t::msgpack, number) and sax->number_unsigned(number);
+ }
+
+ case 0xCF: // uint 64
+ {
+ std::uint64_t number;
+ return get_number(input_format_t::msgpack, number) and sax->number_unsigned(number);
+ }
+
+ case 0xD0: // int 8
+ {
+ std::int8_t number;
+ return get_number(input_format_t::msgpack, number) and sax->number_integer(number);
+ }
+
+ case 0xD1: // int 16
+ {
+ std::int16_t number;
+ return get_number(input_format_t::msgpack, number) and sax->number_integer(number);
+ }
+
+ case 0xD2: // int 32
+ {
+ std::int32_t number;
+ return get_number(input_format_t::msgpack, number) and sax->number_integer(number);
+ }
+
+ case 0xD3: // int 64
+ {
+ std::int64_t number;
+ return get_number(input_format_t::msgpack, number) and sax->number_integer(number);
+ }
+
+ case 0xD9: // str 8
+ case 0xDA: // str 16
+ case 0xDB: // str 32
+ {
+ string_t s;
+ return get_msgpack_string(s) and sax->string(s);
+ }
+
+ case 0xDC: // array 16
+ {
+ std::uint16_t len;
+ return get_number(input_format_t::msgpack, len) and get_msgpack_array(static_cast<std::size_t>(len));
+ }
+
+ case 0xDD: // array 32
+ {
+ std::uint32_t len;
+ return get_number(input_format_t::msgpack, len) and get_msgpack_array(static_cast<std::size_t>(len));
+ }
+
+ case 0xDE: // map 16
+ {
+ std::uint16_t len;
+ return get_number(input_format_t::msgpack, len) and get_msgpack_object(static_cast<std::size_t>(len));
+ }
+
+ case 0xDF: // map 32
+ {
+ std::uint32_t len;
+ return get_number(input_format_t::msgpack, len) and get_msgpack_object(static_cast<std::size_t>(len));
+ }
+
+ // negative fixint
+ case 0xE0:
+ case 0xE1:
+ case 0xE2:
+ case 0xE3:
+ case 0xE4:
+ case 0xE5:
+ case 0xE6:
+ case 0xE7:
+ case 0xE8:
+ case 0xE9:
+ case 0xEA:
+ case 0xEB:
+ case 0xEC:
+ case 0xED:
+ case 0xEE:
+ case 0xEF:
+ case 0xF0:
+ case 0xF1:
+ case 0xF2:
+ case 0xF3:
+ case 0xF4:
+ case 0xF5:
+ case 0xF6:
+ case 0xF7:
+ case 0xF8:
+ case 0xF9:
+ case 0xFA:
+ case 0xFB:
+ case 0xFC:
+ case 0xFD:
+ case 0xFE:
+ case 0xFF:
+ return sax->number_integer(static_cast<std::int8_t>(current));
+
+ default: // anything else
+ {
+ auto last_token = get_token_string();
+ return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::msgpack, "invalid byte: 0x" + last_token, "value")));
+ }
+ }
+ }
+
+ /*!
+ @brief reads a MessagePack string
+
+ This function first reads starting bytes to determine the expected
+ string length and then copies this number of bytes into a string.
+
+ @param[out] result created string
+
+ @return whether string creation completed
+ */
+ bool get_msgpack_string(string_t& result)
+ {
+ if (JSON_UNLIKELY(not unexpect_eof(input_format_t::msgpack, "string")))
+ {
+ return false;
+ }
+
+ switch (current)
+ {
+ // fixstr
+ case 0xA0:
+ case 0xA1:
+ case 0xA2:
+ case 0xA3:
+ case 0xA4:
+ case 0xA5:
+ case 0xA6:
+ case 0xA7:
+ case 0xA8:
+ case 0xA9:
+ case 0xAA:
+ case 0xAB:
+ case 0xAC:
+ case 0xAD:
+ case 0xAE:
+ case 0xAF:
+ case 0xB0:
+ case 0xB1:
+ case 0xB2:
+ case 0xB3:
+ case 0xB4:
+ case 0xB5:
+ case 0xB6:
+ case 0xB7:
+ case 0xB8:
+ case 0xB9:
+ case 0xBA:
+ case 0xBB:
+ case 0xBC:
+ case 0xBD:
+ case 0xBE:
+ case 0xBF:
+ {
+ return get_string(input_format_t::msgpack, static_cast<unsigned int>(current) & 0x1Fu, result);
+ }
+
+ case 0xD9: // str 8
+ {
+ std::uint8_t len;
+ return get_number(input_format_t::msgpack, len) and get_string(input_format_t::msgpack, len, result);
+ }
+
+ case 0xDA: // str 16
+ {
+ std::uint16_t len;
+ return get_number(input_format_t::msgpack, len) and get_string(input_format_t::msgpack, len, result);
+ }
+
+ case 0xDB: // str 32
+ {
+ std::uint32_t len;
+ return get_number(input_format_t::msgpack, len) and get_string(input_format_t::msgpack, len, result);
+ }
+
+ default:
+ {
+ auto last_token = get_token_string();
+ return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::msgpack, "expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0x" + last_token, "string")));
+ }
+ }
+ }
+
+ /*!
+ @param[in] len the length of the array
+ @return whether array creation completed
+ */
+ bool get_msgpack_array(const std::size_t len)
+ {
+ if (JSON_UNLIKELY(not sax->start_array(len)))
+ {
+ return false;
+ }
+
+ for (std::size_t i = 0; i < len; ++i)
+ {
+ if (JSON_UNLIKELY(not parse_msgpack_internal()))
+ {
+ return false;
+ }
+ }
+
+ return sax->end_array();
+ }
+
+ /*!
+ @param[in] len the length of the object
+ @return whether object creation completed
+ */
+ bool get_msgpack_object(const std::size_t len)
+ {
+ if (JSON_UNLIKELY(not sax->start_object(len)))
+ {
+ return false;
+ }
+
+ string_t key;
+ for (std::size_t i = 0; i < len; ++i)
+ {
+ get();
+ if (JSON_UNLIKELY(not get_msgpack_string(key) or not sax->key(key)))
+ {
+ return false;
+ }
+
+ if (JSON_UNLIKELY(not parse_msgpack_internal()))
+ {
+ return false;
+ }
+ key.clear();
+ }
+
+ return sax->end_object();
+ }
+
+ ////////////
+ // UBJSON //
+ ////////////
+
+ /*!
+ @param[in] get_char whether a new character should be retrieved from the
+ input (true, default) or whether the last read
+ character should be considered instead
+
+ @return whether a valid UBJSON value was passed to the SAX parser
+ */
+ bool parse_ubjson_internal(const bool get_char = true)
+ {
+ return get_ubjson_value(get_char ? get_ignore_noop() : current);
+ }
+
+ /*!
+ @brief reads a UBJSON string
+
+ This function is either called after reading the 'S' byte explicitly
+ indicating a string, or in case of an object key where the 'S' byte can be
+ left out.
+
+ @param[out] result created string
+ @param[in] get_char whether a new character should be retrieved from the
+ input (true, default) or whether the last read
+ character should be considered instead
+
+ @return whether string creation completed
+ */
+ bool get_ubjson_string(string_t& result, const bool get_char = true)
+ {
+ if (get_char)
+ {
+ get(); // TODO(niels): may we ignore N here?
+ }
+
+ if (JSON_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "value")))
+ {
+ return false;
+ }
+
+ switch (current)
+ {
+ case 'U':
+ {
+ std::uint8_t len;
+ return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result);
+ }
+
+ case 'i':
+ {
+ std::int8_t len;
+ return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result);
+ }
+
+ case 'I':
+ {
+ std::int16_t len;
+ return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result);
+ }
+
+ case 'l':
+ {
+ std::int32_t len;
+ return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result);
+ }
+
+ case 'L':
+ {
+ std::int64_t len;
+ return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result);
+ }
+
+ default:
+ auto last_token = get_token_string();
+ return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::ubjson, "expected length type specification (U, i, I, l, L); last byte: 0x" + last_token, "string")));
+ }
+ }
+
+ /*!
+ @param[out] result determined size
+ @return whether size determination completed
+ */
+ bool get_ubjson_size_value(std::size_t& result)
+ {
+ switch (get_ignore_noop())
+ {
+ case 'U':
+ {
+ std::uint8_t number;
+ if (JSON_UNLIKELY(not get_number(input_format_t::ubjson, number)))
+ {
+ return false;
+ }
+ result = static_cast<std::size_t>(number);
+ return true;
+ }
+
+ case 'i':
+ {
+ std::int8_t number;
+ if (JSON_UNLIKELY(not get_number(input_format_t::ubjson, number)))
+ {
+ return false;
+ }
+ result = static_cast<std::size_t>(number);
+ return true;
+ }
+
+ case 'I':
+ {
+ std::int16_t number;
+ if (JSON_UNLIKELY(not get_number(input_format_t::ubjson, number)))
+ {
+ return false;
+ }
+ result = static_cast<std::size_t>(number);
+ return true;
+ }
+
+ case 'l':
+ {
+ std::int32_t number;
+ if (JSON_UNLIKELY(not get_number(input_format_t::ubjson, number)))
+ {
+ return false;
+ }
+ result = static_cast<std::size_t>(number);
+ return true;
+ }
+
+ case 'L':
+ {
+ std::int64_t number;
+ if (JSON_UNLIKELY(not get_number(input_format_t::ubjson, number)))
+ {
+ return false;
+ }
+ result = static_cast<std::size_t>(number);
+ return true;
+ }
+
+ default:
+ {
+ auto last_token = get_token_string();
+ return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::ubjson, "expected length type specification (U, i, I, l, L) after '#'; last byte: 0x" + last_token, "size")));
+ }
+ }
+ }
+
+ /*!
+ @brief determine the type and size for a container
+
+ In the optimized UBJSON format, a type and a size can be provided to allow
+ for a more compact representation.
+
+ @param[out] result pair of the size and the type
+
+ @return whether pair creation completed
+ */
+ bool get_ubjson_size_type(std::pair<std::size_t, int>& result)
+ {
+ result.first = string_t::npos; // size
+ result.second = 0; // type
+
+ get_ignore_noop();
+
+ if (current == '$')
+ {
+ result.second = get(); // must not ignore 'N', because 'N' maybe the type
+ if (JSON_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "type")))
+ {
+ return false;
+ }
+
+ get_ignore_noop();
+ if (JSON_UNLIKELY(current != '#'))
+ {
+ if (JSON_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "value")))
+ {
+ return false;
+ }
+ auto last_token = get_token_string();
+ return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::ubjson, "expected '#' after type information; last byte: 0x" + last_token, "size")));
+ }
+
+ return get_ubjson_size_value(result.first);
+ }
+
+ if (current == '#')
+ {
+ return get_ubjson_size_value(result.first);
+ }
+
+ return true;
+ }
+
+ /*!
+ @param prefix the previously read or set type prefix
+ @return whether value creation completed
+ */
+ bool get_ubjson_value(const int prefix)
+ {
+ switch (prefix)
+ {
+ case std::char_traits<char>::eof(): // EOF
+ return unexpect_eof(input_format_t::ubjson, "value");
+
+ case 'T': // true
+ return sax->boolean(true);
+ case 'F': // false
+ return sax->boolean(false);
+
+ case 'Z': // null
+ return sax->null();
+
+ case 'U':
+ {
+ std::uint8_t number;
+ return get_number(input_format_t::ubjson, number) and sax->number_unsigned(number);
+ }
+
+ case 'i':
+ {
+ std::int8_t number;
+ return get_number(input_format_t::ubjson, number) and sax->number_integer(number);
+ }
+
+ case 'I':
+ {
+ std::int16_t number;
+ return get_number(input_format_t::ubjson, number) and sax->number_integer(number);
+ }
+
+ case 'l':
+ {
+ std::int32_t number;
+ return get_number(input_format_t::ubjson, number) and sax->number_integer(number);
+ }
+
+ case 'L':
+ {
+ std::int64_t number;
+ return get_number(input_format_t::ubjson, number) and sax->number_integer(number);
+ }
+
+ case 'd':
+ {
+ float number;
+ return get_number(input_format_t::ubjson, number) and sax->number_float(static_cast<number_float_t>(number), "");
+ }
+
+ case 'D':
+ {
+ double number;
+ return get_number(input_format_t::ubjson, number) and sax->number_float(static_cast<number_float_t>(number), "");
+ }
+
+ case 'C': // char
+ {
+ get();
+ if (JSON_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "char")))
+ {
+ return false;
+ }
+ if (JSON_UNLIKELY(current > 127))
+ {
+ auto last_token = get_token_string();
+ return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::ubjson, "byte after 'C' must be in range 0x00..0x7F; last byte: 0x" + last_token, "char")));
+ }
+ string_t s(1, static_cast<char>(current));
+ return sax->string(s);
+ }
+
+ case 'S': // string
+ {
+ string_t s;
+ return get_ubjson_string(s) and sax->string(s);
+ }
+
+ case '[': // array
+ return get_ubjson_array();
+
+ case '{': // object
+ return get_ubjson_object();
+
+ default: // anything else
+ {
+ auto last_token = get_token_string();
+ return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::ubjson, "invalid byte: 0x" + last_token, "value")));
+ }
+ }
+ }
+
+ /*!
+ @return whether array creation completed
+ */
+ bool get_ubjson_array()
+ {
+ std::pair<std::size_t, int> size_and_type;
+ if (JSON_UNLIKELY(not get_ubjson_size_type(size_and_type)))
+ {
+ return false;
+ }
+
+ if (size_and_type.first != string_t::npos)
+ {
+ if (JSON_UNLIKELY(not sax->start_array(size_and_type.first)))
+ {
+ return false;
+ }
+
+ if (size_and_type.second != 0)
+ {
+ if (size_and_type.second != 'N')
+ {
+ for (std::size_t i = 0; i < size_and_type.first; ++i)
+ {
+ if (JSON_UNLIKELY(not get_ubjson_value(size_and_type.second)))
+ {
+ return false;
+ }
+ }
+ }
+ }
+ else
+ {
+ for (std::size_t i = 0; i < size_and_type.first; ++i)
+ {
+ if (JSON_UNLIKELY(not parse_ubjson_internal()))
+ {
+ return false;
+ }
+ }
+ }
+ }
+ else
+ {
+ if (JSON_UNLIKELY(not sax->start_array(std::size_t(-1))))
+ {
+ return false;
+ }
+
+ while (current != ']')
+ {
+ if (JSON_UNLIKELY(not parse_ubjson_internal(false)))
+ {
+ return false;
+ }
+ get_ignore_noop();
+ }
+ }
+
+ return sax->end_array();
+ }
+
+ /*!
+ @return whether object creation completed
+ */
+ bool get_ubjson_object()
+ {
+ std::pair<std::size_t, int> size_and_type;
+ if (JSON_UNLIKELY(not get_ubjson_size_type(size_and_type)))
+ {
+ return false;
+ }
+
+ string_t key;
+ if (size_and_type.first != string_t::npos)
+ {
+ if (JSON_UNLIKELY(not sax->start_object(size_and_type.first)))
+ {
+ return false;
+ }
+
+ if (size_and_type.second != 0)
+ {
+ for (std::size_t i = 0; i < size_and_type.first; ++i)
+ {
+ if (JSON_UNLIKELY(not get_ubjson_string(key) or not sax->key(key)))
+ {
+ return false;
+ }
+ if (JSON_UNLIKELY(not get_ubjson_value(size_and_type.second)))
+ {
+ return false;
+ }
+ key.clear();
+ }
+ }
+ else
+ {
+ for (std::size_t i = 0; i < size_and_type.first; ++i)
+ {
+ if (JSON_UNLIKELY(not get_ubjson_string(key) or not sax->key(key)))
+ {
+ return false;
+ }
+ if (JSON_UNLIKELY(not parse_ubjson_internal()))
+ {
+ return false;
+ }
+ key.clear();
+ }
+ }
+ }
+ else
+ {
+ if (JSON_UNLIKELY(not sax->start_object(std::size_t(-1))))
+ {
+ return false;
+ }
+
+ while (current != '}')
+ {
+ if (JSON_UNLIKELY(not get_ubjson_string(key, false) or not sax->key(key)))
+ {
+ return false;
+ }
+ if (JSON_UNLIKELY(not parse_ubjson_internal()))
+ {
+ return false;
+ }
+ get_ignore_noop();
+ key.clear();
+ }
+ }
+
+ return sax->end_object();
+ }
+
+ ///////////////////////
+ // Utility functions //
+ ///////////////////////
+
+ /*!
+ @brief get next character from the input
+
+ This function provides the interface to the used input adapter. It does
+ not throw in case the input reached EOF, but returns a -'ve valued
+ `std::char_traits<char>::eof()` in that case.
+
+ @return character read from the input
+ */
+ int get()
+ {
+ ++chars_read;
+ return current = ia->get_character();
+ }
+
+ /*!
+ @return character read from the input after ignoring all 'N' entries
+ */
+ int get_ignore_noop()
+ {
+ do
+ {
+ get();
+ }
+ while (current == 'N');
+
+ return current;
+ }
+
+ /*
+ @brief read a number from the input
+
+ @tparam NumberType the type of the number
+ @param[in] format the current format (for diagnostics)
+ @param[out] result number of type @a NumberType
+
+ @return whether conversion completed
+
+ @note This function needs to respect the system's endianess, because
+ bytes in CBOR, MessagePack, and UBJSON are stored in network order
+ (big endian) and therefore need reordering on little endian systems.
+ */
+ template<typename NumberType, bool InputIsLittleEndian = false>
+ bool get_number(const input_format_t format, NumberType& result)
+ {
+ // step 1: read input into array with system's byte order
+ std::array<std::uint8_t, sizeof(NumberType)> vec;
+ for (std::size_t i = 0; i < sizeof(NumberType); ++i)
+ {
+ get();
+ if (JSON_UNLIKELY(not unexpect_eof(format, "number")))
+ {
+ return false;
+ }
+
+ // reverse byte order prior to conversion if necessary
+ if (is_little_endian != InputIsLittleEndian)
+ {
+ vec[sizeof(NumberType) - i - 1] = static_cast<std::uint8_t>(current);
+ }
+ else
+ {
+ vec[i] = static_cast<std::uint8_t>(current); // LCOV_EXCL_LINE
+ }
+ }
+
+ // step 2: convert array into number of type T and return
+ std::memcpy(&result, vec.data(), sizeof(NumberType));
+ return true;
+ }
+
+ /*!
+ @brief create a string by reading characters from the input
+
+ @tparam NumberType the type of the number
+ @param[in] format the current format (for diagnostics)
+ @param[in] len number of characters to read
+ @param[out] result string created by reading @a len bytes
+
+ @return whether string creation completed
+
+ @note We can not reserve @a len bytes for the result, because @a len
+ may be too large. Usually, @ref unexpect_eof() detects the end of
+ the input before we run out of string memory.
+ */
+ template<typename NumberType>
+ bool get_string(const input_format_t format,
+ const NumberType len,
+ string_t& result)
+ {
+ bool success = true;
+ std::generate_n(std::back_inserter(result), len, [this, &success, &format]()
+ {
+ get();
+ if (JSON_UNLIKELY(not unexpect_eof(format, "string")))
+ {
+ success = false;
+ }
+ return static_cast<char>(current);
+ });
+ return success;
+ }
+
+ /*!
+ @param[in] format the current format (for diagnostics)
+ @param[in] context further context information (for diagnostics)
+ @return whether the last read character is not EOF
+ */
+ bool unexpect_eof(const input_format_t format, const char* context) const
+ {
+ if (JSON_UNLIKELY(current == std::char_traits<char>::eof()))
+ {
+ return sax->parse_error(chars_read, "<end of file>",
+ parse_error::create(110, chars_read, exception_message(format, "unexpected end of input", context)));
+ }
+ return true;
+ }
+
+ /*!
+ @return a string representation of the last read byte
+ */
+ std::string get_token_string() const
+ {
+ std::array<char, 3> cr{{}};
+ (std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast<unsigned char>(current));
+ return std::string{cr.data()};
+ }
+
+ /*!
+ @param[in] format the current format
+ @param[in] detail a detailed error message
+ @param[in] context further contect information
+ @return a message string to use in the parse_error exceptions
+ */
+ std::string exception_message(const input_format_t format,
+ const std::string& detail,
+ const std::string& context) const
+ {
+ std::string error_msg = "syntax error while parsing ";
+
+ switch (format)
+ {
+ case input_format_t::cbor:
+ error_msg += "CBOR";
+ break;
+
+ case input_format_t::msgpack:
+ error_msg += "MessagePack";
+ break;
+
+ case input_format_t::ubjson:
+ error_msg += "UBJSON";
+ break;
+
+ case input_format_t::bson:
+ error_msg += "BSON";
+ break;
+
+ default: // LCOV_EXCL_LINE
+ assert(false); // LCOV_EXCL_LINE
+ }
+
+ return error_msg + " " + context + ": " + detail;
+ }
+
+ private:
+ /// input adapter
+ input_adapter_t ia = nullptr;
+
+ /// the current character
+ int current = std::char_traits<char>::eof();
+
+ /// the number of characters read
+ std::size_t chars_read = 0;
+
+ /// whether we can assume little endianess
+ const bool is_little_endian = little_endianess();
+
+ /// the SAX parser
+ json_sax_t* sax = nullptr;
+};
+} // namespace detail
+} // namespace nlohmann
+
+// #include <nlohmann/detail/input/input_adapters.hpp>
+
+// #include <nlohmann/detail/input/lexer.hpp>
+
+
+#include <array> // array
+#include <clocale> // localeconv
+#include <cstddef> // size_t
+#include <cstdio> // snprintf
+#include <cstdlib> // strtof, strtod, strtold, strtoll, strtoull
+#include <initializer_list> // initializer_list
+#include <string> // char_traits, string
+#include <utility> // move
+#include <vector> // vector
+
+// #include <nlohmann/detail/input/input_adapters.hpp>
+
+// #include <nlohmann/detail/input/position_t.hpp>
+
+// #include <nlohmann/detail/macro_scope.hpp>
+
+
+namespace nlohmann
+{
+namespace detail
+{
+///////////
+// lexer //
+///////////
+
+/*!
+@brief lexical analysis
+
+This class organizes the lexical analysis during JSON deserialization.
+*/
+template<typename BasicJsonType>
+class lexer
+{
+ using number_integer_t = typename BasicJsonType::number_integer_t;
+ using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
+ using number_float_t = typename BasicJsonType::number_float_t;
+ using string_t = typename BasicJsonType::string_t;
+
+ public:
+ /// token types for the parser
+ enum class token_type
+ {
+ uninitialized, ///< indicating the scanner is uninitialized
+ literal_true, ///< the `true` literal
+ literal_false, ///< the `false` literal
+ literal_null, ///< the `null` literal
+ value_string, ///< a string -- use get_string() for actual value
+ value_unsigned, ///< an unsigned integer -- use get_number_unsigned() for actual value
+ value_integer, ///< a signed integer -- use get_number_integer() for actual value
+ value_float, ///< an floating point number -- use get_number_float() for actual value
+ begin_array, ///< the character for array begin `[`
+ begin_object, ///< the character for object begin `{`
+ end_array, ///< the character for array end `]`
+ end_object, ///< the character for object end `}`
+ name_separator, ///< the name separator `:`
+ value_separator, ///< the value separator `,`
+ parse_error, ///< indicating a parse error
+ end_of_input, ///< indicating the end of the input buffer
+ literal_or_value ///< a literal or the begin of a value (only for diagnostics)
+ };
+
+ /// return name of values of type token_type (only used for errors)
+ static const char* token_type_name(const token_type t) noexcept
+ {
+ switch (t)
+ {
+ case token_type::uninitialized:
+ return "<uninitialized>";
+ case token_type::literal_true:
+ return "true literal";
+ case token_type::literal_false:
+ return "false literal";
+ case token_type::literal_null:
+ return "null literal";
+ case token_type::value_string:
+ return "string literal";
+ case lexer::token_type::value_unsigned:
+ case lexer::token_type::value_integer:
+ case lexer::token_type::value_float:
+ return "number literal";
+ case token_type::begin_array:
+ return "'['";
+ case token_type::begin_object:
+ return "'{'";
+ case token_type::end_array:
+ return "']'";
+ case token_type::end_object:
+ return "'}'";
+ case token_type::name_separator:
+ return "':'";
+ case token_type::value_separator:
+ return "','";
+ case token_type::parse_error:
+ return "<parse error>";
+ case token_type::end_of_input:
+ return "end of input";
+ case token_type::literal_or_value:
+ return "'[', '{', or a literal";
+ // LCOV_EXCL_START
+ default: // catch non-enum values
+ return "unknown token";
+ // LCOV_EXCL_STOP
+ }
+ }
+
+ explicit lexer(detail::input_adapter_t&& adapter)
+ : ia(std::move(adapter)), decimal_point_char(get_decimal_point()) {}
+
+ // delete because of pointer members
+ lexer(const lexer&) = delete;
+ lexer(lexer&&) = delete;
+ lexer& operator=(lexer&) = delete;
+ lexer& operator=(lexer&&) = delete;
+ ~lexer() = default;
+
+ private:
+ /////////////////////
+ // locales
+ /////////////////////
+
+ /// return the locale-dependent decimal point
+ static char get_decimal_point() noexcept
+ {
+ const auto loc = localeconv();
+ assert(loc != nullptr);
+ return (loc->decimal_point == nullptr) ? '.' : *(loc->decimal_point);
+ }
+
+ /////////////////////
+ // scan functions
+ /////////////////////
+
+ /*!
+ @brief get codepoint from 4 hex characters following `\u`
+
+ For input "\u c1 c2 c3 c4" the codepoint is:
+ (c1 * 0x1000) + (c2 * 0x0100) + (c3 * 0x0010) + c4
+ = (c1 << 12) + (c2 << 8) + (c3 << 4) + (c4 << 0)
+
+ Furthermore, the possible characters '0'..'9', 'A'..'F', and 'a'..'f'
+ must be converted to the integers 0x0..0x9, 0xA..0xF, 0xA..0xF, resp. The
+ conversion is done by subtracting the offset (0x30, 0x37, and 0x57)
+ between the ASCII value of the character and the desired integer value.
+
+ @return codepoint (0x0000..0xFFFF) or -1 in case of an error (e.g. EOF or
+ non-hex character)
+ */
+ int get_codepoint()
+ {
+ // this function only makes sense after reading `\u`
+ assert(current == 'u');
+ int codepoint = 0;
+
+ const auto factors = { 12u, 8u, 4u, 0u };
+ for (const auto factor : factors)
+ {
+ get();
+
+ if (current >= '0' and current <= '9')
+ {
+ codepoint += static_cast<int>((static_cast<unsigned int>(current) - 0x30u) << factor);
+ }
+ else if (current >= 'A' and current <= 'F')
+ {
+ codepoint += static_cast<int>((static_cast<unsigned int>(current) - 0x37u) << factor);
+ }
+ else if (current >= 'a' and current <= 'f')
+ {
+ codepoint += static_cast<int>((static_cast<unsigned int>(current) - 0x57u) << factor);
+ }
+ else
+ {
+ return -1;
+ }
+ }
+
+ assert(0x0000 <= codepoint and codepoint <= 0xFFFF);
+ return codepoint;
+ }
+
+ /*!
+ @brief check if the next byte(s) are inside a given range
+
+ Adds the current byte and, for each passed range, reads a new byte and
+ checks if it is inside the range. If a violation was detected, set up an
+ error message and return false. Otherwise, return true.
+
+ @param[in] ranges list of integers; interpreted as list of pairs of
+ inclusive lower and upper bound, respectively
+
+ @pre The passed list @a ranges must have 2, 4, or 6 elements; that is,
+ 1, 2, or 3 pairs. This precondition is enforced by an assertion.
+
+ @return true if and only if no range violation was detected
+ */
+ bool next_byte_in_range(std::initializer_list<int> ranges)
+ {
+ assert(ranges.size() == 2 or ranges.size() == 4 or ranges.size() == 6);
+ add(current);
+
+ for (auto range = ranges.begin(); range != ranges.end(); ++range)
+ {
+ get();
+ if (JSON_LIKELY(*range <= current and current <= *(++range)))
+ {
+ add(current);
+ }
+ else
+ {
+ error_message = "invalid string: ill-formed UTF-8 byte";
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /*!
+ @brief scan a string literal
+
+ This function scans a string according to Sect. 7 of RFC 7159. While
+ scanning, bytes are escaped and copied into buffer token_buffer. Then the
+ function returns successfully, token_buffer is *not* null-terminated (as it
+ may contain \0 bytes), and token_buffer.size() is the number of bytes in the
+ string.
+
+ @return token_type::value_string if string could be successfully scanned,
+ token_type::parse_error otherwise
+
+ @note In case of errors, variable error_message contains a textual
+ description.
+ */
+ token_type scan_string()
+ {
+ // reset token_buffer (ignore opening quote)
+ reset();
+
+ // we entered the function by reading an open quote
+ assert(current == '\"');
+
+ while (true)
+ {
+ // get next character
+ switch (get())
+ {
+ // end of file while parsing string
+ case std::char_traits<char>::eof():
+ {
+ error_message = "invalid string: missing closing quote";
+ return token_type::parse_error;
+ }
+
+ // closing quote
+ case '\"':
+ {
+ return token_type::value_string;
+ }
+
+ // escapes
+ case '\\':
+ {
+ switch (get())
+ {
+ // quotation mark
+ case '\"':
+ add('\"');
+ break;
+ // reverse solidus
+ case '\\':
+ add('\\');
+ break;
+ // solidus
+ case '/':
+ add('/');
+ break;
+ // backspace
+ case 'b':
+ add('\b');
+ break;
+ // form feed
+ case 'f':
+ add('\f');
+ break;
+ // line feed
+ case 'n':
+ add('\n');
+ break;
+ // carriage return
+ case 'r':
+ add('\r');
+ break;
+ // tab
+ case 't':
+ add('\t');
+ break;
+
+ // unicode escapes
+ case 'u':
+ {
+ const int codepoint1 = get_codepoint();
+ int codepoint = codepoint1; // start with codepoint1
+
+ if (JSON_UNLIKELY(codepoint1 == -1))
+ {
+ error_message = "invalid string: '\\u' must be followed by 4 hex digits";
+ return token_type::parse_error;
+ }
+
+ // check if code point is a high surrogate
+ if (0xD800 <= codepoint1 and codepoint1 <= 0xDBFF)
+ {
+ // expect next \uxxxx entry
+ if (JSON_LIKELY(get() == '\\' and get() == 'u'))
+ {
+ const int codepoint2 = get_codepoint();
+
+ if (JSON_UNLIKELY(codepoint2 == -1))
+ {
+ error_message = "invalid string: '\\u' must be followed by 4 hex digits";
+ return token_type::parse_error;
+ }
+
+ // check if codepoint2 is a low surrogate
+ if (JSON_LIKELY(0xDC00 <= codepoint2 and codepoint2 <= 0xDFFF))
+ {
+ // overwrite codepoint
+ codepoint = static_cast<int>(
+ // high surrogate occupies the most significant 22 bits
+ (static_cast<unsigned int>(codepoint1) << 10u)
+ // low surrogate occupies the least significant 15 bits
+ + static_cast<unsigned int>(codepoint2)
+ // there is still the 0xD800, 0xDC00 and 0x10000 noise
+ // in the result so we have to subtract with:
+ // (0xD800 << 10) + DC00 - 0x10000 = 0x35FDC00
+ - 0x35FDC00u);
+ }
+ else
+ {
+ error_message = "invalid string: surrogate U+DC00..U+DFFF must be followed by U+DC00..U+DFFF";
+ return token_type::parse_error;
+ }
+ }
+ else
+ {
+ error_message = "invalid string: surrogate U+DC00..U+DFFF must be followed by U+DC00..U+DFFF";
+ return token_type::parse_error;
+ }
+ }
+ else
+ {
+ if (JSON_UNLIKELY(0xDC00 <= codepoint1 and codepoint1 <= 0xDFFF))
+ {
+ error_message = "invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF";
+ return token_type::parse_error;
+ }
+ }
+
+ // result of the above calculation yields a proper codepoint
+ assert(0x00 <= codepoint and codepoint <= 0x10FFFF);
+
+ // translate codepoint into bytes
+ if (codepoint < 0x80)
+ {
+ // 1-byte characters: 0xxxxxxx (ASCII)
+ add(codepoint);
+ }
+ else if (codepoint <= 0x7FF)
+ {
+ // 2-byte characters: 110xxxxx 10xxxxxx
+ add(static_cast<int>(0xC0u | (static_cast<unsigned int>(codepoint) >> 6u)));
+ add(static_cast<int>(0x80u | (static_cast<unsigned int>(codepoint) & 0x3Fu)));
+ }
+ else if (codepoint <= 0xFFFF)
+ {
+ // 3-byte characters: 1110xxxx 10xxxxxx 10xxxxxx
+ add(static_cast<int>(0xE0u | (static_cast<unsigned int>(codepoint) >> 12u)));
+ add(static_cast<int>(0x80u | ((static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
+ add(static_cast<int>(0x80u | (static_cast<unsigned int>(codepoint) & 0x3Fu)));
+ }
+ else
+ {
+ // 4-byte characters: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
+ add(static_cast<int>(0xF0u | (static_cast<unsigned int>(codepoint) >> 18u)));
+ add(static_cast<int>(0x80u | ((static_cast<unsigned int>(codepoint) >> 12u) & 0x3Fu)));
+ add(static_cast<int>(0x80u | ((static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
+ add(static_cast<int>(0x80u | (static_cast<unsigned int>(codepoint) & 0x3Fu)));
+ }
+
+ break;
+ }
+
+ // other characters after escape
+ default:
+ error_message = "invalid string: forbidden character after backslash";
+ return token_type::parse_error;
+ }
+
+ break;
+ }
+
+ // invalid control characters
+ case 0x00:
+ {
+ error_message = "invalid string: control character U+0000 (NUL) must be escaped to \\u0000";
+ return token_type::parse_error;
+ }
+
+ case 0x01:
+ {
+ error_message = "invalid string: control character U+0001 (SOH) must be escaped to \\u0001";
+ return token_type::parse_error;
+ }
+
+ case 0x02:
+ {
+ error_message = "invalid string: control character U+0002 (STX) must be escaped to \\u0002";
+ return token_type::parse_error;
+ }
+
+ case 0x03:
+ {
+ error_message = "invalid string: control character U+0003 (ETX) must be escaped to \\u0003";
+ return token_type::parse_error;
+ }
+
+ case 0x04:
+ {
+ error_message = "invalid string: control character U+0004 (EOT) must be escaped to \\u0004";
+ return token_type::parse_error;
+ }
+
+ case 0x05:
+ {
+ error_message = "invalid string: control character U+0005 (ENQ) must be escaped to \\u0005";
+ return token_type::parse_error;
+ }
+
+ case 0x06:
+ {
+ error_message = "invalid string: control character U+0006 (ACK) must be escaped to \\u0006";
+ return token_type::parse_error;
+ }
+
+ case 0x07:
+ {
+ error_message = "invalid string: control character U+0007 (BEL) must be escaped to \\u0007";
+ return token_type::parse_error;
+ }
+
+ case 0x08:
+ {
+ error_message = "invalid string: control character U+0008 (BS) must be escaped to \\u0008 or \\b";
+ return token_type::parse_error;
+ }
+
+ case 0x09:
+ {
+ error_message = "invalid string: control character U+0009 (HT) must be escaped to \\u0009 or \\t";
+ return token_type::parse_error;
+ }
+
+ case 0x0A:
+ {
+ error_message = "invalid string: control character U+000A (LF) must be escaped to \\u000A or \\n";
+ return token_type::parse_error;
+ }
+
+ case 0x0B:
+ {
+ error_message = "invalid string: control character U+000B (VT) must be escaped to \\u000B";
+ return token_type::parse_error;
+ }
+
+ case 0x0C:
+ {
+ error_message = "invalid string: control character U+000C (FF) must be escaped to \\u000C or \\f";
+ return token_type::parse_error;
+ }
+
+ case 0x0D:
+ {
+ error_message = "invalid string: control character U+000D (CR) must be escaped to \\u000D or \\r";
+ return token_type::parse_error;
+ }
+
+ case 0x0E:
+ {
+ error_message = "invalid string: control character U+000E (SO) must be escaped to \\u000E";
+ return token_type::parse_error;
+ }
+
+ case 0x0F:
+ {
+ error_message = "invalid string: control character U+000F (SI) must be escaped to \\u000F";
+ return token_type::parse_error;
+ }
+
+ case 0x10:
+ {
+ error_message = "invalid string: control character U+0010 (DLE) must be escaped to \\u0010";
+ return token_type::parse_error;
+ }
+
+ case 0x11:
+ {
+ error_message = "invalid string: control character U+0011 (DC1) must be escaped to \\u0011";
+ return token_type::parse_error;
+ }
+
+ case 0x12:
+ {
+ error_message = "invalid string: control character U+0012 (DC2) must be escaped to \\u0012";
+ return token_type::parse_error;
+ }
+
+ case 0x13:
+ {
+ error_message = "invalid string: control character U+0013 (DC3) must be escaped to \\u0013";
+ return token_type::parse_error;
+ }
+
+ case 0x14:
+ {
+ error_message = "invalid string: control character U+0014 (DC4) must be escaped to \\u0014";
+ return token_type::parse_error;
+ }
+
+ case 0x15:
+ {
+ error_message = "invalid string: control character U+0015 (NAK) must be escaped to \\u0015";
+ return token_type::parse_error;
+ }
+
+ case 0x16:
+ {
+ error_message = "invalid string: control character U+0016 (SYN) must be escaped to \\u0016";
+ return token_type::parse_error;
+ }
+
+ case 0x17:
+ {
+ error_message = "invalid string: control character U+0017 (ETB) must be escaped to \\u0017";
+ return token_type::parse_error;
+ }
+
+ case 0x18:
+ {
+ error_message = "invalid string: control character U+0018 (CAN) must be escaped to \\u0018";
+ return token_type::parse_error;
+ }
+
+ case 0x19:
+ {
+ error_message = "invalid string: control character U+0019 (EM) must be escaped to \\u0019";
+ return token_type::parse_error;
+ }
+
+ case 0x1A:
+ {
+ error_message = "invalid string: control character U+001A (SUB) must be escaped to \\u001A";
+ return token_type::parse_error;
+ }
+
+ case 0x1B:
+ {
+ error_message = "invalid string: control character U+001B (ESC) must be escaped to \\u001B";
+ return token_type::parse_error;
+ }
+
+ case 0x1C:
+ {
+ error_message = "invalid string: control character U+001C (FS) must be escaped to \\u001C";
+ return token_type::parse_error;
+ }
+
+ case 0x1D:
+ {
+ error_message = "invalid string: control character U+001D (GS) must be escaped to \\u001D";
+ return token_type::parse_error;
+ }
+
+ case 0x1E:
+ {
+ error_message = "invalid string: control character U+001E (RS) must be escaped to \\u001E";
+ return token_type::parse_error;
+ }
+
+ case 0x1F:
+ {
+ error_message = "invalid string: control character U+001F (US) must be escaped to \\u001F";
+ return token_type::parse_error;
+ }
+
+ // U+0020..U+007F (except U+0022 (quote) and U+005C (backspace))
+ case 0x20:
+ case 0x21:
+ case 0x23:
+ case 0x24:
+ case 0x25:
+ case 0x26:
+ case 0x27:
+ case 0x28:
+ case 0x29:
+ case 0x2A:
+ case 0x2B:
+ case 0x2C:
+ case 0x2D:
+ case 0x2E:
+ case 0x2F:
+ case 0x30:
+ case 0x31:
+ case 0x32:
+ case 0x33:
+ case 0x34:
+ case 0x35:
+ case 0x36:
+ case 0x37:
+ case 0x38:
+ case 0x39:
+ case 0x3A:
+ case 0x3B:
+ case 0x3C:
+ case 0x3D:
+ case 0x3E:
+ case 0x3F:
+ case 0x40:
+ case 0x41:
+ case 0x42:
+ case 0x43:
+ case 0x44:
+ case 0x45:
+ case 0x46:
+ case 0x47:
+ case 0x48:
+ case 0x49:
+ case 0x4A:
+ case 0x4B:
+ case 0x4C:
+ case 0x4D:
+ case 0x4E:
+ case 0x4F:
+ case 0x50:
+ case 0x51:
+ case 0x52:
+ case 0x53:
+ case 0x54:
+ case 0x55:
+ case 0x56:
+ case 0x57:
+ case 0x58:
+ case 0x59:
+ case 0x5A:
+ case 0x5B:
+ case 0x5D:
+ case 0x5E:
+ case 0x5F:
+ case 0x60:
+ case 0x61:
+ case 0x62:
+ case 0x63:
+ case 0x64:
+ case 0x65:
+ case 0x66:
+ case 0x67:
+ case 0x68:
+ case 0x69:
+ case 0x6A:
+ case 0x6B:
+ case 0x6C:
+ case 0x6D:
+ case 0x6E:
+ case 0x6F:
+ case 0x70:
+ case 0x71:
+ case 0x72:
+ case 0x73:
+ case 0x74:
+ case 0x75:
+ case 0x76:
+ case 0x77:
+ case 0x78:
+ case 0x79:
+ case 0x7A:
+ case 0x7B:
+ case 0x7C:
+ case 0x7D:
+ case 0x7E:
+ case 0x7F:
+ {
+ add(current);
+ break;
+ }
+
+ // U+0080..U+07FF: bytes C2..DF 80..BF
+ case 0xC2:
+ case 0xC3:
+ case 0xC4:
+ case 0xC5:
+ case 0xC6:
+ case 0xC7:
+ case 0xC8:
+ case 0xC9:
+ case 0xCA:
+ case 0xCB:
+ case 0xCC:
+ case 0xCD:
+ case 0xCE:
+ case 0xCF:
+ case 0xD0:
+ case 0xD1:
+ case 0xD2:
+ case 0xD3:
+ case 0xD4:
+ case 0xD5:
+ case 0xD6:
+ case 0xD7:
+ case 0xD8:
+ case 0xD9:
+ case 0xDA:
+ case 0xDB:
+ case 0xDC:
+ case 0xDD:
+ case 0xDE:
+ case 0xDF:
+ {
+ if (JSON_UNLIKELY(not next_byte_in_range({0x80, 0xBF})))
+ {
+ return token_type::parse_error;
+ }
+ break;
+ }
+
+ // U+0800..U+0FFF: bytes E0 A0..BF 80..BF
+ case 0xE0:
+ {
+ if (JSON_UNLIKELY(not (next_byte_in_range({0xA0, 0xBF, 0x80, 0xBF}))))
+ {
+ return token_type::parse_error;
+ }
+ break;
+ }
+
+ // U+1000..U+CFFF: bytes E1..EC 80..BF 80..BF
+ // U+E000..U+FFFF: bytes EE..EF 80..BF 80..BF
+ case 0xE1:
+ case 0xE2:
+ case 0xE3:
+ case 0xE4:
+ case 0xE5:
+ case 0xE6:
+ case 0xE7:
+ case 0xE8:
+ case 0xE9:
+ case 0xEA:
+ case 0xEB:
+ case 0xEC:
+ case 0xEE:
+ case 0xEF:
+ {
+ if (JSON_UNLIKELY(not (next_byte_in_range({0x80, 0xBF, 0x80, 0xBF}))))
+ {
+ return token_type::parse_error;
+ }
+ break;
+ }
+
+ // U+D000..U+D7FF: bytes ED 80..9F 80..BF
+ case 0xED:
+ {
+ if (JSON_UNLIKELY(not (next_byte_in_range({0x80, 0x9F, 0x80, 0xBF}))))
+ {
+ return token_type::parse_error;
+ }
+ break;
+ }
+
+ // U+10000..U+3FFFF F0 90..BF 80..BF 80..BF
+ case 0xF0:
+ {
+ if (JSON_UNLIKELY(not (next_byte_in_range({0x90, 0xBF, 0x80, 0xBF, 0x80, 0xBF}))))
+ {
+ return token_type::parse_error;
+ }
+ break;
+ }
+
+ // U+40000..U+FFFFF F1..F3 80..BF 80..BF 80..BF
+ case 0xF1:
+ case 0xF2:
+ case 0xF3:
+ {
+ if (JSON_UNLIKELY(not (next_byte_in_range({0x80, 0xBF, 0x80, 0xBF, 0x80, 0xBF}))))
+ {
+ return token_type::parse_error;
+ }
+ break;
+ }
+
+ // U+100000..U+10FFFF F4 80..8F 80..BF 80..BF
+ case 0xF4:
+ {
+ if (JSON_UNLIKELY(not (next_byte_in_range({0x80, 0x8F, 0x80, 0xBF, 0x80, 0xBF}))))
+ {
+ return token_type::parse_error;
+ }
+ break;
+ }
+
+ // remaining bytes (80..C1 and F5..FF) are ill-formed
+ default:
+ {
+ error_message = "invalid string: ill-formed UTF-8 byte";
+ return token_type::parse_error;
+ }
+ }
+ }
+ }
+
+ static void strtof(float& f, const char* str, char** endptr) noexcept
+ {
+ f = std::strtof(str, endptr);
+ }
+
+ static void strtof(double& f, const char* str, char** endptr) noexcept
+ {
+ f = std::strtod(str, endptr);
+ }
+
+ static void strtof(long double& f, const char* str, char** endptr) noexcept
+ {
+ f = std::strtold(str, endptr);
+ }
+
+ /*!
+ @brief scan a number literal
+
+ This function scans a string according to Sect. 6 of RFC 7159.
+
+ The function is realized with a deterministic finite state machine derived
+ from the grammar described in RFC 7159. Starting in state "init", the
+ input is read and used to determined the next state. Only state "done"
+ accepts the number. State "error" is a trap state to model errors. In the
+ table below, "anything" means any character but the ones listed before.
+
+ state | 0 | 1-9 | e E | + | - | . | anything
+ ---------|----------|----------|----------|---------|---------|----------|-----------
+ init | zero | any1 | [error] | [error] | minus | [error] | [error]
+ minus | zero | any1 | [error] | [error] | [error] | [error] | [error]
+ zero | done | done | exponent | done | done | decimal1 | done
+ any1 | any1 | any1 | exponent | done | done | decimal1 | done
+ decimal1 | decimal2 | [error] | [error] | [error] | [error] | [error] | [error]
+ decimal2 | decimal2 | decimal2 | exponent | done | done | done | done
+ exponent | any2 | any2 | [error] | sign | sign | [error] | [error]
+ sign | any2 | any2 | [error] | [error] | [error] | [error] | [error]
+ any2 | any2 | any2 | done | done | done | done | done
+
+ The state machine is realized with one label per state (prefixed with
+ "scan_number_") and `goto` statements between them. The state machine
+ contains cycles, but any cycle can be left when EOF is read. Therefore,
+ the function is guaranteed to terminate.
+
+ During scanning, the read bytes are stored in token_buffer. This string is
+ then converted to a signed integer, an unsigned integer, or a
+ floating-point number.
+
+ @return token_type::value_unsigned, token_type::value_integer, or
+ token_type::value_float if number could be successfully scanned,
+ token_type::parse_error otherwise
+
+ @note The scanner is independent of the current locale. Internally, the
+ locale's decimal point is used instead of `.` to work with the
+ locale-dependent converters.
+ */
+ token_type scan_number() // lgtm [cpp/use-of-goto]
+ {
+ // reset token_buffer to store the number's bytes
+ reset();
+
+ // the type of the parsed number; initially set to unsigned; will be
+ // changed if minus sign, decimal point or exponent is read
+ token_type number_type = token_type::value_unsigned;
+
+ // state (init): we just found out we need to scan a number
+ switch (current)
+ {
+ case '-':
+ {
+ add(current);
+ goto scan_number_minus;
+ }
+
+ case '0':
+ {
+ add(current);
+ goto scan_number_zero;
+ }
+
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ {
+ add(current);
+ goto scan_number_any1;
+ }
+
+ // all other characters are rejected outside scan_number()
+ default: // LCOV_EXCL_LINE
+ assert(false); // LCOV_EXCL_LINE
+ }
+
+scan_number_minus:
+ // state: we just parsed a leading minus sign
+ number_type = token_type::value_integer;
+ switch (get())
+ {
+ case '0':
+ {
+ add(current);
+ goto scan_number_zero;
+ }
+
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ {
+ add(current);
+ goto scan_number_any1;
+ }
+
+ default:
+ {
+ error_message = "invalid number; expected digit after '-'";
+ return token_type::parse_error;
+ }
+ }
+
+scan_number_zero:
+ // state: we just parse a zero (maybe with a leading minus sign)
+ switch (get())
+ {
+ case '.':
+ {
+ add(decimal_point_char);
+ goto scan_number_decimal1;
+ }
+
+ case 'e':
+ case 'E':
+ {
+ add(current);
+ goto scan_number_exponent;
+ }
+
+ default:
+ goto scan_number_done;
+ }
+
+scan_number_any1:
+ // state: we just parsed a number 0-9 (maybe with a leading minus sign)
+ switch (get())
+ {
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ {
+ add(current);
+ goto scan_number_any1;
+ }
+
+ case '.':
+ {
+ add(decimal_point_char);
+ goto scan_number_decimal1;
+ }
+
+ case 'e':
+ case 'E':
+ {
+ add(current);
+ goto scan_number_exponent;
+ }
+
+ default:
+ goto scan_number_done;
+ }
+
+scan_number_decimal1:
+ // state: we just parsed a decimal point
+ number_type = token_type::value_float;
+ switch (get())
+ {
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ {
+ add(current);
+ goto scan_number_decimal2;
+ }
+
+ default:
+ {
+ error_message = "invalid number; expected digit after '.'";
+ return token_type::parse_error;
+ }
+ }
+
+scan_number_decimal2:
+ // we just parsed at least one number after a decimal point
+ switch (get())
+ {
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ {
+ add(current);
+ goto scan_number_decimal2;
+ }
+
+ case 'e':
+ case 'E':
+ {
+ add(current);
+ goto scan_number_exponent;
+ }
+
+ default:
+ goto scan_number_done;
+ }
+
+scan_number_exponent:
+ // we just parsed an exponent
+ number_type = token_type::value_float;
+ switch (get())
+ {
+ case '+':
+ case '-':
+ {
+ add(current);
+ goto scan_number_sign;
+ }
+
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ {
+ add(current);
+ goto scan_number_any2;
+ }
+
+ default:
+ {
+ error_message =
+ "invalid number; expected '+', '-', or digit after exponent";
+ return token_type::parse_error;
+ }
+ }
+
+scan_number_sign:
+ // we just parsed an exponent sign
+ switch (get())
+ {
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ {
+ add(current);
+ goto scan_number_any2;
+ }
+
+ default:
+ {
+ error_message = "invalid number; expected digit after exponent sign";
+ return token_type::parse_error;
+ }
+ }
+
+scan_number_any2:
+ // we just parsed a number after the exponent or exponent sign
+ switch (get())
+ {
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ {
+ add(current);
+ goto scan_number_any2;
+ }
+
+ default:
+ goto scan_number_done;
+ }
+
+scan_number_done:
+ // unget the character after the number (we only read it to know that
+ // we are done scanning a number)
+ unget();
+
+ char* endptr = nullptr;
+ errno = 0;
+
+ // try to parse integers first and fall back to floats
+ if (number_type == token_type::value_unsigned)
+ {
+ const auto x = std::strtoull(token_buffer.data(), &endptr, 10);
+
+ // we checked the number format before
+ assert(endptr == token_buffer.data() + token_buffer.size());
+
+ if (errno == 0)
+ {
+ value_unsigned = static_cast<number_unsigned_t>(x);
+ if (value_unsigned == x)
+ {
+ return token_type::value_unsigned;
+ }
+ }
+ }
+ else if (number_type == token_type::value_integer)
+ {
+ const auto x = std::strtoll(token_buffer.data(), &endptr, 10);
+
+ // we checked the number format before
+ assert(endptr == token_buffer.data() + token_buffer.size());
+
+ if (errno == 0)
+ {
+ value_integer = static_cast<number_integer_t>(x);
+ if (value_integer == x)
+ {
+ return token_type::value_integer;
+ }
+ }
+ }
+
+ // this code is reached if we parse a floating-point number or if an
+ // integer conversion above failed
+ strtof(value_float, token_buffer.data(), &endptr);
+
+ // we checked the number format before
+ assert(endptr == token_buffer.data() + token_buffer.size());
+
+ return token_type::value_float;
+ }
+
+ /*!
+ @param[in] literal_text the literal text to expect
+ @param[in] length the length of the passed literal text
+ @param[in] return_type the token type to return on success
+ */
+ token_type scan_literal(const char* literal_text, const std::size_t length,
+ token_type return_type)
+ {
+ assert(current == literal_text[0]);
+ for (std::size_t i = 1; i < length; ++i)
+ {
+ if (JSON_UNLIKELY(get() != literal_text[i]))
+ {
+ error_message = "invalid literal";
+ return token_type::parse_error;
+ }
+ }
+ return return_type;
+ }
+
+ /////////////////////
+ // input management
+ /////////////////////
+
+ /// reset token_buffer; current character is beginning of token
+ void reset() noexcept
+ {
+ token_buffer.clear();
+ token_string.clear();
+ token_string.push_back(std::char_traits<char>::to_char_type(current));
+ }
+
+ /*
+ @brief get next character from the input
+
+ This function provides the interface to the used input adapter. It does
+ not throw in case the input reached EOF, but returns a
+ `std::char_traits<char>::eof()` in that case. Stores the scanned characters
+ for use in error messages.
+
+ @return character read from the input
+ */
+ std::char_traits<char>::int_type get()
+ {
+ ++position.chars_read_total;
+ ++position.chars_read_current_line;
+
+ if (next_unget)
+ {
+ // just reset the next_unget variable and work with current
+ next_unget = false;
+ }
+ else
+ {
+ current = ia->get_character();
+ }
+
+ if (JSON_LIKELY(current != std::char_traits<char>::eof()))
+ {
+ token_string.push_back(std::char_traits<char>::to_char_type(current));
+ }
+
+ if (current == '\n')
+ {
+ ++position.lines_read;
+ position.chars_read_current_line = 0;
+ }
+
+ return current;
+ }
+
+ /*!
+ @brief unget current character (read it again on next get)
+
+ We implement unget by setting variable next_unget to true. The input is not
+ changed - we just simulate ungetting by modifying chars_read_total,
+ chars_read_current_line, and token_string. The next call to get() will
+ behave as if the unget character is read again.
+ */
+ void unget()
+ {
+ next_unget = true;
+
+ --position.chars_read_total;
+
+ // in case we "unget" a newline, we have to also decrement the lines_read
+ if (position.chars_read_current_line == 0)
+ {
+ if (position.lines_read > 0)
+ {
+ --position.lines_read;
+ }
+ }
+ else
+ {
+ --position.chars_read_current_line;
+ }
+
+ if (JSON_LIKELY(current != std::char_traits<char>::eof()))
+ {
+ assert(not token_string.empty());
+ token_string.pop_back();
+ }
+ }
+
+ /// add a character to token_buffer
+ void add(int c)
+ {
+ token_buffer.push_back(std::char_traits<char>::to_char_type(c));
+ }
+
+ public:
+ /////////////////////
+ // value getters
+ /////////////////////
+
+ /// return integer value
+ constexpr number_integer_t get_number_integer() const noexcept
+ {
+ return value_integer;
+ }
+
+ /// return unsigned integer value
+ constexpr number_unsigned_t get_number_unsigned() const noexcept
+ {
+ return value_unsigned;
+ }
+
+ /// return floating-point value
+ constexpr number_float_t get_number_float() const noexcept
+ {
+ return value_float;
+ }
+
+ /// return current string value (implicitly resets the token; useful only once)
+ string_t& get_string()
+ {
+ return token_buffer;
+ }
+
+ /////////////////////
+ // diagnostics
+ /////////////////////
+
+ /// return position of last read token
+ constexpr position_t get_position() const noexcept
+ {
+ return position;
+ }
+
+ /// return the last read token (for errors only). Will never contain EOF
+ /// (an arbitrary value that is not a valid char value, often -1), because
+ /// 255 may legitimately occur. May contain NUL, which should be escaped.
+ std::string get_token_string() const
+ {
+ // escape control characters
+ std::string result;
+ for (const auto c : token_string)
+ {
+ if ('\x00' <= c and c <= '\x1F')
+ {
+ // escape control characters
+ std::array<char, 9> cs{{}};
+ (std::snprintf)(cs.data(), cs.size(), "<U+%.4X>", static_cast<unsigned char>(c));
+ result += cs.data();
+ }
+ else
+ {
+ // add character as is
+ result.push_back(c);
+ }
+ }
+
+ return result;
+ }
+
+ /// return syntax error message
+ constexpr const char* get_error_message() const noexcept
+ {
+ return error_message;
+ }
+
+ /////////////////////
+ // actual scanner
+ /////////////////////
+
+ /*!
+ @brief skip the UTF-8 byte order mark
+ @return true iff there is no BOM or the correct BOM has been skipped
+ */
+ bool skip_bom()
+ {
+ if (get() == 0xEF)
+ {
+ // check if we completely parse the BOM
+ return get() == 0xBB and get() == 0xBF;
+ }
+
+ // the first character is not the beginning of the BOM; unget it to
+ // process is later
+ unget();
+ return true;
+ }
+
+ token_type scan()
+ {
+ // initially, skip the BOM
+ if (position.chars_read_total == 0 and not skip_bom())
+ {
+ error_message = "invalid BOM; must be 0xEF 0xBB 0xBF if given";
+ return token_type::parse_error;
+ }
+
+ // read next character and ignore whitespace
+ do
+ {
+ get();
+ }
+ while (current == ' ' or current == '\t' or current == '\n' or current == '\r');
+
+ switch (current)
+ {
+ // structural characters
+ case '[':
+ return token_type::begin_array;
+ case ']':
+ return token_type::end_array;
+ case '{':
+ return token_type::begin_object;
+ case '}':
+ return token_type::end_object;
+ case ':':
+ return token_type::name_separator;
+ case ',':
+ return token_type::value_separator;
+
+ // literals
+ case 't':
+ return scan_literal("true", 4, token_type::literal_true);
+ case 'f':
+ return scan_literal("false", 5, token_type::literal_false);
+ case 'n':
+ return scan_literal("null", 4, token_type::literal_null);
+
+ // string
+ case '\"':
+ return scan_string();
+
+ // number
+ case '-':
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ return scan_number();
+
+ // end of input (the null byte is needed when parsing from
+ // string literals)
+ case '\0':
+ case std::char_traits<char>::eof():
+ return token_type::end_of_input;
+
+ // error
+ default:
+ error_message = "invalid literal";
+ return token_type::parse_error;
+ }
+ }
+
+ private:
+ /// input adapter
+ detail::input_adapter_t ia = nullptr;
+
+ /// the current character
+ std::char_traits<char>::int_type current = std::char_traits<char>::eof();
+
+ /// whether the next get() call should just return current
+ bool next_unget = false;
+
+ /// the start position of the current token
+ position_t position {};
+
+ /// raw input token string (for error messages)
+ std::vector<char> token_string {};
+
+ /// buffer for variable-length tokens (numbers, strings)
+ string_t token_buffer {};
+
+ /// a description of occurred lexer errors
+ const char* error_message = "";
+
+ // number values
+ number_integer_t value_integer = 0;
+ number_unsigned_t value_unsigned = 0;
+ number_float_t value_float = 0;
+
+ /// the decimal point
+ const char decimal_point_char = '.';
+};
+} // namespace detail
+} // namespace nlohmann
+
+// #include <nlohmann/detail/input/parser.hpp>
+
+
+#include <cassert> // assert
+#include <cmath> // isfinite
+#include <cstdint> // uint8_t
+#include <functional> // function
+#include <string> // string
+#include <utility> // move
+#include <vector> // vector
+
+// #include <nlohmann/detail/exceptions.hpp>
+
+// #include <nlohmann/detail/input/input_adapters.hpp>
+
+// #include <nlohmann/detail/input/json_sax.hpp>
+
+// #include <nlohmann/detail/input/lexer.hpp>
+
+// #include <nlohmann/detail/macro_scope.hpp>
+
+// #include <nlohmann/detail/meta/is_sax.hpp>
+
+// #include <nlohmann/detail/value_t.hpp>
+
+
+namespace nlohmann
+{
+namespace detail
+{
+////////////
+// parser //
+////////////
+
+/*!
+@brief syntax analysis
+
+This class implements a recursive decent parser.
+*/
+template<typename BasicJsonType>
+class parser
+{
+ using number_integer_t = typename BasicJsonType::number_integer_t;
+ using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
+ using number_float_t = typename BasicJsonType::number_float_t;
+ using string_t = typename BasicJsonType::string_t;
+ using lexer_t = lexer<BasicJsonType>;
+ using token_type = typename lexer_t::token_type;
+
+ public:
+ enum class parse_event_t : uint8_t
+ {
+ /// the parser read `{` and started to process a JSON object
+ object_start,
+ /// the parser read `}` and finished processing a JSON object
+ object_end,
+ /// the parser read `[` and started to process a JSON array
+ array_start,
+ /// the parser read `]` and finished processing a JSON array
+ array_end,
+ /// the parser read a key of a value in an object
+ key,
+ /// the parser finished reading a JSON value
+ value
+ };
+
+ using parser_callback_t =
+ std::function<bool(int depth, parse_event_t event, BasicJsonType& parsed)>;
+
+ /// a parser reading from an input adapter
+ explicit parser(detail::input_adapter_t&& adapter,
+ const parser_callback_t cb = nullptr,
+ const bool allow_exceptions_ = true)
+ : callback(cb), m_lexer(std::move(adapter)), allow_exceptions(allow_exceptions_)
+ {
+ // read first token
+ get_token();
+ }
+
+ /*!
+ @brief public parser interface
+
+ @param[in] strict whether to expect the last token to be EOF
+ @param[in,out] result parsed JSON value
+
+ @throw parse_error.101 in case of an unexpected token
+ @throw parse_error.102 if to_unicode fails or surrogate error
+ @throw parse_error.103 if to_unicode fails
+ */
+ void parse(const bool strict, BasicJsonType& result)
+ {
+ if (callback)
+ {
+ json_sax_dom_callback_parser<BasicJsonType> sdp(result, callback, allow_exceptions);
+ sax_parse_internal(&sdp);
+ result.assert_invariant();
+
+ // in strict mode, input must be completely read
+ if (strict and (get_token() != token_type::end_of_input))
+ {
+ sdp.parse_error(m_lexer.get_position(),
+ m_lexer.get_token_string(),
+ parse_error::create(101, m_lexer.get_position(),
+ exception_message(token_type::end_of_input, "value")));
+ }
+
+ // in case of an error, return discarded value
+ if (sdp.is_errored())
+ {
+ result = value_t::discarded;
+ return;
+ }
+
+ // set top-level value to null if it was discarded by the callback
+ // function
+ if (result.is_discarded())
+ {
+ result = nullptr;
+ }
+ }
+ else
+ {
+ json_sax_dom_parser<BasicJsonType> sdp(result, allow_exceptions);
+ sax_parse_internal(&sdp);
+ result.assert_invariant();
+
+ // in strict mode, input must be completely read
+ if (strict and (get_token() != token_type::end_of_input))
+ {
+ sdp.parse_error(m_lexer.get_position(),
+ m_lexer.get_token_string(),
+ parse_error::create(101, m_lexer.get_position(),
+ exception_message(token_type::end_of_input, "value")));
+ }
+
+ // in case of an error, return discarded value
+ if (sdp.is_errored())
+ {
+ result = value_t::discarded;
+ return;
+ }
+ }
+ }
+
+ /*!
+ @brief public accept interface
+
+ @param[in] strict whether to expect the last token to be EOF
+ @return whether the input is a proper JSON text
+ */
+ bool accept(const bool strict = true)
+ {
+ json_sax_acceptor<BasicJsonType> sax_acceptor;
+ return sax_parse(&sax_acceptor, strict);
+ }
+
+ template <typename SAX>
+ bool sax_parse(SAX* sax, const bool strict = true)
+ {
+ (void)detail::is_sax_static_asserts<SAX, BasicJsonType> {};
+ const bool result = sax_parse_internal(sax);
+
+ // strict mode: next byte must be EOF
+ if (result and strict and (get_token() != token_type::end_of_input))
+ {
+ return sax->parse_error(m_lexer.get_position(),
+ m_lexer.get_token_string(),
+ parse_error::create(101, m_lexer.get_position(),
+ exception_message(token_type::end_of_input, "value")));
+ }
+
+ return result;
+ }
+
+ private:
+ template <typename SAX>
+ bool sax_parse_internal(SAX* sax)
+ {
+ // stack to remember the hierarchy of structured values we are parsing
+ // true = array; false = object
+ std::vector<bool> states;
+ // value to avoid a goto (see comment where set to true)
+ bool skip_to_state_evaluation = false;
+
+ while (true)
+ {
+ if (not skip_to_state_evaluation)
+ {
+ // invariant: get_token() was called before each iteration
+ switch (last_token)
+ {
+ case token_type::begin_object:
+ {
+ if (JSON_UNLIKELY(not sax->start_object(std::size_t(-1))))
+ {
+ return false;
+ }
+
+ // closing } -> we are done
+ if (get_token() == token_type::end_object)
+ {
+ if (JSON_UNLIKELY(not sax->end_object()))
+ {
+ return false;
+ }
+ break;
+ }
+
+ // parse key
+ if (JSON_UNLIKELY(last_token != token_type::value_string))
+ {
+ return sax->parse_error(m_lexer.get_position(),
+ m_lexer.get_token_string(),
+ parse_error::create(101, m_lexer.get_position(),
+ exception_message(token_type::value_string, "object key")));
+ }
+ if (JSON_UNLIKELY(not sax->key(m_lexer.get_string())))
+ {
+ return false;
+ }
+
+ // parse separator (:)
+ if (JSON_UNLIKELY(get_token() != token_type::name_separator))
+ {
+ return sax->parse_error(m_lexer.get_position(),
+ m_lexer.get_token_string(),
+ parse_error::create(101, m_lexer.get_position(),
+ exception_message(token_type::name_separator, "object separator")));
+ }
+
+ // remember we are now inside an object
+ states.push_back(false);
+
+ // parse values
+ get_token();
+ continue;
+ }
+
+ case token_type::begin_array:
+ {
+ if (JSON_UNLIKELY(not sax->start_array(std::size_t(-1))))
+ {
+ return false;
+ }
+
+ // closing ] -> we are done
+ if (get_token() == token_type::end_array)
+ {
+ if (JSON_UNLIKELY(not sax->end_array()))
+ {
+ return false;
+ }
+ break;
+ }
+
+ // remember we are now inside an array
+ states.push_back(true);
+
+ // parse values (no need to call get_token)
+ continue;
+ }
+
+ case token_type::value_float:
+ {
+ const auto res = m_lexer.get_number_float();
+
+ if (JSON_UNLIKELY(not std::isfinite(res)))
+ {
+ return sax->parse_error(m_lexer.get_position(),
+ m_lexer.get_token_string(),
+ out_of_range::create(406, "number overflow parsing '" + m_lexer.get_token_string() + "'"));
+ }
+
+ if (JSON_UNLIKELY(not sax->number_float(res, m_lexer.get_string())))
+ {
+ return false;
+ }
+
+ break;
+ }
+
+ case token_type::literal_false:
+ {
+ if (JSON_UNLIKELY(not sax->boolean(false)))
+ {
+ return false;
+ }
+ break;
+ }
+
+ case token_type::literal_null:
+ {
+ if (JSON_UNLIKELY(not sax->null()))
+ {
+ return false;
+ }
+ break;
+ }
+
+ case token_type::literal_true:
+ {
+ if (JSON_UNLIKELY(not sax->boolean(true)))
+ {
+ return false;
+ }
+ break;
+ }
+
+ case token_type::value_integer:
+ {
+ if (JSON_UNLIKELY(not sax->number_integer(m_lexer.get_number_integer())))
+ {
+ return false;
+ }
+ break;
+ }
+
+ case token_type::value_string:
+ {
+ if (JSON_UNLIKELY(not sax->string(m_lexer.get_string())))
+ {
+ return false;
+ }
+ break;
+ }
+
+ case token_type::value_unsigned:
+ {
+ if (JSON_UNLIKELY(not sax->number_unsigned(m_lexer.get_number_unsigned())))
+ {
+ return false;
+ }
+ break;
+ }
+
+ case token_type::parse_error:
+ {
+ // using "uninitialized" to avoid "expected" message
+ return sax->parse_error(m_lexer.get_position(),
+ m_lexer.get_token_string(),
+ parse_error::create(101, m_lexer.get_position(),
+ exception_message(token_type::uninitialized, "value")));
+ }
+
+ default: // the last token was unexpected
+ {
+ return sax->parse_error(m_lexer.get_position(),
+ m_lexer.get_token_string(),
+ parse_error::create(101, m_lexer.get_position(),
+ exception_message(token_type::literal_or_value, "value")));
+ }
+ }
+ }
+ else
+ {
+ skip_to_state_evaluation = false;
+ }
+
+ // we reached this line after we successfully parsed a value
+ if (states.empty())
+ {
+ // empty stack: we reached the end of the hierarchy: done
+ return true;
+ }
+
+ if (states.back()) // array
+ {
+ // comma -> next value
+ if (get_token() == token_type::value_separator)
+ {
+ // parse a new value
+ get_token();
+ continue;
+ }
+
+ // closing ]
+ if (JSON_LIKELY(last_token == token_type::end_array))
+ {
+ if (JSON_UNLIKELY(not sax->end_array()))
+ {
+ return false;
+ }
+
+ // We are done with this array. Before we can parse a
+ // new value, we need to evaluate the new state first.
+ // By setting skip_to_state_evaluation to false, we
+ // are effectively jumping to the beginning of this if.
+ assert(not states.empty());
+ states.pop_back();
+ skip_to_state_evaluation = true;
+ continue;
+ }
+
+ return sax->parse_error(m_lexer.get_position(),
+ m_lexer.get_token_string(),
+ parse_error::create(101, m_lexer.get_position(),
+ exception_message(token_type::end_array, "array")));
+ }
+ else // object
+ {
+ // comma -> next value
+ if (get_token() == token_type::value_separator)
+ {
+ // parse key
+ if (JSON_UNLIKELY(get_token() != token_type::value_string))
+ {
+ return sax->parse_error(m_lexer.get_position(),
+ m_lexer.get_token_string(),
+ parse_error::create(101, m_lexer.get_position(),
+ exception_message(token_type::value_string, "object key")));
+ }
+
+ if (JSON_UNLIKELY(not sax->key(m_lexer.get_string())))
+ {
+ return false;
+ }
+
+ // parse separator (:)
+ if (JSON_UNLIKELY(get_token() != token_type::name_separator))
+ {
+ return sax->parse_error(m_lexer.get_position(),
+ m_lexer.get_token_string(),
+ parse_error::create(101, m_lexer.get_position(),
+ exception_message(token_type::name_separator, "object separator")));
+ }
+
+ // parse values
+ get_token();
+ continue;
+ }
+
+ // closing }
+ if (JSON_LIKELY(last_token == token_type::end_object))
+ {
+ if (JSON_UNLIKELY(not sax->end_object()))
+ {
+ return false;
+ }
+
+ // We are done with this object. Before we can parse a
+ // new value, we need to evaluate the new state first.
+ // By setting skip_to_state_evaluation to false, we
+ // are effectively jumping to the beginning of this if.
+ assert(not states.empty());
+ states.pop_back();
+ skip_to_state_evaluation = true;
+ continue;
+ }
+
+ return sax->parse_error(m_lexer.get_position(),
+ m_lexer.get_token_string(),
+ parse_error::create(101, m_lexer.get_position(),
+ exception_message(token_type::end_object, "object")));
+ }
+ }
+ }
+
+ /// get next token from lexer
+ token_type get_token()
+ {
+ return last_token = m_lexer.scan();
+ }
+
+ std::string exception_message(const token_type expected, const std::string& context)
+ {
+ std::string error_msg = "syntax error ";
+
+ if (not context.empty())
+ {
+ error_msg += "while parsing " + context + " ";
+ }
+
+ error_msg += "- ";
+
+ if (last_token == token_type::parse_error)
+ {
+ error_msg += std::string(m_lexer.get_error_message()) + "; last read: '" +
+ m_lexer.get_token_string() + "'";
+ }
+ else
+ {
+ error_msg += "unexpected " + std::string(lexer_t::token_type_name(last_token));
+ }
+
+ if (expected != token_type::uninitialized)
+ {
+ error_msg += "; expected " + std::string(lexer_t::token_type_name(expected));
+ }
+
+ return error_msg;
+ }
+
+ private:
+ /// callback function
+ const parser_callback_t callback = nullptr;
+ /// the type of the last read token
+ token_type last_token = token_type::uninitialized;
+ /// the lexer
+ lexer_t m_lexer;
+ /// whether to throw exceptions in case of errors
+ const bool allow_exceptions = true;
+};
+} // namespace detail
+} // namespace nlohmann
+
+// #include <nlohmann/detail/iterators/internal_iterator.hpp>
+
+
+// #include <nlohmann/detail/iterators/primitive_iterator.hpp>
+
+
+#include <cstddef> // ptrdiff_t
+#include <limits> // numeric_limits
+
+namespace nlohmann
+{
+namespace detail
+{
+/*
+@brief an iterator for primitive JSON types
+
+This class models an iterator for primitive JSON types (boolean, number,
+string). It's only purpose is to allow the iterator/const_iterator classes
+to "iterate" over primitive values. Internally, the iterator is modeled by
+a `difference_type` variable. Value begin_value (`0`) models the begin,
+end_value (`1`) models past the end.
+*/
+class primitive_iterator_t
+{
+ private:
+ using difference_type = std::ptrdiff_t;
+ static constexpr difference_type begin_value = 0;
+ static constexpr difference_type end_value = begin_value + 1;
+
+ /// iterator as signed integer type
+ difference_type m_it = (std::numeric_limits<std::ptrdiff_t>::min)();
+
+ public:
+ constexpr difference_type get_value() const noexcept
+ {
+ return m_it;
+ }
+
+ /// set iterator to a defined beginning
+ void set_begin() noexcept
+ {
+ m_it = begin_value;
+ }
+
+ /// set iterator to a defined past the end
+ void set_end() noexcept
+ {
+ m_it = end_value;
+ }
+
+ /// return whether the iterator can be dereferenced
+ constexpr bool is_begin() const noexcept
+ {
+ return m_it == begin_value;
+ }
+
+ /// return whether the iterator is at end
+ constexpr bool is_end() const noexcept
+ {
+ return m_it == end_value;
+ }
+
+ friend constexpr bool operator==(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
+ {
+ return lhs.m_it == rhs.m_it;
+ }
+
+ friend constexpr bool operator<(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
+ {
+ return lhs.m_it < rhs.m_it;
+ }
+
+ primitive_iterator_t operator+(difference_type n) noexcept
+ {
+ auto result = *this;
+ result += n;
+ return result;
+ }
+
+ friend constexpr difference_type operator-(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
+ {
+ return lhs.m_it - rhs.m_it;
+ }
+
+ primitive_iterator_t& operator++() noexcept
+ {
+ ++m_it;
+ return *this;
+ }
+
+ primitive_iterator_t const operator++(int) noexcept
+ {
+ auto result = *this;
+ ++m_it;
+ return result;
+ }
+
+ primitive_iterator_t& operator--() noexcept
+ {
+ --m_it;
+ return *this;
+ }
+
+ primitive_iterator_t const operator--(int) noexcept
+ {
+ auto result = *this;
+ --m_it;
+ return result;
+ }
+
+ primitive_iterator_t& operator+=(difference_type n) noexcept
+ {
+ m_it += n;
+ return *this;
+ }
+
+ primitive_iterator_t& operator-=(difference_type n) noexcept
+ {
+ m_it -= n;
+ return *this;
+ }
+};
+} // namespace detail
+} // namespace nlohmann
+
+
+namespace nlohmann
+{
+namespace detail
+{
+/*!
+@brief an iterator value
+
+@note This structure could easily be a union, but MSVC currently does not allow
+unions members with complex constructors, see https://github.com/nlohmann/json/pull/105.
+*/
+template<typename BasicJsonType> struct internal_iterator
+{
+ /// iterator for JSON objects
+ typename BasicJsonType::object_t::iterator object_iterator {};
+ /// iterator for JSON arrays
+ typename BasicJsonType::array_t::iterator array_iterator {};
+ /// generic iterator for all other types
+ primitive_iterator_t primitive_iterator {};
+};
+} // namespace detail
+} // namespace nlohmann
+
+// #include <nlohmann/detail/iterators/iter_impl.hpp>
+
+
+#include <ciso646> // not
+#include <iterator> // iterator, random_access_iterator_tag, bidirectional_iterator_tag, advance, next
+#include <type_traits> // conditional, is_const, remove_const
+
+// #include <nlohmann/detail/exceptions.hpp>
+
+// #include <nlohmann/detail/iterators/internal_iterator.hpp>
+
+// #include <nlohmann/detail/iterators/primitive_iterator.hpp>
+
+// #include <nlohmann/detail/macro_scope.hpp>
+
+// #include <nlohmann/detail/meta/cpp_future.hpp>
+
+// #include <nlohmann/detail/meta/type_traits.hpp>
+
+// #include <nlohmann/detail/value_t.hpp>
+
+
+namespace nlohmann
+{
+namespace detail
+{
+// forward declare, to be able to friend it later on
+template<typename IteratorType> class iteration_proxy;
+template<typename IteratorType> class iteration_proxy_value;
+
+/*!
+@brief a template for a bidirectional iterator for the @ref basic_json class
+This class implements a both iterators (iterator and const_iterator) for the
+@ref basic_json class.
+@note An iterator is called *initialized* when a pointer to a JSON value has
+ been set (e.g., by a constructor or a copy assignment). If the iterator is
+ default-constructed, it is *uninitialized* and most methods are undefined.
+ **The library uses assertions to detect calls on uninitialized iterators.**
+@requirement The class satisfies the following concept requirements:
+-
+[BidirectionalIterator](https://en.cppreference.com/w/cpp/named_req/BidirectionalIterator):
+ The iterator that can be moved can be moved in both directions (i.e.
+ incremented and decremented).
+@since version 1.0.0, simplified in version 2.0.9, change to bidirectional
+ iterators in version 3.0.0 (see https://github.com/nlohmann/json/issues/593)
+*/
+template<typename BasicJsonType>
+class iter_impl
+{
+ /// allow basic_json to access private members
+ friend iter_impl<typename std::conditional<std::is_const<BasicJsonType>::value, typename std::remove_const<BasicJsonType>::type, const BasicJsonType>::type>;
+ friend BasicJsonType;
+ friend iteration_proxy<iter_impl>;
+ friend iteration_proxy_value<iter_impl>;
+
+ using object_t = typename BasicJsonType::object_t;
+ using array_t = typename BasicJsonType::array_t;
+ // make sure BasicJsonType is basic_json or const basic_json
+ static_assert(is_basic_json<typename std::remove_const<BasicJsonType>::type>::value,
+ "iter_impl only accepts (const) basic_json");
+
+ public:
+
+ /// The std::iterator class template (used as a base class to provide typedefs) is deprecated in C++17.
+ /// The C++ Standard has never required user-defined iterators to derive from std::iterator.
+ /// A user-defined iterator should provide publicly accessible typedefs named
+ /// iterator_category, value_type, difference_type, pointer, and reference.
+ /// Note that value_type is required to be non-const, even for constant iterators.
+ using iterator_category = std::bidirectional_iterator_tag;
+
+ /// the type of the values when the iterator is dereferenced
+ using value_type = typename BasicJsonType::value_type;
+ /// a type to represent differences between iterators
+ using difference_type = typename BasicJsonType::difference_type;
+ /// defines a pointer to the type iterated over (value_type)
+ using pointer = typename std::conditional<std::is_const<BasicJsonType>::value,
+ typename BasicJsonType::const_pointer,
+ typename BasicJsonType::pointer>::type;
+ /// defines a reference to the type iterated over (value_type)
+ using reference =
+ typename std::conditional<std::is_const<BasicJsonType>::value,
+ typename BasicJsonType::const_reference,
+ typename BasicJsonType::reference>::type;
+
+ /// default constructor
+ iter_impl() = default;
+
+ /*!
+ @brief constructor for a given JSON instance
+ @param[in] object pointer to a JSON object for this iterator
+ @pre object != nullptr
+ @post The iterator is initialized; i.e. `m_object != nullptr`.
+ */
+ explicit iter_impl(pointer object) noexcept : m_object(object)
+ {
+ assert(m_object != nullptr);
+
+ switch (m_object->m_type)
+ {
+ case value_t::object:
+ {
+ m_it.object_iterator = typename object_t::iterator();
+ break;
+ }
+
+ case value_t::array:
+ {
+ m_it.array_iterator = typename array_t::iterator();
+ break;
+ }
+
+ default:
+ {
+ m_it.primitive_iterator = primitive_iterator_t();
+ break;
+ }
+ }
+ }
+
+ /*!
+ @note The conventional copy constructor and copy assignment are implicitly
+ defined. Combined with the following converting constructor and
+ assignment, they support: (1) copy from iterator to iterator, (2)
+ copy from const iterator to const iterator, and (3) conversion from
+ iterator to const iterator. However conversion from const iterator
+ to iterator is not defined.
+ */
+
+ /*!
+ @brief converting constructor
+ @param[in] other non-const iterator to copy from
+ @note It is not checked whether @a other is initialized.
+ */
+ iter_impl(const iter_impl<typename std::remove_const<BasicJsonType>::type>& other) noexcept
+ : m_object(other.m_object), m_it(other.m_it) {}
+
+ /*!
+ @brief converting assignment
+ @param[in,out] other non-const iterator to copy from
+ @return const/non-const iterator
+ @note It is not checked whether @a other is initialized.
+ */
+ iter_impl& operator=(const iter_impl<typename std::remove_const<BasicJsonType>::type>& other) noexcept
+ {
+ m_object = other.m_object;
+ m_it = other.m_it;
+ return *this;
+ }
+
+ private:
+ /*!
+ @brief set the iterator to the first value
+ @pre The iterator is initialized; i.e. `m_object != nullptr`.
+ */
+ void set_begin() noexcept
+ {
+ assert(m_object != nullptr);
+
+ switch (m_object->m_type)
+ {
+ case value_t::object:
+ {
+ m_it.object_iterator = m_object->m_value.object->begin();
+ break;
+ }
+
+ case value_t::array:
+ {
+ m_it.array_iterator = m_object->m_value.array->begin();
+ break;
+ }
+
+ case value_t::null:
+ {
+ // set to end so begin()==end() is true: null is empty
+ m_it.primitive_iterator.set_end();
+ break;
+ }
+
+ default:
+ {
+ m_it.primitive_iterator.set_begin();
+ break;
+ }
+ }
+ }
+
+ /*!
+ @brief set the iterator past the last value
+ @pre The iterator is initialized; i.e. `m_object != nullptr`.
+ */
+ void set_end() noexcept
+ {
+ assert(m_object != nullptr);
+
+ switch (m_object->m_type)
+ {
+ case value_t::object:
+ {
+ m_it.object_iterator = m_object->m_value.object->end();
+ break;
+ }
+
+ case value_t::array:
+ {
+ m_it.array_iterator = m_object->m_value.array->end();
+ break;
+ }
+
+ default:
+ {
+ m_it.primitive_iterator.set_end();
+ break;
+ }
+ }
+ }
+
+ public:
+ /*!
+ @brief return a reference to the value pointed to by the iterator
+ @pre The iterator is initialized; i.e. `m_object != nullptr`.
+ */
+ reference operator*() const
+ {
+ assert(m_object != nullptr);
+
+ switch (m_object->m_type)
+ {
+ case value_t::object:
+ {
+ assert(m_it.object_iterator != m_object->m_value.object->end());
+ return m_it.object_iterator->second;
+ }
+
+ case value_t::array:
+ {
+ assert(m_it.array_iterator != m_object->m_value.array->end());
+ return *m_it.array_iterator;
+ }
+
+ case value_t::null:
+ JSON_THROW(invalid_iterator::create(214, "cannot get value"));
+
+ default:
+ {
+ if (JSON_LIKELY(m_it.primitive_iterator.is_begin()))
+ {
+ return *m_object;
+ }
+
+ JSON_THROW(invalid_iterator::create(214, "cannot get value"));
+ }
+ }
+ }
+
+ /*!
+ @brief dereference the iterator
+ @pre The iterator is initialized; i.e. `m_object != nullptr`.
+ */
+ pointer operator->() const
+ {
+ assert(m_object != nullptr);
+
+ switch (m_object->m_type)
+ {
+ case value_t::object:
+ {
+ assert(m_it.object_iterator != m_object->m_value.object->end());
+ return &(m_it.object_iterator->second);
+ }
+
+ case value_t::array:
+ {
+ assert(m_it.array_iterator != m_object->m_value.array->end());
+ return &*m_it.array_iterator;
+ }
+
+ default:
+ {
+ if (JSON_LIKELY(m_it.primitive_iterator.is_begin()))
+ {
+ return m_object;
+ }
+
+ JSON_THROW(invalid_iterator::create(214, "cannot get value"));
+ }
+ }
+ }
+
+ /*!
+ @brief post-increment (it++)
+ @pre The iterator is initialized; i.e. `m_object != nullptr`.
+ */
+ iter_impl const operator++(int)
+ {
+ auto result = *this;
+ ++(*this);
+ return result;
+ }
+
+ /*!
+ @brief pre-increment (++it)
+ @pre The iterator is initialized; i.e. `m_object != nullptr`.
+ */
+ iter_impl& operator++()
+ {
+ assert(m_object != nullptr);
+
+ switch (m_object->m_type)
+ {
+ case value_t::object:
+ {
+ std::advance(m_it.object_iterator, 1);
+ break;
+ }
+
+ case value_t::array:
+ {
+ std::advance(m_it.array_iterator, 1);
+ break;
+ }
+
+ default:
+ {
+ ++m_it.primitive_iterator;
+ break;
+ }
+ }
+
+ return *this;
+ }
+
+ /*!
+ @brief post-decrement (it--)
+ @pre The iterator is initialized; i.e. `m_object != nullptr`.
+ */
+ iter_impl const operator--(int)
+ {
+ auto result = *this;
+ --(*this);
+ return result;
+ }
+
+ /*!
+ @brief pre-decrement (--it)
+ @pre The iterator is initialized; i.e. `m_object != nullptr`.
+ */
+ iter_impl& operator--()
+ {
+ assert(m_object != nullptr);
+
+ switch (m_object->m_type)
+ {
+ case value_t::object:
+ {
+ std::advance(m_it.object_iterator, -1);
+ break;
+ }
+
+ case value_t::array:
+ {
+ std::advance(m_it.array_iterator, -1);
+ break;
+ }
+
+ default:
+ {
+ --m_it.primitive_iterator;
+ break;
+ }
+ }
+
+ return *this;
+ }
+
+ /*!
+ @brief comparison: equal
+ @pre The iterator is initialized; i.e. `m_object != nullptr`.
+ */
+ bool operator==(const iter_impl& other) const
+ {
+ // if objects are not the same, the comparison is undefined
+ if (JSON_UNLIKELY(m_object != other.m_object))
+ {
+ JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers"));
+ }
+
+ assert(m_object != nullptr);
+
+ switch (m_object->m_type)
+ {
+ case value_t::object:
+ return (m_it.object_iterator == other.m_it.object_iterator);
+
+ case value_t::array:
+ return (m_it.array_iterator == other.m_it.array_iterator);
+
+ default:
+ return (m_it.primitive_iterator == other.m_it.primitive_iterator);
+ }
+ }
+
+ /*!
+ @brief comparison: not equal
+ @pre The iterator is initialized; i.e. `m_object != nullptr`.
+ */
+ bool operator!=(const iter_impl& other) const
+ {
+ return not operator==(other);
+ }
+
+ /*!
+ @brief comparison: smaller
+ @pre The iterator is initialized; i.e. `m_object != nullptr`.
+ */
+ bool operator<(const iter_impl& other) const
+ {
+ // if objects are not the same, the comparison is undefined
+ if (JSON_UNLIKELY(m_object != other.m_object))
+ {
+ JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers"));
+ }
+
+ assert(m_object != nullptr);
+
+ switch (m_object->m_type)
+ {
+ case value_t::object:
+ JSON_THROW(invalid_iterator::create(213, "cannot compare order of object iterators"));
+
+ case value_t::array:
+ return (m_it.array_iterator < other.m_it.array_iterator);
+
+ default:
+ return (m_it.primitive_iterator < other.m_it.primitive_iterator);
+ }
+ }
+
+ /*!
+ @brief comparison: less than or equal
+ @pre The iterator is initialized; i.e. `m_object != nullptr`.
+ */
+ bool operator<=(const iter_impl& other) const
+ {
+ return not other.operator < (*this);
+ }
+
+ /*!
+ @brief comparison: greater than
+ @pre The iterator is initialized; i.e. `m_object != nullptr`.
+ */
+ bool operator>(const iter_impl& other) const
+ {
+ return not operator<=(other);
+ }
+
+ /*!
+ @brief comparison: greater than or equal
+ @pre The iterator is initialized; i.e. `m_object != nullptr`.
+ */
+ bool operator>=(const iter_impl& other) const
+ {
+ return not operator<(other);
+ }
+
+ /*!
+ @brief add to iterator
+ @pre The iterator is initialized; i.e. `m_object != nullptr`.
+ */
+ iter_impl& operator+=(difference_type i)
+ {
+ assert(m_object != nullptr);
+
+ switch (m_object->m_type)
+ {
+ case value_t::object:
+ JSON_THROW(invalid_iterator::create(209, "cannot use offsets with object iterators"));
+
+ case value_t::array:
+ {
+ std::advance(m_it.array_iterator, i);
+ break;
+ }
+
+ default:
+ {
+ m_it.primitive_iterator += i;
+ break;
+ }
+ }
+
+ return *this;
+ }
+
+ /*!
+ @brief subtract from iterator
+ @pre The iterator is initialized; i.e. `m_object != nullptr`.
+ */
+ iter_impl& operator-=(difference_type i)
+ {
+ return operator+=(-i);
+ }
+
+ /*!
+ @brief add to iterator
+ @pre The iterator is initialized; i.e. `m_object != nullptr`.
+ */
+ iter_impl operator+(difference_type i) const
+ {
+ auto result = *this;
+ result += i;
+ return result;
+ }
+
+ /*!
+ @brief addition of distance and iterator
+ @pre The iterator is initialized; i.e. `m_object != nullptr`.
+ */
+ friend iter_impl operator+(difference_type i, const iter_impl& it)
+ {
+ auto result = it;
+ result += i;
+ return result;
+ }
+
+ /*!
+ @brief subtract from iterator
+ @pre The iterator is initialized; i.e. `m_object != nullptr`.
+ */
+ iter_impl operator-(difference_type i) const
+ {
+ auto result = *this;
+ result -= i;
+ return result;
+ }
+
+ /*!
+ @brief return difference
+ @pre The iterator is initialized; i.e. `m_object != nullptr`.
+ */
+ difference_type operator-(const iter_impl& other) const
+ {
+ assert(m_object != nullptr);
+
+ switch (m_object->m_type)
+ {
+ case value_t::object:
+ JSON_THROW(invalid_iterator::create(209, "cannot use offsets with object iterators"));
+
+ case value_t::array:
+ return m_it.array_iterator - other.m_it.array_iterator;
+
+ default:
+ return m_it.primitive_iterator - other.m_it.primitive_iterator;
+ }
+ }
+
+ /*!
+ @brief access to successor
+ @pre The iterator is initialized; i.e. `m_object != nullptr`.
+ */
+ reference operator[](difference_type n) const
+ {
+ assert(m_object != nullptr);
+
+ switch (m_object->m_type)
+ {
+ case value_t::object:
+ JSON_THROW(invalid_iterator::create(208, "cannot use operator[] for object iterators"));
+
+ case value_t::array:
+ return *std::next(m_it.array_iterator, n);
+
+ case value_t::null:
+ JSON_THROW(invalid_iterator::create(214, "cannot get value"));
+
+ default:
+ {
+ if (JSON_LIKELY(m_it.primitive_iterator.get_value() == -n))
+ {
+ return *m_object;
+ }
+
+ JSON_THROW(invalid_iterator::create(214, "cannot get value"));
+ }
+ }
+ }
+
+ /*!
+ @brief return the key of an object iterator
+ @pre The iterator is initialized; i.e. `m_object != nullptr`.
+ */
+ const typename object_t::key_type& key() const
+ {
+ assert(m_object != nullptr);
+
+ if (JSON_LIKELY(m_object->is_object()))
+ {
+ return m_it.object_iterator->first;
+ }
+
+ JSON_THROW(invalid_iterator::create(207, "cannot use key() for non-object iterators"));
+ }
+
+ /*!
+ @brief return the value of an iterator
+ @pre The iterator is initialized; i.e. `m_object != nullptr`.
+ */
+ reference value() const
+ {
+ return operator*();
+ }
+
+ private:
+ /// associated JSON instance
+ pointer m_object = nullptr;
+ /// the actual iterator of the associated instance
+ internal_iterator<typename std::remove_const<BasicJsonType>::type> m_it {};
+};
+} // namespace detail
+} // namespace nlohmann
+
+// #include <nlohmann/detail/iterators/iteration_proxy.hpp>
+
+// #include <nlohmann/detail/iterators/json_reverse_iterator.hpp>
+
+
+#include <cstddef> // ptrdiff_t
+#include <iterator> // reverse_iterator
+#include <utility> // declval
+
+namespace nlohmann
+{
+namespace detail
+{
+//////////////////////
+// reverse_iterator //
+//////////////////////
+
+/*!
+@brief a template for a reverse iterator class
+
+@tparam Base the base iterator type to reverse. Valid types are @ref
+iterator (to create @ref reverse_iterator) and @ref const_iterator (to
+create @ref const_reverse_iterator).
+
+@requirement The class satisfies the following concept requirements:
+-
+[BidirectionalIterator](https://en.cppreference.com/w/cpp/named_req/BidirectionalIterator):
+ The iterator that can be moved can be moved in both directions (i.e.
+ incremented and decremented).
+- [OutputIterator](https://en.cppreference.com/w/cpp/named_req/OutputIterator):
+ It is possible to write to the pointed-to element (only if @a Base is
+ @ref iterator).
+
+@since version 1.0.0
+*/
+template<typename Base>
+class json_reverse_iterator : public std::reverse_iterator<Base>
+{
+ public:
+ using difference_type = std::ptrdiff_t;
+ /// shortcut to the reverse iterator adapter
+ using base_iterator = std::reverse_iterator<Base>;
+ /// the reference type for the pointed-to element
+ using reference = typename Base::reference;
+
+ /// create reverse iterator from iterator
+ explicit json_reverse_iterator(const typename base_iterator::iterator_type& it) noexcept
+ : base_iterator(it) {}
+
+ /// create reverse iterator from base class
+ explicit json_reverse_iterator(const base_iterator& it) noexcept : base_iterator(it) {}
+
+ /// post-increment (it++)
+ json_reverse_iterator const operator++(int)
+ {
+ return static_cast<json_reverse_iterator>(base_iterator::operator++(1));
+ }
+
+ /// pre-increment (++it)
+ json_reverse_iterator& operator++()
+ {
+ return static_cast<json_reverse_iterator&>(base_iterator::operator++());
+ }
+
+ /// post-decrement (it--)
+ json_reverse_iterator const operator--(int)
+ {
+ return static_cast<json_reverse_iterator>(base_iterator::operator--(1));
+ }
+
+ /// pre-decrement (--it)
+ json_reverse_iterator& operator--()
+ {
+ return static_cast<json_reverse_iterator&>(base_iterator::operator--());
+ }
+
+ /// add to iterator
+ json_reverse_iterator& operator+=(difference_type i)
+ {
+ return static_cast<json_reverse_iterator&>(base_iterator::operator+=(i));
+ }
+
+ /// add to iterator
+ json_reverse_iterator operator+(difference_type i) const
+ {
+ return static_cast<json_reverse_iterator>(base_iterator::operator+(i));
+ }
+
+ /// subtract from iterator
+ json_reverse_iterator operator-(difference_type i) const
+ {
+ return static_cast<json_reverse_iterator>(base_iterator::operator-(i));
+ }
+
+ /// return difference
+ difference_type operator-(const json_reverse_iterator& other) const
+ {
+ return base_iterator(*this) - base_iterator(other);
+ }
+
+ /// access to successor
+ reference operator[](difference_type n) const
+ {
+ return *(this->operator+(n));
+ }
+
+ /// return the key of an object iterator
+ auto key() const -> decltype(std::declval<Base>().key())
+ {
+ auto it = --this->base();
+ return it.key();
+ }
+
+ /// return the value of an iterator
+ reference value() const
+ {
+ auto it = --this->base();
+ return it.operator * ();
+ }
+};
+} // namespace detail
+} // namespace nlohmann
+
+// #include <nlohmann/detail/iterators/primitive_iterator.hpp>
+
+// #include <nlohmann/detail/json_pointer.hpp>
+
+
+#include <algorithm> // all_of
+#include <cassert> // assert
+#include <numeric> // accumulate
+#include <string> // string
+#include <utility> // move
+#include <vector> // vector
+
+// #include <nlohmann/detail/exceptions.hpp>
+
+// #include <nlohmann/detail/macro_scope.hpp>
+
+// #include <nlohmann/detail/value_t.hpp>
+
+
+namespace nlohmann
+{
+template<typename BasicJsonType>
+class json_pointer
+{
+ // allow basic_json to access private members
+ NLOHMANN_BASIC_JSON_TPL_DECLARATION
+ friend class basic_json;
+
+ public:
+ /*!
+ @brief create JSON pointer
+
+ Create a JSON pointer according to the syntax described in
+ [Section 3 of RFC6901](https://tools.ietf.org/html/rfc6901#section-3).
+
+ @param[in] s string representing the JSON pointer; if omitted, the empty
+ string is assumed which references the whole JSON value
+
+ @throw parse_error.107 if the given JSON pointer @a s is nonempty and does
+ not begin with a slash (`/`); see example below
+
+ @throw parse_error.108 if a tilde (`~`) in the given JSON pointer @a s is
+ not followed by `0` (representing `~`) or `1` (representing `/`); see
+ example below
+
+ @liveexample{The example shows the construction several valid JSON pointers
+ as well as the exceptional behavior.,json_pointer}
+
+ @since version 2.0.0
+ */
+ explicit json_pointer(const std::string& s = "")
+ : reference_tokens(split(s))
+ {}
+
+ /*!
+ @brief return a string representation of the JSON pointer
+
+ @invariant For each JSON pointer `ptr`, it holds:
+ @code {.cpp}
+ ptr == json_pointer(ptr.to_string());
+ @endcode
+
+ @return a string representation of the JSON pointer
+
+ @liveexample{The example shows the result of `to_string`.,json_pointer__to_string}
+
+ @since version 2.0.0
+ */
+ std::string to_string() const
+ {
+ return std::accumulate(reference_tokens.begin(), reference_tokens.end(),
+ std::string{},
+ [](const std::string & a, const std::string & b)
+ {
+ return a + "/" + escape(b);
+ });
+ }
+
+ /// @copydoc to_string()
+ operator std::string() const
+ {
+ return to_string();
+ }
+
+ /*!
+ @brief append another JSON pointer at the end of this JSON pointer
+
+ @param[in] ptr JSON pointer to append
+ @return JSON pointer with @a ptr appended
+
+ @liveexample{The example shows the usage of `operator/=`.,json_pointer__operator_add}
+
+ @complexity Linear in the length of @a ptr.
+
+ @sa @ref operator/=(std::string) to append a reference token
+ @sa @ref operator/=(std::size_t) to append an array index
+ @sa @ref operator/(const json_pointer&, const json_pointer&) for a binary operator
+
+ @since version 3.6.0
+ */
+ json_pointer& operator/=(const json_pointer& ptr)
+ {
+ reference_tokens.insert(reference_tokens.end(),
+ ptr.reference_tokens.begin(),
+ ptr.reference_tokens.end());
+ return *this;
+ }
+
+ /*!
+ @brief append an unescaped reference token at the end of this JSON pointer
+
+ @param[in] token reference token to append
+ @return JSON pointer with @a token appended without escaping @a token
+
+ @liveexample{The example shows the usage of `operator/=`.,json_pointer__operator_add}
+
+ @complexity Amortized constant.
+
+ @sa @ref operator/=(const json_pointer&) to append a JSON pointer
+ @sa @ref operator/=(std::size_t) to append an array index
+ @sa @ref operator/(const json_pointer&, std::size_t) for a binary operator
+
+ @since version 3.6.0
+ */
+ json_pointer& operator/=(std::string token)
+ {
+ push_back(std::move(token));
+ return *this;
+ }
+
+ /*!
+ @brief append an array index at the end of this JSON pointer
+
+ @param[in] array_index array index ot append
+ @return JSON pointer with @a array_index appended
+
+ @liveexample{The example shows the usage of `operator/=`.,json_pointer__operator_add}
+
+ @complexity Amortized constant.
+
+ @sa @ref operator/=(const json_pointer&) to append a JSON pointer
+ @sa @ref operator/=(std::string) to append a reference token
+ @sa @ref operator/(const json_pointer&, std::string) for a binary operator
+
+ @since version 3.6.0
+ */
+ json_pointer& operator/=(std::size_t array_index)
+ {
+ return *this /= std::to_string(array_index);
+ }
+
+ /*!
+ @brief create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer
+
+ @param[in] lhs JSON pointer
+ @param[in] rhs JSON pointer
+ @return a new JSON pointer with @a rhs appended to @a lhs
+
+ @liveexample{The example shows the usage of `operator/`.,json_pointer__operator_add_binary}
+
+ @complexity Linear in the length of @a lhs and @a rhs.
+
+ @sa @ref operator/=(const json_pointer&) to append a JSON pointer
+
+ @since version 3.6.0
+ */
+ friend json_pointer operator/(const json_pointer& lhs,
+ const json_pointer& rhs)
+ {
+ return json_pointer(lhs) /= rhs;
+ }
+
+ /*!
+ @brief create a new JSON pointer by appending the unescaped token at the end of the JSON pointer
+
+ @param[in] ptr JSON pointer
+ @param[in] token reference token
+ @return a new JSON pointer with unescaped @a token appended to @a ptr
+
+ @liveexample{The example shows the usage of `operator/`.,json_pointer__operator_add_binary}
+
+ @complexity Linear in the length of @a ptr.
+
+ @sa @ref operator/=(std::string) to append a reference token
+
+ @since version 3.6.0
+ */
+ friend json_pointer operator/(const json_pointer& ptr, std::string token)
+ {
+ return json_pointer(ptr) /= std::move(token);
+ }
+
+ /*!
+ @brief create a new JSON pointer by appending the array-index-token at the end of the JSON pointer
+
+ @param[in] ptr JSON pointer
+ @param[in] array_index array index
+ @return a new JSON pointer with @a array_index appended to @a ptr
+
+ @liveexample{The example shows the usage of `operator/`.,json_pointer__operator_add_binary}
+
+ @complexity Linear in the length of @a ptr.
+
+ @sa @ref operator/=(std::size_t) to append an array index
+
+ @since version 3.6.0
+ */
+ friend json_pointer operator/(const json_pointer& ptr, std::size_t array_index)
+ {
+ return json_pointer(ptr) /= array_index;
+ }
+
+ /*!
+ @brief returns the parent of this JSON pointer
+
+ @return parent of this JSON pointer; in case this JSON pointer is the root,
+ the root itself is returned
+
+ @complexity Linear in the length of the JSON pointer.
+
+ @liveexample{The example shows the result of `parent_pointer` for different
+ JSON Pointers.,json_pointer__parent_pointer}
+
+ @since version 3.6.0
+ */
+ json_pointer parent_pointer() const
+ {
+ if (empty())
+ {
+ return *this;
+ }
+
+ json_pointer res = *this;
+ res.pop_back();
+ return res;
+ }
+
+ /*!
+ @brief remove last reference token
+
+ @pre not `empty()`
+
+ @liveexample{The example shows the usage of `pop_back`.,json_pointer__pop_back}
+
+ @complexity Constant.
+
+ @throw out_of_range.405 if JSON pointer has no parent
+
+ @since version 3.6.0
+ */
+ void pop_back()
+ {
+ if (JSON_UNLIKELY(empty()))
+ {
+ JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent"));
+ }
+
+ reference_tokens.pop_back();
+ }
+
+ /*!
+ @brief return last reference token
+
+ @pre not `empty()`
+ @return last reference token
+
+ @liveexample{The example shows the usage of `back`.,json_pointer__back}
+
+ @complexity Constant.
+
+ @throw out_of_range.405 if JSON pointer has no parent
+
+ @since version 3.6.0
+ */
+ const std::string& back()
+ {
+ if (JSON_UNLIKELY(empty()))
+ {
+ JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent"));
+ }
+
+ return reference_tokens.back();
+ }
+
+ /*!
+ @brief append an unescaped token at the end of the reference pointer
+
+ @param[in] token token to add
+
+ @complexity Amortized constant.
+
+ @liveexample{The example shows the result of `push_back` for different
+ JSON Pointers.,json_pointer__push_back}
+
+ @since version 3.6.0
+ */
+ void push_back(const std::string& token)
+ {
+ reference_tokens.push_back(token);
+ }
+
+ /// @copydoc push_back(const std::string&)
+ void push_back(std::string&& token)
+ {
+ reference_tokens.push_back(std::move(token));
+ }
+
+ /*!
+ @brief return whether pointer points to the root document
+
+ @return true iff the JSON pointer points to the root document
+
+ @complexity Constant.
+
+ @exceptionsafety No-throw guarantee: this function never throws exceptions.
+
+ @liveexample{The example shows the result of `empty` for different JSON
+ Pointers.,json_pointer__empty}
+
+ @since version 3.6.0
+ */
+ bool empty() const noexcept
+ {
+ return reference_tokens.empty();
+ }
+
+ private:
+ /*!
+ @param[in] s reference token to be converted into an array index
+
+ @return integer representation of @a s
+
+ @throw out_of_range.404 if string @a s could not be converted to an integer
+ */
+ static int array_index(const std::string& s)
+ {
+ std::size_t processed_chars = 0;
+ const int res = std::stoi(s, &processed_chars);
+
+ // check if the string was completely read
+ if (JSON_UNLIKELY(processed_chars != s.size()))
+ {
+ JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + s + "'"));
+ }
+
+ return res;
+ }
+
+ json_pointer top() const
+ {
+ if (JSON_UNLIKELY(empty()))
+ {
+ JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent"));
+ }
+
+ json_pointer result = *this;
+ result.reference_tokens = {reference_tokens[0]};
+ return result;
+ }
+
+ /*!
+ @brief create and return a reference to the pointed to value
+
+ @complexity Linear in the number of reference tokens.
+
+ @throw parse_error.109 if array index is not a number
+ @throw type_error.313 if value cannot be unflattened
+ */
+ BasicJsonType& get_and_create(BasicJsonType& j) const
+ {
+ using size_type = typename BasicJsonType::size_type;
+ auto result = &j;
+
+ // in case no reference tokens exist, return a reference to the JSON value
+ // j which will be overwritten by a primitive value
+ for (const auto& reference_token : reference_tokens)
+ {
+ switch (result->m_type)
+ {
+ case detail::value_t::null:
+ {
+ if (reference_token == "0")
+ {
+ // start a new array if reference token is 0
+ result = &result->operator[](0);
+ }
+ else
+ {
+ // start a new object otherwise
+ result = &result->operator[](reference_token);
+ }
+ break;
+ }
+
+ case detail::value_t::object:
+ {
+ // create an entry in the object
+ result = &result->operator[](reference_token);
+ break;
+ }
+
+ case detail::value_t::array:
+ {
+ // create an entry in the array
+ JSON_TRY
+ {
+ result = &result->operator[](static_cast<size_type>(array_index(reference_token)));
+ }
+ JSON_CATCH(std::invalid_argument&)
+ {
+ JSON_THROW(detail::parse_error::create(109, 0, "array index '" + reference_token + "' is not a number"));
+ }
+ break;
+ }
+
+ /*
+ The following code is only reached if there exists a reference
+ token _and_ the current value is primitive. In this case, we have
+ an error situation, because primitive values may only occur as
+ single value; that is, with an empty list of reference tokens.
+ */
+ default:
+ JSON_THROW(detail::type_error::create(313, "invalid value to unflatten"));
+ }
+ }
+
+ return *result;
+ }
+
+ /*!
+ @brief return a reference to the pointed to value
+
+ @note This version does not throw if a value is not present, but tries to
+ create nested values instead. For instance, calling this function
+ with pointer `"/this/that"` on a null value is equivalent to calling
+ `operator[]("this").operator[]("that")` on that value, effectively
+ changing the null value to an object.
+
+ @param[in] ptr a JSON value
+
+ @return reference to the JSON value pointed to by the JSON pointer
+
+ @complexity Linear in the length of the JSON pointer.
+
+ @throw parse_error.106 if an array index begins with '0'
+ @throw parse_error.109 if an array index was not a number
+ @throw out_of_range.404 if the JSON pointer can not be resolved
+ */
+ BasicJsonType& get_unchecked(BasicJsonType* ptr) const
+ {
+ using size_type = typename BasicJsonType::size_type;
+ for (const auto& reference_token : reference_tokens)
+ {
+ // convert null values to arrays or objects before continuing
+ if (ptr->m_type == detail::value_t::null)
+ {
+ // check if reference token is a number
+ const bool nums =
+ std::all_of(reference_token.begin(), reference_token.end(),
+ [](const char x)
+ {
+ return x >= '0' and x <= '9';
+ });
+
+ // change value to array for numbers or "-" or to object otherwise
+ *ptr = (nums or reference_token == "-")
+ ? detail::value_t::array
+ : detail::value_t::object;
+ }
+
+ switch (ptr->m_type)
+ {
+ case detail::value_t::object:
+ {
+ // use unchecked object access
+ ptr = &ptr->operator[](reference_token);
+ break;
+ }
+
+ case detail::value_t::array:
+ {
+ // error condition (cf. RFC 6901, Sect. 4)
+ if (JSON_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0'))
+ {
+ JSON_THROW(detail::parse_error::create(106, 0,
+ "array index '" + reference_token +
+ "' must not begin with '0'"));
+ }
+
+ if (reference_token == "-")
+ {
+ // explicitly treat "-" as index beyond the end
+ ptr = &ptr->operator[](ptr->m_value.array->size());
+ }
+ else
+ {
+ // convert array index to number; unchecked access
+ JSON_TRY
+ {
+ ptr = &ptr->operator[](
+ static_cast<size_type>(array_index(reference_token)));
+ }
+ JSON_CATCH(std::invalid_argument&)
+ {
+ JSON_THROW(detail::parse_error::create(109, 0, "array index '" + reference_token + "' is not a number"));
+ }
+ }
+ break;
+ }
+
+ default:
+ JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'"));
+ }
+ }
+
+ return *ptr;
+ }
+
+ /*!
+ @throw parse_error.106 if an array index begins with '0'
+ @throw parse_error.109 if an array index was not a number
+ @throw out_of_range.402 if the array index '-' is used
+ @throw out_of_range.404 if the JSON pointer can not be resolved
+ */
+ BasicJsonType& get_checked(BasicJsonType* ptr) const
+ {
+ using size_type = typename BasicJsonType::size_type;
+ for (const auto& reference_token : reference_tokens)
+ {
+ switch (ptr->m_type)
+ {
+ case detail::value_t::object:
+ {
+ // note: at performs range check
+ ptr = &ptr->at(reference_token);
+ break;
+ }
+
+ case detail::value_t::array:
+ {
+ if (JSON_UNLIKELY(reference_token == "-"))
+ {
+ // "-" always fails the range check
+ JSON_THROW(detail::out_of_range::create(402,
+ "array index '-' (" + std::to_string(ptr->m_value.array->size()) +
+ ") is out of range"));
+ }
+
+ // error condition (cf. RFC 6901, Sect. 4)
+ if (JSON_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0'))
+ {
+ JSON_THROW(detail::parse_error::create(106, 0,
+ "array index '" + reference_token +
+ "' must not begin with '0'"));
+ }
+
+ // note: at performs range check
+ JSON_TRY
+ {
+ ptr = &ptr->at(static_cast<size_type>(array_index(reference_token)));
+ }
+ JSON_CATCH(std::invalid_argument&)
+ {
+ JSON_THROW(detail::parse_error::create(109, 0, "array index '" + reference_token + "' is not a number"));
+ }
+ break;
+ }
+
+ default:
+ JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'"));
+ }
+ }
+
+ return *ptr;
+ }
+
+ /*!
+ @brief return a const reference to the pointed to value
+
+ @param[in] ptr a JSON value
+
+ @return const reference to the JSON value pointed to by the JSON
+ pointer
+
+ @throw parse_error.106 if an array index begins with '0'
+ @throw parse_error.109 if an array index was not a number
+ @throw out_of_range.402 if the array index '-' is used
+ @throw out_of_range.404 if the JSON pointer can not be resolved
+ */
+ const BasicJsonType& get_unchecked(const BasicJsonType* ptr) const
+ {
+ using size_type = typename BasicJsonType::size_type;
+ for (const auto& reference_token : reference_tokens)
+ {
+ switch (ptr->m_type)
+ {
+ case detail::value_t::object:
+ {
+ // use unchecked object access
+ ptr = &ptr->operator[](reference_token);
+ break;
+ }
+
+ case detail::value_t::array:
+ {
+ if (JSON_UNLIKELY(reference_token == "-"))
+ {
+ // "-" cannot be used for const access
+ JSON_THROW(detail::out_of_range::create(402,
+ "array index '-' (" + std::to_string(ptr->m_value.array->size()) +
+ ") is out of range"));
+ }
+
+ // error condition (cf. RFC 6901, Sect. 4)
+ if (JSON_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0'))
+ {
+ JSON_THROW(detail::parse_error::create(106, 0,
+ "array index '" + reference_token +
+ "' must not begin with '0'"));
+ }
+
+ // use unchecked array access
+ JSON_TRY
+ {
+ ptr = &ptr->operator[](
+ static_cast<size_type>(array_index(reference_token)));
+ }
+ JSON_CATCH(std::invalid_argument&)
+ {
+ JSON_THROW(detail::parse_error::create(109, 0, "array index '" + reference_token + "' is not a number"));
+ }
+ break;
+ }
+
+ default:
+ JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'"));
+ }
+ }
+
+ return *ptr;
+ }
+
+ /*!
+ @throw parse_error.106 if an array index begins with '0'
+ @throw parse_error.109 if an array index was not a number
+ @throw out_of_range.402 if the array index '-' is used
+ @throw out_of_range.404 if the JSON pointer can not be resolved
+ */
+ const BasicJsonType& get_checked(const BasicJsonType* ptr) const
+ {
+ using size_type = typename BasicJsonType::size_type;
+ for (const auto& reference_token : reference_tokens)
+ {
+ switch (ptr->m_type)
+ {
+ case detail::value_t::object:
+ {
+ // note: at performs range check
+ ptr = &ptr->at(reference_token);
+ break;
+ }
+
+ case detail::value_t::array:
+ {
+ if (JSON_UNLIKELY(reference_token == "-"))
+ {
+ // "-" always fails the range check
+ JSON_THROW(detail::out_of_range::create(402,
+ "array index '-' (" + std::to_string(ptr->m_value.array->size()) +
+ ") is out of range"));
+ }
+
+ // error condition (cf. RFC 6901, Sect. 4)
+ if (JSON_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0'))
+ {
+ JSON_THROW(detail::parse_error::create(106, 0,
+ "array index '" + reference_token +
+ "' must not begin with '0'"));
+ }
+
+ // note: at performs range check
+ JSON_TRY
+ {
+ ptr = &ptr->at(static_cast<size_type>(array_index(reference_token)));
+ }
+ JSON_CATCH(std::invalid_argument&)
+ {
+ JSON_THROW(detail::parse_error::create(109, 0, "array index '" + reference_token + "' is not a number"));
+ }
+ break;
+ }
+
+ default:
+ JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'"));
+ }
+ }
+
+ return *ptr;
+ }
+
+ /*!
+ @brief split the string input to reference tokens
+
+ @note This function is only called by the json_pointer constructor.
+ All exceptions below are documented there.
+
+ @throw parse_error.107 if the pointer is not empty or begins with '/'
+ @throw parse_error.108 if character '~' is not followed by '0' or '1'
+ */
+ static std::vector<std::string> split(const std::string& reference_string)
+ {
+ std::vector<std::string> result;
+
+ // special case: empty reference string -> no reference tokens
+ if (reference_string.empty())
+ {
+ return result;
+ }
+
+ // check if nonempty reference string begins with slash
+ if (JSON_UNLIKELY(reference_string[0] != '/'))
+ {
+ JSON_THROW(detail::parse_error::create(107, 1,
+ "JSON pointer must be empty or begin with '/' - was: '" +
+ reference_string + "'"));
+ }
+
+ // extract the reference tokens:
+ // - slash: position of the last read slash (or end of string)
+ // - start: position after the previous slash
+ for (
+ // search for the first slash after the first character
+ std::size_t slash = reference_string.find_first_of('/', 1),
+ // set the beginning of the first reference token
+ start = 1;
+ // we can stop if start == 0 (if slash == std::string::npos)
+ start != 0;
+ // set the beginning of the next reference token
+ // (will eventually be 0 if slash == std::string::npos)
+ start = (slash == std::string::npos) ? 0 : slash + 1,
+ // find next slash
+ slash = reference_string.find_first_of('/', start))
+ {
+ // use the text between the beginning of the reference token
+ // (start) and the last slash (slash).
+ auto reference_token = reference_string.substr(start, slash - start);
+
+ // check reference tokens are properly escaped
+ for (std::size_t pos = reference_token.find_first_of('~');
+ pos != std::string::npos;
+ pos = reference_token.find_first_of('~', pos + 1))
+ {
+ assert(reference_token[pos] == '~');
+
+ // ~ must be followed by 0 or 1
+ if (JSON_UNLIKELY(pos == reference_token.size() - 1 or
+ (reference_token[pos + 1] != '0' and
+ reference_token[pos + 1] != '1')))
+ {
+ JSON_THROW(detail::parse_error::create(108, 0, "escape character '~' must be followed with '0' or '1'"));
+ }
+ }
+
+ // finally, store the reference token
+ unescape(reference_token);
+ result.push_back(reference_token);
+ }
+
+ return result;
+ }
+
+ /*!
+ @brief replace all occurrences of a substring by another string
+
+ @param[in,out] s the string to manipulate; changed so that all
+ occurrences of @a f are replaced with @a t
+ @param[in] f the substring to replace with @a t
+ @param[in] t the string to replace @a f
+
+ @pre The search string @a f must not be empty. **This precondition is
+ enforced with an assertion.**
+
+ @since version 2.0.0
+ */
+ static void replace_substring(std::string& s, const std::string& f,
+ const std::string& t)
+ {
+ assert(not f.empty());
+ for (auto pos = s.find(f); // find first occurrence of f
+ pos != std::string::npos; // make sure f was found
+ s.replace(pos, f.size(), t), // replace with t, and
+ pos = s.find(f, pos + t.size())) // find next occurrence of f
+ {}
+ }
+
+ /// escape "~" to "~0" and "/" to "~1"
+ static std::string escape(std::string s)
+ {
+ replace_substring(s, "~", "~0");
+ replace_substring(s, "/", "~1");
+ return s;
+ }
+
+ /// unescape "~1" to tilde and "~0" to slash (order is important!)
+ static void unescape(std::string& s)
+ {
+ replace_substring(s, "~1", "/");
+ replace_substring(s, "~0", "~");
+ }
+
+ /*!
+ @param[in] reference_string the reference string to the current value
+ @param[in] value the value to consider
+ @param[in,out] result the result object to insert values to
+
+ @note Empty objects or arrays are flattened to `null`.
+ */
+ static void flatten(const std::string& reference_string,
+ const BasicJsonType& value,
+ BasicJsonType& result)
+ {
+ switch (value.m_type)
+ {
+ case detail::value_t::array:
+ {
+ if (value.m_value.array->empty())
+ {
+ // flatten empty array as null
+ result[reference_string] = nullptr;
+ }
+ else
+ {
+ // iterate array and use index as reference string
+ for (std::size_t i = 0; i < value.m_value.array->size(); ++i)
+ {
+ flatten(reference_string + "/" + std::to_string(i),
+ value.m_value.array->operator[](i), result);
+ }
+ }
+ break;
+ }
+
+ case detail::value_t::object:
+ {
+ if (value.m_value.object->empty())
+ {
+ // flatten empty object as null
+ result[reference_string] = nullptr;
+ }
+ else
+ {
+ // iterate object and use keys as reference string
+ for (const auto& element : *value.m_value.object)
+ {
+ flatten(reference_string + "/" + escape(element.first), element.second, result);
+ }
+ }
+ break;
+ }
+
+ default:
+ {
+ // add primitive value with its reference string
+ result[reference_string] = value;
+ break;
+ }
+ }
+ }
+
+ /*!
+ @param[in] value flattened JSON
+
+ @return unflattened JSON
+
+ @throw parse_error.109 if array index is not a number
+ @throw type_error.314 if value is not an object
+ @throw type_error.315 if object values are not primitive
+ @throw type_error.313 if value cannot be unflattened
+ */
+ static BasicJsonType
+ unflatten(const BasicJsonType& value)
+ {
+ if (JSON_UNLIKELY(not value.is_object()))
+ {
+ JSON_THROW(detail::type_error::create(314, "only objects can be unflattened"));
+ }
+
+ BasicJsonType result;
+
+ // iterate the JSON object values
+ for (const auto& element : *value.m_value.object)
+ {
+ if (JSON_UNLIKELY(not element.second.is_primitive()))
+ {
+ JSON_THROW(detail::type_error::create(315, "values in object must be primitive"));
+ }
+
+ // assign value to reference pointed to by JSON pointer; Note that if
+ // the JSON pointer is "" (i.e., points to the whole value), function
+ // get_and_create returns a reference to result itself. An assignment
+ // will then create a primitive value.
+ json_pointer(element.first).get_and_create(result) = element.second;
+ }
+
+ return result;
+ }
+
+ /*!
+ @brief compares two JSON pointers for equality
+
+ @param[in] lhs JSON pointer to compare
+ @param[in] rhs JSON pointer to compare
+ @return whether @a lhs is equal to @a rhs
+
+ @complexity Linear in the length of the JSON pointer
+
+ @exceptionsafety No-throw guarantee: this function never throws exceptions.
+ */
+ friend bool operator==(json_pointer const& lhs,
+ json_pointer const& rhs) noexcept
+ {
+ return lhs.reference_tokens == rhs.reference_tokens;
+ }
+
+ /*!
+ @brief compares two JSON pointers for inequality
+
+ @param[in] lhs JSON pointer to compare
+ @param[in] rhs JSON pointer to compare
+ @return whether @a lhs is not equal @a rhs
+
+ @complexity Linear in the length of the JSON pointer
+
+ @exceptionsafety No-throw guarantee: this function never throws exceptions.
+ */
+ friend bool operator!=(json_pointer const& lhs,
+ json_pointer const& rhs) noexcept
+ {
+ return not (lhs == rhs);
+ }
+
+ /// the reference tokens
+ std::vector<std::string> reference_tokens;
+};
+} // namespace nlohmann
+
+// #include <nlohmann/detail/json_ref.hpp>
+
+
+#include <initializer_list>
+#include <utility>
+
+// #include <nlohmann/detail/meta/type_traits.hpp>
+
+
+namespace nlohmann
+{
+namespace detail
+{
+template<typename BasicJsonType>
+class json_ref
+{
+ public:
+ using value_type = BasicJsonType;
+
+ json_ref(value_type&& value)
+ : owned_value(std::move(value)), value_ref(&owned_value), is_rvalue(true)
+ {}
+
+ json_ref(const value_type& value)
+ : value_ref(const_cast<value_type*>(&value)), is_rvalue(false)
+ {}
+
+ json_ref(std::initializer_list<json_ref> init)
+ : owned_value(init), value_ref(&owned_value), is_rvalue(true)
+ {}
+
+ template <
+ class... Args,
+ enable_if_t<std::is_constructible<value_type, Args...>::value, int> = 0 >
+ json_ref(Args && ... args)
+ : owned_value(std::forward<Args>(args)...), value_ref(&owned_value),
+ is_rvalue(true) {}
+
+ // class should be movable only
+ json_ref(json_ref&&) = default;
+ json_ref(const json_ref&) = delete;
+ json_ref& operator=(const json_ref&) = delete;
+ json_ref& operator=(json_ref&&) = delete;
+ ~json_ref() = default;
+
+ value_type moved_or_copied() const
+ {
+ if (is_rvalue)
+ {
+ return std::move(*value_ref);
+ }
+ return *value_ref;
+ }
+
+ value_type const& operator*() const
+ {
+ return *static_cast<value_type const*>(value_ref);
+ }
+
+ value_type const* operator->() const
+ {
+ return static_cast<value_type const*>(value_ref);
+ }
+
+ private:
+ mutable value_type owned_value = nullptr;
+ value_type* value_ref = nullptr;
+ const bool is_rvalue;
+};
+} // namespace detail
+} // namespace nlohmann
+
+// #include <nlohmann/detail/macro_scope.hpp>
+
+// #include <nlohmann/detail/meta/cpp_future.hpp>
+
+// #include <nlohmann/detail/meta/type_traits.hpp>
+
+// #include <nlohmann/detail/output/binary_writer.hpp>
+
+
+#include <algorithm> // reverse
+#include <array> // array
+#include <cstdint> // uint8_t, uint16_t, uint32_t, uint64_t
+#include <cstring> // memcpy
+#include <limits> // numeric_limits
+#include <string> // string
+
+// #include <nlohmann/detail/input/binary_reader.hpp>
+
+// #include <nlohmann/detail/output/output_adapters.hpp>
+
+
+#include <algorithm> // copy
+#include <cstddef> // size_t
+#include <ios> // streamsize
+#include <iterator> // back_inserter
+#include <memory> // shared_ptr, make_shared
+#include <ostream> // basic_ostream
+#include <string> // basic_string
+#include <vector> // vector
+
+namespace nlohmann
+{
+namespace detail
+{
+/// abstract output adapter interface
+template<typename CharType> struct output_adapter_protocol
+{
+ virtual void write_character(CharType c) = 0;
+ virtual void write_characters(const CharType* s, std::size_t length) = 0;
+ virtual ~output_adapter_protocol() = default;
+};
+
+/// a type to simplify interfaces
+template<typename CharType>
+using output_adapter_t = std::shared_ptr<output_adapter_protocol<CharType>>;
+
+/// output adapter for byte vectors
+template<typename CharType>
+class output_vector_adapter : public output_adapter_protocol<CharType>
+{
+ public:
+ explicit output_vector_adapter(std::vector<CharType>& vec) noexcept
+ : v(vec)
+ {}
+
+ void write_character(CharType c) override
+ {
+ v.push_back(c);
+ }
+
+ void write_characters(const CharType* s, std::size_t length) override
+ {
+ std::copy(s, s + length, std::back_inserter(v));
+ }
+
+ private:
+ std::vector<CharType>& v;
+};
+
+/// output adapter for output streams
+template<typename CharType>
+class output_stream_adapter : public output_adapter_protocol<CharType>
+{
+ public:
+ explicit output_stream_adapter(std::basic_ostream<CharType>& s) noexcept
+ : stream(s)
+ {}
+
+ void write_character(CharType c) override
+ {
+ stream.put(c);
+ }
+
+ void write_characters(const CharType* s, std::size_t length) override
+ {
+ stream.write(s, static_cast<std::streamsize>(length));
+ }
+
+ private:
+ std::basic_ostream<CharType>& stream;
+};
+
+/// output adapter for basic_string
+template<typename CharType, typename StringType = std::basic_string<CharType>>
+class output_string_adapter : public output_adapter_protocol<CharType>
+{
+ public:
+ explicit output_string_adapter(StringType& s) noexcept
+ : str(s)
+ {}
+
+ void write_character(CharType c) override
+ {
+ str.push_back(c);
+ }
+
+ void write_characters(const CharType* s, std::size_t length) override
+ {
+ str.append(s, length);
+ }
+
+ private:
+ StringType& str;
+};
+
+template<typename CharType, typename StringType = std::basic_string<CharType>>
+class output_adapter
+{
+ public:
+ output_adapter(std::vector<CharType>& vec)
+ : oa(std::make_shared<output_vector_adapter<CharType>>(vec)) {}
+
+ output_adapter(std::basic_ostream<CharType>& s)
+ : oa(std::make_shared<output_stream_adapter<CharType>>(s)) {}
+
+ output_adapter(StringType& s)
+ : oa(std::make_shared<output_string_adapter<CharType, StringType>>(s)) {}
+
+ operator output_adapter_t<CharType>()
+ {
+ return oa;
+ }
+
+ private:
+ output_adapter_t<CharType> oa = nullptr;
+};
+} // namespace detail
+} // namespace nlohmann
+
+
+namespace nlohmann
+{
+namespace detail
+{
+///////////////////
+// binary writer //
+///////////////////
+
+/*!
+@brief serialization to CBOR and MessagePack values
+*/
+template<typename BasicJsonType, typename CharType>
+class binary_writer
+{
+ using string_t = typename BasicJsonType::string_t;
+
+ public:
+ /*!
+ @brief create a binary writer
+
+ @param[in] adapter output adapter to write to
+ */
+ explicit binary_writer(output_adapter_t<CharType> adapter) : oa(adapter)
+ {
+ assert(oa);
+ }
+
+ /*!
+ @param[in] j JSON value to serialize
+ @pre j.type() == value_t::object
+ */
+ void write_bson(const BasicJsonType& j)
+ {
+ switch (j.type())
+ {
+ case value_t::object:
+ {
+ write_bson_object(*j.m_value.object);
+ break;
+ }
+
+ default:
+ {
+ JSON_THROW(type_error::create(317, "to serialize to BSON, top-level type must be object, but is " + std::string(j.type_name())));
+ }
+ }
+ }
+
+ /*!
+ @param[in] j JSON value to serialize
+ */
+ void write_cbor(const BasicJsonType& j)
+ {
+ switch (j.type())
+ {
+ case value_t::null:
+ {
+ oa->write_character(to_char_type(0xF6));
+ break;
+ }
+
+ case value_t::boolean:
+ {
+ oa->write_character(j.m_value.boolean
+ ? to_char_type(0xF5)
+ : to_char_type(0xF4));
+ break;
+ }
+
+ case value_t::number_integer:
+ {
+ if (j.m_value.number_integer >= 0)
+ {
+ // CBOR does not differentiate between positive signed
+ // integers and unsigned integers. Therefore, we used the
+ // code from the value_t::number_unsigned case here.
+ if (j.m_value.number_integer <= 0x17)
+ {
+ write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
+ }
+ else if (j.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
+ {
+ oa->write_character(to_char_type(0x18));
+ write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
+ }
+ else if (j.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)())
+ {
+ oa->write_character(to_char_type(0x19));
+ write_number(static_cast<std::uint16_t>(j.m_value.number_integer));
+ }
+ else if (j.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)())
+ {
+ oa->write_character(to_char_type(0x1A));
+ write_number(static_cast<std::uint32_t>(j.m_value.number_integer));
+ }
+ else
+ {
+ oa->write_character(to_char_type(0x1B));
+ write_number(static_cast<std::uint64_t>(j.m_value.number_integer));
+ }
+ }
+ else
+ {
+ // The conversions below encode the sign in the first
+ // byte, and the value is converted to a positive number.
+ const auto positive_number = -1 - j.m_value.number_integer;
+ if (j.m_value.number_integer >= -24)
+ {
+ write_number(static_cast<std::uint8_t>(0x20 + positive_number));
+ }
+ else if (positive_number <= (std::numeric_limits<std::uint8_t>::max)())
+ {
+ oa->write_character(to_char_type(0x38));
+ write_number(static_cast<std::uint8_t>(positive_number));
+ }
+ else if (positive_number <= (std::numeric_limits<std::uint16_t>::max)())
+ {
+ oa->write_character(to_char_type(0x39));
+ write_number(static_cast<std::uint16_t>(positive_number));
+ }
+ else if (positive_number <= (std::numeric_limits<std::uint32_t>::max)())
+ {
+ oa->write_character(to_char_type(0x3A));
+ write_number(static_cast<std::uint32_t>(positive_number));
+ }
+ else
+ {
+ oa->write_character(to_char_type(0x3B));
+ write_number(static_cast<std::uint64_t>(positive_number));
+ }
+ }
+ break;
+ }
+
+ case value_t::number_unsigned:
+ {
+ if (j.m_value.number_unsigned <= 0x17)
+ {
+ write_number(static_cast<std::uint8_t>(j.m_value.number_unsigned));
+ }
+ else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
+ {
+ oa->write_character(to_char_type(0x18));
+ write_number(static_cast<std::uint8_t>(j.m_value.number_unsigned));
+ }
+ else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
+ {
+ oa->write_character(to_char_type(0x19));
+ write_number(static_cast<std::uint16_t>(j.m_value.number_unsigned));
+ }
+ else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
+ {
+ oa->write_character(to_char_type(0x1A));
+ write_number(static_cast<std::uint32_t>(j.m_value.number_unsigned));
+ }
+ else
+ {
+ oa->write_character(to_char_type(0x1B));
+ write_number(static_cast<std::uint64_t>(j.m_value.number_unsigned));
+ }
+ break;
+ }
+
+ case value_t::number_float:
+ {
+ oa->write_character(get_cbor_float_prefix(j.m_value.number_float));
+ write_number(j.m_value.number_float);
+ break;
+ }
+
+ case value_t::string:
+ {
+ // step 1: write control byte and the string length
+ const auto N = j.m_value.string->size();
+ if (N <= 0x17)
+ {
+ write_number(static_cast<std::uint8_t>(0x60 + N));
+ }
+ else if (N <= (std::numeric_limits<std::uint8_t>::max)())
+ {
+ oa->write_character(to_char_type(0x78));
+ write_number(static_cast<std::uint8_t>(N));
+ }
+ else if (N <= (std::numeric_limits<std::uint16_t>::max)())
+ {
+ oa->write_character(to_char_type(0x79));
+ write_number(static_cast<std::uint16_t>(N));
+ }
+ else if (N <= (std::numeric_limits<std::uint32_t>::max)())
+ {
+ oa->write_character(to_char_type(0x7A));
+ write_number(static_cast<std::uint32_t>(N));
+ }
+ // LCOV_EXCL_START
+ else if (N <= (std::numeric_limits<std::uint64_t>::max)())
+ {
+ oa->write_character(to_char_type(0x7B));
+ write_number(static_cast<std::uint64_t>(N));
+ }
+ // LCOV_EXCL_STOP
+
+ // step 2: write the string
+ oa->write_characters(
+ reinterpret_cast<const CharType*>(j.m_value.string->c_str()),
+ j.m_value.string->size());
+ break;
+ }
+
+ case value_t::array:
+ {
+ // step 1: write control byte and the array size
+ const auto N = j.m_value.array->size();
+ if (N <= 0x17)
+ {
+ write_number(static_cast<std::uint8_t>(0x80 + N));
+ }
+ else if (N <= (std::numeric_limits<std::uint8_t>::max)())
+ {
+ oa->write_character(to_char_type(0x98));
+ write_number(static_cast<std::uint8_t>(N));
+ }
+ else if (N <= (std::numeric_limits<std::uint16_t>::max)())
+ {
+ oa->write_character(to_char_type(0x99));
+ write_number(static_cast<std::uint16_t>(N));
+ }
+ else if (N <= (std::numeric_limits<std::uint32_t>::max)())
+ {
+ oa->write_character(to_char_type(0x9A));
+ write_number(static_cast<std::uint32_t>(N));
+ }
+ // LCOV_EXCL_START
+ else if (N <= (std::numeric_limits<std::uint64_t>::max)())
+ {
+ oa->write_character(to_char_type(0x9B));
+ write_number(static_cast<std::uint64_t>(N));
+ }
+ // LCOV_EXCL_STOP
+
+ // step 2: write each element
+ for (const auto& el : *j.m_value.array)
+ {
+ write_cbor(el);
+ }
+ break;
+ }
+
+ case value_t::object:
+ {
+ // step 1: write control byte and the object size
+ const auto N = j.m_value.object->size();
+ if (N <= 0x17)
+ {
+ write_number(static_cast<std::uint8_t>(0xA0 + N));
+ }
+ else if (N <= (std::numeric_limits<std::uint8_t>::max)())
+ {
+ oa->write_character(to_char_type(0xB8));
+ write_number(static_cast<std::uint8_t>(N));
+ }
+ else if (N <= (std::numeric_limits<std::uint16_t>::max)())
+ {
+ oa->write_character(to_char_type(0xB9));
+ write_number(static_cast<std::uint16_t>(N));
+ }
+ else if (N <= (std::numeric_limits<std::uint32_t>::max)())
+ {
+ oa->write_character(to_char_type(0xBA));
+ write_number(static_cast<std::uint32_t>(N));
+ }
+ // LCOV_EXCL_START
+ else if (N <= (std::numeric_limits<std::uint64_t>::max)())
+ {
+ oa->write_character(to_char_type(0xBB));
+ write_number(static_cast<std::uint64_t>(N));
+ }
+ // LCOV_EXCL_STOP
+
+ // step 2: write each element
+ for (const auto& el : *j.m_value.object)
+ {
+ write_cbor(el.first);
+ write_cbor(el.second);
+ }
+ break;
+ }
+
+ default:
+ break;
+ }
+ }
+
+ /*!
+ @param[in] j JSON value to serialize
+ */
+ void write_msgpack(const BasicJsonType& j)
+ {
+ switch (j.type())
+ {
+ case value_t::null: // nil
+ {
+ oa->write_character(to_char_type(0xC0));
+ break;
+ }
+
+ case value_t::boolean: // true and false
+ {
+ oa->write_character(j.m_value.boolean
+ ? to_char_type(0xC3)
+ : to_char_type(0xC2));
+ break;
+ }
+
+ case value_t::number_integer:
+ {
+ if (j.m_value.number_integer >= 0)
+ {
+ // MessagePack does not differentiate between positive
+ // signed integers and unsigned integers. Therefore, we used
+ // the code from the value_t::number_unsigned case here.
+ if (j.m_value.number_unsigned < 128)
+ {
+ // positive fixnum
+ write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
+ }
+ else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
+ {
+ // uint 8
+ oa->write_character(to_char_type(0xCC));
+ write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
+ }
+ else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
+ {
+ // uint 16
+ oa->write_character(to_char_type(0xCD));
+ write_number(static_cast<std::uint16_t>(j.m_value.number_integer));
+ }
+ else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
+ {
+ // uint 32
+ oa->write_character(to_char_type(0xCE));
+ write_number(static_cast<std::uint32_t>(j.m_value.number_integer));
+ }
+ else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
+ {
+ // uint 64
+ oa->write_character(to_char_type(0xCF));
+ write_number(static_cast<std::uint64_t>(j.m_value.number_integer));
+ }
+ }
+ else
+ {
+ if (j.m_value.number_integer >= -32)
+ {
+ // negative fixnum
+ write_number(static_cast<std::int8_t>(j.m_value.number_integer));
+ }
+ else if (j.m_value.number_integer >= (std::numeric_limits<std::int8_t>::min)() and
+ j.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
+ {
+ // int 8
+ oa->write_character(to_char_type(0xD0));
+ write_number(static_cast<std::int8_t>(j.m_value.number_integer));
+ }
+ else if (j.m_value.number_integer >= (std::numeric_limits<std::int16_t>::min)() and
+ j.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
+ {
+ // int 16
+ oa->write_character(to_char_type(0xD1));
+ write_number(static_cast<std::int16_t>(j.m_value.number_integer));
+ }
+ else if (j.m_value.number_integer >= (std::numeric_limits<std::int32_t>::min)() and
+ j.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
+ {
+ // int 32
+ oa->write_character(to_char_type(0xD2));
+ write_number(static_cast<std::int32_t>(j.m_value.number_integer));
+ }
+ else if (j.m_value.number_integer >= (std::numeric_limits<std::int64_t>::min)() and
+ j.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
+ {
+ // int 64
+ oa->write_character(to_char_type(0xD3));
+ write_number(static_cast<std::int64_t>(j.m_value.number_integer));
+ }
+ }
+ break;
+ }
+
+ case value_t::number_unsigned:
+ {
+ if (j.m_value.number_unsigned < 128)
+ {
+ // positive fixnum
+ write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
+ }
+ else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
+ {
+ // uint 8
+ oa->write_character(to_char_type(0xCC));
+ write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
+ }
+ else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
+ {
+ // uint 16
+ oa->write_character(to_char_type(0xCD));
+ write_number(static_cast<std::uint16_t>(j.m_value.number_integer));
+ }
+ else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
+ {
+ // uint 32
+ oa->write_character(to_char_type(0xCE));
+ write_number(static_cast<std::uint32_t>(j.m_value.number_integer));
+ }
+ else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
+ {
+ // uint 64
+ oa->write_character(to_char_type(0xCF));
+ write_number(static_cast<std::uint64_t>(j.m_value.number_integer));
+ }
+ break;
+ }
+
+ case value_t::number_float:
+ {
+ oa->write_character(get_msgpack_float_prefix(j.m_value.number_float));
+ write_number(j.m_value.number_float);
+ break;
+ }
+
+ case value_t::string:
+ {
+ // step 1: write control byte and the string length
+ const auto N = j.m_value.string->size();
+ if (N <= 31)
+ {
+ // fixstr
+ write_number(static_cast<std::uint8_t>(0xA0 | N));
+ }
+ else if (N <= (std::numeric_limits<std::uint8_t>::max)())
+ {
+ // str 8
+ oa->write_character(to_char_type(0xD9));
+ write_number(static_cast<std::uint8_t>(N));
+ }
+ else if (N <= (std::numeric_limits<std::uint16_t>::max)())
+ {
+ // str 16
+ oa->write_character(to_char_type(0xDA));
+ write_number(static_cast<std::uint16_t>(N));
+ }
+ else if (N <= (std::numeric_limits<std::uint32_t>::max)())
+ {
+ // str 32
+ oa->write_character(to_char_type(0xDB));
+ write_number(static_cast<std::uint32_t>(N));
+ }
+
+ // step 2: write the string
+ oa->write_characters(
+ reinterpret_cast<const CharType*>(j.m_value.string->c_str()),
+ j.m_value.string->size());
+ break;
+ }
+
+ case value_t::array:
+ {
+ // step 1: write control byte and the array size
+ const auto N = j.m_value.array->size();
+ if (N <= 15)
+ {
+ // fixarray
+ write_number(static_cast<std::uint8_t>(0x90 | N));
+ }
+ else if (N <= (std::numeric_limits<std::uint16_t>::max)())
+ {
+ // array 16
+ oa->write_character(to_char_type(0xDC));
+ write_number(static_cast<std::uint16_t>(N));
+ }
+ else if (N <= (std::numeric_limits<std::uint32_t>::max)())
+ {
+ // array 32
+ oa->write_character(to_char_type(0xDD));
+ write_number(static_cast<std::uint32_t>(N));
+ }
+
+ // step 2: write each element
+ for (const auto& el : *j.m_value.array)
+ {
+ write_msgpack(el);
+ }
+ break;
+ }
+
+ case value_t::object:
+ {
+ // step 1: write control byte and the object size
+ const auto N = j.m_value.object->size();
+ if (N <= 15)
+ {
+ // fixmap
+ write_number(static_cast<std::uint8_t>(0x80 | (N & 0xF)));
+ }
+ else if (N <= (std::numeric_limits<std::uint16_t>::max)())
+ {
+ // map 16
+ oa->write_character(to_char_type(0xDE));
+ write_number(static_cast<std::uint16_t>(N));
+ }
+ else if (N <= (std::numeric_limits<std::uint32_t>::max)())
+ {
+ // map 32
+ oa->write_character(to_char_type(0xDF));
+ write_number(static_cast<std::uint32_t>(N));
+ }
+
+ // step 2: write each element
+ for (const auto& el : *j.m_value.object)
+ {
+ write_msgpack(el.first);
+ write_msgpack(el.second);
+ }
+ break;
+ }
+
+ default:
+ break;
+ }
+ }
+
+ /*!
+ @param[in] j JSON value to serialize
+ @param[in] use_count whether to use '#' prefixes (optimized format)
+ @param[in] use_type whether to use '$' prefixes (optimized format)
+ @param[in] add_prefix whether prefixes need to be used for this value
+ */
+ void write_ubjson(const BasicJsonType& j, const bool use_count,
+ const bool use_type, const bool add_prefix = true)
+ {
+ switch (j.type())
+ {
+ case value_t::null:
+ {
+ if (add_prefix)
+ {
+ oa->write_character(to_char_type('Z'));
+ }
+ break;
+ }
+
+ case value_t::boolean:
+ {
+ if (add_prefix)
+ {
+ oa->write_character(j.m_value.boolean
+ ? to_char_type('T')
+ : to_char_type('F'));
+ }
+ break;
+ }
+
+ case value_t::number_integer:
+ {
+ write_number_with_ubjson_prefix(j.m_value.number_integer, add_prefix);
+ break;
+ }
+
+ case value_t::number_unsigned:
+ {
+ write_number_with_ubjson_prefix(j.m_value.number_unsigned, add_prefix);
+ break;
+ }
+
+ case value_t::number_float:
+ {
+ write_number_with_ubjson_prefix(j.m_value.number_float, add_prefix);
+ break;
+ }
+
+ case value_t::string:
+ {
+ if (add_prefix)
+ {
+ oa->write_character(to_char_type('S'));
+ }
+ write_number_with_ubjson_prefix(j.m_value.string->size(), true);
+ oa->write_characters(
+ reinterpret_cast<const CharType*>(j.m_value.string->c_str()),
+ j.m_value.string->size());
+ break;
+ }
+
+ case value_t::array:
+ {
+ if (add_prefix)
+ {
+ oa->write_character(to_char_type('['));
+ }
+
+ bool prefix_required = true;
+ if (use_type and not j.m_value.array->empty())
+ {
+ assert(use_count);
+ const CharType first_prefix = ubjson_prefix(j.front());
+ const bool same_prefix = std::all_of(j.begin() + 1, j.end(),
+ [this, first_prefix](const BasicJsonType & v)
+ {
+ return ubjson_prefix(v) == first_prefix;
+ });
+
+ if (same_prefix)
+ {
+ prefix_required = false;
+ oa->write_character(to_char_type('$'));
+ oa->write_character(first_prefix);
+ }
+ }
+
+ if (use_count)
+ {
+ oa->write_character(to_char_type('#'));
+ write_number_with_ubjson_prefix(j.m_value.array->size(), true);
+ }
+
+ for (const auto& el : *j.m_value.array)
+ {
+ write_ubjson(el, use_count, use_type, prefix_required);
+ }
+
+ if (not use_count)
+ {
+ oa->write_character(to_char_type(']'));
+ }
+
+ break;
+ }
+
+ case value_t::object:
+ {
+ if (add_prefix)
+ {
+ oa->write_character(to_char_type('{'));
+ }
+
+ bool prefix_required = true;
+ if (use_type and not j.m_value.object->empty())
+ {
+ assert(use_count);
+ const CharType first_prefix = ubjson_prefix(j.front());
+ const bool same_prefix = std::all_of(j.begin(), j.end(),
+ [this, first_prefix](const BasicJsonType & v)
+ {
+ return ubjson_prefix(v) == first_prefix;
+ });
+
+ if (same_prefix)
+ {
+ prefix_required = false;
+ oa->write_character(to_char_type('$'));
+ oa->write_character(first_prefix);
+ }
+ }
+
+ if (use_count)
+ {
+ oa->write_character(to_char_type('#'));
+ write_number_with_ubjson_prefix(j.m_value.object->size(), true);
+ }
+
+ for (const auto& el : *j.m_value.object)
+ {
+ write_number_with_ubjson_prefix(el.first.size(), true);
+ oa->write_characters(
+ reinterpret_cast<const CharType*>(el.first.c_str()),
+ el.first.size());
+ write_ubjson(el.second, use_count, use_type, prefix_required);
+ }
+
+ if (not use_count)
+ {
+ oa->write_character(to_char_type('}'));
+ }
+
+ break;
+ }
+
+ default:
+ break;
+ }
+ }
+
+ private:
+ //////////
+ // BSON //
+ //////////
+
+ /*!
+ @return The size of a BSON document entry header, including the id marker
+ and the entry name size (and its null-terminator).
+ */
+ static std::size_t calc_bson_entry_header_size(const string_t& name)
+ {
+ const auto it = name.find(static_cast<typename string_t::value_type>(0));
+ if (JSON_UNLIKELY(it != BasicJsonType::string_t::npos))
+ {
+ JSON_THROW(out_of_range::create(409,
+ "BSON key cannot contain code point U+0000 (at byte " + std::to_string(it) + ")"));
+ }
+
+ return /*id*/ 1ul + name.size() + /*zero-terminator*/1u;
+ }
+
+ /*!
+ @brief Writes the given @a element_type and @a name to the output adapter
+ */
+ void write_bson_entry_header(const string_t& name,
+ const std::uint8_t element_type)
+ {
+ oa->write_character(to_char_type(element_type)); // boolean
+ oa->write_characters(
+ reinterpret_cast<const CharType*>(name.c_str()),
+ name.size() + 1u);
+ }
+
+ /*!
+ @brief Writes a BSON element with key @a name and boolean value @a value
+ */
+ void write_bson_boolean(const string_t& name,
+ const bool value)
+ {
+ write_bson_entry_header(name, 0x08);
+ oa->write_character(value ? to_char_type(0x01) : to_char_type(0x00));
+ }
+
+ /*!
+ @brief Writes a BSON element with key @a name and double value @a value
+ */
+ void write_bson_double(const string_t& name,
+ const double value)
+ {
+ write_bson_entry_header(name, 0x01);
+ write_number<double, true>(value);
+ }
+
+ /*!
+ @return The size of the BSON-encoded string in @a value
+ */
+ static std::size_t calc_bson_string_size(const string_t& value)
+ {
+ return sizeof(std::int32_t) + value.size() + 1ul;
+ }
+
+ /*!
+ @brief Writes a BSON element with key @a name and string value @a value
+ */
+ void write_bson_string(const string_t& name,
+ const string_t& value)
+ {
+ write_bson_entry_header(name, 0x02);
+
+ write_number<std::int32_t, true>(static_cast<std::int32_t>(value.size() + 1ul));
+ oa->write_characters(
+ reinterpret_cast<const CharType*>(value.c_str()),
+ value.size() + 1);
+ }
+
+ /*!
+ @brief Writes a BSON element with key @a name and null value
+ */
+ void write_bson_null(const string_t& name)
+ {
+ write_bson_entry_header(name, 0x0A);
+ }
+
+ /*!
+ @return The size of the BSON-encoded integer @a value
+ */
+ static std::size_t calc_bson_integer_size(const std::int64_t value)
+ {
+ return (std::numeric_limits<std::int32_t>::min)() <= value and value <= (std::numeric_limits<std::int32_t>::max)()
+ ? sizeof(std::int32_t)
+ : sizeof(std::int64_t);
+ }
+
+ /*!
+ @brief Writes a BSON element with key @a name and integer @a value
+ */
+ void write_bson_integer(const string_t& name,
+ const std::int64_t value)
+ {
+ if ((std::numeric_limits<std::int32_t>::min)() <= value and value <= (std::numeric_limits<std::int32_t>::max)())
+ {
+ write_bson_entry_header(name, 0x10); // int32
+ write_number<std::int32_t, true>(static_cast<std::int32_t>(value));
+ }
+ else
+ {
+ write_bson_entry_header(name, 0x12); // int64
+ write_number<std::int64_t, true>(static_cast<std::int64_t>(value));
+ }
+ }
+
+ /*!
+ @return The size of the BSON-encoded unsigned integer in @a j
+ */
+ static constexpr std::size_t calc_bson_unsigned_size(const std::uint64_t value) noexcept
+ {
+ return (value <= static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)()))
+ ? sizeof(std::int32_t)
+ : sizeof(std::int64_t);
+ }
+
+ /*!
+ @brief Writes a BSON element with key @a name and unsigned @a value
+ */
+ void write_bson_unsigned(const string_t& name,
+ const std::uint64_t value)
+ {
+ if (value <= static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)()))
+ {
+ write_bson_entry_header(name, 0x10 /* int32 */);
+ write_number<std::int32_t, true>(static_cast<std::int32_t>(value));
+ }
+ else if (value <= static_cast<std::uint64_t>((std::numeric_limits<std::int64_t>::max)()))
+ {
+ write_bson_entry_header(name, 0x12 /* int64 */);
+ write_number<std::int64_t, true>(static_cast<std::int64_t>(value));
+ }
+ else
+ {
+ JSON_THROW(out_of_range::create(407, "integer number " + std::to_string(value) + " cannot be represented by BSON as it does not fit int64"));
+ }
+ }
+
+ /*!
+ @brief Writes a BSON element with key @a name and object @a value
+ */
+ void write_bson_object_entry(const string_t& name,
+ const typename BasicJsonType::object_t& value)
+ {
+ write_bson_entry_header(name, 0x03); // object
+ write_bson_object(value);
+ }
+
+ /*!
+ @return The size of the BSON-encoded array @a value
+ */
+ static std::size_t calc_bson_array_size(const typename BasicJsonType::array_t& value)
+ {
+ std::size_t embedded_document_size = 0ul;
+ std::size_t array_index = 0ul;
+
+ for (const auto& el : value)
+ {
+ embedded_document_size += calc_bson_element_size(std::to_string(array_index++), el);
+ }
+
+ return sizeof(std::int32_t) + embedded_document_size + 1ul;
+ }
+
+ /*!
+ @brief Writes a BSON element with key @a name and array @a value
+ */
+ void write_bson_array(const string_t& name,
+ const typename BasicJsonType::array_t& value)
+ {
+ write_bson_entry_header(name, 0x04); // array
+ write_number<std::int32_t, true>(static_cast<std::int32_t>(calc_bson_array_size(value)));
+
+ std::size_t array_index = 0ul;
+
+ for (const auto& el : value)
+ {
+ write_bson_element(std::to_string(array_index++), el);
+ }
+
+ oa->write_character(to_char_type(0x00));
+ }
+
+ /*!
+ @brief Calculates the size necessary to serialize the JSON value @a j with its @a name
+ @return The calculated size for the BSON document entry for @a j with the given @a name.
+ */
+ static std::size_t calc_bson_element_size(const string_t& name,
+ const BasicJsonType& j)
+ {
+ const auto header_size = calc_bson_entry_header_size(name);
+ switch (j.type())
+ {
+ case value_t::object:
+ return header_size + calc_bson_object_size(*j.m_value.object);
+
+ case value_t::array:
+ return header_size + calc_bson_array_size(*j.m_value.array);
+
+ case value_t::boolean:
+ return header_size + 1ul;
+
+ case value_t::number_float:
+ return header_size + 8ul;
+
+ case value_t::number_integer:
+ return header_size + calc_bson_integer_size(j.m_value.number_integer);
+
+ case value_t::number_unsigned:
+ return header_size + calc_bson_unsigned_size(j.m_value.number_unsigned);
+
+ case value_t::string:
+ return header_size + calc_bson_string_size(*j.m_value.string);
+
+ case value_t::null:
+ return header_size + 0ul;
+
+ // LCOV_EXCL_START
+ default:
+ assert(false);
+ return 0ul;
+ // LCOV_EXCL_STOP
+ }
+ }
+
+ /*!
+ @brief Serializes the JSON value @a j to BSON and associates it with the
+ key @a name.
+ @param name The name to associate with the JSON entity @a j within the
+ current BSON document
+ @return The size of the BSON entry
+ */
+ void write_bson_element(const string_t& name,
+ const BasicJsonType& j)
+ {
+ switch (j.type())
+ {
+ case value_t::object:
+ return write_bson_object_entry(name, *j.m_value.object);
+
+ case value_t::array:
+ return write_bson_array(name, *j.m_value.array);
+
+ case value_t::boolean:
+ return write_bson_boolean(name, j.m_value.boolean);
+
+ case value_t::number_float:
+ return write_bson_double(name, j.m_value.number_float);
+
+ case value_t::number_integer:
+ return write_bson_integer(name, j.m_value.number_integer);
+
+ case value_t::number_unsigned:
+ return write_bson_unsigned(name, j.m_value.number_unsigned);
+
+ case value_t::string:
+ return write_bson_string(name, *j.m_value.string);
+
+ case value_t::null:
+ return write_bson_null(name);
+
+ // LCOV_EXCL_START
+ default:
+ assert(false);
+ return;
+ // LCOV_EXCL_STOP
+ }
+ }
+
+ /*!
+ @brief Calculates the size of the BSON serialization of the given
+ JSON-object @a j.
+ @param[in] j JSON value to serialize
+ @pre j.type() == value_t::object
+ */
+ static std::size_t calc_bson_object_size(const typename BasicJsonType::object_t& value)
+ {
+ std::size_t document_size = std::accumulate(value.begin(), value.end(), 0ul,
+ [](size_t result, const typename BasicJsonType::object_t::value_type & el)
+ {
+ return result += calc_bson_element_size(el.first, el.second);
+ });
+
+ return sizeof(std::int32_t) + document_size + 1ul;
+ }
+
+ /*!
+ @param[in] j JSON value to serialize
+ @pre j.type() == value_t::object
+ */
+ void write_bson_object(const typename BasicJsonType::object_t& value)
+ {
+ write_number<std::int32_t, true>(static_cast<std::int32_t>(calc_bson_object_size(value)));
+
+ for (const auto& el : value)
+ {
+ write_bson_element(el.first, el.second);
+ }
+
+ oa->write_character(to_char_type(0x00));
+ }
+
+ //////////
+ // CBOR //
+ //////////
+
+ static constexpr CharType get_cbor_float_prefix(float /*unused*/)
+ {
+ return to_char_type(0xFA); // Single-Precision Float
+ }
+
+ static constexpr CharType get_cbor_float_prefix(double /*unused*/)
+ {
+ return to_char_type(0xFB); // Double-Precision Float
+ }
+
+ /////////////
+ // MsgPack //
+ /////////////
+
+ static constexpr CharType get_msgpack_float_prefix(float /*unused*/)
+ {
+ return to_char_type(0xCA); // float 32
+ }
+
+ static constexpr CharType get_msgpack_float_prefix(double /*unused*/)
+ {
+ return to_char_type(0xCB); // float 64
+ }
+
+ ////////////
+ // UBJSON //
+ ////////////
+
+ // UBJSON: write number (floating point)
+ template<typename NumberType, typename std::enable_if<
+ std::is_floating_point<NumberType>::value, int>::type = 0>
+ void write_number_with_ubjson_prefix(const NumberType n,
+ const bool add_prefix)
+ {
+ if (add_prefix)
+ {
+ oa->write_character(get_ubjson_float_prefix(n));
+ }
+ write_number(n);
+ }
+
+ // UBJSON: write number (unsigned integer)
+ template<typename NumberType, typename std::enable_if<
+ std::is_unsigned<NumberType>::value, int>::type = 0>
+ void write_number_with_ubjson_prefix(const NumberType n,
+ const bool add_prefix)
+ {
+ if (n <= static_cast<std::uint64_t>((std::numeric_limits<std::int8_t>::max)()))
+ {
+ if (add_prefix)
+ {
+ oa->write_character(to_char_type('i')); // int8
+ }
+ write_number(static_cast<std::uint8_t>(n));
+ }
+ else if (n <= (std::numeric_limits<std::uint8_t>::max)())
+ {
+ if (add_prefix)
+ {
+ oa->write_character(to_char_type('U')); // uint8
+ }
+ write_number(static_cast<std::uint8_t>(n));
+ }
+ else if (n <= static_cast<std::uint64_t>((std::numeric_limits<std::int16_t>::max)()))
+ {
+ if (add_prefix)
+ {
+ oa->write_character(to_char_type('I')); // int16
+ }
+ write_number(static_cast<std::int16_t>(n));
+ }
+ else if (n <= static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)()))
+ {
+ if (add_prefix)
+ {
+ oa->write_character(to_char_type('l')); // int32
+ }
+ write_number(static_cast<std::int32_t>(n));
+ }
+ else if (n <= static_cast<std::uint64_t>((std::numeric_limits<std::int64_t>::max)()))
+ {
+ if (add_prefix)
+ {
+ oa->write_character(to_char_type('L')); // int64
+ }
+ write_number(static_cast<std::int64_t>(n));
+ }
+ else
+ {
+ JSON_THROW(out_of_range::create(407, "integer number " + std::to_string(n) + " cannot be represented by UBJSON as it does not fit int64"));
+ }
+ }
+
+ // UBJSON: write number (signed integer)
+ template<typename NumberType, typename std::enable_if<
+ std::is_signed<NumberType>::value and
+ not std::is_floating_point<NumberType>::value, int>::type = 0>
+ void write_number_with_ubjson_prefix(const NumberType n,
+ const bool add_prefix)
+ {
+ if ((std::numeric_limits<std::int8_t>::min)() <= n and n <= (std::numeric_limits<std::int8_t>::max)())
+ {
+ if (add_prefix)
+ {
+ oa->write_character(to_char_type('i')); // int8
+ }
+ write_number(static_cast<std::int8_t>(n));
+ }
+ else if (static_cast<std::int64_t>((std::numeric_limits<std::uint8_t>::min)()) <= n and n <= static_cast<std::int64_t>((std::numeric_limits<std::uint8_t>::max)()))
+ {
+ if (add_prefix)
+ {
+ oa->write_character(to_char_type('U')); // uint8
+ }
+ write_number(static_cast<std::uint8_t>(n));
+ }
+ else if ((std::numeric_limits<std::int16_t>::min)() <= n and n <= (std::numeric_limits<std::int16_t>::max)())
+ {
+ if (add_prefix)
+ {
+ oa->write_character(to_char_type('I')); // int16
+ }
+ write_number(static_cast<std::int16_t>(n));
+ }
+ else if ((std::numeric_limits<std::int32_t>::min)() <= n and n <= (std::numeric_limits<std::int32_t>::max)())
+ {
+ if (add_prefix)
+ {
+ oa->write_character(to_char_type('l')); // int32
+ }
+ write_number(static_cast<std::int32_t>(n));
+ }
+ else if ((std::numeric_limits<std::int64_t>::min)() <= n and n <= (std::numeric_limits<std::int64_t>::max)())
+ {
+ if (add_prefix)
+ {
+ oa->write_character(to_char_type('L')); // int64
+ }
+ write_number(static_cast<std::int64_t>(n));
+ }
+ // LCOV_EXCL_START
+ else
+ {
+ JSON_THROW(out_of_range::create(407, "integer number " + std::to_string(n) + " cannot be represented by UBJSON as it does not fit int64"));
+ }
+ // LCOV_EXCL_STOP
+ }
+
+ /*!
+ @brief determine the type prefix of container values
+
+ @note This function does not need to be 100% accurate when it comes to
+ integer limits. In case a number exceeds the limits of int64_t,
+ this will be detected by a later call to function
+ write_number_with_ubjson_prefix. Therefore, we return 'L' for any
+ value that does not fit the previous limits.
+ */
+ CharType ubjson_prefix(const BasicJsonType& j) const noexcept
+ {
+ switch (j.type())
+ {
+ case value_t::null:
+ return 'Z';
+
+ case value_t::boolean:
+ return j.m_value.boolean ? 'T' : 'F';
+
+ case value_t::number_integer:
+ {
+ if ((std::numeric_limits<std::int8_t>::min)() <= j.m_value.number_integer and j.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
+ {
+ return 'i';
+ }
+ if ((std::numeric_limits<std::uint8_t>::min)() <= j.m_value.number_integer and j.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
+ {
+ return 'U';
+ }
+ if ((std::numeric_limits<std::int16_t>::min)() <= j.m_value.number_integer and j.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
+ {
+ return 'I';
+ }
+ if ((std::numeric_limits<std::int32_t>::min)() <= j.m_value.number_integer and j.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
+ {
+ return 'l';
+ }
+ // no check and assume int64_t (see note above)
+ return 'L';
+ }
+
+ case value_t::number_unsigned:
+ {
+ if (j.m_value.number_unsigned <= (std::numeric_limits<std::int8_t>::max)())
+ {
+ return 'i';
+ }
+ if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
+ {
+ return 'U';
+ }
+ if (j.m_value.number_unsigned <= (std::numeric_limits<std::int16_t>::max)())
+ {
+ return 'I';
+ }
+ if (j.m_value.number_unsigned <= (std::numeric_limits<std::int32_t>::max)())
+ {
+ return 'l';
+ }
+ // no check and assume int64_t (see note above)
+ return 'L';
+ }
+
+ case value_t::number_float:
+ return get_ubjson_float_prefix(j.m_value.number_float);
+
+ case value_t::string:
+ return 'S';
+
+ case value_t::array:
+ return '[';
+
+ case value_t::object:
+ return '{';
+
+ default: // discarded values
+ return 'N';
+ }
+ }
+
+ static constexpr CharType get_ubjson_float_prefix(float /*unused*/)
+ {
+ return 'd'; // float 32
+ }
+
+ static constexpr CharType get_ubjson_float_prefix(double /*unused*/)
+ {
+ return 'D'; // float 64
+ }
+
+ ///////////////////////
+ // Utility functions //
+ ///////////////////////
+
+ /*
+ @brief write a number to output input
+ @param[in] n number of type @a NumberType
+ @tparam NumberType the type of the number
+ @tparam OutputIsLittleEndian Set to true if output data is
+ required to be little endian
+
+ @note This function needs to respect the system's endianess, because bytes
+ in CBOR, MessagePack, and UBJSON are stored in network order (big
+ endian) and therefore need reordering on little endian systems.
+ */
+ template<typename NumberType, bool OutputIsLittleEndian = false>
+ void write_number(const NumberType n)
+ {
+ // step 1: write number to array of length NumberType
+ std::array<CharType, sizeof(NumberType)> vec;
+ std::memcpy(vec.data(), &n, sizeof(NumberType));
+
+ // step 2: write array to output (with possible reordering)
+ if (is_little_endian != OutputIsLittleEndian)
+ {
+ // reverse byte order prior to conversion if necessary
+ std::reverse(vec.begin(), vec.end());
+ }
+
+ oa->write_characters(vec.data(), sizeof(NumberType));
+ }
+
+ public:
+ // The following to_char_type functions are implement the conversion
+ // between uint8_t and CharType. In case CharType is not unsigned,
+ // such a conversion is required to allow values greater than 128.
+ // See <https://github.com/nlohmann/json/issues/1286> for a discussion.
+ template < typename C = CharType,
+ enable_if_t < std::is_signed<C>::value and std::is_signed<char>::value > * = nullptr >
+ static constexpr CharType to_char_type(std::uint8_t x) noexcept
+ {
+ return *reinterpret_cast<char*>(&x);
+ }
+
+ template < typename C = CharType,
+ enable_if_t < std::is_signed<C>::value and std::is_unsigned<char>::value > * = nullptr >
+ static CharType to_char_type(std::uint8_t x) noexcept
+ {
+ static_assert(sizeof(std::uint8_t) == sizeof(CharType), "size of CharType must be equal to std::uint8_t");
+ static_assert(std::is_pod<CharType>::value, "CharType must be POD");
+ CharType result;
+ std::memcpy(&result, &x, sizeof(x));
+ return result;
+ }
+
+ template<typename C = CharType,
+ enable_if_t<std::is_unsigned<C>::value>* = nullptr>
+ static constexpr CharType to_char_type(std::uint8_t x) noexcept
+ {
+ return x;
+ }
+
+ template < typename InputCharType, typename C = CharType,
+ enable_if_t <
+ std::is_signed<C>::value and
+ std::is_signed<char>::value and
+ std::is_same<char, typename std::remove_cv<InputCharType>::type>::value
+ > * = nullptr >
+ static constexpr CharType to_char_type(InputCharType x) noexcept
+ {
+ return x;
+ }
+
+ private:
+ /// whether we can assume little endianess
+ const bool is_little_endian = binary_reader<BasicJsonType>::little_endianess();
+
+ /// the output
+ output_adapter_t<CharType> oa = nullptr;
+};
+} // namespace detail
+} // namespace nlohmann
+
+// #include <nlohmann/detail/output/output_adapters.hpp>
+
+// #include <nlohmann/detail/output/serializer.hpp>
+
+
+#include <algorithm> // reverse, remove, fill, find, none_of
+#include <array> // array
+#include <cassert> // assert
+#include <ciso646> // and, or
+#include <clocale> // localeconv, lconv
+#include <cmath> // labs, isfinite, isnan, signbit
+#include <cstddef> // size_t, ptrdiff_t
+#include <cstdint> // uint8_t
+#include <cstdio> // snprintf
+#include <limits> // numeric_limits
+#include <string> // string
+#include <type_traits> // is_same
+#include <utility> // move
+
+// #include <nlohmann/detail/conversions/to_chars.hpp>
+
+
+#include <array> // array
+#include <cassert> // assert
+#include <ciso646> // or, and, not
+#include <cmath> // signbit, isfinite
+#include <cstdint> // intN_t, uintN_t
+#include <cstring> // memcpy, memmove
+#include <limits> // numeric_limits
+#include <type_traits> // conditional
+
+namespace nlohmann
+{
+namespace detail
+{
+
+/*!
+@brief implements the Grisu2 algorithm for binary to decimal floating-point
+conversion.
+
+This implementation is a slightly modified version of the reference
+implementation which may be obtained from
+http://florian.loitsch.com/publications (bench.tar.gz).
+
+The code is distributed under the MIT license, Copyright (c) 2009 Florian Loitsch.
+
+For a detailed description of the algorithm see:
+
+[1] Loitsch, "Printing Floating-Point Numbers Quickly and Accurately with
+ Integers", Proceedings of the ACM SIGPLAN 2010 Conference on Programming
+ Language Design and Implementation, PLDI 2010
+[2] Burger, Dybvig, "Printing Floating-Point Numbers Quickly and Accurately",
+ Proceedings of the ACM SIGPLAN 1996 Conference on Programming Language
+ Design and Implementation, PLDI 1996
+*/
+namespace dtoa_impl
+{
+
+template <typename Target, typename Source>
+Target reinterpret_bits(const Source source)
+{
+ static_assert(sizeof(Target) == sizeof(Source), "size mismatch");
+
+ Target target;
+ std::memcpy(&target, &source, sizeof(Source));
+ return target;
+}
+
+struct diyfp // f * 2^e
+{
+ static constexpr int kPrecision = 64; // = q
+
+ std::uint64_t f = 0;
+ int e = 0;
+
+ constexpr diyfp(std::uint64_t f_, int e_) noexcept : f(f_), e(e_) {}
+
+ /*!
+ @brief returns x - y
+ @pre x.e == y.e and x.f >= y.f
+ */
+ static diyfp sub(const diyfp& x, const diyfp& y) noexcept
+ {
+ assert(x.e == y.e);
+ assert(x.f >= y.f);
+
+ return {x.f - y.f, x.e};
+ }
+
+ /*!
+ @brief returns x * y
+ @note The result is rounded. (Only the upper q bits are returned.)
+ */
+ static diyfp mul(const diyfp& x, const diyfp& y) noexcept
+ {
+ static_assert(kPrecision == 64, "internal error");
+
+ // Computes:
+ // f = round((x.f * y.f) / 2^q)
+ // e = x.e + y.e + q
+
+ // Emulate the 64-bit * 64-bit multiplication:
+ //
+ // p = u * v
+ // = (u_lo + 2^32 u_hi) (v_lo + 2^32 v_hi)
+ // = (u_lo v_lo ) + 2^32 ((u_lo v_hi ) + (u_hi v_lo )) + 2^64 (u_hi v_hi )
+ // = (p0 ) + 2^32 ((p1 ) + (p2 )) + 2^64 (p3 )
+ // = (p0_lo + 2^32 p0_hi) + 2^32 ((p1_lo + 2^32 p1_hi) + (p2_lo + 2^32 p2_hi)) + 2^64 (p3 )
+ // = (p0_lo ) + 2^32 (p0_hi + p1_lo + p2_lo ) + 2^64 (p1_hi + p2_hi + p3)
+ // = (p0_lo ) + 2^32 (Q ) + 2^64 (H )
+ // = (p0_lo ) + 2^32 (Q_lo + 2^32 Q_hi ) + 2^64 (H )
+ //
+ // (Since Q might be larger than 2^32 - 1)
+ //
+ // = (p0_lo + 2^32 Q_lo) + 2^64 (Q_hi + H)
+ //
+ // (Q_hi + H does not overflow a 64-bit int)
+ //
+ // = p_lo + 2^64 p_hi
+
+ const std::uint64_t u_lo = x.f & 0xFFFFFFFFu;
+ const std::uint64_t u_hi = x.f >> 32u;
+ const std::uint64_t v_lo = y.f & 0xFFFFFFFFu;
+ const std::uint64_t v_hi = y.f >> 32u;
+
+ const std::uint64_t p0 = u_lo * v_lo;
+ const std::uint64_t p1 = u_lo * v_hi;
+ const std::uint64_t p2 = u_hi * v_lo;
+ const std::uint64_t p3 = u_hi * v_hi;
+
+ const std::uint64_t p0_hi = p0 >> 32u;
+ const std::uint64_t p1_lo = p1 & 0xFFFFFFFFu;
+ const std::uint64_t p1_hi = p1 >> 32u;
+ const std::uint64_t p2_lo = p2 & 0xFFFFFFFFu;
+ const std::uint64_t p2_hi = p2 >> 32u;
+
+ std::uint64_t Q = p0_hi + p1_lo + p2_lo;
+
+ // The full product might now be computed as
+ //
+ // p_hi = p3 + p2_hi + p1_hi + (Q >> 32)
+ // p_lo = p0_lo + (Q << 32)
+ //
+ // But in this particular case here, the full p_lo is not required.
+ // Effectively we only need to add the highest bit in p_lo to p_hi (and
+ // Q_hi + 1 does not overflow).
+
+ Q += std::uint64_t{1} << (64u - 32u - 1u); // round, ties up
+
+ const std::uint64_t h = p3 + p2_hi + p1_hi + (Q >> 32u);
+
+ return {h, x.e + y.e + 64};
+ }
+
+ /*!
+ @brief normalize x such that the significand is >= 2^(q-1)
+ @pre x.f != 0
+ */
+ static diyfp normalize(diyfp x) noexcept
+ {
+ assert(x.f != 0);
+
+ while ((x.f >> 63u) == 0)
+ {
+ x.f <<= 1u;
+ x.e--;
+ }
+
+ return x;
+ }
+
+ /*!
+ @brief normalize x such that the result has the exponent E
+ @pre e >= x.e and the upper e - x.e bits of x.f must be zero.
+ */
+ static diyfp normalize_to(const diyfp& x, const int target_exponent) noexcept
+ {
+ const int delta = x.e - target_exponent;
+
+ assert(delta >= 0);
+ assert(((x.f << delta) >> delta) == x.f);
+
+ return {x.f << delta, target_exponent};
+ }
+};
+
+struct boundaries
+{
+ diyfp w;
+ diyfp minus;
+ diyfp plus;
+};
+
+/*!
+Compute the (normalized) diyfp representing the input number 'value' and its
+boundaries.
+
+@pre value must be finite and positive
+*/
+template <typename FloatType>
+boundaries compute_boundaries(FloatType value)
+{
+ assert(std::isfinite(value));
+ assert(value > 0);
+
+ // Convert the IEEE representation into a diyfp.
+ //
+ // If v is denormal:
+ // value = 0.F * 2^(1 - bias) = ( F) * 2^(1 - bias - (p-1))
+ // If v is normalized:
+ // value = 1.F * 2^(E - bias) = (2^(p-1) + F) * 2^(E - bias - (p-1))
+
+ static_assert(std::numeric_limits<FloatType>::is_iec559,
+ "internal error: dtoa_short requires an IEEE-754 floating-point implementation");
+
+ constexpr int kPrecision = std::numeric_limits<FloatType>::digits; // = p (includes the hidden bit)
+ constexpr int kBias = std::numeric_limits<FloatType>::max_exponent - 1 + (kPrecision - 1);
+ constexpr int kMinExp = 1 - kBias;
+ constexpr std::uint64_t kHiddenBit = std::uint64_t{1} << (kPrecision - 1); // = 2^(p-1)
+
+ using bits_type = typename std::conditional<kPrecision == 24, std::uint32_t, std::uint64_t >::type;
+
+ const std::uint64_t bits = reinterpret_bits<bits_type>(value);
+ const std::uint64_t E = bits >> (kPrecision - 1);
+ const std::uint64_t F = bits & (kHiddenBit - 1);
+
+ const bool is_denormal = E == 0;
+ const diyfp v = is_denormal
+ ? diyfp(F, kMinExp)
+ : diyfp(F + kHiddenBit, static_cast<int>(E) - kBias);
+
+ // Compute the boundaries m- and m+ of the floating-point value
+ // v = f * 2^e.
+ //
+ // Determine v- and v+, the floating-point predecessor and successor if v,
+ // respectively.
+ //
+ // v- = v - 2^e if f != 2^(p-1) or e == e_min (A)
+ // = v - 2^(e-1) if f == 2^(p-1) and e > e_min (B)
+ //
+ // v+ = v + 2^e
+ //
+ // Let m- = (v- + v) / 2 and m+ = (v + v+) / 2. All real numbers _strictly_
+ // between m- and m+ round to v, regardless of how the input rounding
+ // algorithm breaks ties.
+ //
+ // ---+-------------+-------------+-------------+-------------+--- (A)
+ // v- m- v m+ v+
+ //
+ // -----------------+------+------+-------------+-------------+--- (B)
+ // v- m- v m+ v+
+
+ const bool lower_boundary_is_closer = F == 0 and E > 1;
+ const diyfp m_plus = diyfp(2 * v.f + 1, v.e - 1);
+ const diyfp m_minus = lower_boundary_is_closer
+ ? diyfp(4 * v.f - 1, v.e - 2) // (B)
+ : diyfp(2 * v.f - 1, v.e - 1); // (A)
+
+ // Determine the normalized w+ = m+.
+ const diyfp w_plus = diyfp::normalize(m_plus);
+
+ // Determine w- = m- such that e_(w-) = e_(w+).
+ const diyfp w_minus = diyfp::normalize_to(m_minus, w_plus.e);
+
+ return {diyfp::normalize(v), w_minus, w_plus};
+}
+
+// Given normalized diyfp w, Grisu needs to find a (normalized) cached
+// power-of-ten c, such that the exponent of the product c * w = f * 2^e lies
+// within a certain range [alpha, gamma] (Definition 3.2 from [1])
+//
+// alpha <= e = e_c + e_w + q <= gamma
+//
+// or
+//
+// f_c * f_w * 2^alpha <= f_c 2^(e_c) * f_w 2^(e_w) * 2^q
+// <= f_c * f_w * 2^gamma
+//
+// Since c and w are normalized, i.e. 2^(q-1) <= f < 2^q, this implies
+//
+// 2^(q-1) * 2^(q-1) * 2^alpha <= c * w * 2^q < 2^q * 2^q * 2^gamma
+//
+// or
+//
+// 2^(q - 2 + alpha) <= c * w < 2^(q + gamma)
+//
+// The choice of (alpha,gamma) determines the size of the table and the form of
+// the digit generation procedure. Using (alpha,gamma)=(-60,-32) works out well
+// in practice:
+//
+// The idea is to cut the number c * w = f * 2^e into two parts, which can be
+// processed independently: An integral part p1, and a fractional part p2:
+//
+// f * 2^e = ( (f div 2^-e) * 2^-e + (f mod 2^-e) ) * 2^e
+// = (f div 2^-e) + (f mod 2^-e) * 2^e
+// = p1 + p2 * 2^e
+//
+// The conversion of p1 into decimal form requires a series of divisions and
+// modulos by (a power of) 10. These operations are faster for 32-bit than for
+// 64-bit integers, so p1 should ideally fit into a 32-bit integer. This can be
+// achieved by choosing
+//
+// -e >= 32 or e <= -32 := gamma
+//
+// In order to convert the fractional part
+//
+// p2 * 2^e = p2 / 2^-e = d[-1] / 10^1 + d[-2] / 10^2 + ...
+//
+// into decimal form, the fraction is repeatedly multiplied by 10 and the digits
+// d[-i] are extracted in order:
+//
+// (10 * p2) div 2^-e = d[-1]
+// (10 * p2) mod 2^-e = d[-2] / 10^1 + ...
+//
+// The multiplication by 10 must not overflow. It is sufficient to choose
+//
+// 10 * p2 < 16 * p2 = 2^4 * p2 <= 2^64.
+//
+// Since p2 = f mod 2^-e < 2^-e,
+//
+// -e <= 60 or e >= -60 := alpha
+
+constexpr int kAlpha = -60;
+constexpr int kGamma = -32;
+
+struct cached_power // c = f * 2^e ~= 10^k
+{
+ std::uint64_t f;
+ int e;
+ int k;
+};
+
+/*!
+For a normalized diyfp w = f * 2^e, this function returns a (normalized) cached
+power-of-ten c = f_c * 2^e_c, such that the exponent of the product w * c
+satisfies (Definition 3.2 from [1])
+
+ alpha <= e_c + e + q <= gamma.
+*/
+inline cached_power get_cached_power_for_binary_exponent(int e)
+{
+ // Now
+ //
+ // alpha <= e_c + e + q <= gamma (1)
+ // ==> f_c * 2^alpha <= c * 2^e * 2^q
+ //
+ // and since the c's are normalized, 2^(q-1) <= f_c,
+ //
+ // ==> 2^(q - 1 + alpha) <= c * 2^(e + q)
+ // ==> 2^(alpha - e - 1) <= c
+ //
+ // If c were an exakt power of ten, i.e. c = 10^k, one may determine k as
+ //
+ // k = ceil( log_10( 2^(alpha - e - 1) ) )
+ // = ceil( (alpha - e - 1) * log_10(2) )
+ //
+ // From the paper:
+ // "In theory the result of the procedure could be wrong since c is rounded,
+ // and the computation itself is approximated [...]. In practice, however,
+ // this simple function is sufficient."
+ //
+ // For IEEE double precision floating-point numbers converted into
+ // normalized diyfp's w = f * 2^e, with q = 64,
+ //
+ // e >= -1022 (min IEEE exponent)
+ // -52 (p - 1)
+ // -52 (p - 1, possibly normalize denormal IEEE numbers)
+ // -11 (normalize the diyfp)
+ // = -1137
+ //
+ // and
+ //
+ // e <= +1023 (max IEEE exponent)
+ // -52 (p - 1)
+ // -11 (normalize the diyfp)
+ // = 960
+ //
+ // This binary exponent range [-1137,960] results in a decimal exponent
+ // range [-307,324]. One does not need to store a cached power for each
+ // k in this range. For each such k it suffices to find a cached power
+ // such that the exponent of the product lies in [alpha,gamma].
+ // This implies that the difference of the decimal exponents of adjacent
+ // table entries must be less than or equal to
+ //
+ // floor( (gamma - alpha) * log_10(2) ) = 8.
+ //
+ // (A smaller distance gamma-alpha would require a larger table.)
+
+ // NB:
+ // Actually this function returns c, such that -60 <= e_c + e + 64 <= -34.
+
+ constexpr int kCachedPowersMinDecExp = -300;
+ constexpr int kCachedPowersDecStep = 8;
+
+ static constexpr std::array<cached_power, 79> kCachedPowers =
+ {
+ {
+ { 0xAB70FE17C79AC6CA, -1060, -300 },
+ { 0xFF77B1FCBEBCDC4F, -1034, -292 },
+ { 0xBE5691EF416BD60C, -1007, -284 },
+ { 0x8DD01FAD907FFC3C, -980, -276 },
+ { 0xD3515C2831559A83, -954, -268 },
+ { 0x9D71AC8FADA6C9B5, -927, -260 },
+ { 0xEA9C227723EE8BCB, -901, -252 },
+ { 0xAECC49914078536D, -874, -244 },
+ { 0x823C12795DB6CE57, -847, -236 },
+ { 0xC21094364DFB5637, -821, -228 },
+ { 0x9096EA6F3848984F, -794, -220 },
+ { 0xD77485CB25823AC7, -768, -212 },
+ { 0xA086CFCD97BF97F4, -741, -204 },
+ { 0xEF340A98172AACE5, -715, -196 },
+ { 0xB23867FB2A35B28E, -688, -188 },
+ { 0x84C8D4DFD2C63F3B, -661, -180 },
+ { 0xC5DD44271AD3CDBA, -635, -172 },
+ { 0x936B9FCEBB25C996, -608, -164 },
+ { 0xDBAC6C247D62A584, -582, -156 },
+ { 0xA3AB66580D5FDAF6, -555, -148 },
+ { 0xF3E2F893DEC3F126, -529, -140 },
+ { 0xB5B5ADA8AAFF80B8, -502, -132 },
+ { 0x87625F056C7C4A8B, -475, -124 },
+ { 0xC9BCFF6034C13053, -449, -116 },
+ { 0x964E858C91BA2655, -422, -108 },
+ { 0xDFF9772470297EBD, -396, -100 },
+ { 0xA6DFBD9FB8E5B88F, -369, -92 },
+ { 0xF8A95FCF88747D94, -343, -84 },
+ { 0xB94470938FA89BCF, -316, -76 },
+ { 0x8A08F0F8BF0F156B, -289, -68 },
+ { 0xCDB02555653131B6, -263, -60 },
+ { 0x993FE2C6D07B7FAC, -236, -52 },
+ { 0xE45C10C42A2B3B06, -210, -44 },
+ { 0xAA242499697392D3, -183, -36 },
+ { 0xFD87B5F28300CA0E, -157, -28 },
+ { 0xBCE5086492111AEB, -130, -20 },
+ { 0x8CBCCC096F5088CC, -103, -12 },
+ { 0xD1B71758E219652C, -77, -4 },
+ { 0x9C40000000000000, -50, 4 },
+ { 0xE8D4A51000000000, -24, 12 },
+ { 0xAD78EBC5AC620000, 3, 20 },
+ { 0x813F3978F8940984, 30, 28 },
+ { 0xC097CE7BC90715B3, 56, 36 },
+ { 0x8F7E32CE7BEA5C70, 83, 44 },
+ { 0xD5D238A4ABE98068, 109, 52 },
+ { 0x9F4F2726179A2245, 136, 60 },
+ { 0xED63A231D4C4FB27, 162, 68 },
+ { 0xB0DE65388CC8ADA8, 189, 76 },
+ { 0x83C7088E1AAB65DB, 216, 84 },
+ { 0xC45D1DF942711D9A, 242, 92 },
+ { 0x924D692CA61BE758, 269, 100 },
+ { 0xDA01EE641A708DEA, 295, 108 },
+ { 0xA26DA3999AEF774A, 322, 116 },
+ { 0xF209787BB47D6B85, 348, 124 },
+ { 0xB454E4A179DD1877, 375, 132 },
+ { 0x865B86925B9BC5C2, 402, 140 },
+ { 0xC83553C5C8965D3D, 428, 148 },
+ { 0x952AB45CFA97A0B3, 455, 156 },
+ { 0xDE469FBD99A05FE3, 481, 164 },
+ { 0xA59BC234DB398C25, 508, 172 },
+ { 0xF6C69A72A3989F5C, 534, 180 },
+ { 0xB7DCBF5354E9BECE, 561, 188 },
+ { 0x88FCF317F22241E2, 588, 196 },
+ { 0xCC20CE9BD35C78A5, 614, 204 },
+ { 0x98165AF37B2153DF, 641, 212 },
+ { 0xE2A0B5DC971F303A, 667, 220 },
+ { 0xA8D9D1535CE3B396, 694, 228 },
+ { 0xFB9B7CD9A4A7443C, 720, 236 },
+ { 0xBB764C4CA7A44410, 747, 244 },
+ { 0x8BAB8EEFB6409C1A, 774, 252 },
+ { 0xD01FEF10A657842C, 800, 260 },
+ { 0x9B10A4E5E9913129, 827, 268 },
+ { 0xE7109BFBA19C0C9D, 853, 276 },
+ { 0xAC2820D9623BF429, 880, 284 },
+ { 0x80444B5E7AA7CF85, 907, 292 },
+ { 0xBF21E44003ACDD2D, 933, 300 },
+ { 0x8E679C2F5E44FF8F, 960, 308 },
+ { 0xD433179D9C8CB841, 986, 316 },
+ { 0x9E19DB92B4E31BA9, 1013, 324 },
+ }
+ };
+
+ // This computation gives exactly the same results for k as
+ // k = ceil((kAlpha - e - 1) * 0.30102999566398114)
+ // for |e| <= 1500, but doesn't require floating-point operations.
+ // NB: log_10(2) ~= 78913 / 2^18
+ assert(e >= -1500);
+ assert(e <= 1500);
+ const int f = kAlpha - e - 1;
+ const int k = (f * 78913) / (1 << 18) + static_cast<int>(f > 0);
+
+ const int index = (-kCachedPowersMinDecExp + k + (kCachedPowersDecStep - 1)) / kCachedPowersDecStep;
+ assert(index >= 0);
+ assert(static_cast<std::size_t>(index) < kCachedPowers.size());
+
+ const cached_power cached = kCachedPowers[static_cast<std::size_t>(index)];
+ assert(kAlpha <= cached.e + e + 64);
+ assert(kGamma >= cached.e + e + 64);
+
+ return cached;
+}
+
+/*!
+For n != 0, returns k, such that pow10 := 10^(k-1) <= n < 10^k.
+For n == 0, returns 1 and sets pow10 := 1.
+*/
+inline int find_largest_pow10(const std::uint32_t n, std::uint32_t& pow10)
+{
+ // LCOV_EXCL_START
+ if (n >= 1000000000)
+ {
+ pow10 = 1000000000;
+ return 10;
+ }
+ // LCOV_EXCL_STOP
+ else if (n >= 100000000)
+ {
+ pow10 = 100000000;
+ return 9;
+ }
+ else if (n >= 10000000)
+ {
+ pow10 = 10000000;
+ return 8;
+ }
+ else if (n >= 1000000)
+ {
+ pow10 = 1000000;
+ return 7;
+ }
+ else if (n >= 100000)
+ {
+ pow10 = 100000;
+ return 6;
+ }
+ else if (n >= 10000)
+ {
+ pow10 = 10000;
+ return 5;
+ }
+ else if (n >= 1000)
+ {
+ pow10 = 1000;
+ return 4;
+ }
+ else if (n >= 100)
+ {
+ pow10 = 100;
+ return 3;
+ }
+ else if (n >= 10)
+ {
+ pow10 = 10;
+ return 2;
+ }
+ else
+ {
+ pow10 = 1;
+ return 1;
+ }
+}
+
+inline void grisu2_round(char* buf, int len, std::uint64_t dist, std::uint64_t delta,
+ std::uint64_t rest, std::uint64_t ten_k)
+{
+ assert(len >= 1);
+ assert(dist <= delta);
+ assert(rest <= delta);
+ assert(ten_k > 0);
+
+ // <--------------------------- delta ---->
+ // <---- dist --------->
+ // --------------[------------------+-------------------]--------------
+ // M- w M+
+ //
+ // ten_k
+ // <------>
+ // <---- rest ---->
+ // --------------[------------------+----+--------------]--------------
+ // w V
+ // = buf * 10^k
+ //
+ // ten_k represents a unit-in-the-last-place in the decimal representation
+ // stored in buf.
+ // Decrement buf by ten_k while this takes buf closer to w.
+
+ // The tests are written in this order to avoid overflow in unsigned
+ // integer arithmetic.
+
+ while (rest < dist
+ and delta - rest >= ten_k
+ and (rest + ten_k < dist or dist - rest > rest + ten_k - dist))
+ {
+ assert(buf[len - 1] != '0');
+ buf[len - 1]--;
+ rest += ten_k;
+ }
+}
+
+/*!
+Generates V = buffer * 10^decimal_exponent, such that M- <= V <= M+.
+M- and M+ must be normalized and share the same exponent -60 <= e <= -32.
+*/
+inline void grisu2_digit_gen(char* buffer, int& length, int& decimal_exponent,
+ diyfp M_minus, diyfp w, diyfp M_plus)
+{
+ static_assert(kAlpha >= -60, "internal error");
+ static_assert(kGamma <= -32, "internal error");
+
+ // Generates the digits (and the exponent) of a decimal floating-point
+ // number V = buffer * 10^decimal_exponent in the range [M-, M+]. The diyfp's
+ // w, M- and M+ share the same exponent e, which satisfies alpha <= e <= gamma.
+ //
+ // <--------------------------- delta ---->
+ // <---- dist --------->
+ // --------------[------------------+-------------------]--------------
+ // M- w M+
+ //
+ // Grisu2 generates the digits of M+ from left to right and stops as soon as
+ // V is in [M-,M+].
+
+ assert(M_plus.e >= kAlpha);
+ assert(M_plus.e <= kGamma);
+
+ std::uint64_t delta = diyfp::sub(M_plus, M_minus).f; // (significand of (M+ - M-), implicit exponent is e)
+ std::uint64_t dist = diyfp::sub(M_plus, w ).f; // (significand of (M+ - w ), implicit exponent is e)
+
+ // Split M+ = f * 2^e into two parts p1 and p2 (note: e < 0):
+ //
+ // M+ = f * 2^e
+ // = ((f div 2^-e) * 2^-e + (f mod 2^-e)) * 2^e
+ // = ((p1 ) * 2^-e + (p2 )) * 2^e
+ // = p1 + p2 * 2^e
+
+ const diyfp one(std::uint64_t{1} << -M_plus.e, M_plus.e);
+
+ auto p1 = static_cast<std::uint32_t>(M_plus.f >> -one.e); // p1 = f div 2^-e (Since -e >= 32, p1 fits into a 32-bit int.)
+ std::uint64_t p2 = M_plus.f & (one.f - 1); // p2 = f mod 2^-e
+
+ // 1)
+ //
+ // Generate the digits of the integral part p1 = d[n-1]...d[1]d[0]
+
+ assert(p1 > 0);
+
+ std::uint32_t pow10;
+ const int k = find_largest_pow10(p1, pow10);
+
+ // 10^(k-1) <= p1 < 10^k, pow10 = 10^(k-1)
+ //
+ // p1 = (p1 div 10^(k-1)) * 10^(k-1) + (p1 mod 10^(k-1))
+ // = (d[k-1] ) * 10^(k-1) + (p1 mod 10^(k-1))
+ //
+ // M+ = p1 + p2 * 2^e
+ // = d[k-1] * 10^(k-1) + (p1 mod 10^(k-1)) + p2 * 2^e
+ // = d[k-1] * 10^(k-1) + ((p1 mod 10^(k-1)) * 2^-e + p2) * 2^e
+ // = d[k-1] * 10^(k-1) + ( rest) * 2^e
+ //
+ // Now generate the digits d[n] of p1 from left to right (n = k-1,...,0)
+ //
+ // p1 = d[k-1]...d[n] * 10^n + d[n-1]...d[0]
+ //
+ // but stop as soon as
+ //
+ // rest * 2^e = (d[n-1]...d[0] * 2^-e + p2) * 2^e <= delta * 2^e
+
+ int n = k;
+ while (n > 0)
+ {
+ // Invariants:
+ // M+ = buffer * 10^n + (p1 + p2 * 2^e) (buffer = 0 for n = k)
+ // pow10 = 10^(n-1) <= p1 < 10^n
+ //
+ const std::uint32_t d = p1 / pow10; // d = p1 div 10^(n-1)
+ const std::uint32_t r = p1 % pow10; // r = p1 mod 10^(n-1)
+ //
+ // M+ = buffer * 10^n + (d * 10^(n-1) + r) + p2 * 2^e
+ // = (buffer * 10 + d) * 10^(n-1) + (r + p2 * 2^e)
+ //
+ assert(d <= 9);
+ buffer[length++] = static_cast<char>('0' + d); // buffer := buffer * 10 + d
+ //
+ // M+ = buffer * 10^(n-1) + (r + p2 * 2^e)
+ //
+ p1 = r;
+ n--;
+ //
+ // M+ = buffer * 10^n + (p1 + p2 * 2^e)
+ // pow10 = 10^n
+ //
+
+ // Now check if enough digits have been generated.
+ // Compute
+ //
+ // p1 + p2 * 2^e = (p1 * 2^-e + p2) * 2^e = rest * 2^e
+ //
+ // Note:
+ // Since rest and delta share the same exponent e, it suffices to
+ // compare the significands.
+ const std::uint64_t rest = (std::uint64_t{p1} << -one.e) + p2;
+ if (rest <= delta)
+ {
+ // V = buffer * 10^n, with M- <= V <= M+.
+
+ decimal_exponent += n;
+
+ // We may now just stop. But instead look if the buffer could be
+ // decremented to bring V closer to w.
+ //
+ // pow10 = 10^n is now 1 ulp in the decimal representation V.
+ // The rounding procedure works with diyfp's with an implicit
+ // exponent of e.
+ //
+ // 10^n = (10^n * 2^-e) * 2^e = ulp * 2^e
+ //
+ const std::uint64_t ten_n = std::uint64_t{pow10} << -one.e;
+ grisu2_round(buffer, length, dist, delta, rest, ten_n);
+
+ return;
+ }
+
+ pow10 /= 10;
+ //
+ // pow10 = 10^(n-1) <= p1 < 10^n
+ // Invariants restored.
+ }
+
+ // 2)
+ //
+ // The digits of the integral part have been generated:
+ //
+ // M+ = d[k-1]...d[1]d[0] + p2 * 2^e
+ // = buffer + p2 * 2^e
+ //
+ // Now generate the digits of the fractional part p2 * 2^e.
+ //
+ // Note:
+ // No decimal point is generated: the exponent is adjusted instead.
+ //
+ // p2 actually represents the fraction
+ //
+ // p2 * 2^e
+ // = p2 / 2^-e
+ // = d[-1] / 10^1 + d[-2] / 10^2 + ...
+ //
+ // Now generate the digits d[-m] of p1 from left to right (m = 1,2,...)
+ //
+ // p2 * 2^e = d[-1]d[-2]...d[-m] * 10^-m
+ // + 10^-m * (d[-m-1] / 10^1 + d[-m-2] / 10^2 + ...)
+ //
+ // using
+ //
+ // 10^m * p2 = ((10^m * p2) div 2^-e) * 2^-e + ((10^m * p2) mod 2^-e)
+ // = ( d) * 2^-e + ( r)
+ //
+ // or
+ // 10^m * p2 * 2^e = d + r * 2^e
+ //
+ // i.e.
+ //
+ // M+ = buffer + p2 * 2^e
+ // = buffer + 10^-m * (d + r * 2^e)
+ // = (buffer * 10^m + d) * 10^-m + 10^-m * r * 2^e
+ //
+ // and stop as soon as 10^-m * r * 2^e <= delta * 2^e
+
+ assert(p2 > delta);
+
+ int m = 0;
+ for (;;)
+ {
+ // Invariant:
+ // M+ = buffer * 10^-m + 10^-m * (d[-m-1] / 10 + d[-m-2] / 10^2 + ...) * 2^e
+ // = buffer * 10^-m + 10^-m * (p2 ) * 2^e
+ // = buffer * 10^-m + 10^-m * (1/10 * (10 * p2) ) * 2^e
+ // = buffer * 10^-m + 10^-m * (1/10 * ((10*p2 div 2^-e) * 2^-e + (10*p2 mod 2^-e)) * 2^e
+ //
+ assert(p2 <= (std::numeric_limits<std::uint64_t>::max)() / 10);
+ p2 *= 10;
+ const std::uint64_t d = p2 >> -one.e; // d = (10 * p2) div 2^-e
+ const std::uint64_t r = p2 & (one.f - 1); // r = (10 * p2) mod 2^-e
+ //
+ // M+ = buffer * 10^-m + 10^-m * (1/10 * (d * 2^-e + r) * 2^e
+ // = buffer * 10^-m + 10^-m * (1/10 * (d + r * 2^e))
+ // = (buffer * 10 + d) * 10^(-m-1) + 10^(-m-1) * r * 2^e
+ //
+ assert(d <= 9);
+ buffer[length++] = static_cast<char>('0' + d); // buffer := buffer * 10 + d
+ //
+ // M+ = buffer * 10^(-m-1) + 10^(-m-1) * r * 2^e
+ //
+ p2 = r;
+ m++;
+ //
+ // M+ = buffer * 10^-m + 10^-m * p2 * 2^e
+ // Invariant restored.
+
+ // Check if enough digits have been generated.
+ //
+ // 10^-m * p2 * 2^e <= delta * 2^e
+ // p2 * 2^e <= 10^m * delta * 2^e
+ // p2 <= 10^m * delta
+ delta *= 10;
+ dist *= 10;
+ if (p2 <= delta)
+ {
+ break;
+ }
+ }
+
+ // V = buffer * 10^-m, with M- <= V <= M+.
+
+ decimal_exponent -= m;
+
+ // 1 ulp in the decimal representation is now 10^-m.
+ // Since delta and dist are now scaled by 10^m, we need to do the
+ // same with ulp in order to keep the units in sync.
+ //
+ // 10^m * 10^-m = 1 = 2^-e * 2^e = ten_m * 2^e
+ //
+ const std::uint64_t ten_m = one.f;
+ grisu2_round(buffer, length, dist, delta, p2, ten_m);
+
+ // By construction this algorithm generates the shortest possible decimal
+ // number (Loitsch, Theorem 6.2) which rounds back to w.
+ // For an input number of precision p, at least
+ //
+ // N = 1 + ceil(p * log_10(2))
+ //
+ // decimal digits are sufficient to identify all binary floating-point
+ // numbers (Matula, "In-and-Out conversions").
+ // This implies that the algorithm does not produce more than N decimal
+ // digits.
+ //
+ // N = 17 for p = 53 (IEEE double precision)
+ // N = 9 for p = 24 (IEEE single precision)
+}
+
+/*!
+v = buf * 10^decimal_exponent
+len is the length of the buffer (number of decimal digits)
+The buffer must be large enough, i.e. >= max_digits10.
+*/
+inline void grisu2(char* buf, int& len, int& decimal_exponent,
+ diyfp m_minus, diyfp v, diyfp m_plus)
+{
+ assert(m_plus.e == m_minus.e);
+ assert(m_plus.e == v.e);
+
+ // --------(-----------------------+-----------------------)-------- (A)
+ // m- v m+
+ //
+ // --------------------(-----------+-----------------------)-------- (B)
+ // m- v m+
+ //
+ // First scale v (and m- and m+) such that the exponent is in the range
+ // [alpha, gamma].
+
+ const cached_power cached = get_cached_power_for_binary_exponent(m_plus.e);
+
+ const diyfp c_minus_k(cached.f, cached.e); // = c ~= 10^-k
+
+ // The exponent of the products is = v.e + c_minus_k.e + q and is in the range [alpha,gamma]
+ const diyfp w = diyfp::mul(v, c_minus_k);
+ const diyfp w_minus = diyfp::mul(m_minus, c_minus_k);
+ const diyfp w_plus = diyfp::mul(m_plus, c_minus_k);
+
+ // ----(---+---)---------------(---+---)---------------(---+---)----
+ // w- w w+
+ // = c*m- = c*v = c*m+
+ //
+ // diyfp::mul rounds its result and c_minus_k is approximated too. w, w- and
+ // w+ are now off by a small amount.
+ // In fact:
+ //
+ // w - v * 10^k < 1 ulp
+ //
+ // To account for this inaccuracy, add resp. subtract 1 ulp.
+ //
+ // --------+---[---------------(---+---)---------------]---+--------
+ // w- M- w M+ w+
+ //
+ // Now any number in [M-, M+] (bounds included) will round to w when input,
+ // regardless of how the input rounding algorithm breaks ties.
+ //
+ // And digit_gen generates the shortest possible such number in [M-, M+].
+ // Note that this does not mean that Grisu2 always generates the shortest
+ // possible number in the interval (m-, m+).
+ const diyfp M_minus(w_minus.f + 1, w_minus.e);
+ const diyfp M_plus (w_plus.f - 1, w_plus.e );
+
+ decimal_exponent = -cached.k; // = -(-k) = k
+
+ grisu2_digit_gen(buf, len, decimal_exponent, M_minus, w, M_plus);
+}
+
+/*!
+v = buf * 10^decimal_exponent
+len is the length of the buffer (number of decimal digits)
+The buffer must be large enough, i.e. >= max_digits10.
+*/
+template <typename FloatType>
+void grisu2(char* buf, int& len, int& decimal_exponent, FloatType value)
+{
+ static_assert(diyfp::kPrecision >= std::numeric_limits<FloatType>::digits + 3,
+ "internal error: not enough precision");
+
+ assert(std::isfinite(value));
+ assert(value > 0);
+
+ // If the neighbors (and boundaries) of 'value' are always computed for double-precision
+ // numbers, all float's can be recovered using strtod (and strtof). However, the resulting
+ // decimal representations are not exactly "short".
+ //
+ // The documentation for 'std::to_chars' (https://en.cppreference.com/w/cpp/utility/to_chars)
+ // says "value is converted to a string as if by std::sprintf in the default ("C") locale"
+ // and since sprintf promotes float's to double's, I think this is exactly what 'std::to_chars'
+ // does.
+ // On the other hand, the documentation for 'std::to_chars' requires that "parsing the
+ // representation using the corresponding std::from_chars function recovers value exactly". That
+ // indicates that single precision floating-point numbers should be recovered using
+ // 'std::strtof'.
+ //
+ // NB: If the neighbors are computed for single-precision numbers, there is a single float
+ // (7.0385307e-26f) which can't be recovered using strtod. The resulting double precision
+ // value is off by 1 ulp.
+#if 0
+ const boundaries w = compute_boundaries(static_cast<double>(value));
+#else
+ const boundaries w = compute_boundaries(value);
+#endif
+
+ grisu2(buf, len, decimal_exponent, w.minus, w.w, w.plus);
+}
+
+/*!
+@brief appends a decimal representation of e to buf
+@return a pointer to the element following the exponent.
+@pre -1000 < e < 1000
+*/
+inline char* append_exponent(char* buf, int e)
+{
+ assert(e > -1000);
+ assert(e < 1000);
+
+ if (e < 0)
+ {
+ e = -e;
+ *buf++ = '-';
+ }
+ else
+ {
+ *buf++ = '+';
+ }
+
+ auto k = static_cast<std::uint32_t>(e);
+ if (k < 10)
+ {
+ // Always print at least two digits in the exponent.
+ // This is for compatibility with printf("%g").
+ *buf++ = '0';
+ *buf++ = static_cast<char>('0' + k);
+ }
+ else if (k < 100)
+ {
+ *buf++ = static_cast<char>('0' + k / 10);
+ k %= 10;
+ *buf++ = static_cast<char>('0' + k);
+ }
+ else
+ {
+ *buf++ = static_cast<char>('0' + k / 100);
+ k %= 100;
+ *buf++ = static_cast<char>('0' + k / 10);
+ k %= 10;
+ *buf++ = static_cast<char>('0' + k);
+ }
+
+ return buf;
+}
+
+/*!
+@brief prettify v = buf * 10^decimal_exponent
+
+If v is in the range [10^min_exp, 10^max_exp) it will be printed in fixed-point
+notation. Otherwise it will be printed in exponential notation.
+
+@pre min_exp < 0
+@pre max_exp > 0
+*/
+inline char* format_buffer(char* buf, int len, int decimal_exponent,
+ int min_exp, int max_exp)
+{
+ assert(min_exp < 0);
+ assert(max_exp > 0);
+
+ const int k = len;
+ const int n = len + decimal_exponent;
+
+ // v = buf * 10^(n-k)
+ // k is the length of the buffer (number of decimal digits)
+ // n is the position of the decimal point relative to the start of the buffer.
+
+ if (k <= n and n <= max_exp)
+ {
+ // digits[000]
+ // len <= max_exp + 2
+
+ std::memset(buf + k, '0', static_cast<size_t>(n - k));
+ // Make it look like a floating-point number (#362, #378)
+ buf[n + 0] = '.';
+ buf[n + 1] = '0';
+ return buf + (n + 2);
+ }
+
+ if (0 < n and n <= max_exp)
+ {
+ // dig.its
+ // len <= max_digits10 + 1
+
+ assert(k > n);
+
+ std::memmove(buf + (n + 1), buf + n, static_cast<size_t>(k - n));
+ buf[n] = '.';
+ return buf + (k + 1);
+ }
+
+ if (min_exp < n and n <= 0)
+ {
+ // 0.[000]digits
+ // len <= 2 + (-min_exp - 1) + max_digits10
+
+ std::memmove(buf + (2 + -n), buf, static_cast<size_t>(k));
+ buf[0] = '0';
+ buf[1] = '.';
+ std::memset(buf + 2, '0', static_cast<size_t>(-n));
+ return buf + (2 + (-n) + k);
+ }
+
+ if (k == 1)
+ {
+ // dE+123
+ // len <= 1 + 5
+
+ buf += 1;
+ }
+ else
+ {
+ // d.igitsE+123
+ // len <= max_digits10 + 1 + 5
+
+ std::memmove(buf + 2, buf + 1, static_cast<size_t>(k - 1));
+ buf[1] = '.';
+ buf += 1 + k;
+ }
+
+ *buf++ = 'e';
+ return append_exponent(buf, n - 1);
+}
+
+} // namespace dtoa_impl
+
+/*!
+@brief generates a decimal representation of the floating-point number value in [first, last).
+
+The format of the resulting decimal representation is similar to printf's %g
+format. Returns an iterator pointing past-the-end of the decimal representation.
+
+@note The input number must be finite, i.e. NaN's and Inf's are not supported.
+@note The buffer must be large enough.
+@note The result is NOT null-terminated.
+*/
+template <typename FloatType>
+char* to_chars(char* first, const char* last, FloatType value)
+{
+ static_cast<void>(last); // maybe unused - fix warning
+ assert(std::isfinite(value));
+
+ // Use signbit(value) instead of (value < 0) since signbit works for -0.
+ if (std::signbit(value))
+ {
+ value = -value;
+ *first++ = '-';
+ }
+
+ if (value == 0) // +-0
+ {
+ *first++ = '0';
+ // Make it look like a floating-point number (#362, #378)
+ *first++ = '.';
+ *first++ = '0';
+ return first;
+ }
+
+ assert(last - first >= std::numeric_limits<FloatType>::max_digits10);
+
+ // Compute v = buffer * 10^decimal_exponent.
+ // The decimal digits are stored in the buffer, which needs to be interpreted
+ // as an unsigned decimal integer.
+ // len is the length of the buffer, i.e. the number of decimal digits.
+ int len = 0;
+ int decimal_exponent = 0;
+ dtoa_impl::grisu2(first, len, decimal_exponent, value);
+
+ assert(len <= std::numeric_limits<FloatType>::max_digits10);
+
+ // Format the buffer like printf("%.*g", prec, value)
+ constexpr int kMinExp = -4;
+ // Use digits10 here to increase compatibility with version 2.
+ constexpr int kMaxExp = std::numeric_limits<FloatType>::digits10;
+
+ assert(last - first >= kMaxExp + 2);
+ assert(last - first >= 2 + (-kMinExp - 1) + std::numeric_limits<FloatType>::max_digits10);
+ assert(last - first >= std::numeric_limits<FloatType>::max_digits10 + 6);
+
+ return dtoa_impl::format_buffer(first, len, decimal_exponent, kMinExp, kMaxExp);
+}
+
+} // namespace detail
+} // namespace nlohmann
+
+// #include <nlohmann/detail/exceptions.hpp>
+
+// #include <nlohmann/detail/macro_scope.hpp>
+
+// #include <nlohmann/detail/meta/cpp_future.hpp>
+
+// #include <nlohmann/detail/output/binary_writer.hpp>
+
+// #include <nlohmann/detail/output/output_adapters.hpp>
+
+// #include <nlohmann/detail/value_t.hpp>
+
+
+namespace nlohmann
+{
+namespace detail
+{
+///////////////////
+// serialization //
+///////////////////
+
+/// how to treat decoding errors
+enum class error_handler_t
+{
+ strict, ///< throw a type_error exception in case of invalid UTF-8
+ replace, ///< replace invalid UTF-8 sequences with U+FFFD
+ ignore ///< ignore invalid UTF-8 sequences
+};
+
+template<typename BasicJsonType>
+class serializer
+{
+ using string_t = typename BasicJsonType::string_t;
+ using number_float_t = typename BasicJsonType::number_float_t;
+ using number_integer_t = typename BasicJsonType::number_integer_t;
+ using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
+ static constexpr std::uint8_t UTF8_ACCEPT = 0;
+ static constexpr std::uint8_t UTF8_REJECT = 1;
+
+ public:
+ /*!
+ @param[in] s output stream to serialize to
+ @param[in] ichar indentation character to use
+ @param[in] error_handler_ how to react on decoding errors
+ */
+ serializer(output_adapter_t<char> s, const char ichar,
+ error_handler_t error_handler_ = error_handler_t::strict)
+ : o(std::move(s))
+ , loc(std::localeconv())
+ , thousands_sep(loc->thousands_sep == nullptr ? '\0' : * (loc->thousands_sep))
+ , decimal_point(loc->decimal_point == nullptr ? '\0' : * (loc->decimal_point))
+ , indent_char(ichar)
+ , indent_string(512, indent_char)
+ , error_handler(error_handler_)
+ {}
+
+ // delete because of pointer members
+ serializer(const serializer&) = delete;
+ serializer& operator=(const serializer&) = delete;
+ serializer(serializer&&) = delete;
+ serializer& operator=(serializer&&) = delete;
+ ~serializer() = default;
+
+ /*!
+ @brief internal implementation of the serialization function
+
+ This function is called by the public member function dump and organizes
+ the serialization internally. The indentation level is propagated as
+ additional parameter. In case of arrays and objects, the function is
+ called recursively.
+
+ - strings and object keys are escaped using `escape_string()`
+ - integer numbers are converted implicitly via `operator<<`
+ - floating-point numbers are converted to a string using `"%g"` format
+
+ @param[in] val value to serialize
+ @param[in] pretty_print whether the output shall be pretty-printed
+ @param[in] indent_step the indent level
+ @param[in] current_indent the current indent level (only used internally)
+ */
+ void dump(const BasicJsonType& val, const bool pretty_print,
+ const bool ensure_ascii,
+ const unsigned int indent_step,
+ const unsigned int current_indent = 0)
+ {
+ switch (val.m_type)
+ {
+ case value_t::object:
+ {
+ if (val.m_value.object->empty())
+ {
+ o->write_characters("{}", 2);
+ return;
+ }
+
+ if (pretty_print)
+ {
+ o->write_characters("{\n", 2);
+
+ // variable to hold indentation for recursive calls
+ const auto new_indent = current_indent + indent_step;
+ if (JSON_UNLIKELY(indent_string.size() < new_indent))
+ {
+ indent_string.resize(indent_string.size() * 2, ' ');
+ }
+
+ // first n-1 elements
+ auto i = val.m_value.object->cbegin();
+ for (std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++i)
+ {
+ o->write_characters(indent_string.c_str(), new_indent);
+ o->write_character('\"');
+ dump_escaped(i->first, ensure_ascii);
+ o->write_characters("\": ", 3);
+ dump(i->second, true, ensure_ascii, indent_step, new_indent);
+ o->write_characters(",\n", 2);
+ }
+
+ // last element
+ assert(i != val.m_value.object->cend());
+ assert(std::next(i) == val.m_value.object->cend());
+ o->write_characters(indent_string.c_str(), new_indent);
+ o->write_character('\"');
+ dump_escaped(i->first, ensure_ascii);
+ o->write_characters("\": ", 3);
+ dump(i->second, true, ensure_ascii, indent_step, new_indent);
+
+ o->write_character('\n');
+ o->write_characters(indent_string.c_str(), current_indent);
+ o->write_character('}');
+ }
+ else
+ {
+ o->write_character('{');
+
+ // first n-1 elements
+ auto i = val.m_value.object->cbegin();
+ for (std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++i)
+ {
+ o->write_character('\"');
+ dump_escaped(i->first, ensure_ascii);
+ o->write_characters("\":", 2);
+ dump(i->second, false, ensure_ascii, indent_step, current_indent);
+ o->write_character(',');
+ }
+
+ // last element
+ assert(i != val.m_value.object->cend());
+ assert(std::next(i) == val.m_value.object->cend());
+ o->write_character('\"');
+ dump_escaped(i->first, ensure_ascii);
+ o->write_characters("\":", 2);
+ dump(i->second, false, ensure_ascii, indent_step, current_indent);
+
+ o->write_character('}');
+ }
+
+ return;
+ }
+
+ case value_t::array:
+ {
+ if (val.m_value.array->empty())
+ {
+ o->write_characters("[]", 2);
+ return;
+ }
+
+ if (pretty_print)
+ {
+ o->write_characters("[\n", 2);
+
+ // variable to hold indentation for recursive calls
+ const auto new_indent = current_indent + indent_step;
+ if (JSON_UNLIKELY(indent_string.size() < new_indent))
+ {
+ indent_string.resize(indent_string.size() * 2, ' ');
+ }
+
+ // first n-1 elements
+ for (auto i = val.m_value.array->cbegin();
+ i != val.m_value.array->cend() - 1; ++i)
+ {
+ o->write_characters(indent_string.c_str(), new_indent);
+ dump(*i, true, ensure_ascii, indent_step, new_indent);
+ o->write_characters(",\n", 2);
+ }
+
+ // last element
+ assert(not val.m_value.array->empty());
+ o->write_characters(indent_string.c_str(), new_indent);
+ dump(val.m_value.array->back(), true, ensure_ascii, indent_step, new_indent);
+
+ o->write_character('\n');
+ o->write_characters(indent_string.c_str(), current_indent);
+ o->write_character(']');
+ }
+ else
+ {
+ o->write_character('[');
+
+ // first n-1 elements
+ for (auto i = val.m_value.array->cbegin();
+ i != val.m_value.array->cend() - 1; ++i)
+ {
+ dump(*i, false, ensure_ascii, indent_step, current_indent);
+ o->write_character(',');
+ }
+
+ // last element
+ assert(not val.m_value.array->empty());
+ dump(val.m_value.array->back(), false, ensure_ascii, indent_step, current_indent);
+
+ o->write_character(']');
+ }
+
+ return;
+ }
+
+ case value_t::string:
+ {
+ o->write_character('\"');
+ dump_escaped(*val.m_value.string, ensure_ascii);
+ o->write_character('\"');
+ return;
+ }
+
+ case value_t::boolean:
+ {
+ if (val.m_value.boolean)
+ {
+ o->write_characters("true", 4);
+ }
+ else
+ {
+ o->write_characters("false", 5);
+ }
+ return;
+ }
+
+ case value_t::number_integer:
+ {
+ dump_integer(val.m_value.number_integer);
+ return;
+ }
+
+ case value_t::number_unsigned:
+ {
+ dump_integer(val.m_value.number_unsigned);
+ return;
+ }
+
+ case value_t::number_float:
+ {
+ dump_float(val.m_value.number_float);
+ return;
+ }
+
+ case value_t::discarded:
+ {
+ o->write_characters("<discarded>", 11);
+ return;
+ }
+
+ case value_t::null:
+ {
+ o->write_characters("null", 4);
+ return;
+ }
+
+ default: // LCOV_EXCL_LINE
+ assert(false); // LCOV_EXCL_LINE
+ }
+ }
+
+ private:
+ /*!
+ @brief dump escaped string
+
+ Escape a string by replacing certain special characters by a sequence of an
+ escape character (backslash) and another character and other control
+ characters by a sequence of "\u" followed by a four-digit hex
+ representation. The escaped string is written to output stream @a o.
+
+ @param[in] s the string to escape
+ @param[in] ensure_ascii whether to escape non-ASCII characters with
+ \uXXXX sequences
+
+ @complexity Linear in the length of string @a s.
+ */
+ void dump_escaped(const string_t& s, const bool ensure_ascii)
+ {
+ std::uint32_t codepoint;
+ std::uint8_t state = UTF8_ACCEPT;
+ std::size_t bytes = 0; // number of bytes written to string_buffer
+
+ // number of bytes written at the point of the last valid byte
+ std::size_t bytes_after_last_accept = 0;
+ std::size_t undumped_chars = 0;
+
+ for (std::size_t i = 0; i < s.size(); ++i)
+ {
+ const auto byte = static_cast<uint8_t>(s[i]);
+
+ switch (decode(state, codepoint, byte))
+ {
+ case UTF8_ACCEPT: // decode found a new code point
+ {
+ switch (codepoint)
+ {
+ case 0x08: // backspace
+ {
+ string_buffer[bytes++] = '\\';
+ string_buffer[bytes++] = 'b';
+ break;
+ }
+
+ case 0x09: // horizontal tab
+ {
+ string_buffer[bytes++] = '\\';
+ string_buffer[bytes++] = 't';
+ break;
+ }
+
+ case 0x0A: // newline
+ {
+ string_buffer[bytes++] = '\\';
+ string_buffer[bytes++] = 'n';
+ break;
+ }
+
+ case 0x0C: // formfeed
+ {
+ string_buffer[bytes++] = '\\';
+ string_buffer[bytes++] = 'f';
+ break;
+ }
+
+ case 0x0D: // carriage return
+ {
+ string_buffer[bytes++] = '\\';
+ string_buffer[bytes++] = 'r';
+ break;
+ }
+
+ case 0x22: // quotation mark
+ {
+ string_buffer[bytes++] = '\\';
+ string_buffer[bytes++] = '\"';
+ break;
+ }
+
+ case 0x5C: // reverse solidus
+ {
+ string_buffer[bytes++] = '\\';
+ string_buffer[bytes++] = '\\';
+ break;
+ }
+
+ default:
+ {
+ // escape control characters (0x00..0x1F) or, if
+ // ensure_ascii parameter is used, non-ASCII characters
+ if ((codepoint <= 0x1F) or (ensure_ascii and (codepoint >= 0x7F)))
+ {
+ if (codepoint <= 0xFFFF)
+ {
+ (std::snprintf)(string_buffer.data() + bytes, 7, "\\u%04x",
+ static_cast<std::uint16_t>(codepoint));
+ bytes += 6;
+ }
+ else
+ {
+ (std::snprintf)(string_buffer.data() + bytes, 13, "\\u%04x\\u%04x",
+ static_cast<std::uint16_t>(0xD7C0u + (codepoint >> 10u)),
+ static_cast<std::uint16_t>(0xDC00u + (codepoint & 0x3FFu)));
+ bytes += 12;
+ }
+ }
+ else
+ {
+ // copy byte to buffer (all previous bytes
+ // been copied have in default case above)
+ string_buffer[bytes++] = s[i];
+ }
+ break;
+ }
+ }
+
+ // write buffer and reset index; there must be 13 bytes
+ // left, as this is the maximal number of bytes to be
+ // written ("\uxxxx\uxxxx\0") for one code point
+ if (string_buffer.size() - bytes < 13)
+ {
+ o->write_characters(string_buffer.data(), bytes);
+ bytes = 0;
+ }
+
+ // remember the byte position of this accept
+ bytes_after_last_accept = bytes;
+ undumped_chars = 0;
+ break;
+ }
+
+ case UTF8_REJECT: // decode found invalid UTF-8 byte
+ {
+ switch (error_handler)
+ {
+ case error_handler_t::strict:
+ {
+ std::string sn(3, '\0');
+ (std::snprintf)(&sn[0], sn.size(), "%.2X", byte);
+ JSON_THROW(type_error::create(316, "invalid UTF-8 byte at index " + std::to_string(i) + ": 0x" + sn));
+ }
+
+ case error_handler_t::ignore:
+ case error_handler_t::replace:
+ {
+ // in case we saw this character the first time, we
+ // would like to read it again, because the byte
+ // may be OK for itself, but just not OK for the
+ // previous sequence
+ if (undumped_chars > 0)
+ {
+ --i;
+ }
+
+ // reset length buffer to the last accepted index;
+ // thus removing/ignoring the invalid characters
+ bytes = bytes_after_last_accept;
+
+ if (error_handler == error_handler_t::replace)
+ {
+ // add a replacement character
+ if (ensure_ascii)
+ {
+ string_buffer[bytes++] = '\\';
+ string_buffer[bytes++] = 'u';
+ string_buffer[bytes++] = 'f';
+ string_buffer[bytes++] = 'f';
+ string_buffer[bytes++] = 'f';
+ string_buffer[bytes++] = 'd';
+ }
+ else
+ {
+ string_buffer[bytes++] = detail::binary_writer<BasicJsonType, char>::to_char_type('\xEF');
+ string_buffer[bytes++] = detail::binary_writer<BasicJsonType, char>::to_char_type('\xBF');
+ string_buffer[bytes++] = detail::binary_writer<BasicJsonType, char>::to_char_type('\xBD');
+ }
+
+ // write buffer and reset index; there must be 13 bytes
+ // left, as this is the maximal number of bytes to be
+ // written ("\uxxxx\uxxxx\0") for one code point
+ if (string_buffer.size() - bytes < 13)
+ {
+ o->write_characters(string_buffer.data(), bytes);
+ bytes = 0;
+ }
+
+ bytes_after_last_accept = bytes;
+ }
+
+ undumped_chars = 0;
+
+ // continue processing the string
+ state = UTF8_ACCEPT;
+ break;
+ }
+
+ default: // LCOV_EXCL_LINE
+ assert(false); // LCOV_EXCL_LINE
+ }
+ break;
+ }
+
+ default: // decode found yet incomplete multi-byte code point
+ {
+ if (not ensure_ascii)
+ {
+ // code point will not be escaped - copy byte to buffer
+ string_buffer[bytes++] = s[i];
+ }
+ ++undumped_chars;
+ break;
+ }
+ }
+ }
+
+ // we finished processing the string
+ if (JSON_LIKELY(state == UTF8_ACCEPT))
+ {
+ // write buffer
+ if (bytes > 0)
+ {
+ o->write_characters(string_buffer.data(), bytes);
+ }
+ }
+ else
+ {
+ // we finish reading, but do not accept: string was incomplete
+ switch (error_handler)
+ {
+ case error_handler_t::strict:
+ {
+ std::string sn(3, '\0');
+ (std::snprintf)(&sn[0], sn.size(), "%.2X", static_cast<std::uint8_t>(s.back()));
+ JSON_THROW(type_error::create(316, "incomplete UTF-8 string; last byte: 0x" + sn));
+ }
+
+ case error_handler_t::ignore:
+ {
+ // write all accepted bytes
+ o->write_characters(string_buffer.data(), bytes_after_last_accept);
+ break;
+ }
+
+ case error_handler_t::replace:
+ {
+ // write all accepted bytes
+ o->write_characters(string_buffer.data(), bytes_after_last_accept);
+ // add a replacement character
+ if (ensure_ascii)
+ {
+ o->write_characters("\\ufffd", 6);
+ }
+ else
+ {
+ o->write_characters("\xEF\xBF\xBD", 3);
+ }
+ break;
+ }
+
+ default: // LCOV_EXCL_LINE
+ assert(false); // LCOV_EXCL_LINE
+ }
+ }
+ }
+
+ /*!
+ @brief count digits
+
+ Count the number of decimal (base 10) digits for an input unsigned integer.
+
+ @param[in] x unsigned integer number to count its digits
+ @return number of decimal digits
+ */
+ inline unsigned int count_digits(number_unsigned_t x) noexcept
+ {
+ unsigned int n_digits = 1;
+ for (;;)
+ {
+ if (x < 10)
+ {
+ return n_digits;
+ }
+ if (x < 100)
+ {
+ return n_digits + 1;
+ }
+ if (x < 1000)
+ {
+ return n_digits + 2;
+ }
+ if (x < 10000)
+ {
+ return n_digits + 3;
+ }
+ x = x / 10000u;
+ n_digits += 4;
+ }
+ }
+
+ /*!
+ @brief dump an integer
+
+ Dump a given integer to output stream @a o. Works internally with
+ @a number_buffer.
+
+ @param[in] x integer number (signed or unsigned) to dump
+ @tparam NumberType either @a number_integer_t or @a number_unsigned_t
+ */
+ template<typename NumberType, detail::enable_if_t<
+ std::is_same<NumberType, number_unsigned_t>::value or
+ std::is_same<NumberType, number_integer_t>::value,
+ int> = 0>
+ void dump_integer(NumberType x)
+ {
+ static constexpr std::array<std::array<char, 2>, 100> digits_to_99
+ {
+ {
+ {{'0', '0'}}, {{'0', '1'}}, {{'0', '2'}}, {{'0', '3'}}, {{'0', '4'}}, {{'0', '5'}}, {{'0', '6'}}, {{'0', '7'}}, {{'0', '8'}}, {{'0', '9'}},
+ {{'1', '0'}}, {{'1', '1'}}, {{'1', '2'}}, {{'1', '3'}}, {{'1', '4'}}, {{'1', '5'}}, {{'1', '6'}}, {{'1', '7'}}, {{'1', '8'}}, {{'1', '9'}},
+ {{'2', '0'}}, {{'2', '1'}}, {{'2', '2'}}, {{'2', '3'}}, {{'2', '4'}}, {{'2', '5'}}, {{'2', '6'}}, {{'2', '7'}}, {{'2', '8'}}, {{'2', '9'}},
+ {{'3', '0'}}, {{'3', '1'}}, {{'3', '2'}}, {{'3', '3'}}, {{'3', '4'}}, {{'3', '5'}}, {{'3', '6'}}, {{'3', '7'}}, {{'3', '8'}}, {{'3', '9'}},
+ {{'4', '0'}}, {{'4', '1'}}, {{'4', '2'}}, {{'4', '3'}}, {{'4', '4'}}, {{'4', '5'}}, {{'4', '6'}}, {{'4', '7'}}, {{'4', '8'}}, {{'4', '9'}},
+ {{'5', '0'}}, {{'5', '1'}}, {{'5', '2'}}, {{'5', '3'}}, {{'5', '4'}}, {{'5', '5'}}, {{'5', '6'}}, {{'5', '7'}}, {{'5', '8'}}, {{'5', '9'}},
+ {{'6', '0'}}, {{'6', '1'}}, {{'6', '2'}}, {{'6', '3'}}, {{'6', '4'}}, {{'6', '5'}}, {{'6', '6'}}, {{'6', '7'}}, {{'6', '8'}}, {{'6', '9'}},
+ {{'7', '0'}}, {{'7', '1'}}, {{'7', '2'}}, {{'7', '3'}}, {{'7', '4'}}, {{'7', '5'}}, {{'7', '6'}}, {{'7', '7'}}, {{'7', '8'}}, {{'7', '9'}},
+ {{'8', '0'}}, {{'8', '1'}}, {{'8', '2'}}, {{'8', '3'}}, {{'8', '4'}}, {{'8', '5'}}, {{'8', '6'}}, {{'8', '7'}}, {{'8', '8'}}, {{'8', '9'}},
+ {{'9', '0'}}, {{'9', '1'}}, {{'9', '2'}}, {{'9', '3'}}, {{'9', '4'}}, {{'9', '5'}}, {{'9', '6'}}, {{'9', '7'}}, {{'9', '8'}}, {{'9', '9'}},
+ }
+ };
+
+ // special case for "0"
+ if (x == 0)
+ {
+ o->write_character('0');
+ return;
+ }
+
+ // use a pointer to fill the buffer
+ auto buffer_ptr = number_buffer.begin();
+
+ const bool is_negative = std::is_same<NumberType, number_integer_t>::value and not(x >= 0); // see issue #755
+ number_unsigned_t abs_value;
+
+ unsigned int n_chars;
+
+ if (is_negative)
+ {
+ *buffer_ptr = '-';
+ abs_value = static_cast<number_unsigned_t>(std::abs(static_cast<std::intmax_t>(x)));
+
+ // account one more byte for the minus sign
+ n_chars = 1 + count_digits(abs_value);
+ }
+ else
+ {
+ abs_value = static_cast<number_unsigned_t>(x);
+ n_chars = count_digits(abs_value);
+ }
+
+ // spare 1 byte for '\0'
+ assert(n_chars < number_buffer.size() - 1);
+
+ // jump to the end to generate the string from backward
+ // so we later avoid reversing the result
+ buffer_ptr += n_chars;
+
+ // Fast int2ascii implementation inspired by "Fastware" talk by Andrei Alexandrescu
+ // See: https://www.youtube.com/watch?v=o4-CwDo2zpg
+ while (abs_value >= 100)
+ {
+ const auto digits_index = static_cast<unsigned>((abs_value % 100));
+ abs_value /= 100;
+ *(--buffer_ptr) = digits_to_99[digits_index][1];
+ *(--buffer_ptr) = digits_to_99[digits_index][0];
+ }
+
+ if (abs_value >= 10)
+ {
+ const auto digits_index = static_cast<unsigned>(abs_value);
+ *(--buffer_ptr) = digits_to_99[digits_index][1];
+ *(--buffer_ptr) = digits_to_99[digits_index][0];
+ }
+ else
+ {
+ *(--buffer_ptr) = static_cast<char>('0' + abs_value);
+ }
+
+ o->write_characters(number_buffer.data(), n_chars);
+ }
+
+ /*!
+ @brief dump a floating-point number
+
+ Dump a given floating-point number to output stream @a o. Works internally
+ with @a number_buffer.
+
+ @param[in] x floating-point number to dump
+ */
+ void dump_float(number_float_t x)
+ {
+ // NaN / inf
+ if (not std::isfinite(x))
+ {
+ o->write_characters("null", 4);
+ return;
+ }
+
+ // If number_float_t is an IEEE-754 single or double precision number,
+ // use the Grisu2 algorithm to produce short numbers which are
+ // guaranteed to round-trip, using strtof and strtod, resp.
+ //
+ // NB: The test below works if <long double> == <double>.
+ static constexpr bool is_ieee_single_or_double
+ = (std::numeric_limits<number_float_t>::is_iec559 and std::numeric_limits<number_float_t>::digits == 24 and std::numeric_limits<number_float_t>::max_exponent == 128) or
+ (std::numeric_limits<number_float_t>::is_iec559 and std::numeric_limits<number_float_t>::digits == 53 and std::numeric_limits<number_float_t>::max_exponent == 1024);
+
+ dump_float(x, std::integral_constant<bool, is_ieee_single_or_double>());
+ }
+
+ void dump_float(number_float_t x, std::true_type /*is_ieee_single_or_double*/)
+ {
+ char* begin = number_buffer.data();
+ char* end = ::nlohmann::detail::to_chars(begin, begin + number_buffer.size(), x);
+
+ o->write_characters(begin, static_cast<size_t>(end - begin));
+ }
+
+ void dump_float(number_float_t x, std::false_type /*is_ieee_single_or_double*/)
+ {
+ // get number of digits for a float -> text -> float round-trip
+ static constexpr auto d = std::numeric_limits<number_float_t>::max_digits10;
+
+ // the actual conversion
+ std::ptrdiff_t len = (std::snprintf)(number_buffer.data(), number_buffer.size(), "%.*g", d, x);
+
+ // negative value indicates an error
+ assert(len > 0);
+ // check if buffer was large enough
+ assert(static_cast<std::size_t>(len) < number_buffer.size());
+
+ // erase thousands separator
+ if (thousands_sep != '\0')
+ {
+ const auto end = std::remove(number_buffer.begin(),
+ number_buffer.begin() + len, thousands_sep);
+ std::fill(end, number_buffer.end(), '\0');
+ assert((end - number_buffer.begin()) <= len);
+ len = (end - number_buffer.begin());
+ }
+
+ // convert decimal point to '.'
+ if (decimal_point != '\0' and decimal_point != '.')
+ {
+ const auto dec_pos = std::find(number_buffer.begin(), number_buffer.end(), decimal_point);
+ if (dec_pos != number_buffer.end())
+ {
+ *dec_pos = '.';
+ }
+ }
+
+ o->write_characters(number_buffer.data(), static_cast<std::size_t>(len));
+
+ // determine if need to append ".0"
+ const bool value_is_int_like =
+ std::none_of(number_buffer.begin(), number_buffer.begin() + len + 1,
+ [](char c)
+ {
+ return c == '.' or c == 'e';
+ });
+
+ if (value_is_int_like)
+ {
+ o->write_characters(".0", 2);
+ }
+ }
+
+ /*!
+ @brief check whether a string is UTF-8 encoded
+
+ The function checks each byte of a string whether it is UTF-8 encoded. The
+ result of the check is stored in the @a state parameter. The function must
+ be called initially with state 0 (accept). State 1 means the string must
+ be rejected, because the current byte is not allowed. If the string is
+ completely processed, but the state is non-zero, the string ended
+ prematurely; that is, the last byte indicated more bytes should have
+ followed.
+
+ @param[in,out] state the state of the decoding
+ @param[in,out] codep codepoint (valid only if resulting state is UTF8_ACCEPT)
+ @param[in] byte next byte to decode
+ @return new state
+
+ @note The function has been edited: a std::array is used.
+
+ @copyright Copyright (c) 2008-2009 Bjoern Hoehrmann <bjoern@hoehrmann.de>
+ @sa http://bjoern.hoehrmann.de/utf-8/decoder/dfa/
+ */
+ static std::uint8_t decode(std::uint8_t& state, std::uint32_t& codep, const std::uint8_t byte) noexcept
+ {
+ static const std::array<std::uint8_t, 400> utf8d =
+ {
+ {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 00..1F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 20..3F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 40..5F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 60..7F
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, // 80..9F
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // A0..BF
+ 8, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // C0..DF
+ 0xA, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, 0x3, // E0..EF
+ 0xB, 0x6, 0x6, 0x6, 0x5, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, // F0..FF
+ 0x0, 0x1, 0x2, 0x3, 0x5, 0x8, 0x7, 0x1, 0x1, 0x1, 0x4, 0x6, 0x1, 0x1, 0x1, 0x1, // s0..s0
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, // s1..s2
+ 1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, // s3..s4
+ 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, // s5..s6
+ 1, 3, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // s7..s8
+ }
+ };
+
+ const std::uint8_t type = utf8d[byte];
+
+ codep = (state != UTF8_ACCEPT)
+ ? (byte & 0x3fu) | (codep << 6u)
+ : (0xFFu >> type) & (byte);
+
+ state = utf8d[256u + state * 16u + type];
+ return state;
+ }
+
+ private:
+ /// the output of the serializer
+ output_adapter_t<char> o = nullptr;
+
+ /// a (hopefully) large enough character buffer
+ std::array<char, 64> number_buffer{{}};
+
+ /// the locale
+ const std::lconv* loc = nullptr;
+ /// the locale's thousand separator character
+ const char thousands_sep = '\0';
+ /// the locale's decimal point character
+ const char decimal_point = '\0';
+
+ /// string buffer
+ std::array<char, 512> string_buffer{{}};
+
+ /// the indentation character
+ const char indent_char;
+ /// the indentation string
+ string_t indent_string;
+
+ /// error_handler how to react on decoding errors
+ const error_handler_t error_handler;
+};
+} // namespace detail
+} // namespace nlohmann
+
+// #include <nlohmann/detail/value_t.hpp>
+
+// #include <nlohmann/json_fwd.hpp>
+
+
+/*!
+@brief namespace for Niels Lohmann
+@see https://github.com/nlohmann
+@since version 1.0.0
+*/
+namespace nlohmann
+{
+
+/*!
+@brief a class to store JSON values
+
+@tparam ObjectType type for JSON objects (`std::map` by default; will be used
+in @ref object_t)
+@tparam ArrayType type for JSON arrays (`std::vector` by default; will be used
+in @ref array_t)
+@tparam StringType type for JSON strings and object keys (`std::string` by
+default; will be used in @ref string_t)
+@tparam BooleanType type for JSON booleans (`bool` by default; will be used
+in @ref boolean_t)
+@tparam NumberIntegerType type for JSON integer numbers (`int64_t` by
+default; will be used in @ref number_integer_t)
+@tparam NumberUnsignedType type for JSON unsigned integer numbers (@c
+`uint64_t` by default; will be used in @ref number_unsigned_t)
+@tparam NumberFloatType type for JSON floating-point numbers (`double` by
+default; will be used in @ref number_float_t)
+@tparam AllocatorType type of the allocator to use (`std::allocator` by
+default)
+@tparam JSONSerializer the serializer to resolve internal calls to `to_json()`
+and `from_json()` (@ref adl_serializer by default)
+
+@requirement The class satisfies the following concept requirements:
+- Basic
+ - [DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible):
+ JSON values can be default constructed. The result will be a JSON null
+ value.
+ - [MoveConstructible](https://en.cppreference.com/w/cpp/named_req/MoveConstructible):
+ A JSON value can be constructed from an rvalue argument.
+ - [CopyConstructible](https://en.cppreference.com/w/cpp/named_req/CopyConstructible):
+ A JSON value can be copy-constructed from an lvalue expression.
+ - [MoveAssignable](https://en.cppreference.com/w/cpp/named_req/MoveAssignable):
+ A JSON value van be assigned from an rvalue argument.
+ - [CopyAssignable](https://en.cppreference.com/w/cpp/named_req/CopyAssignable):
+ A JSON value can be copy-assigned from an lvalue expression.
+ - [Destructible](https://en.cppreference.com/w/cpp/named_req/Destructible):
+ JSON values can be destructed.
+- Layout
+ - [StandardLayoutType](https://en.cppreference.com/w/cpp/named_req/StandardLayoutType):
+ JSON values have
+ [standard layout](https://en.cppreference.com/w/cpp/language/data_members#Standard_layout):
+ All non-static data members are private and standard layout types, the
+ class has no virtual functions or (virtual) base classes.
+- Library-wide
+ - [EqualityComparable](https://en.cppreference.com/w/cpp/named_req/EqualityComparable):
+ JSON values can be compared with `==`, see @ref
+ operator==(const_reference,const_reference).
+ - [LessThanComparable](https://en.cppreference.com/w/cpp/named_req/LessThanComparable):
+ JSON values can be compared with `<`, see @ref
+ operator<(const_reference,const_reference).
+ - [Swappable](https://en.cppreference.com/w/cpp/named_req/Swappable):
+ Any JSON lvalue or rvalue of can be swapped with any lvalue or rvalue of
+ other compatible types, using unqualified function call @ref swap().
+ - [NullablePointer](https://en.cppreference.com/w/cpp/named_req/NullablePointer):
+ JSON values can be compared against `std::nullptr_t` objects which are used
+ to model the `null` value.
+- Container
+ - [Container](https://en.cppreference.com/w/cpp/named_req/Container):
+ JSON values can be used like STL containers and provide iterator access.
+ - [ReversibleContainer](https://en.cppreference.com/w/cpp/named_req/ReversibleContainer);
+ JSON values can be used like STL containers and provide reverse iterator
+ access.
+
+@invariant The member variables @a m_value and @a m_type have the following
+relationship:
+- If `m_type == value_t::object`, then `m_value.object != nullptr`.
+- If `m_type == value_t::array`, then `m_value.array != nullptr`.
+- If `m_type == value_t::string`, then `m_value.string != nullptr`.
+The invariants are checked by member function assert_invariant().
+
+@internal
+@note ObjectType trick from http://stackoverflow.com/a/9860911
+@endinternal
+
+@see [RFC 7159: The JavaScript Object Notation (JSON) Data Interchange
+Format](http://rfc7159.net/rfc7159)
+
+@since version 1.0.0
+
+@nosubgrouping
+*/
+NLOHMANN_BASIC_JSON_TPL_DECLARATION
+class basic_json
+{
+ private:
+ template<detail::value_t> friend struct detail::external_constructor;
+ friend ::nlohmann::json_pointer<basic_json>;
+ friend ::nlohmann::detail::parser<basic_json>;
+ friend ::nlohmann::detail::serializer<basic_json>;
+ template<typename BasicJsonType>
+ friend class ::nlohmann::detail::iter_impl;
+ template<typename BasicJsonType, typename CharType>
+ friend class ::nlohmann::detail::binary_writer;
+ template<typename BasicJsonType, typename SAX>
+ friend class ::nlohmann::detail::binary_reader;
+ template<typename BasicJsonType>
+ friend class ::nlohmann::detail::json_sax_dom_parser;
+ template<typename BasicJsonType>
+ friend class ::nlohmann::detail::json_sax_dom_callback_parser;
+
+ /// workaround type for MSVC
+ using basic_json_t = NLOHMANN_BASIC_JSON_TPL;
+
+ // convenience aliases for types residing in namespace detail;
+ using lexer = ::nlohmann::detail::lexer<basic_json>;
+ using parser = ::nlohmann::detail::parser<basic_json>;
+
+ using primitive_iterator_t = ::nlohmann::detail::primitive_iterator_t;
+ template<typename BasicJsonType>
+ using internal_iterator = ::nlohmann::detail::internal_iterator<BasicJsonType>;
+ template<typename BasicJsonType>
+ using iter_impl = ::nlohmann::detail::iter_impl<BasicJsonType>;
+ template<typename Iterator>
+ using iteration_proxy = ::nlohmann::detail::iteration_proxy<Iterator>;
+ template<typename Base> using json_reverse_iterator = ::nlohmann::detail::json_reverse_iterator<Base>;
+
+ template<typename CharType>
+ using output_adapter_t = ::nlohmann::detail::output_adapter_t<CharType>;
+
+ using binary_reader = ::nlohmann::detail::binary_reader<basic_json>;
+ template<typename CharType> using binary_writer = ::nlohmann::detail::binary_writer<basic_json, CharType>;
+
+ using serializer = ::nlohmann::detail::serializer<basic_json>;
+
+ public:
+ using value_t = detail::value_t;
+ /// JSON Pointer, see @ref nlohmann::json_pointer
+ using json_pointer = ::nlohmann::json_pointer<basic_json>;
+ template<typename T, typename SFINAE>
+ using json_serializer = JSONSerializer<T, SFINAE>;
+ /// how to treat decoding errors
+ using error_handler_t = detail::error_handler_t;
+ /// helper type for initializer lists of basic_json values
+ using initializer_list_t = std::initializer_list<detail::json_ref<basic_json>>;
+
+ using input_format_t = detail::input_format_t;
+ /// SAX interface type, see @ref nlohmann::json_sax
+ using json_sax_t = json_sax<basic_json>;
+
+ ////////////////
+ // exceptions //
+ ////////////////
+
+ /// @name exceptions
+ /// Classes to implement user-defined exceptions.
+ /// @{
+
+ /// @copydoc detail::exception
+ using exception = detail::exception;
+ /// @copydoc detail::parse_error
+ using parse_error = detail::parse_error;
+ /// @copydoc detail::invalid_iterator
+ using invalid_iterator = detail::invalid_iterator;
+ /// @copydoc detail::type_error
+ using type_error = detail::type_error;
+ /// @copydoc detail::out_of_range
+ using out_of_range = detail::out_of_range;
+ /// @copydoc detail::other_error
+ using other_error = detail::other_error;
+
+ /// @}
+
+
+ /////////////////////
+ // container types //
+ /////////////////////
+
+ /// @name container types
+ /// The canonic container types to use @ref basic_json like any other STL
+ /// container.
+ /// @{
+
+ /// the type of elements in a basic_json container
+ using value_type = basic_json;
+
+ /// the type of an element reference
+ using reference = value_type&;
+ /// the type of an element const reference
+ using const_reference = const value_type&;
+
+ /// a type to represent differences between iterators
+ using difference_type = std::ptrdiff_t;
+ /// a type to represent container sizes
+ using size_type = std::size_t;
+
+ /// the allocator type
+ using allocator_type = AllocatorType<basic_json>;
+
+ /// the type of an element pointer
+ using pointer = typename std::allocator_traits<allocator_type>::pointer;
+ /// the type of an element const pointer
+ using const_pointer = typename std::allocator_traits<allocator_type>::const_pointer;
+
+ /// an iterator for a basic_json container
+ using iterator = iter_impl<basic_json>;
+ /// a const iterator for a basic_json container
+ using const_iterator = iter_impl<const basic_json>;
+ /// a reverse iterator for a basic_json container
+ using reverse_iterator = json_reverse_iterator<typename basic_json::iterator>;
+ /// a const reverse iterator for a basic_json container
+ using const_reverse_iterator = json_reverse_iterator<typename basic_json::const_iterator>;
+
+ /// @}
+
+
+ /*!
+ @brief returns the allocator associated with the container
+ */
+ static allocator_type get_allocator()
+ {
+ return allocator_type();
+ }
+
+ /*!
+ @brief returns version information on the library
+
+ This function returns a JSON object with information about the library,
+ including the version number and information on the platform and compiler.
+
+ @return JSON object holding version information
+ key | description
+ ----------- | ---------------
+ `compiler` | Information on the used compiler. It is an object with the following keys: `c++` (the used C++ standard), `family` (the compiler family; possible values are `clang`, `icc`, `gcc`, `ilecpp`, `msvc`, `pgcpp`, `sunpro`, and `unknown`), and `version` (the compiler version).
+ `copyright` | The copyright line for the library as string.
+ `name` | The name of the library as string.
+ `platform` | The used platform as string. Possible values are `win32`, `linux`, `apple`, `unix`, and `unknown`.
+ `url` | The URL of the project as string.
+ `version` | The version of the library. It is an object with the following keys: `major`, `minor`, and `patch` as defined by [Semantic Versioning](http://semver.org), and `string` (the version string).
+
+ @liveexample{The following code shows an example output of the `meta()`
+ function.,meta}
+
+ @exceptionsafety Strong guarantee: if an exception is thrown, there are no
+ changes to any JSON value.
+
+ @complexity Constant.
+
+ @since 2.1.0
+ */
+ JSON_NODISCARD
+ static basic_json meta()
+ {
+ basic_json result;
+
+ result["copyright"] = "(C) 2013-2017 Niels Lohmann";
+ result["name"] = "JSON for Modern C++";
+ result["url"] = "https://github.com/nlohmann/json";
+ result["version"]["string"] =
+ std::to_string(NLOHMANN_JSON_VERSION_MAJOR) + "." +
+ std::to_string(NLOHMANN_JSON_VERSION_MINOR) + "." +
+ std::to_string(NLOHMANN_JSON_VERSION_PATCH);
+ result["version"]["major"] = NLOHMANN_JSON_VERSION_MAJOR;
+ result["version"]["minor"] = NLOHMANN_JSON_VERSION_MINOR;
+ result["version"]["patch"] = NLOHMANN_JSON_VERSION_PATCH;
+
+#ifdef _WIN32
+ result["platform"] = "win32";
+#elif defined __linux__
+ result["platform"] = "linux";
+#elif defined __APPLE__
+ result["platform"] = "apple";
+#elif defined __unix__
+ result["platform"] = "unix";
+#else
+ result["platform"] = "unknown";
+#endif
+
+#if defined(__ICC) || defined(__INTEL_COMPILER)
+ result["compiler"] = {{"family", "icc"}, {"version", __INTEL_COMPILER}};
+#elif defined(__clang__)
+ result["compiler"] = {{"family", "clang"}, {"version", __clang_version__}};
+#elif defined(__GNUC__) || defined(__GNUG__)
+ result["compiler"] = {{"family", "gcc"}, {"version", std::to_string(__GNUC__) + "." + std::to_string(__GNUC_MINOR__) + "." + std::to_string(__GNUC_PATCHLEVEL__)}};
+#elif defined(__HP_cc) || defined(__HP_aCC)
+ result["compiler"] = "hp"
+#elif defined(__IBMCPP__)
+ result["compiler"] = {{"family", "ilecpp"}, {"version", __IBMCPP__}};
+#elif defined(_MSC_VER)
+ result["compiler"] = {{"family", "msvc"}, {"version", _MSC_VER}};
+#elif defined(__PGI)
+ result["compiler"] = {{"family", "pgcpp"}, {"version", __PGI}};
+#elif defined(__SUNPRO_CC)
+ result["compiler"] = {{"family", "sunpro"}, {"version", __SUNPRO_CC}};
+#else
+ result["compiler"] = {{"family", "unknown"}, {"version", "unknown"}};
+#endif
+
+#ifdef __cplusplus
+ result["compiler"]["c++"] = std::to_string(__cplusplus);
+#else
+ result["compiler"]["c++"] = "unknown";
+#endif
+ return result;
+ }
+
+
+ ///////////////////////////
+ // JSON value data types //
+ ///////////////////////////
+
+ /// @name JSON value data types
+ /// The data types to store a JSON value. These types are derived from
+ /// the template arguments passed to class @ref basic_json.
+ /// @{
+
+#if defined(JSON_HAS_CPP_14)
+ // Use transparent comparator if possible, combined with perfect forwarding
+ // on find() and count() calls prevents unnecessary string construction.
+ using object_comparator_t = std::less<>;
+#else
+ using object_comparator_t = std::less<StringType>;
+#endif
+
+ /*!
+ @brief a type for an object
+
+ [RFC 7159](http://rfc7159.net/rfc7159) describes JSON objects as follows:
+ > An object is an unordered collection of zero or more name/value pairs,
+ > where a name is a string and a value is a string, number, boolean, null,
+ > object, or array.
+
+ To store objects in C++, a type is defined by the template parameters
+ described below.
+
+ @tparam ObjectType the container to store objects (e.g., `std::map` or
+ `std::unordered_map`)
+ @tparam StringType the type of the keys or names (e.g., `std::string`).
+ The comparison function `std::less<StringType>` is used to order elements
+ inside the container.
+ @tparam AllocatorType the allocator to use for objects (e.g.,
+ `std::allocator`)
+
+ #### Default type
+
+ With the default values for @a ObjectType (`std::map`), @a StringType
+ (`std::string`), and @a AllocatorType (`std::allocator`), the default
+ value for @a object_t is:
+
+ @code {.cpp}
+ std::map<
+ std::string, // key_type
+ basic_json, // value_type
+ std::less<std::string>, // key_compare
+ std::allocator<std::pair<const std::string, basic_json>> // allocator_type
+ >
+ @endcode
+
+ #### Behavior
+
+ The choice of @a object_t influences the behavior of the JSON class. With
+ the default type, objects have the following behavior:
+
+ - When all names are unique, objects will be interoperable in the sense
+ that all software implementations receiving that object will agree on
+ the name-value mappings.
+ - When the names within an object are not unique, it is unspecified which
+ one of the values for a given key will be chosen. For instance,
+ `{"key": 2, "key": 1}` could be equal to either `{"key": 1}` or
+ `{"key": 2}`.
+ - Internally, name/value pairs are stored in lexicographical order of the
+ names. Objects will also be serialized (see @ref dump) in this order.
+ For instance, `{"b": 1, "a": 2}` and `{"a": 2, "b": 1}` will be stored
+ and serialized as `{"a": 2, "b": 1}`.
+ - When comparing objects, the order of the name/value pairs is irrelevant.
+ This makes objects interoperable in the sense that they will not be
+ affected by these differences. For instance, `{"b": 1, "a": 2}` and
+ `{"a": 2, "b": 1}` will be treated as equal.
+
+ #### Limits
+
+ [RFC 7159](http://rfc7159.net/rfc7159) specifies:
+ > An implementation may set limits on the maximum depth of nesting.
+
+ In this class, the object's limit of nesting is not explicitly constrained.
+ However, a maximum depth of nesting may be introduced by the compiler or
+ runtime environment. A theoretical limit can be queried by calling the
+ @ref max_size function of a JSON object.
+
+ #### Storage
+
+ Objects are stored as pointers in a @ref basic_json type. That is, for any
+ access to object values, a pointer of type `object_t*` must be
+ dereferenced.
+
+ @sa @ref array_t -- type for an array value
+
+ @since version 1.0.0
+
+ @note The order name/value pairs are added to the object is *not*
+ preserved by the library. Therefore, iterating an object may return
+ name/value pairs in a different order than they were originally stored. In
+ fact, keys will be traversed in alphabetical order as `std::map` with
+ `std::less` is used by default. Please note this behavior conforms to [RFC
+ 7159](http://rfc7159.net/rfc7159), because any order implements the
+ specified "unordered" nature of JSON objects.
+ */
+ using object_t = ObjectType<StringType,
+ basic_json,
+ object_comparator_t,
+ AllocatorType<std::pair<const StringType,
+ basic_json>>>;
+
+ /*!
+ @brief a type for an array
+
+ [RFC 7159](http://rfc7159.net/rfc7159) describes JSON arrays as follows:
+ > An array is an ordered sequence of zero or more values.
+
+ To store objects in C++, a type is defined by the template parameters
+ explained below.
+
+ @tparam ArrayType container type to store arrays (e.g., `std::vector` or
+ `std::list`)
+ @tparam AllocatorType allocator to use for arrays (e.g., `std::allocator`)
+
+ #### Default type
+
+ With the default values for @a ArrayType (`std::vector`) and @a
+ AllocatorType (`std::allocator`), the default value for @a array_t is:
+
+ @code {.cpp}
+ std::vector<
+ basic_json, // value_type
+ std::allocator<basic_json> // allocator_type
+ >
+ @endcode
+
+ #### Limits
+
+ [RFC 7159](http://rfc7159.net/rfc7159) specifies:
+ > An implementation may set limits on the maximum depth of nesting.
+
+ In this class, the array's limit of nesting is not explicitly constrained.
+ However, a maximum depth of nesting may be introduced by the compiler or
+ runtime environment. A theoretical limit can be queried by calling the
+ @ref max_size function of a JSON array.
+
+ #### Storage
+
+ Arrays are stored as pointers in a @ref basic_json type. That is, for any
+ access to array values, a pointer of type `array_t*` must be dereferenced.
+
+ @sa @ref object_t -- type for an object value
+
+ @since version 1.0.0
+ */
+ using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
+
+ /*!
+ @brief a type for a string
+
+ [RFC 7159](http://rfc7159.net/rfc7159) describes JSON strings as follows:
+ > A string is a sequence of zero or more Unicode characters.
+
+ To store objects in C++, a type is defined by the template parameter
+ described below. Unicode values are split by the JSON class into
+ byte-sized characters during deserialization.
+
+ @tparam StringType the container to store strings (e.g., `std::string`).
+ Note this container is used for keys/names in objects, see @ref object_t.
+
+ #### Default type
+
+ With the default values for @a StringType (`std::string`), the default
+ value for @a string_t is:
+
+ @code {.cpp}
+ std::string
+ @endcode
+
+ #### Encoding
+
+ Strings are stored in UTF-8 encoding. Therefore, functions like
+ `std::string::size()` or `std::string::length()` return the number of
+ bytes in the string rather than the number of characters or glyphs.
+
+ #### String comparison
+
+ [RFC 7159](http://rfc7159.net/rfc7159) states:
+ > Software implementations are typically required to test names of object
+ > members for equality. Implementations that transform the textual
+ > representation into sequences of Unicode code units and then perform the
+ > comparison numerically, code unit by code unit, are interoperable in the
+ > sense that implementations will agree in all cases on equality or
+ > inequality of two strings. For example, implementations that compare
+ > strings with escaped characters unconverted may incorrectly find that
+ > `"a\\b"` and `"a\u005Cb"` are not equal.
+
+ This implementation is interoperable as it does compare strings code unit
+ by code unit.
+
+ #### Storage
+
+ String values are stored as pointers in a @ref basic_json type. That is,
+ for any access to string values, a pointer of type `string_t*` must be
+ dereferenced.
+
+ @since version 1.0.0
+ */
+ using string_t = StringType;
+
+ /*!
+ @brief a type for a boolean
+
+ [RFC 7159](http://rfc7159.net/rfc7159) implicitly describes a boolean as a
+ type which differentiates the two literals `true` and `false`.
+
+ To store objects in C++, a type is defined by the template parameter @a
+ BooleanType which chooses the type to use.
+
+ #### Default type
+
+ With the default values for @a BooleanType (`bool`), the default value for
+ @a boolean_t is:
+
+ @code {.cpp}
+ bool
+ @endcode
+
+ #### Storage
+
+ Boolean values are stored directly inside a @ref basic_json type.
+
+ @since version 1.0.0
+ */
+ using boolean_t = BooleanType;
+
+ /*!
+ @brief a type for a number (integer)
+
+ [RFC 7159](http://rfc7159.net/rfc7159) describes numbers as follows:
+ > The representation of numbers is similar to that used in most
+ > programming languages. A number is represented in base 10 using decimal
+ > digits. It contains an integer component that may be prefixed with an
+ > optional minus sign, which may be followed by a fraction part and/or an
+ > exponent part. Leading zeros are not allowed. (...) Numeric values that
+ > cannot be represented in the grammar below (such as Infinity and NaN)
+ > are not permitted.
+
+ This description includes both integer and floating-point numbers.
+ However, C++ allows more precise storage if it is known whether the number
+ is a signed integer, an unsigned integer or a floating-point number.
+ Therefore, three different types, @ref number_integer_t, @ref
+ number_unsigned_t and @ref number_float_t are used.
+
+ To store integer numbers in C++, a type is defined by the template
+ parameter @a NumberIntegerType which chooses the type to use.
+
+ #### Default type
+
+ With the default values for @a NumberIntegerType (`int64_t`), the default
+ value for @a number_integer_t is:
+
+ @code {.cpp}
+ int64_t
+ @endcode
+
+ #### Default behavior
+
+ - The restrictions about leading zeros is not enforced in C++. Instead,
+ leading zeros in integer literals lead to an interpretation as octal
+ number. Internally, the value will be stored as decimal number. For
+ instance, the C++ integer literal `010` will be serialized to `8`.
+ During deserialization, leading zeros yield an error.
+ - Not-a-number (NaN) values will be serialized to `null`.
+
+ #### Limits
+
+ [RFC 7159](http://rfc7159.net/rfc7159) specifies:
+ > An implementation may set limits on the range and precision of numbers.
+
+ When the default type is used, the maximal integer number that can be
+ stored is `9223372036854775807` (INT64_MAX) and the minimal integer number
+ that can be stored is `-9223372036854775808` (INT64_MIN). Integer numbers
+ that are out of range will yield over/underflow when used in a
+ constructor. During deserialization, too large or small integer numbers
+ will be automatically be stored as @ref number_unsigned_t or @ref
+ number_float_t.
+
+ [RFC 7159](http://rfc7159.net/rfc7159) further states:
+ > Note that when such software is used, numbers that are integers and are
+ > in the range \f$[-2^{53}+1, 2^{53}-1]\f$ are interoperable in the sense
+ > that implementations will agree exactly on their numeric values.
+
+ As this range is a subrange of the exactly supported range [INT64_MIN,
+ INT64_MAX], this class's integer type is interoperable.
+
+ #### Storage
+
+ Integer number values are stored directly inside a @ref basic_json type.
+
+ @sa @ref number_float_t -- type for number values (floating-point)
+
+ @sa @ref number_unsigned_t -- type for number values (unsigned integer)
+
+ @since version 1.0.0
+ */
+ using number_integer_t = NumberIntegerType;
+
+ /*!
+ @brief a type for a number (unsigned)
+
+ [RFC 7159](http://rfc7159.net/rfc7159) describes numbers as follows:
+ > The representation of numbers is similar to that used in most
+ > programming languages. A number is represented in base 10 using decimal
+ > digits. It contains an integer component that may be prefixed with an
+ > optional minus sign, which may be followed by a fraction part and/or an
+ > exponent part. Leading zeros are not allowed. (...) Numeric values that
+ > cannot be represented in the grammar below (such as Infinity and NaN)
+ > are not permitted.
+
+ This description includes both integer and floating-point numbers.
+ However, C++ allows more precise storage if it is known whether the number
+ is a signed integer, an unsigned integer or a floating-point number.
+ Therefore, three different types, @ref number_integer_t, @ref
+ number_unsigned_t and @ref number_float_t are used.
+
+ To store unsigned integer numbers in C++, a type is defined by the
+ template parameter @a NumberUnsignedType which chooses the type to use.
+
+ #### Default type
+
+ With the default values for @a NumberUnsignedType (`uint64_t`), the
+ default value for @a number_unsigned_t is:
+
+ @code {.cpp}
+ uint64_t
+ @endcode
+
+ #### Default behavior
+
+ - The restrictions about leading zeros is not enforced in C++. Instead,
+ leading zeros in integer literals lead to an interpretation as octal
+ number. Internally, the value will be stored as decimal number. For
+ instance, the C++ integer literal `010` will be serialized to `8`.
+ During deserialization, leading zeros yield an error.
+ - Not-a-number (NaN) values will be serialized to `null`.
+
+ #### Limits
+
+ [RFC 7159](http://rfc7159.net/rfc7159) specifies:
+ > An implementation may set limits on the range and precision of numbers.
+
+ When the default type is used, the maximal integer number that can be
+ stored is `18446744073709551615` (UINT64_MAX) and the minimal integer
+ number that can be stored is `0`. Integer numbers that are out of range
+ will yield over/underflow when used in a constructor. During
+ deserialization, too large or small integer numbers will be automatically
+ be stored as @ref number_integer_t or @ref number_float_t.
+
+ [RFC 7159](http://rfc7159.net/rfc7159) further states:
+ > Note that when such software is used, numbers that are integers and are
+ > in the range \f$[-2^{53}+1, 2^{53}-1]\f$ are interoperable in the sense
+ > that implementations will agree exactly on their numeric values.
+
+ As this range is a subrange (when considered in conjunction with the
+ number_integer_t type) of the exactly supported range [0, UINT64_MAX],
+ this class's integer type is interoperable.
+
+ #### Storage
+
+ Integer number values are stored directly inside a @ref basic_json type.
+
+ @sa @ref number_float_t -- type for number values (floating-point)
+ @sa @ref number_integer_t -- type for number values (integer)
+
+ @since version 2.0.0
+ */
+ using number_unsigned_t = NumberUnsignedType;
+
+ /*!
+ @brief a type for a number (floating-point)
+
+ [RFC 7159](http://rfc7159.net/rfc7159) describes numbers as follows:
+ > The representation of numbers is similar to that used in most
+ > programming languages. A number is represented in base 10 using decimal
+ > digits. It contains an integer component that may be prefixed with an
+ > optional minus sign, which may be followed by a fraction part and/or an
+ > exponent part. Leading zeros are not allowed. (...) Numeric values that
+ > cannot be represented in the grammar below (such as Infinity and NaN)
+ > are not permitted.
+
+ This description includes both integer and floating-point numbers.
+ However, C++ allows more precise storage if it is known whether the number
+ is a signed integer, an unsigned integer or a floating-point number.
+ Therefore, three different types, @ref number_integer_t, @ref
+ number_unsigned_t and @ref number_float_t are used.
+
+ To store floating-point numbers in C++, a type is defined by the template
+ parameter @a NumberFloatType which chooses the type to use.
+
+ #### Default type
+
+ With the default values for @a NumberFloatType (`double`), the default
+ value for @a number_float_t is:
+
+ @code {.cpp}
+ double
+ @endcode
+
+ #### Default behavior
+
+ - The restrictions about leading zeros is not enforced in C++. Instead,
+ leading zeros in floating-point literals will be ignored. Internally,
+ the value will be stored as decimal number. For instance, the C++
+ floating-point literal `01.2` will be serialized to `1.2`. During
+ deserialization, leading zeros yield an error.
+ - Not-a-number (NaN) values will be serialized to `null`.
+
+ #### Limits
+
+ [RFC 7159](http://rfc7159.net/rfc7159) states:
+ > This specification allows implementations to set limits on the range and
+ > precision of numbers accepted. Since software that implements IEEE
+ > 754-2008 binary64 (double precision) numbers is generally available and
+ > widely used, good interoperability can be achieved by implementations
+ > that expect no more precision or range than these provide, in the sense
+ > that implementations will approximate JSON numbers within the expected
+ > precision.
+
+ This implementation does exactly follow this approach, as it uses double
+ precision floating-point numbers. Note values smaller than
+ `-1.79769313486232e+308` and values greater than `1.79769313486232e+308`
+ will be stored as NaN internally and be serialized to `null`.
+
+ #### Storage
+
+ Floating-point number values are stored directly inside a @ref basic_json
+ type.
+
+ @sa @ref number_integer_t -- type for number values (integer)
+
+ @sa @ref number_unsigned_t -- type for number values (unsigned integer)
+
+ @since version 1.0.0
+ */
+ using number_float_t = NumberFloatType;
+
+ /// @}
+
+ private:
+
+ /// helper for exception-safe object creation
+ template<typename T, typename... Args>
+ static T* create(Args&& ... args)
+ {
+ AllocatorType<T> alloc;
+ using AllocatorTraits = std::allocator_traits<AllocatorType<T>>;
+
+ auto deleter = [&](T * object)
+ {
+ AllocatorTraits::deallocate(alloc, object, 1);
+ };
+ std::unique_ptr<T, decltype(deleter)> object(AllocatorTraits::allocate(alloc, 1), deleter);
+ AllocatorTraits::construct(alloc, object.get(), std::forward<Args>(args)...);
+ assert(object != nullptr);
+ return object.release();
+ }
+
+ ////////////////////////
+ // JSON value storage //
+ ////////////////////////
+
+ /*!
+ @brief a JSON value
+
+ The actual storage for a JSON value of the @ref basic_json class. This
+ union combines the different storage types for the JSON value types
+ defined in @ref value_t.
+
+ JSON type | value_t type | used type
+ --------- | --------------- | ------------------------
+ object | object | pointer to @ref object_t
+ array | array | pointer to @ref array_t
+ string | string | pointer to @ref string_t
+ boolean | boolean | @ref boolean_t
+ number | number_integer | @ref number_integer_t
+ number | number_unsigned | @ref number_unsigned_t
+ number | number_float | @ref number_float_t
+ null | null | *no value is stored*
+
+ @note Variable-length types (objects, arrays, and strings) are stored as
+ pointers. The size of the union should not exceed 64 bits if the default
+ value types are used.
+
+ @since version 1.0.0
+ */
+ union json_value
+ {
+ /// object (stored with pointer to save storage)
+ object_t* object;
+ /// array (stored with pointer to save storage)
+ array_t* array;
+ /// string (stored with pointer to save storage)
+ string_t* string;
+ /// boolean
+ boolean_t boolean;
+ /// number (integer)
+ number_integer_t number_integer;
+ /// number (unsigned integer)
+ number_unsigned_t number_unsigned;
+ /// number (floating-point)
+ number_float_t number_float;
+
+ /// default constructor (for null values)
+ json_value() = default;
+ /// constructor for booleans
+ json_value(boolean_t v) noexcept : boolean(v) {}
+ /// constructor for numbers (integer)
+ json_value(number_integer_t v) noexcept : number_integer(v) {}
+ /// constructor for numbers (unsigned)
+ json_value(number_unsigned_t v) noexcept : number_unsigned(v) {}
+ /// constructor for numbers (floating-point)
+ json_value(number_float_t v) noexcept : number_float(v) {}
+ /// constructor for empty values of a given type
+ json_value(value_t t)
+ {
+ switch (t)
+ {
+ case value_t::object:
+ {
+ object = create<object_t>();
+ break;
+ }
+
+ case value_t::array:
+ {
+ array = create<array_t>();
+ break;
+ }
+
+ case value_t::string:
+ {
+ string = create<string_t>("");
+ break;
+ }
+
+ case value_t::boolean:
+ {
+ boolean = boolean_t(false);
+ break;
+ }
+
+ case value_t::number_integer:
+ {
+ number_integer = number_integer_t(0);
+ break;
+ }
+
+ case value_t::number_unsigned:
+ {
+ number_unsigned = number_unsigned_t(0);
+ break;
+ }
+
+ case value_t::number_float:
+ {
+ number_float = number_float_t(0.0);
+ break;
+ }
+
+ case value_t::null:
+ {
+ object = nullptr; // silence warning, see #821
+ break;
+ }
+
+ default:
+ {
+ object = nullptr; // silence warning, see #821
+ if (JSON_UNLIKELY(t == value_t::null))
+ {
+ JSON_THROW(other_error::create(500, "961c151d2e87f2686a955a9be24d316f1362bf21 3.6.1")); // LCOV_EXCL_LINE
+ }
+ break;
+ }
+ }
+ }
+
+ /// constructor for strings
+ json_value(const string_t& value)
+ {
+ string = create<string_t>(value);
+ }
+
+ /// constructor for rvalue strings
+ json_value(string_t&& value)
+ {
+ string = create<string_t>(std::move(value));
+ }
+
+ /// constructor for objects
+ json_value(const object_t& value)
+ {
+ object = create<object_t>(value);
+ }
+
+ /// constructor for rvalue objects
+ json_value(object_t&& value)
+ {
+ object = create<object_t>(std::move(value));
+ }
+
+ /// constructor for arrays
+ json_value(const array_t& value)
+ {
+ array = create<array_t>(value);
+ }
+
+ /// constructor for rvalue arrays
+ json_value(array_t&& value)
+ {
+ array = create<array_t>(std::move(value));
+ }
+
+ void destroy(value_t t) noexcept
+ {
+ switch (t)
+ {
+ case value_t::object:
+ {
+ AllocatorType<object_t> alloc;
+ std::allocator_traits<decltype(alloc)>::destroy(alloc, object);
+ std::allocator_traits<decltype(alloc)>::deallocate(alloc, object, 1);
+ break;
+ }
+
+ case value_t::array:
+ {
+ AllocatorType<array_t> alloc;
+ std::allocator_traits<decltype(alloc)>::destroy(alloc, array);
+ std::allocator_traits<decltype(alloc)>::deallocate(alloc, array, 1);
+ break;
+ }
+
+ case value_t::string:
+ {
+ AllocatorType<string_t> alloc;
+ std::allocator_traits<decltype(alloc)>::destroy(alloc, string);
+ std::allocator_traits<decltype(alloc)>::deallocate(alloc, string, 1);
+ break;
+ }
+
+ default:
+ {
+ break;
+ }
+ }
+ }
+ };
+
+ /*!
+ @brief checks the class invariants
+
+ This function asserts the class invariants. It needs to be called at the
+ end of every constructor to make sure that created objects respect the
+ invariant. Furthermore, it has to be called each time the type of a JSON
+ value is changed, because the invariant expresses a relationship between
+ @a m_type and @a m_value.
+ */
+ void assert_invariant() const noexcept
+ {
+ assert(m_type != value_t::object or m_value.object != nullptr);
+ assert(m_type != value_t::array or m_value.array != nullptr);
+ assert(m_type != value_t::string or m_value.string != nullptr);
+ }
+
+ public:
+ //////////////////////////
+ // JSON parser callback //
+ //////////////////////////
+
+ /*!
+ @brief parser event types
+
+ The parser callback distinguishes the following events:
+ - `object_start`: the parser read `{` and started to process a JSON object
+ - `key`: the parser read a key of a value in an object
+ - `object_end`: the parser read `}` and finished processing a JSON object
+ - `array_start`: the parser read `[` and started to process a JSON array
+ - `array_end`: the parser read `]` and finished processing a JSON array
+ - `value`: the parser finished reading a JSON value
+
+ @image html callback_events.png "Example when certain parse events are triggered"
+
+ @sa @ref parser_callback_t for more information and examples
+ */
+ using parse_event_t = typename parser::parse_event_t;
+
+ /*!
+ @brief per-element parser callback type
+
+ With a parser callback function, the result of parsing a JSON text can be
+ influenced. When passed to @ref parse, it is called on certain events
+ (passed as @ref parse_event_t via parameter @a event) with a set recursion
+ depth @a depth and context JSON value @a parsed. The return value of the
+ callback function is a boolean indicating whether the element that emitted
+ the callback shall be kept or not.
+
+ We distinguish six scenarios (determined by the event type) in which the
+ callback function can be called. The following table describes the values
+ of the parameters @a depth, @a event, and @a parsed.
+
+ parameter @a event | description | parameter @a depth | parameter @a parsed
+ ------------------ | ----------- | ------------------ | -------------------
+ parse_event_t::object_start | the parser read `{` and started to process a JSON object | depth of the parent of the JSON object | a JSON value with type discarded
+ parse_event_t::key | the parser read a key of a value in an object | depth of the currently parsed JSON object | a JSON string containing the key
+ parse_event_t::object_end | the parser read `}` and finished processing a JSON object | depth of the parent of the JSON object | the parsed JSON object
+ parse_event_t::array_start | the parser read `[` and started to process a JSON array | depth of the parent of the JSON array | a JSON value with type discarded
+ parse_event_t::array_end | the parser read `]` and finished processing a JSON array | depth of the parent of the JSON array | the parsed JSON array
+ parse_event_t::value | the parser finished reading a JSON value | depth of the value | the parsed JSON value
+
+ @image html callback_events.png "Example when certain parse events are triggered"
+
+ Discarding a value (i.e., returning `false`) has different effects
+ depending on the context in which function was called:
+
+ - Discarded values in structured types are skipped. That is, the parser
+ will behave as if the discarded value was never read.
+ - In case a value outside a structured type is skipped, it is replaced
+ with `null`. This case happens if the top-level element is skipped.
+
+ @param[in] depth the depth of the recursion during parsing
+
+ @param[in] event an event of type parse_event_t indicating the context in
+ the callback function has been called
+
+ @param[in,out] parsed the current intermediate parse result; note that
+ writing to this value has no effect for parse_event_t::key events
+
+ @return Whether the JSON value which called the function during parsing
+ should be kept (`true`) or not (`false`). In the latter case, it is either
+ skipped completely or replaced by an empty discarded object.
+
+ @sa @ref parse for examples
+
+ @since version 1.0.0
+ */
+ using parser_callback_t = typename parser::parser_callback_t;
+
+ //////////////////
+ // constructors //
+ //////////////////
+
+ /// @name constructors and destructors
+ /// Constructors of class @ref basic_json, copy/move constructor, copy
+ /// assignment, static functions creating objects, and the destructor.
+ /// @{
+
+ /*!
+ @brief create an empty value with a given type
+
+ Create an empty JSON value with a given type. The value will be default
+ initialized with an empty value which depends on the type:
+
+ Value type | initial value
+ ----------- | -------------
+ null | `null`
+ boolean | `false`
+ string | `""`
+ number | `0`
+ object | `{}`
+ array | `[]`
+
+ @param[in] v the type of the value to create
+
+ @complexity Constant.
+
+ @exceptionsafety Strong guarantee: if an exception is thrown, there are no
+ changes to any JSON value.
+
+ @liveexample{The following code shows the constructor for different @ref
+ value_t values,basic_json__value_t}
+
+ @sa @ref clear() -- restores the postcondition of this constructor
+
+ @since version 1.0.0
+ */
+ basic_json(const value_t v)
+ : m_type(v), m_value(v)
+ {
+ assert_invariant();
+ }
+
+ /*!
+ @brief create a null object
+
+ Create a `null` JSON value. It either takes a null pointer as parameter
+ (explicitly creating `null`) or no parameter (implicitly creating `null`).
+ The passed null pointer itself is not read -- it is only used to choose
+ the right constructor.
+
+ @complexity Constant.
+
+ @exceptionsafety No-throw guarantee: this constructor never throws
+ exceptions.
+
+ @liveexample{The following code shows the constructor with and without a
+ null pointer parameter.,basic_json__nullptr_t}
+
+ @since version 1.0.0
+ */
+ basic_json(std::nullptr_t = nullptr) noexcept
+ : basic_json(value_t::null)
+ {
+ assert_invariant();
+ }
+
+ /*!
+ @brief create a JSON value
+
+ This is a "catch all" constructor for all compatible JSON types; that is,
+ types for which a `to_json()` method exists. The constructor forwards the
+ parameter @a val to that method (to `json_serializer<U>::to_json` method
+ with `U = uncvref_t<CompatibleType>`, to be exact).
+
+ Template type @a CompatibleType includes, but is not limited to, the
+ following types:
+ - **arrays**: @ref array_t and all kinds of compatible containers such as
+ `std::vector`, `std::deque`, `std::list`, `std::forward_list`,
+ `std::array`, `std::valarray`, `std::set`, `std::unordered_set`,
+ `std::multiset`, and `std::unordered_multiset` with a `value_type` from
+ which a @ref basic_json value can be constructed.
+ - **objects**: @ref object_t and all kinds of compatible associative
+ containers such as `std::map`, `std::unordered_map`, `std::multimap`,
+ and `std::unordered_multimap` with a `key_type` compatible to
+ @ref string_t and a `value_type` from which a @ref basic_json value can
+ be constructed.
+ - **strings**: @ref string_t, string literals, and all compatible string
+ containers can be used.
+ - **numbers**: @ref number_integer_t, @ref number_unsigned_t,
+ @ref number_float_t, and all convertible number types such as `int`,
+ `size_t`, `int64_t`, `float` or `double` can be used.
+ - **boolean**: @ref boolean_t / `bool` can be used.
+
+ See the examples below.
+
+ @tparam CompatibleType a type such that:
+ - @a CompatibleType is not derived from `std::istream`,
+ - @a CompatibleType is not @ref basic_json (to avoid hijacking copy/move
+ constructors),
+ - @a CompatibleType is not a different @ref basic_json type (i.e. with different template arguments)
+ - @a CompatibleType is not a @ref basic_json nested type (e.g.,
+ @ref json_pointer, @ref iterator, etc ...)
+ - @ref @ref json_serializer<U> has a
+ `to_json(basic_json_t&, CompatibleType&&)` method
+
+ @tparam U = `uncvref_t<CompatibleType>`
+
+ @param[in] val the value to be forwarded to the respective constructor
+
+ @complexity Usually linear in the size of the passed @a val, also
+ depending on the implementation of the called `to_json()`
+ method.
+
+ @exceptionsafety Depends on the called constructor. For types directly
+ supported by the library (i.e., all types for which no `to_json()` function
+ was provided), strong guarantee holds: if an exception is thrown, there are
+ no changes to any JSON value.
+
+ @liveexample{The following code shows the constructor with several
+ compatible types.,basic_json__CompatibleType}
+
+ @since version 2.1.0
+ */
+ template <typename CompatibleType,
+ typename U = detail::uncvref_t<CompatibleType>,
+ detail::enable_if_t<
+ not detail::is_basic_json<U>::value and detail::is_compatible_type<basic_json_t, U>::value, int> = 0>
+ basic_json(CompatibleType && val) noexcept(noexcept(
+ JSONSerializer<U>::to_json(std::declval<basic_json_t&>(),
+ std::forward<CompatibleType>(val))))
+ {
+ JSONSerializer<U>::to_json(*this, std::forward<CompatibleType>(val));
+ assert_invariant();
+ }
+
+ /*!
+ @brief create a JSON value from an existing one
+
+ This is a constructor for existing @ref basic_json types.
+ It does not hijack copy/move constructors, since the parameter has different
+ template arguments than the current ones.
+
+ The constructor tries to convert the internal @ref m_value of the parameter.
+
+ @tparam BasicJsonType a type such that:
+ - @a BasicJsonType is a @ref basic_json type.
+ - @a BasicJsonType has different template arguments than @ref basic_json_t.
+
+ @param[in] val the @ref basic_json value to be converted.
+
+ @complexity Usually linear in the size of the passed @a val, also
+ depending on the implementation of the called `to_json()`
+ method.
+
+ @exceptionsafety Depends on the called constructor. For types directly
+ supported by the library (i.e., all types for which no `to_json()` function
+ was provided), strong guarantee holds: if an exception is thrown, there are
+ no changes to any JSON value.
+
+ @since version 3.2.0
+ */
+ template <typename BasicJsonType,
+ detail::enable_if_t<
+ detail::is_basic_json<BasicJsonType>::value and not std::is_same<basic_json, BasicJsonType>::value, int> = 0>
+ basic_json(const BasicJsonType& val)
+ {
+ using other_boolean_t = typename BasicJsonType::boolean_t;
+ using other_number_float_t = typename BasicJsonType::number_float_t;
+ using other_number_integer_t = typename BasicJsonType::number_integer_t;
+ using other_number_unsigned_t = typename BasicJsonType::number_unsigned_t;
+ using other_string_t = typename BasicJsonType::string_t;
+ using other_object_t = typename BasicJsonType::object_t;
+ using other_array_t = typename BasicJsonType::array_t;
+
+ switch (val.type())
+ {
+ case value_t::boolean:
+ JSONSerializer<other_boolean_t>::to_json(*this, val.template get<other_boolean_t>());
+ break;
+ case value_t::number_float:
+ JSONSerializer<other_number_float_t>::to_json(*this, val.template get<other_number_float_t>());
+ break;
+ case value_t::number_integer:
+ JSONSerializer<other_number_integer_t>::to_json(*this, val.template get<other_number_integer_t>());
+ break;
+ case value_t::number_unsigned:
+ JSONSerializer<other_number_unsigned_t>::to_json(*this, val.template get<other_number_unsigned_t>());
+ break;
+ case value_t::string:
+ JSONSerializer<other_string_t>::to_json(*this, val.template get_ref<const other_string_t&>());
+ break;
+ case value_t::object:
+ JSONSerializer<other_object_t>::to_json(*this, val.template get_ref<const other_object_t&>());
+ break;
+ case value_t::array:
+ JSONSerializer<other_array_t>::to_json(*this, val.template get_ref<const other_array_t&>());
+ break;
+ case value_t::null:
+ *this = nullptr;
+ break;
+ case value_t::discarded:
+ m_type = value_t::discarded;
+ break;
+ default: // LCOV_EXCL_LINE
+ assert(false); // LCOV_EXCL_LINE
+ }
+ assert_invariant();
+ }
+
+ /*!
+ @brief create a container (array or object) from an initializer list
+
+ Creates a JSON value of type array or object from the passed initializer
+ list @a init. In case @a type_deduction is `true` (default), the type of
+ the JSON value to be created is deducted from the initializer list @a init
+ according to the following rules:
+
+ 1. If the list is empty, an empty JSON object value `{}` is created.
+ 2. If the list consists of pairs whose first element is a string, a JSON
+ object value is created where the first elements of the pairs are
+ treated as keys and the second elements are as values.
+ 3. In all other cases, an array is created.
+
+ The rules aim to create the best fit between a C++ initializer list and
+ JSON values. The rationale is as follows:
+
+ 1. The empty initializer list is written as `{}` which is exactly an empty
+ JSON object.
+ 2. C++ has no way of describing mapped types other than to list a list of
+ pairs. As JSON requires that keys must be of type string, rule 2 is the
+ weakest constraint one can pose on initializer lists to interpret them
+ as an object.
+ 3. In all other cases, the initializer list could not be interpreted as
+ JSON object type, so interpreting it as JSON array type is safe.
+
+ With the rules described above, the following JSON values cannot be
+ expressed by an initializer list:
+
+ - the empty array (`[]`): use @ref array(initializer_list_t)
+ with an empty initializer list in this case
+ - arrays whose elements satisfy rule 2: use @ref
+ array(initializer_list_t) with the same initializer list
+ in this case
+
+ @note When used without parentheses around an empty initializer list, @ref
+ basic_json() is called instead of this function, yielding the JSON null
+ value.
+
+ @param[in] init initializer list with JSON values
+
+ @param[in] type_deduction internal parameter; when set to `true`, the type
+ of the JSON value is deducted from the initializer list @a init; when set
+ to `false`, the type provided via @a manual_type is forced. This mode is
+ used by the functions @ref array(initializer_list_t) and
+ @ref object(initializer_list_t).
+
+ @param[in] manual_type internal parameter; when @a type_deduction is set
+ to `false`, the created JSON value will use the provided type (only @ref
+ value_t::array and @ref value_t::object are valid); when @a type_deduction
+ is set to `true`, this parameter has no effect
+
+ @throw type_error.301 if @a type_deduction is `false`, @a manual_type is
+ `value_t::object`, but @a init contains an element which is not a pair
+ whose first element is a string. In this case, the constructor could not
+ create an object. If @a type_deduction would have be `true`, an array
+ would have been created. See @ref object(initializer_list_t)
+ for an example.
+
+ @complexity Linear in the size of the initializer list @a init.
+
+ @exceptionsafety Strong guarantee: if an exception is thrown, there are no
+ changes to any JSON value.
+
+ @liveexample{The example below shows how JSON values are created from
+ initializer lists.,basic_json__list_init_t}
+
+ @sa @ref array(initializer_list_t) -- create a JSON array
+ value from an initializer list
+ @sa @ref object(initializer_list_t) -- create a JSON object
+ value from an initializer list
+
+ @since version 1.0.0
+ */
+ basic_json(initializer_list_t init,
+ bool type_deduction = true,
+ value_t manual_type = value_t::array)
+ {
+ // check if each element is an array with two elements whose first
+ // element is a string
+ bool is_an_object = std::all_of(init.begin(), init.end(),
+ [](const detail::json_ref<basic_json>& element_ref)
+ {
+ return element_ref->is_array() and element_ref->size() == 2 and (*element_ref)[0].is_string();
+ });
+
+ // adjust type if type deduction is not wanted
+ if (not type_deduction)
+ {
+ // if array is wanted, do not create an object though possible
+ if (manual_type == value_t::array)
+ {
+ is_an_object = false;
+ }
+
+ // if object is wanted but impossible, throw an exception
+ if (JSON_UNLIKELY(manual_type == value_t::object and not is_an_object))
+ {
+ JSON_THROW(type_error::create(301, "cannot create object from initializer list"));
+ }
+ }
+
+ if (is_an_object)
+ {
+ // the initializer list is a list of pairs -> create object
+ m_type = value_t::object;
+ m_value = value_t::object;
+
+ std::for_each(init.begin(), init.end(), [this](const detail::json_ref<basic_json>& element_ref)
+ {
+ auto element = element_ref.moved_or_copied();
+ m_value.object->emplace(
+ std::move(*((*element.m_value.array)[0].m_value.string)),
+ std::move((*element.m_value.array)[1]));
+ });
+ }
+ else
+ {
+ // the initializer list describes an array -> create array
+ m_type = value_t::array;
+ m_value.array = create<array_t>(init.begin(), init.end());
+ }
+
+ assert_invariant();
+ }
+
+ /*!
+ @brief explicitly create an array from an initializer list
+
+ Creates a JSON array value from a given initializer list. That is, given a
+ list of values `a, b, c`, creates the JSON value `[a, b, c]`. If the
+ initializer list is empty, the empty array `[]` is created.
+
+ @note This function is only needed to express two edge cases that cannot
+ be realized with the initializer list constructor (@ref
+ basic_json(initializer_list_t, bool, value_t)). These cases
+ are:
+ 1. creating an array whose elements are all pairs whose first element is a
+ string -- in this case, the initializer list constructor would create an
+ object, taking the first elements as keys
+ 2. creating an empty array -- passing the empty initializer list to the
+ initializer list constructor yields an empty object
+
+ @param[in] init initializer list with JSON values to create an array from
+ (optional)
+
+ @return JSON array value
+
+ @complexity Linear in the size of @a init.
+
+ @exceptionsafety Strong guarantee: if an exception is thrown, there are no
+ changes to any JSON value.
+
+ @liveexample{The following code shows an example for the `array`
+ function.,array}
+
+ @sa @ref basic_json(initializer_list_t, bool, value_t) --
+ create a JSON value from an initializer list
+ @sa @ref object(initializer_list_t) -- create a JSON object
+ value from an initializer list
+
+ @since version 1.0.0
+ */
+ JSON_NODISCARD
+ static basic_json array(initializer_list_t init = {})
+ {
+ return basic_json(init, false, value_t::array);
+ }
+
+ /*!
+ @brief explicitly create an object from an initializer list
+
+ Creates a JSON object value from a given initializer list. The initializer
+ lists elements must be pairs, and their first elements must be strings. If
+ the initializer list is empty, the empty object `{}` is created.
+
+ @note This function is only added for symmetry reasons. In contrast to the
+ related function @ref array(initializer_list_t), there are
+ no cases which can only be expressed by this function. That is, any
+ initializer list @a init can also be passed to the initializer list
+ constructor @ref basic_json(initializer_list_t, bool, value_t).
+
+ @param[in] init initializer list to create an object from (optional)
+
+ @return JSON object value
+
+ @throw type_error.301 if @a init is not a list of pairs whose first
+ elements are strings. In this case, no object can be created. When such a
+ value is passed to @ref basic_json(initializer_list_t, bool, value_t),
+ an array would have been created from the passed initializer list @a init.
+ See example below.
+
+ @complexity Linear in the size of @a init.
+
+ @exceptionsafety Strong guarantee: if an exception is thrown, there are no
+ changes to any JSON value.
+
+ @liveexample{The following code shows an example for the `object`
+ function.,object}
+
+ @sa @ref basic_json(initializer_list_t, bool, value_t) --
+ create a JSON value from an initializer list
+ @sa @ref array(initializer_list_t) -- create a JSON array
+ value from an initializer list
+
+ @since version 1.0.0
+ */
+ JSON_NODISCARD
+ static basic_json object(initializer_list_t init = {})
+ {
+ return basic_json(init, false, value_t::object);
+ }
+
+ /*!
+ @brief construct an array with count copies of given value
+
+ Constructs a JSON array value by creating @a cnt copies of a passed value.
+ In case @a cnt is `0`, an empty array is created.
+
+ @param[in] cnt the number of JSON copies of @a val to create
+ @param[in] val the JSON value to copy
+
+ @post `std::distance(begin(),end()) == cnt` holds.
+
+ @complexity Linear in @a cnt.
+
+ @exceptionsafety Strong guarantee: if an exception is thrown, there are no
+ changes to any JSON value.
+
+ @liveexample{The following code shows examples for the @ref
+ basic_json(size_type\, const basic_json&)
+ constructor.,basic_json__size_type_basic_json}
+
+ @since version 1.0.0
+ */
+ basic_json(size_type cnt, const basic_json& val)
+ : m_type(value_t::array)
+ {
+ m_value.array = create<array_t>(cnt, val);
+ assert_invariant();
+ }
+
+ /*!
+ @brief construct a JSON container given an iterator range
+
+ Constructs the JSON value with the contents of the range `[first, last)`.
+ The semantics depends on the different types a JSON value can have:
+ - In case of a null type, invalid_iterator.206 is thrown.
+ - In case of other primitive types (number, boolean, or string), @a first
+ must be `begin()` and @a last must be `end()`. In this case, the value is
+ copied. Otherwise, invalid_iterator.204 is thrown.
+ - In case of structured types (array, object), the constructor behaves as
+ similar versions for `std::vector` or `std::map`; that is, a JSON array
+ or object is constructed from the values in the range.
+
+ @tparam InputIT an input iterator type (@ref iterator or @ref
+ const_iterator)
+
+ @param[in] first begin of the range to copy from (included)
+ @param[in] last end of the range to copy from (excluded)
+
+ @pre Iterators @a first and @a last must be initialized. **This
+ precondition is enforced with an assertion (see warning).** If
+ assertions are switched off, a violation of this precondition yields
+ undefined behavior.
+
+ @pre Range `[first, last)` is valid. Usually, this precondition cannot be
+ checked efficiently. Only certain edge cases are detected; see the
+ description of the exceptions below. A violation of this precondition
+ yields undefined behavior.
+
+ @warning A precondition is enforced with a runtime assertion that will
+ result in calling `std::abort` if this precondition is not met.
+ Assertions can be disabled by defining `NDEBUG` at compile time.
+ See https://en.cppreference.com/w/cpp/error/assert for more
+ information.
+
+ @throw invalid_iterator.201 if iterators @a first and @a last are not
+ compatible (i.e., do not belong to the same JSON value). In this case,
+ the range `[first, last)` is undefined.
+ @throw invalid_iterator.204 if iterators @a first and @a last belong to a
+ primitive type (number, boolean, or string), but @a first does not point
+ to the first element any more. In this case, the range `[first, last)` is
+ undefined. See example code below.
+ @throw invalid_iterator.206 if iterators @a first and @a last belong to a
+ null value. In this case, the range `[first, last)` is undefined.
+
+ @complexity Linear in distance between @a first and @a last.
+
+ @exceptionsafety Strong guarantee: if an exception is thrown, there are no
+ changes to any JSON value.
+
+ @liveexample{The example below shows several ways to create JSON values by
+ specifying a subrange with iterators.,basic_json__InputIt_InputIt}
+
+ @since version 1.0.0
+ */
+ template<class InputIT, typename std::enable_if<
+ std::is_same<InputIT, typename basic_json_t::iterator>::value or
+ std::is_same<InputIT, typename basic_json_t::const_iterator>::value, int>::type = 0>
+ basic_json(InputIT first, InputIT last)
+ {
+ assert(first.m_object != nullptr);
+ assert(last.m_object != nullptr);
+
+ // make sure iterator fits the current value
+ if (JSON_UNLIKELY(first.m_object != last.m_object))
+ {
+ JSON_THROW(invalid_iterator::create(201, "iterators are not compatible"));
+ }
+
+ // copy type from first iterator
+ m_type = first.m_object->m_type;
+
+ // check if iterator range is complete for primitive values
+ switch (m_type)
+ {
+ case value_t::boolean:
+ case value_t::number_float:
+ case value_t::number_integer:
+ case value_t::number_unsigned:
+ case value_t::string:
+ {
+ if (JSON_UNLIKELY(not first.m_it.primitive_iterator.is_begin()
+ or not last.m_it.primitive_iterator.is_end()))
+ {
+ JSON_THROW(invalid_iterator::create(204, "iterators out of range"));
+ }
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ switch (m_type)
+ {
+ case value_t::number_integer:
+ {
+ m_value.number_integer = first.m_object->m_value.number_integer;
+ break;
+ }
+
+ case value_t::number_unsigned:
+ {
+ m_value.number_unsigned = first.m_object->m_value.number_unsigned;
+ break;
+ }
+
+ case value_t::number_float:
+ {
+ m_value.number_float = first.m_object->m_value.number_float;
+ break;
+ }
+
+ case value_t::boolean:
+ {
+ m_value.boolean = first.m_object->m_value.boolean;
+ break;
+ }
+
+ case value_t::string:
+ {
+ m_value = *first.m_object->m_value.string;
+ break;
+ }
+
+ case value_t::object:
+ {
+ m_value.object = create<object_t>(first.m_it.object_iterator,
+ last.m_it.object_iterator);
+ break;
+ }
+
+ case value_t::array:
+ {
+ m_value.array = create<array_t>(first.m_it.array_iterator,
+ last.m_it.array_iterator);
+ break;
+ }
+
+ default:
+ JSON_THROW(invalid_iterator::create(206, "cannot construct with iterators from " +
+ std::string(first.m_object->type_name())));
+ }
+
+ assert_invariant();
+ }
+
+
+ ///////////////////////////////////////
+ // other constructors and destructor //
+ ///////////////////////////////////////
+
+ /// @private
+ basic_json(const detail::json_ref<basic_json>& ref)
+ : basic_json(ref.moved_or_copied())
+ {}
+
+ /*!
+ @brief copy constructor
+
+ Creates a copy of a given JSON value.
+
+ @param[in] other the JSON value to copy
+
+ @post `*this == other`
+
+ @complexity Linear in the size of @a other.
+
+ @exceptionsafety Strong guarantee: if an exception is thrown, there are no
+ changes to any JSON value.
+
+ @requirement This function helps `basic_json` satisfying the
+ [Container](https://en.cppreference.com/w/cpp/named_req/Container)
+ requirements:
+ - The complexity is linear.
+ - As postcondition, it holds: `other == basic_json(other)`.
+
+ @liveexample{The following code shows an example for the copy
+ constructor.,basic_json__basic_json}
+
+ @since version 1.0.0
+ */
+ basic_json(const basic_json& other)
+ : m_type(other.m_type)
+ {
+ // check of passed value is valid
+ other.assert_invariant();
+
+ switch (m_type)
+ {
+ case value_t::object:
+ {
+ m_value = *other.m_value.object;
+ break;
+ }
+
+ case value_t::array:
+ {
+ m_value = *other.m_value.array;
+ break;
+ }
+
+ case value_t::string:
+ {
+ m_value = *other.m_value.string;
+ break;
+ }
+
+ case value_t::boolean:
+ {
+ m_value = other.m_value.boolean;
+ break;
+ }
+
+ case value_t::number_integer:
+ {
+ m_value = other.m_value.number_integer;
+ break;
+ }
+
+ case value_t::number_unsigned:
+ {
+ m_value = other.m_value.number_unsigned;
+ break;
+ }
+
+ case value_t::number_float:
+ {
+ m_value = other.m_value.number_float;
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ assert_invariant();
+ }
+
+ /*!
+ @brief move constructor
+
+ Move constructor. Constructs a JSON value with the contents of the given
+ value @a other using move semantics. It "steals" the resources from @a
+ other and leaves it as JSON null value.
+
+ @param[in,out] other value to move to this object
+
+ @post `*this` has the same value as @a other before the call.
+ @post @a other is a JSON null value.
+
+ @complexity Constant.
+
+ @exceptionsafety No-throw guarantee: this constructor never throws
+ exceptions.
+
+ @requirement This function helps `basic_json` satisfying the
+ [MoveConstructible](https://en.cppreference.com/w/cpp/named_req/MoveConstructible)
+ requirements.
+
+ @liveexample{The code below shows the move constructor explicitly called
+ via std::move.,basic_json__moveconstructor}
+
+ @since version 1.0.0
+ */
+ basic_json(basic_json&& other) noexcept
+ : m_type(std::move(other.m_type)),
+ m_value(std::move(other.m_value))
+ {
+ // check that passed value is valid
+ other.assert_invariant();
+
+ // invalidate payload
+ other.m_type = value_t::null;
+ other.m_value = {};
+
+ assert_invariant();
+ }
+
+ /*!
+ @brief copy assignment
+
+ Copy assignment operator. Copies a JSON value via the "copy and swap"
+ strategy: It is expressed in terms of the copy constructor, destructor,
+ and the `swap()` member function.
+
+ @param[in] other value to copy from
+
+ @complexity Linear.
+
+ @requirement This function helps `basic_json` satisfying the
+ [Container](https://en.cppreference.com/w/cpp/named_req/Container)
+ requirements:
+ - The complexity is linear.
+
+ @liveexample{The code below shows and example for the copy assignment. It
+ creates a copy of value `a` which is then swapped with `b`. Finally\, the
+ copy of `a` (which is the null value after the swap) is
+ destroyed.,basic_json__copyassignment}
+
+ @since version 1.0.0
+ */
+ basic_json& operator=(basic_json other) noexcept (
+ std::is_nothrow_move_constructible<value_t>::value and
+ std::is_nothrow_move_assignable<value_t>::value and
+ std::is_nothrow_move_constructible<json_value>::value and
+ std::is_nothrow_move_assignable<json_value>::value
+ )
+ {
+ // check that passed value is valid
+ other.assert_invariant();
+
+ using std::swap;
+ swap(m_type, other.m_type);
+ swap(m_value, other.m_value);
+
+ assert_invariant();
+ return *this;
+ }
+
+ /*!
+ @brief destructor
+
+ Destroys the JSON value and frees all allocated memory.
+
+ @complexity Linear.
+
+ @requirement This function helps `basic_json` satisfying the
+ [Container](https://en.cppreference.com/w/cpp/named_req/Container)
+ requirements:
+ - The complexity is linear.
+ - All stored elements are destroyed and all memory is freed.
+
+ @since version 1.0.0
+ */
+ ~basic_json() noexcept
+ {
+ assert_invariant();
+ m_value.destroy(m_type);
+ }
+
+ /// @}
+
+ public:
+ ///////////////////////
+ // object inspection //
+ ///////////////////////
+
+ /// @name object inspection
+ /// Functions to inspect the type of a JSON value.
+ /// @{
+
+ /*!
+ @brief serialization
+
+ Serialization function for JSON values. The function tries to mimic
+ Python's `json.dumps()` function, and currently supports its @a indent
+ and @a ensure_ascii parameters.
+
+ @param[in] indent If indent is nonnegative, then array elements and object
+ members will be pretty-printed with that indent level. An indent level of
+ `0` will only insert newlines. `-1` (the default) selects the most compact
+ representation.
+ @param[in] indent_char The character to use for indentation if @a indent is
+ greater than `0`. The default is ` ` (space).
+ @param[in] ensure_ascii If @a ensure_ascii is true, all non-ASCII characters
+ in the output are escaped with `\uXXXX` sequences, and the result consists
+ of ASCII characters only.
+ @param[in] error_handler how to react on decoding errors; there are three
+ possible values: `strict` (throws and exception in case a decoding error
+ occurs; default), `replace` (replace invalid UTF-8 sequences with U+FFFD),
+ and `ignore` (ignore invalid UTF-8 sequences during serialization).
+
+ @return string containing the serialization of the JSON value
+
+ @throw type_error.316 if a string stored inside the JSON value is not
+ UTF-8 encoded
+
+ @complexity Linear.
+
+ @exceptionsafety Strong guarantee: if an exception is thrown, there are no
+ changes in the JSON value.
+
+ @liveexample{The following example shows the effect of different @a indent\,
+ @a indent_char\, and @a ensure_ascii parameters to the result of the
+ serialization.,dump}
+
+ @see https://docs.python.org/2/library/json.html#json.dump
+
+ @since version 1.0.0; indentation character @a indent_char, option
+ @a ensure_ascii and exceptions added in version 3.0.0; error
+ handlers added in version 3.4.0.
+ */
+ string_t dump(const int indent = -1,
+ const char indent_char = ' ',
+ const bool ensure_ascii = false,
+ const error_handler_t error_handler = error_handler_t::strict) const
+ {
+ string_t result;
+ serializer s(detail::output_adapter<char, string_t>(result), indent_char, error_handler);
+
+ if (indent >= 0)
+ {
+ s.dump(*this, true, ensure_ascii, static_cast<unsigned int>(indent));
+ }
+ else
+ {
+ s.dump(*this, false, ensure_ascii, 0);
+ }
+
+ return result;
+ }
+
+ /*!
+ @brief return the type of the JSON value (explicit)
+
+ Return the type of the JSON value as a value from the @ref value_t
+ enumeration.
+
+ @return the type of the JSON value
+ Value type | return value
+ ------------------------- | -------------------------
+ null | value_t::null
+ boolean | value_t::boolean
+ string | value_t::string
+ number (integer) | value_t::number_integer
+ number (unsigned integer) | value_t::number_unsigned
+ number (floating-point) | value_t::number_float
+ object | value_t::object
+ array | value_t::array
+ discarded | value_t::discarded
+
+ @complexity Constant.
+
+ @exceptionsafety No-throw guarantee: this member function never throws
+ exceptions.
+
+ @liveexample{The following code exemplifies `type()` for all JSON
+ types.,type}
+
+ @sa @ref operator value_t() -- return the type of the JSON value (implicit)
+ @sa @ref type_name() -- return the type as string
+
+ @since version 1.0.0
+ */
+ constexpr value_t type() const noexcept
+ {
+ return m_type;
+ }
+
+ /*!
+ @brief return whether type is primitive
+
+ This function returns true if and only if the JSON type is primitive
+ (string, number, boolean, or null).
+
+ @return `true` if type is primitive (string, number, boolean, or null),
+ `false` otherwise.
+
+ @complexity Constant.
+
+ @exceptionsafety No-throw guarantee: this member function never throws
+ exceptions.
+
+ @liveexample{The following code exemplifies `is_primitive()` for all JSON
+ types.,is_primitive}
+
+ @sa @ref is_structured() -- returns whether JSON value is structured
+ @sa @ref is_null() -- returns whether JSON value is `null`
+ @sa @ref is_string() -- returns whether JSON value is a string
+ @sa @ref is_boolean() -- returns whether JSON value is a boolean
+ @sa @ref is_number() -- returns whether JSON value is a number
+
+ @since version 1.0.0
+ */
+ constexpr bool is_primitive() const noexcept
+ {
+ return is_null() or is_string() or is_boolean() or is_number();
+ }
+
+ /*!
+ @brief return whether type is structured
+
+ This function returns true if and only if the JSON type is structured
+ (array or object).
+
+ @return `true` if type is structured (array or object), `false` otherwise.
+
+ @complexity Constant.
+
+ @exceptionsafety No-throw guarantee: this member function never throws
+ exceptions.
+
+ @liveexample{The following code exemplifies `is_structured()` for all JSON
+ types.,is_structured}
+
+ @sa @ref is_primitive() -- returns whether value is primitive
+ @sa @ref is_array() -- returns whether value is an array
+ @sa @ref is_object() -- returns whether value is an object
+
+ @since version 1.0.0
+ */
+ constexpr bool is_structured() const noexcept
+ {
+ return is_array() or is_object();
+ }
+
+ /*!
+ @brief return whether value is null
+
+ This function returns true if and only if the JSON value is null.
+
+ @return `true` if type is null, `false` otherwise.
+
+ @complexity Constant.
+
+ @exceptionsafety No-throw guarantee: this member function never throws
+ exceptions.
+
+ @liveexample{The following code exemplifies `is_null()` for all JSON
+ types.,is_null}
+
+ @since version 1.0.0
+ */
+ constexpr bool is_null() const noexcept
+ {
+ return m_type == value_t::null;
+ }
+
+ /*!
+ @brief return whether value is a boolean
+
+ This function returns true if and only if the JSON value is a boolean.
+
+ @return `true` if type is boolean, `false` otherwise.
+
+ @complexity Constant.
+
+ @exceptionsafety No-throw guarantee: this member function never throws
+ exceptions.
+
+ @liveexample{The following code exemplifies `is_boolean()` for all JSON
+ types.,is_boolean}
+
+ @since version 1.0.0
+ */
+ constexpr bool is_boolean() const noexcept
+ {
+ return m_type == value_t::boolean;
+ }
+
+ /*!
+ @brief return whether value is a number
+
+ This function returns true if and only if the JSON value is a number. This
+ includes both integer (signed and unsigned) and floating-point values.
+
+ @return `true` if type is number (regardless whether integer, unsigned
+ integer or floating-type), `false` otherwise.
+
+ @complexity Constant.
+
+ @exceptionsafety No-throw guarantee: this member function never throws
+ exceptions.
+
+ @liveexample{The following code exemplifies `is_number()` for all JSON
+ types.,is_number}
+
+ @sa @ref is_number_integer() -- check if value is an integer or unsigned
+ integer number
+ @sa @ref is_number_unsigned() -- check if value is an unsigned integer
+ number
+ @sa @ref is_number_float() -- check if value is a floating-point number
+
+ @since version 1.0.0
+ */
+ constexpr bool is_number() const noexcept
+ {
+ return is_number_integer() or is_number_float();
+ }
+
+ /*!
+ @brief return whether value is an integer number
+
+ This function returns true if and only if the JSON value is a signed or
+ unsigned integer number. This excludes floating-point values.
+
+ @return `true` if type is an integer or unsigned integer number, `false`
+ otherwise.
+
+ @complexity Constant.
+
+ @exceptionsafety No-throw guarantee: this member function never throws
+ exceptions.
+
+ @liveexample{The following code exemplifies `is_number_integer()` for all
+ JSON types.,is_number_integer}
+
+ @sa @ref is_number() -- check if value is a number
+ @sa @ref is_number_unsigned() -- check if value is an unsigned integer
+ number
+ @sa @ref is_number_float() -- check if value is a floating-point number
+
+ @since version 1.0.0
+ */
+ constexpr bool is_number_integer() const noexcept
+ {
+ return m_type == value_t::number_integer or m_type == value_t::number_unsigned;
+ }
+
+ /*!
+ @brief return whether value is an unsigned integer number
+
+ This function returns true if and only if the JSON value is an unsigned
+ integer number. This excludes floating-point and signed integer values.
+
+ @return `true` if type is an unsigned integer number, `false` otherwise.
+
+ @complexity Constant.
+
+ @exceptionsafety No-throw guarantee: this member function never throws
+ exceptions.
+
+ @liveexample{The following code exemplifies `is_number_unsigned()` for all
+ JSON types.,is_number_unsigned}
+
+ @sa @ref is_number() -- check if value is a number
+ @sa @ref is_number_integer() -- check if value is an integer or unsigned
+ integer number
+ @sa @ref is_number_float() -- check if value is a floating-point number
+
+ @since version 2.0.0
+ */
+ constexpr bool is_number_unsigned() const noexcept
+ {
+ return m_type == value_t::number_unsigned;
+ }
+
+ /*!
+ @brief return whether value is a floating-point number
+
+ This function returns true if and only if the JSON value is a
+ floating-point number. This excludes signed and unsigned integer values.
+
+ @return `true` if type is a floating-point number, `false` otherwise.
+
+ @complexity Constant.
+
+ @exceptionsafety No-throw guarantee: this member function never throws
+ exceptions.
+
+ @liveexample{The following code exemplifies `is_number_float()` for all
+ JSON types.,is_number_float}
+
+ @sa @ref is_number() -- check if value is number
+ @sa @ref is_number_integer() -- check if value is an integer number
+ @sa @ref is_number_unsigned() -- check if value is an unsigned integer
+ number
+
+ @since version 1.0.0
+ */
+ constexpr bool is_number_float() const noexcept
+ {
+ return m_type == value_t::number_float;
+ }
+
+ /*!
+ @brief return whether value is an object
+
+ This function returns true if and only if the JSON value is an object.
+
+ @return `true` if type is object, `false` otherwise.
+
+ @complexity Constant.
+
+ @exceptionsafety No-throw guarantee: this member function never throws
+ exceptions.
+
+ @liveexample{The following code exemplifies `is_object()` for all JSON
+ types.,is_object}
+
+ @since version 1.0.0
+ */
+ constexpr bool is_object() const noexcept
+ {
+ return m_type == value_t::object;
+ }
+
+ /*!
+ @brief return whether value is an array
+
+ This function returns true if and only if the JSON value is an array.
+
+ @return `true` if type is array, `false` otherwise.
+
+ @complexity Constant.
+
+ @exceptionsafety No-throw guarantee: this member function never throws
+ exceptions.
+
+ @liveexample{The following code exemplifies `is_array()` for all JSON
+ types.,is_array}
+
+ @since version 1.0.0
+ */
+ constexpr bool is_array() const noexcept
+ {
+ return m_type == value_t::array;
+ }
+
+ /*!
+ @brief return whether value is a string
+
+ This function returns true if and only if the JSON value is a string.
+
+ @return `true` if type is string, `false` otherwise.
+
+ @complexity Constant.
+
+ @exceptionsafety No-throw guarantee: this member function never throws
+ exceptions.
+
+ @liveexample{The following code exemplifies `is_string()` for all JSON
+ types.,is_string}
+
+ @since version 1.0.0
+ */
+ constexpr bool is_string() const noexcept
+ {
+ return m_type == value_t::string;
+ }
+
+ /*!
+ @brief return whether value is discarded
+
+ This function returns true if and only if the JSON value was discarded
+ during parsing with a callback function (see @ref parser_callback_t).
+
+ @note This function will always be `false` for JSON values after parsing.
+ That is, discarded values can only occur during parsing, but will be
+ removed when inside a structured value or replaced by null in other cases.
+
+ @return `true` if type is discarded, `false` otherwise.
+
+ @complexity Constant.
+
+ @exceptionsafety No-throw guarantee: this member function never throws
+ exceptions.
+
+ @liveexample{The following code exemplifies `is_discarded()` for all JSON
+ types.,is_discarded}
+
+ @since version 1.0.0
+ */
+ constexpr bool is_discarded() const noexcept
+ {
+ return m_type == value_t::discarded;
+ }
+
+ /*!
+ @brief return the type of the JSON value (implicit)
+
+ Implicitly return the type of the JSON value as a value from the @ref
+ value_t enumeration.
+
+ @return the type of the JSON value
+
+ @complexity Constant.
+
+ @exceptionsafety No-throw guarantee: this member function never throws
+ exceptions.
+
+ @liveexample{The following code exemplifies the @ref value_t operator for
+ all JSON types.,operator__value_t}
+
+ @sa @ref type() -- return the type of the JSON value (explicit)
+ @sa @ref type_name() -- return the type as string
+
+ @since version 1.0.0
+ */
+ constexpr operator value_t() const noexcept
+ {
+ return m_type;
+ }
+
+ /// @}
+
+ private:
+ //////////////////
+ // value access //
+ //////////////////
+
+ /// get a boolean (explicit)
+ boolean_t get_impl(boolean_t* /*unused*/) const
+ {
+ if (JSON_LIKELY(is_boolean()))
+ {
+ return m_value.boolean;
+ }
+
+ JSON_THROW(type_error::create(302, "type must be boolean, but is " + std::string(type_name())));
+ }
+
+ /// get a pointer to the value (object)
+ object_t* get_impl_ptr(object_t* /*unused*/) noexcept
+ {
+ return is_object() ? m_value.object : nullptr;
+ }
+
+ /// get a pointer to the value (object)
+ constexpr const object_t* get_impl_ptr(const object_t* /*unused*/) const noexcept
+ {
+ return is_object() ? m_value.object : nullptr;
+ }
+
+ /// get a pointer to the value (array)
+ array_t* get_impl_ptr(array_t* /*unused*/) noexcept
+ {
+ return is_array() ? m_value.array : nullptr;
+ }
+
+ /// get a pointer to the value (array)
+ constexpr const array_t* get_impl_ptr(const array_t* /*unused*/) const noexcept
+ {
+ return is_array() ? m_value.array : nullptr;
+ }
+
+ /// get a pointer to the value (string)
+ string_t* get_impl_ptr(string_t* /*unused*/) noexcept
+ {
+ return is_string() ? m_value.string : nullptr;
+ }
+
+ /// get a pointer to the value (string)
+ constexpr const string_t* get_impl_ptr(const string_t* /*unused*/) const noexcept
+ {
+ return is_string() ? m_value.string : nullptr;
+ }
+
+ /// get a pointer to the value (boolean)
+ boolean_t* get_impl_ptr(boolean_t* /*unused*/) noexcept
+ {
+ return is_boolean() ? &m_value.boolean : nullptr;
+ }
+
+ /// get a pointer to the value (boolean)
+ constexpr const boolean_t* get_impl_ptr(const boolean_t* /*unused*/) const noexcept
+ {
+ return is_boolean() ? &m_value.boolean : nullptr;
+ }
+
+ /// get a pointer to the value (integer number)
+ number_integer_t* get_impl_ptr(number_integer_t* /*unused*/) noexcept
+ {
+ return is_number_integer() ? &m_value.number_integer : nullptr;
+ }
+
+ /// get a pointer to the value (integer number)
+ constexpr const number_integer_t* get_impl_ptr(const number_integer_t* /*unused*/) const noexcept
+ {
+ return is_number_integer() ? &m_value.number_integer : nullptr;
+ }
+
+ /// get a pointer to the value (unsigned number)
+ number_unsigned_t* get_impl_ptr(number_unsigned_t* /*unused*/) noexcept
+ {
+ return is_number_unsigned() ? &m_value.number_unsigned : nullptr;
+ }
+
+ /// get a pointer to the value (unsigned number)
+ constexpr const number_unsigned_t* get_impl_ptr(const number_unsigned_t* /*unused*/) const noexcept
+ {
+ return is_number_unsigned() ? &m_value.number_unsigned : nullptr;
+ }
+
+ /// get a pointer to the value (floating-point number)
+ number_float_t* get_impl_ptr(number_float_t* /*unused*/) noexcept
+ {
+ return is_number_float() ? &m_value.number_float : nullptr;
+ }
+
+ /// get a pointer to the value (floating-point number)
+ constexpr const number_float_t* get_impl_ptr(const number_float_t* /*unused*/) const noexcept
+ {
+ return is_number_float() ? &m_value.number_float : nullptr;
+ }
+
+ /*!
+ @brief helper function to implement get_ref()
+
+ This function helps to implement get_ref() without code duplication for
+ const and non-const overloads
+
+ @tparam ThisType will be deduced as `basic_json` or `const basic_json`
+
+ @throw type_error.303 if ReferenceType does not match underlying value
+ type of the current JSON
+ */
+ template<typename ReferenceType, typename ThisType>
+ static ReferenceType get_ref_impl(ThisType& obj)
+ {
+ // delegate the call to get_ptr<>()
+ auto ptr = obj.template get_ptr<typename std::add_pointer<ReferenceType>::type>();
+
+ if (JSON_LIKELY(ptr != nullptr))
+ {
+ return *ptr;
+ }
+
+ JSON_THROW(type_error::create(303, "incompatible ReferenceType for get_ref, actual type is " + std::string(obj.type_name())));
+ }
+
+ public:
+ /// @name value access
+ /// Direct access to the stored value of a JSON value.
+ /// @{
+
+ /*!
+ @brief get special-case overload
+
+ This overloads avoids a lot of template boilerplate, it can be seen as the
+ identity method
+
+ @tparam BasicJsonType == @ref basic_json
+
+ @return a copy of *this
+
+ @complexity Constant.
+
+ @since version 2.1.0
+ */
+ template<typename BasicJsonType, detail::enable_if_t<
+ std::is_same<typename std::remove_const<BasicJsonType>::type, basic_json_t>::value,
+ int> = 0>
+ basic_json get() const
+ {
+ return *this;
+ }
+
+ /*!
+ @brief get special-case overload
+
+ This overloads converts the current @ref basic_json in a different
+ @ref basic_json type
+
+ @tparam BasicJsonType == @ref basic_json
+
+ @return a copy of *this, converted into @tparam BasicJsonType
+
+ @complexity Depending on the implementation of the called `from_json()`
+ method.
+
+ @since version 3.2.0
+ */
+ template<typename BasicJsonType, detail::enable_if_t<
+ not std::is_same<BasicJsonType, basic_json>::value and
+ detail::is_basic_json<BasicJsonType>::value, int> = 0>
+ BasicJsonType get() const
+ {
+ return *this;
+ }
+
+ /*!
+ @brief get a value (explicit)
+
+ Explicit type conversion between the JSON value and a compatible value
+ which is [CopyConstructible](https://en.cppreference.com/w/cpp/named_req/CopyConstructible)
+ and [DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible).
+ The value is converted by calling the @ref json_serializer<ValueType>
+ `from_json()` method.
+
+ The function is equivalent to executing
+ @code {.cpp}
+ ValueType ret;
+ JSONSerializer<ValueType>::from_json(*this, ret);
+ return ret;
+ @endcode
+
+ This overloads is chosen if:
+ - @a ValueType is not @ref basic_json,
+ - @ref json_serializer<ValueType> has a `from_json()` method of the form
+ `void from_json(const basic_json&, ValueType&)`, and
+ - @ref json_serializer<ValueType> does not have a `from_json()` method of
+ the form `ValueType from_json(const basic_json&)`
+
+ @tparam ValueTypeCV the provided value type
+ @tparam ValueType the returned value type
+
+ @return copy of the JSON value, converted to @a ValueType
+
+ @throw what @ref json_serializer<ValueType> `from_json()` method throws
+
+ @liveexample{The example below shows several conversions from JSON values
+ to other types. There a few things to note: (1) Floating-point numbers can
+ be converted to integers\, (2) A JSON array can be converted to a standard
+ `std::vector<short>`\, (3) A JSON object can be converted to C++
+ associative containers such as `std::unordered_map<std::string\,
+ json>`.,get__ValueType_const}
+
+ @since version 2.1.0
+ */
+ template<typename ValueTypeCV, typename ValueType = detail::uncvref_t<ValueTypeCV>,
+ detail::enable_if_t <
+ not detail::is_basic_json<ValueType>::value and
+ detail::has_from_json<basic_json_t, ValueType>::value and
+ not detail::has_non_default_from_json<basic_json_t, ValueType>::value,
+ int> = 0>
+ ValueType get() const noexcept(noexcept(
+ JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), std::declval<ValueType&>())))
+ {
+ // we cannot static_assert on ValueTypeCV being non-const, because
+ // there is support for get<const basic_json_t>(), which is why we
+ // still need the uncvref
+ static_assert(not std::is_reference<ValueTypeCV>::value,
+ "get() cannot be used with reference types, you might want to use get_ref()");
+ static_assert(std::is_default_constructible<ValueType>::value,
+ "types must be DefaultConstructible when used with get()");
+
+ ValueType ret;
+ JSONSerializer<ValueType>::from_json(*this, ret);
+ return ret;
+ }
+
+ /*!
+ @brief get a value (explicit); special case
+
+ Explicit type conversion between the JSON value and a compatible value
+ which is **not** [CopyConstructible](https://en.cppreference.com/w/cpp/named_req/CopyConstructible)
+ and **not** [DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible).
+ The value is converted by calling the @ref json_serializer<ValueType>
+ `from_json()` method.
+
+ The function is equivalent to executing
+ @code {.cpp}
+ return JSONSerializer<ValueTypeCV>::from_json(*this);
+ @endcode
+
+ This overloads is chosen if:
+ - @a ValueType is not @ref basic_json and
+ - @ref json_serializer<ValueType> has a `from_json()` method of the form
+ `ValueType from_json(const basic_json&)`
+
+ @note If @ref json_serializer<ValueType> has both overloads of
+ `from_json()`, this one is chosen.
+
+ @tparam ValueTypeCV the provided value type
+ @tparam ValueType the returned value type
+
+ @return copy of the JSON value, converted to @a ValueType
+
+ @throw what @ref json_serializer<ValueType> `from_json()` method throws
+
+ @since version 2.1.0
+ */
+ template<typename ValueTypeCV, typename ValueType = detail::uncvref_t<ValueTypeCV>,
+ detail::enable_if_t<not std::is_same<basic_json_t, ValueType>::value and
+ detail::has_non_default_from_json<basic_json_t, ValueType>::value,
+ int> = 0>
+ ValueType get() const noexcept(noexcept(
+ JSONSerializer<ValueTypeCV>::from_json(std::declval<const basic_json_t&>())))
+ {
+ static_assert(not std::is_reference<ValueTypeCV>::value,
+ "get() cannot be used with reference types, you might want to use get_ref()");
+ return JSONSerializer<ValueTypeCV>::from_json(*this);
+ }
+
+ /*!
+ @brief get a value (explicit)
+
+ Explicit type conversion between the JSON value and a compatible value.
+ The value is filled into the input parameter by calling the @ref json_serializer<ValueType>
+ `from_json()` method.
+
+ The function is equivalent to executing
+ @code {.cpp}
+ ValueType v;
+ JSONSerializer<ValueType>::from_json(*this, v);
+ @endcode
+
+ This overloads is chosen if:
+ - @a ValueType is not @ref basic_json,
+ - @ref json_serializer<ValueType> has a `from_json()` method of the form
+ `void from_json(const basic_json&, ValueType&)`, and
+
+ @tparam ValueType the input parameter type.
+
+ @return the input parameter, allowing chaining calls.
+
+ @throw what @ref json_serializer<ValueType> `from_json()` method throws
+
+ @liveexample{The example below shows several conversions from JSON values
+ to other types. There a few things to note: (1) Floating-point numbers can
+ be converted to integers\, (2) A JSON array can be converted to a standard
+ `std::vector<short>`\, (3) A JSON object can be converted to C++
+ associative containers such as `std::unordered_map<std::string\,
+ json>`.,get_to}
+
+ @since version 3.3.0
+ */
+ template<typename ValueType,
+ detail::enable_if_t <
+ not detail::is_basic_json<ValueType>::value and
+ detail::has_from_json<basic_json_t, ValueType>::value,
+ int> = 0>
+ ValueType & get_to(ValueType& v) const noexcept(noexcept(
+ JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), v)))
+ {
+ JSONSerializer<ValueType>::from_json(*this, v);
+ return v;
+ }
+
+
+ /*!
+ @brief get a pointer value (implicit)
+
+ Implicit pointer access to the internally stored JSON value. No copies are
+ made.
+
+ @warning Writing data to the pointee of the result yields an undefined
+ state.
+
+ @tparam PointerType pointer type; must be a pointer to @ref array_t, @ref
+ object_t, @ref string_t, @ref boolean_t, @ref number_integer_t,
+ @ref number_unsigned_t, or @ref number_float_t. Enforced by a static
+ assertion.
+
+ @return pointer to the internally stored JSON value if the requested
+ pointer type @a PointerType fits to the JSON value; `nullptr` otherwise
+
+ @complexity Constant.
+
+ @liveexample{The example below shows how pointers to internal values of a
+ JSON value can be requested. Note that no type conversions are made and a
+ `nullptr` is returned if the value and the requested pointer type does not
+ match.,get_ptr}
+
+ @since version 1.0.0
+ */
+ template<typename PointerType, typename std::enable_if<
+ std::is_pointer<PointerType>::value, int>::type = 0>
+ auto get_ptr() noexcept -> decltype(std::declval<basic_json_t&>().get_impl_ptr(std::declval<PointerType>()))
+ {
+ // delegate the call to get_impl_ptr<>()
+ return get_impl_ptr(static_cast<PointerType>(nullptr));
+ }
+
+ /*!
+ @brief get a pointer value (implicit)
+ @copydoc get_ptr()
+ */
+ template<typename PointerType, typename std::enable_if<
+ std::is_pointer<PointerType>::value and
+ std::is_const<typename std::remove_pointer<PointerType>::type>::value, int>::type = 0>
+ constexpr auto get_ptr() const noexcept -> decltype(std::declval<const basic_json_t&>().get_impl_ptr(std::declval<PointerType>()))
+ {
+ // delegate the call to get_impl_ptr<>() const
+ return get_impl_ptr(static_cast<PointerType>(nullptr));
+ }
+
+ /*!
+ @brief get a pointer value (explicit)
+
+ Explicit pointer access to the internally stored JSON value. No copies are
+ made.
+
+ @warning The pointer becomes invalid if the underlying JSON object
+ changes.
+
+ @tparam PointerType pointer type; must be a pointer to @ref array_t, @ref
+ object_t, @ref string_t, @ref boolean_t, @ref number_integer_t,
+ @ref number_unsigned_t, or @ref number_float_t.
+
+ @return pointer to the internally stored JSON value if the requested
+ pointer type @a PointerType fits to the JSON value; `nullptr` otherwise
+
+ @complexity Constant.
+
+ @liveexample{The example below shows how pointers to internal values of a
+ JSON value can be requested. Note that no type conversions are made and a
+ `nullptr` is returned if the value and the requested pointer type does not
+ match.,get__PointerType}
+
+ @sa @ref get_ptr() for explicit pointer-member access
+
+ @since version 1.0.0
+ */
+ template<typename PointerType, typename std::enable_if<
+ std::is_pointer<PointerType>::value, int>::type = 0>
+ auto get() noexcept -> decltype(std::declval<basic_json_t&>().template get_ptr<PointerType>())
+ {
+ // delegate the call to get_ptr
+ return get_ptr<PointerType>();
+ }
+
+ /*!
+ @brief get a pointer value (explicit)
+ @copydoc get()
+ */
+ template<typename PointerType, typename std::enable_if<
+ std::is_pointer<PointerType>::value, int>::type = 0>
+ constexpr auto get() const noexcept -> decltype(std::declval<const basic_json_t&>().template get_ptr<PointerType>())
+ {
+ // delegate the call to get_ptr
+ return get_ptr<PointerType>();
+ }
+
+ /*!
+ @brief get a reference value (implicit)
+
+ Implicit reference access to the internally stored JSON value. No copies
+ are made.
+
+ @warning Writing data to the referee of the result yields an undefined
+ state.
+
+ @tparam ReferenceType reference type; must be a reference to @ref array_t,
+ @ref object_t, @ref string_t, @ref boolean_t, @ref number_integer_t, or
+ @ref number_float_t. Enforced by static assertion.
+
+ @return reference to the internally stored JSON value if the requested
+ reference type @a ReferenceType fits to the JSON value; throws
+ type_error.303 otherwise
+
+ @throw type_error.303 in case passed type @a ReferenceType is incompatible
+ with the stored JSON value; see example below
+
+ @complexity Constant.
+
+ @liveexample{The example shows several calls to `get_ref()`.,get_ref}
+
+ @since version 1.1.0
+ */
+ template<typename ReferenceType, typename std::enable_if<
+ std::is_reference<ReferenceType>::value, int>::type = 0>
+ ReferenceType get_ref()
+ {
+ // delegate call to get_ref_impl
+ return get_ref_impl<ReferenceType>(*this);
+ }
+
+ /*!
+ @brief get a reference value (implicit)
+ @copydoc get_ref()
+ */
+ template<typename ReferenceType, typename std::enable_if<
+ std::is_reference<ReferenceType>::value and
+ std::is_const<typename std::remove_reference<ReferenceType>::type>::value, int>::type = 0>
+ ReferenceType get_ref() const
+ {
+ // delegate call to get_ref_impl
+ return get_ref_impl<ReferenceType>(*this);
+ }
+
+ /*!
+ @brief get a value (implicit)
+
+ Implicit type conversion between the JSON value and a compatible value.
+ The call is realized by calling @ref get() const.
+
+ @tparam ValueType non-pointer type compatible to the JSON value, for
+ instance `int` for JSON integer numbers, `bool` for JSON booleans, or
+ `std::vector` types for JSON arrays. The character type of @ref string_t
+ as well as an initializer list of this type is excluded to avoid
+ ambiguities as these types implicitly convert to `std::string`.
+
+ @return copy of the JSON value, converted to type @a ValueType
+
+ @throw type_error.302 in case passed type @a ValueType is incompatible
+ to the JSON value type (e.g., the JSON value is of type boolean, but a
+ string is requested); see example below
+
+ @complexity Linear in the size of the JSON value.
+
+ @liveexample{The example below shows several conversions from JSON values
+ to other types. There a few things to note: (1) Floating-point numbers can
+ be converted to integers\, (2) A JSON array can be converted to a standard
+ `std::vector<short>`\, (3) A JSON object can be converted to C++
+ associative containers such as `std::unordered_map<std::string\,
+ json>`.,operator__ValueType}
+
+ @since version 1.0.0
+ */
+ template < typename ValueType, typename std::enable_if <
+ not std::is_pointer<ValueType>::value and
+ not std::is_same<ValueType, detail::json_ref<basic_json>>::value and
+ not std::is_same<ValueType, typename string_t::value_type>::value and
+ not detail::is_basic_json<ValueType>::value
+
+#ifndef _MSC_VER // fix for issue #167 operator<< ambiguity under VS2015
+ and not std::is_same<ValueType, std::initializer_list<typename string_t::value_type>>::value
+#if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) and _MSC_VER <= 1914))
+ and not std::is_same<ValueType, typename std::string_view>::value
+#endif
+#endif
+ and detail::is_detected<detail::get_template_function, const basic_json_t&, ValueType>::value
+ , int >::type = 0 >
+ operator ValueType() const
+ {
+ // delegate the call to get<>() const
+ return get<ValueType>();
+ }
+
+ /// @}
+
+
+ ////////////////////
+ // element access //
+ ////////////////////
+
+ /// @name element access
+ /// Access to the JSON value.
+ /// @{
+
+ /*!
+ @brief access specified array element with bounds checking
+
+ Returns a reference to the element at specified location @a idx, with
+ bounds checking.
+
+ @param[in] idx index of the element to access
+
+ @return reference to the element at index @a idx
+
+ @throw type_error.304 if the JSON value is not an array; in this case,
+ calling `at` with an index makes no sense. See example below.
+ @throw out_of_range.401 if the index @a idx is out of range of the array;
+ that is, `idx >= size()`. See example below.
+
+ @exceptionsafety Strong guarantee: if an exception is thrown, there are no
+ changes in the JSON value.
+
+ @complexity Constant.
+
+ @since version 1.0.0
+
+ @liveexample{The example below shows how array elements can be read and
+ written using `at()`. It also demonstrates the different exceptions that
+ can be thrown.,at__size_type}
+ */
+ reference at(size_type idx)
+ {
+ // at only works for arrays
+ if (JSON_LIKELY(is_array()))
+ {
+ JSON_TRY
+ {
+ return m_value.array->at(idx);
+ }
+ JSON_CATCH (std::out_of_range&)
+ {
+ // create better exception explanation
+ JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range"));
+ }
+ }
+ else
+ {
+ JSON_THROW(type_error::create(304, "cannot use at() with " + std::string(type_name())));
+ }
+ }
+
+ /*!
+ @brief access specified array element with bounds checking
+
+ Returns a const reference to the element at specified location @a idx,
+ with bounds checking.
+
+ @param[in] idx index of the element to access
+
+ @return const reference to the element at index @a idx
+
+ @throw type_error.304 if the JSON value is not an array; in this case,
+ calling `at` with an index makes no sense. See example below.
+ @throw out_of_range.401 if the index @a idx is out of range of the array;
+ that is, `idx >= size()`. See example below.
+
+ @exceptionsafety Strong guarantee: if an exception is thrown, there are no
+ changes in the JSON value.
+
+ @complexity Constant.
+
+ @since version 1.0.0
+
+ @liveexample{The example below shows how array elements can be read using
+ `at()`. It also demonstrates the different exceptions that can be thrown.,
+ at__size_type_const}
+ */
+ const_reference at(size_type idx) const
+ {
+ // at only works for arrays
+ if (JSON_LIKELY(is_array()))
+ {
+ JSON_TRY
+ {
+ return m_value.array->at(idx);
+ }
+ JSON_CATCH (std::out_of_range&)
+ {
+ // create better exception explanation
+ JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range"));
+ }
+ }
+ else
+ {
+ JSON_THROW(type_error::create(304, "cannot use at() with " + std::string(type_name())));
+ }
+ }
+
+ /*!
+ @brief access specified object element with bounds checking
+
+ Returns a reference to the element at with specified key @a key, with
+ bounds checking.
+
+ @param[in] key key of the element to access
+
+ @return reference to the element at key @a key
+
+ @throw type_error.304 if the JSON value is not an object; in this case,
+ calling `at` with a key makes no sense. See example below.
+ @throw out_of_range.403 if the key @a key is is not stored in the object;
+ that is, `find(key) == end()`. See example below.
+
+ @exceptionsafety Strong guarantee: if an exception is thrown, there are no
+ changes in the JSON value.
+
+ @complexity Logarithmic in the size of the container.
+
+ @sa @ref operator[](const typename object_t::key_type&) for unchecked
+ access by reference
+ @sa @ref value() for access by value with a default value
+
+ @since version 1.0.0
+
+ @liveexample{The example below shows how object elements can be read and
+ written using `at()`. It also demonstrates the different exceptions that
+ can be thrown.,at__object_t_key_type}
+ */
+ reference at(const typename object_t::key_type& key)
+ {
+ // at only works for objects
+ if (JSON_LIKELY(is_object()))
+ {
+ JSON_TRY
+ {
+ return m_value.object->at(key);
+ }
+ JSON_CATCH (std::out_of_range&)
+ {
+ // create better exception explanation
+ JSON_THROW(out_of_range::create(403, "key '" + key + "' not found"));
+ }
+ }
+ else
+ {
+ JSON_THROW(type_error::create(304, "cannot use at() with " + std::string(type_name())));
+ }
+ }
+
+ /*!
+ @brief access specified object element with bounds checking
+
+ Returns a const reference to the element at with specified key @a key,
+ with bounds checking.
+
+ @param[in] key key of the element to access
+
+ @return const reference to the element at key @a key
+
+ @throw type_error.304 if the JSON value is not an object; in this case,
+ calling `at` with a key makes no sense. See example below.
+ @throw out_of_range.403 if the key @a key is is not stored in the object;
+ that is, `find(key) == end()`. See example below.
+
+ @exceptionsafety Strong guarantee: if an exception is thrown, there are no
+ changes in the JSON value.
+
+ @complexity Logarithmic in the size of the container.
+
+ @sa @ref operator[](const typename object_t::key_type&) for unchecked
+ access by reference
+ @sa @ref value() for access by value with a default value
+
+ @since version 1.0.0
+
+ @liveexample{The example below shows how object elements can be read using
+ `at()`. It also demonstrates the different exceptions that can be thrown.,
+ at__object_t_key_type_const}
+ */
+ const_reference at(const typename object_t::key_type& key) const
+ {
+ // at only works for objects
+ if (JSON_LIKELY(is_object()))
+ {
+ JSON_TRY
+ {
+ return m_value.object->at(key);
+ }
+ JSON_CATCH (std::out_of_range&)
+ {
+ // create better exception explanation
+ JSON_THROW(out_of_range::create(403, "key '" + key + "' not found"));
+ }
+ }
+ else
+ {
+ JSON_THROW(type_error::create(304, "cannot use at() with " + std::string(type_name())));
+ }
+ }
+
+ /*!
+ @brief access specified array element
+
+ Returns a reference to the element at specified location @a idx.
+
+ @note If @a idx is beyond the range of the array (i.e., `idx >= size()`),
+ then the array is silently filled up with `null` values to make `idx` a
+ valid reference to the last stored element.
+
+ @param[in] idx index of the element to access
+
+ @return reference to the element at index @a idx
+
+ @throw type_error.305 if the JSON value is not an array or null; in that
+ cases, using the [] operator with an index makes no sense.
+
+ @complexity Constant if @a idx is in the range of the array. Otherwise
+ linear in `idx - size()`.
+
+ @liveexample{The example below shows how array elements can be read and
+ written using `[]` operator. Note the addition of `null`
+ values.,operatorarray__size_type}
+
+ @since version 1.0.0
+ */
+ reference operator[](size_type idx)
+ {
+ // implicitly convert null value to an empty array
+ if (is_null())
+ {
+ m_type = value_t::array;
+ m_value.array = create<array_t>();
+ assert_invariant();
+ }
+
+ // operator[] only works for arrays
+ if (JSON_LIKELY(is_array()))
+ {
+ // fill up array with null values if given idx is outside range
+ if (idx >= m_value.array->size())
+ {
+ m_value.array->insert(m_value.array->end(),
+ idx - m_value.array->size() + 1,
+ basic_json());
+ }
+
+ return m_value.array->operator[](idx);
+ }
+
+ JSON_THROW(type_error::create(305, "cannot use operator[] with a numeric argument with " + std::string(type_name())));
+ }
+
+ /*!
+ @brief access specified array element
+
+ Returns a const reference to the element at specified location @a idx.
+
+ @param[in] idx index of the element to access
+
+ @return const reference to the element at index @a idx
+
+ @throw type_error.305 if the JSON value is not an array; in that case,
+ using the [] operator with an index makes no sense.
+
+ @complexity Constant.
+
+ @liveexample{The example below shows how array elements can be read using
+ the `[]` operator.,operatorarray__size_type_const}
+
+ @since version 1.0.0
+ */
+ const_reference operator[](size_type idx) const
+ {
+ // const operator[] only works for arrays
+ if (JSON_LIKELY(is_array()))
+ {
+ return m_value.array->operator[](idx);
+ }
+
+ JSON_THROW(type_error::create(305, "cannot use operator[] with a numeric argument with " + std::string(type_name())));
+ }
+
+ /*!
+ @brief access specified object element
+
+ Returns a reference to the element at with specified key @a key.
+
+ @note If @a key is not found in the object, then it is silently added to
+ the object and filled with a `null` value to make `key` a valid reference.
+ In case the value was `null` before, it is converted to an object.
+
+ @param[in] key key of the element to access
+
+ @return reference to the element at key @a key
+
+ @throw type_error.305 if the JSON value is not an object or null; in that
+ cases, using the [] operator with a key makes no sense.
+
+ @complexity Logarithmic in the size of the container.
+
+ @liveexample{The example below shows how object elements can be read and
+ written using the `[]` operator.,operatorarray__key_type}
+
+ @sa @ref at(const typename object_t::key_type&) for access by reference
+ with range checking
+ @sa @ref value() for access by value with a default value
+
+ @since version 1.0.0
+ */
+ reference operator[](const typename object_t::key_type& key)
+ {
+ // implicitly convert null value to an empty object
+ if (is_null())
+ {
+ m_type = value_t::object;
+ m_value.object = create<object_t>();
+ assert_invariant();
+ }
+
+ // operator[] only works for objects
+ if (JSON_LIKELY(is_object()))
+ {
+ return m_value.object->operator[](key);
+ }
+
+ JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name())));
+ }
+
+ /*!
+ @brief read-only access specified object element
+
+ Returns a const reference to the element at with specified key @a key. No
+ bounds checking is performed.
+
+ @warning If the element with key @a key does not exist, the behavior is
+ undefined.
+
+ @param[in] key key of the element to access
+
+ @return const reference to the element at key @a key
+
+ @pre The element with key @a key must exist. **This precondition is
+ enforced with an assertion.**
+
+ @throw type_error.305 if the JSON value is not an object; in that case,
+ using the [] operator with a key makes no sense.
+
+ @complexity Logarithmic in the size of the container.
+
+ @liveexample{The example below shows how object elements can be read using
+ the `[]` operator.,operatorarray__key_type_const}
+
+ @sa @ref at(const typename object_t::key_type&) for access by reference
+ with range checking
+ @sa @ref value() for access by value with a default value
+
+ @since version 1.0.0
+ */
+ const_reference operator[](const typename object_t::key_type& key) const
+ {
+ // const operator[] only works for objects
+ if (JSON_LIKELY(is_object()))
+ {
+ assert(m_value.object->find(key) != m_value.object->end());
+ return m_value.object->find(key)->second;
+ }
+
+ JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name())));
+ }
+
+ /*!
+ @brief access specified object element
+
+ Returns a reference to the element at with specified key @a key.
+
+ @note If @a key is not found in the object, then it is silently added to
+ the object and filled with a `null` value to make `key` a valid reference.
+ In case the value was `null` before, it is converted to an object.
+
+ @param[in] key key of the element to access
+
+ @return reference to the element at key @a key
+
+ @throw type_error.305 if the JSON value is not an object or null; in that
+ cases, using the [] operator with a key makes no sense.
+
+ @complexity Logarithmic in the size of the container.
+
+ @liveexample{The example below shows how object elements can be read and
+ written using the `[]` operator.,operatorarray__key_type}
+
+ @sa @ref at(const typename object_t::key_type&) for access by reference
+ with range checking
+ @sa @ref value() for access by value with a default value
+
+ @since version 1.1.0
+ */
+ template<typename T>
+ reference operator[](T* key)
+ {
+ // implicitly convert null to object
+ if (is_null())
+ {
+ m_type = value_t::object;
+ m_value = value_t::object;
+ assert_invariant();
+ }
+
+ // at only works for objects
+ if (JSON_LIKELY(is_object()))
+ {
+ return m_value.object->operator[](key);
+ }
+
+ JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name())));
+ }
+
+ /*!
+ @brief read-only access specified object element
+
+ Returns a const reference to the element at with specified key @a key. No
+ bounds checking is performed.
+
+ @warning If the element with key @a key does not exist, the behavior is
+ undefined.
+
+ @param[in] key key of the element to access
+
+ @return const reference to the element at key @a key
+
+ @pre The element with key @a key must exist. **This precondition is
+ enforced with an assertion.**
+
+ @throw type_error.305 if the JSON value is not an object; in that case,
+ using the [] operator with a key makes no sense.
+
+ @complexity Logarithmic in the size of the container.
+
+ @liveexample{The example below shows how object elements can be read using
+ the `[]` operator.,operatorarray__key_type_const}
+
+ @sa @ref at(const typename object_t::key_type&) for access by reference
+ with range checking
+ @sa @ref value() for access by value with a default value
+
+ @since version 1.1.0
+ */
+ template<typename T>
+ const_reference operator[](T* key) const
+ {
+ // at only works for objects
+ if (JSON_LIKELY(is_object()))
+ {
+ assert(m_value.object->find(key) != m_value.object->end());
+ return m_value.object->find(key)->second;
+ }
+
+ JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name())));
+ }
+
+ /*!
+ @brief access specified object element with default value
+
+ Returns either a copy of an object's element at the specified key @a key
+ or a given default value if no element with key @a key exists.
+
+ The function is basically equivalent to executing
+ @code {.cpp}
+ try {
+ return at(key);
+ } catch(out_of_range) {
+ return default_value;
+ }
+ @endcode
+
+ @note Unlike @ref at(const typename object_t::key_type&), this function
+ does not throw if the given key @a key was not found.
+
+ @note Unlike @ref operator[](const typename object_t::key_type& key), this
+ function does not implicitly add an element to the position defined by @a
+ key. This function is furthermore also applicable to const objects.
+
+ @param[in] key key of the element to access
+ @param[in] default_value the value to return if @a key is not found
+
+ @tparam ValueType type compatible to JSON values, for instance `int` for
+ JSON integer numbers, `bool` for JSON booleans, or `std::vector` types for
+ JSON arrays. Note the type of the expected value at @a key and the default
+ value @a default_value must be compatible.
+
+ @return copy of the element at key @a key or @a default_value if @a key
+ is not found
+
+ @throw type_error.306 if the JSON value is not an object; in that case,
+ using `value()` with a key makes no sense.
+
+ @complexity Logarithmic in the size of the container.
+
+ @liveexample{The example below shows how object elements can be queried
+ with a default value.,basic_json__value}
+
+ @sa @ref at(const typename object_t::key_type&) for access by reference
+ with range checking
+ @sa @ref operator[](const typename object_t::key_type&) for unchecked
+ access by reference
+
+ @since version 1.0.0
+ */
+ template<class ValueType, typename std::enable_if<
+ std::is_convertible<basic_json_t, ValueType>::value, int>::type = 0>
+ ValueType value(const typename object_t::key_type& key, const ValueType& default_value) const
+ {
+ // at only works for objects
+ if (JSON_LIKELY(is_object()))
+ {
+ // if key is found, return value and given default value otherwise
+ const auto it = find(key);
+ if (it != end())
+ {
+ return *it;
+ }
+
+ return default_value;
+ }
+
+ JSON_THROW(type_error::create(306, "cannot use value() with " + std::string(type_name())));
+ }
+
+ /*!
+ @brief overload for a default value of type const char*
+ @copydoc basic_json::value(const typename object_t::key_type&, const ValueType&) const
+ */
+ string_t value(const typename object_t::key_type& key, const char* default_value) const
+ {
+ return value(key, string_t(default_value));
+ }
+
+ /*!
+ @brief access specified object element via JSON Pointer with default value
+
+ Returns either a copy of an object's element at the specified key @a key
+ or a given default value if no element with key @a key exists.
+
+ The function is basically equivalent to executing
+ @code {.cpp}
+ try {
+ return at(ptr);
+ } catch(out_of_range) {
+ return default_value;
+ }
+ @endcode
+
+ @note Unlike @ref at(const json_pointer&), this function does not throw
+ if the given key @a key was not found.
+
+ @param[in] ptr a JSON pointer to the element to access
+ @param[in] default_value the value to return if @a ptr found no value
+
+ @tparam ValueType type compatible to JSON values, for instance `int` for
+ JSON integer numbers, `bool` for JSON booleans, or `std::vector` types for
+ JSON arrays. Note the type of the expected value at @a key and the default
+ value @a default_value must be compatible.
+
+ @return copy of the element at key @a key or @a default_value if @a key
+ is not found
+
+ @throw type_error.306 if the JSON value is not an object; in that case,
+ using `value()` with a key makes no sense.
+
+ @complexity Logarithmic in the size of the container.
+
+ @liveexample{The example below shows how object elements can be queried
+ with a default value.,basic_json__value_ptr}
+
+ @sa @ref operator[](const json_pointer&) for unchecked access by reference
+
+ @since version 2.0.2
+ */
+ template<class ValueType, typename std::enable_if<
+ std::is_convertible<basic_json_t, ValueType>::value, int>::type = 0>
+ ValueType value(const json_pointer& ptr, const ValueType& default_value) const
+ {
+ // at only works for objects
+ if (JSON_LIKELY(is_object()))
+ {
+ // if pointer resolves a value, return it or use default value
+ JSON_TRY
+ {
+ return ptr.get_checked(this);
+ }
+ JSON_INTERNAL_CATCH (out_of_range&)
+ {
+ return default_value;
+ }
+ }
+
+ JSON_THROW(type_error::create(306, "cannot use value() with " + std::string(type_name())));
+ }
+
+ /*!
+ @brief overload for a default value of type const char*
+ @copydoc basic_json::value(const json_pointer&, ValueType) const
+ */
+ string_t value(const json_pointer& ptr, const char* default_value) const
+ {
+ return value(ptr, string_t(default_value));
+ }
+
+ /*!
+ @brief access the first element
+
+ Returns a reference to the first element in the container. For a JSON
+ container `c`, the expression `c.front()` is equivalent to `*c.begin()`.
+
+ @return In case of a structured type (array or object), a reference to the
+ first element is returned. In case of number, string, or boolean values, a
+ reference to the value is returned.
+
+ @complexity Constant.
+
+ @pre The JSON value must not be `null` (would throw `std::out_of_range`)
+ or an empty array or object (undefined behavior, **guarded by
+ assertions**).
+ @post The JSON value remains unchanged.
+
+ @throw invalid_iterator.214 when called on `null` value
+
+ @liveexample{The following code shows an example for `front()`.,front}
+
+ @sa @ref back() -- access the last element
+
+ @since version 1.0.0
+ */
+ reference front()
+ {
+ return *begin();
+ }
+
+ /*!
+ @copydoc basic_json::front()
+ */
+ const_reference front() const
+ {
+ return *cbegin();
+ }
+
+ /*!
+ @brief access the last element
+
+ Returns a reference to the last element in the container. For a JSON
+ container `c`, the expression `c.back()` is equivalent to
+ @code {.cpp}
+ auto tmp = c.end();
+ --tmp;
+ return *tmp;
+ @endcode
+
+ @return In case of a structured type (array or object), a reference to the
+ last element is returned. In case of number, string, or boolean values, a
+ reference to the value is returned.
+
+ @complexity Constant.
+
+ @pre The JSON value must not be `null` (would throw `std::out_of_range`)
+ or an empty array or object (undefined behavior, **guarded by
+ assertions**).
+ @post The JSON value remains unchanged.
+
+ @throw invalid_iterator.214 when called on a `null` value. See example
+ below.
+
+ @liveexample{The following code shows an example for `back()`.,back}
+
+ @sa @ref front() -- access the first element
+
+ @since version 1.0.0
+ */
+ reference back()
+ {
+ auto tmp = end();
+ --tmp;
+ return *tmp;
+ }
+
+ /*!
+ @copydoc basic_json::back()
+ */
+ const_reference back() const
+ {
+ auto tmp = cend();
+ --tmp;
+ return *tmp;
+ }
+
+ /*!
+ @brief remove element given an iterator
+
+ Removes the element specified by iterator @a pos. The iterator @a pos must
+ be valid and dereferenceable. Thus the `end()` iterator (which is valid,
+ but is not dereferenceable) cannot be used as a value for @a pos.
+
+ If called on a primitive type other than `null`, the resulting JSON value
+ will be `null`.
+
+ @param[in] pos iterator to the element to remove
+ @return Iterator following the last removed element. If the iterator @a
+ pos refers to the last element, the `end()` iterator is returned.
+
+ @tparam IteratorType an @ref iterator or @ref const_iterator
+
+ @post Invalidates iterators and references at or after the point of the
+ erase, including the `end()` iterator.
+
+ @throw type_error.307 if called on a `null` value; example: `"cannot use
+ erase() with null"`
+ @throw invalid_iterator.202 if called on an iterator which does not belong
+ to the current JSON value; example: `"iterator does not fit current
+ value"`
+ @throw invalid_iterator.205 if called on a primitive type with invalid
+ iterator (i.e., any iterator which is not `begin()`); example: `"iterator
+ out of range"`
+
+ @complexity The complexity depends on the type:
+ - objects: amortized constant
+ - arrays: linear in distance between @a pos and the end of the container
+ - strings: linear in the length of the string
+ - other types: constant
+
+ @liveexample{The example shows the result of `erase()` for different JSON
+ types.,erase__IteratorType}
+
+ @sa @ref erase(IteratorType, IteratorType) -- removes the elements in
+ the given range
+ @sa @ref erase(const typename object_t::key_type&) -- removes the element
+ from an object at the given key
+ @sa @ref erase(const size_type) -- removes the element from an array at
+ the given index
+
+ @since version 1.0.0
+ */
+ template<class IteratorType, typename std::enable_if<
+ std::is_same<IteratorType, typename basic_json_t::iterator>::value or
+ std::is_same<IteratorType, typename basic_json_t::const_iterator>::value, int>::type
+ = 0>
+ IteratorType erase(IteratorType pos)
+ {
+ // make sure iterator fits the current value
+ if (JSON_UNLIKELY(this != pos.m_object))
+ {
+ JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value"));
+ }
+
+ IteratorType result = end();
+
+ switch (m_type)
+ {
+ case value_t::boolean:
+ case value_t::number_float:
+ case value_t::number_integer:
+ case value_t::number_unsigned:
+ case value_t::string:
+ {
+ if (JSON_UNLIKELY(not pos.m_it.primitive_iterator.is_begin()))
+ {
+ JSON_THROW(invalid_iterator::create(205, "iterator out of range"));
+ }
+
+ if (is_string())
+ {
+ AllocatorType<string_t> alloc;
+ std::allocator_traits<decltype(alloc)>::destroy(alloc, m_value.string);
+ std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.string, 1);
+ m_value.string = nullptr;
+ }
+
+ m_type = value_t::null;
+ assert_invariant();
+ break;
+ }
+
+ case value_t::object:
+ {
+ result.m_it.object_iterator = m_value.object->erase(pos.m_it.object_iterator);
+ break;
+ }
+
+ case value_t::array:
+ {
+ result.m_it.array_iterator = m_value.array->erase(pos.m_it.array_iterator);
+ break;
+ }
+
+ default:
+ JSON_THROW(type_error::create(307, "cannot use erase() with " + std::string(type_name())));
+ }
+
+ return result;
+ }
+
+ /*!
+ @brief remove elements given an iterator range
+
+ Removes the element specified by the range `[first; last)`. The iterator
+ @a first does not need to be dereferenceable if `first == last`: erasing
+ an empty range is a no-op.
+
+ If called on a primitive type other than `null`, the resulting JSON value
+ will be `null`.
+
+ @param[in] first iterator to the beginning of the range to remove
+ @param[in] last iterator past the end of the range to remove
+ @return Iterator following the last removed element. If the iterator @a
+ second refers to the last element, the `end()` iterator is returned.
+
+ @tparam IteratorType an @ref iterator or @ref const_iterator
+
+ @post Invalidates iterators and references at or after the point of the
+ erase, including the `end()` iterator.
+
+ @throw type_error.307 if called on a `null` value; example: `"cannot use
+ erase() with null"`
+ @throw invalid_iterator.203 if called on iterators which does not belong
+ to the current JSON value; example: `"iterators do not fit current value"`
+ @throw invalid_iterator.204 if called on a primitive type with invalid
+ iterators (i.e., if `first != begin()` and `last != end()`); example:
+ `"iterators out of range"`
+
+ @complexity The complexity depends on the type:
+ - objects: `log(size()) + std::distance(first, last)`
+ - arrays: linear in the distance between @a first and @a last, plus linear
+ in the distance between @a last and end of the container
+ - strings: linear in the length of the string
+ - other types: constant
+
+ @liveexample{The example shows the result of `erase()` for different JSON
+ types.,erase__IteratorType_IteratorType}
+
+ @sa @ref erase(IteratorType) -- removes the element at a given position
+ @sa @ref erase(const typename object_t::key_type&) -- removes the element
+ from an object at the given key
+ @sa @ref erase(const size_type) -- removes the element from an array at
+ the given index
+
+ @since version 1.0.0
+ */
+ template<class IteratorType, typename std::enable_if<
+ std::is_same<IteratorType, typename basic_json_t::iterator>::value or
+ std::is_same<IteratorType, typename basic_json_t::const_iterator>::value, int>::type
+ = 0>
+ IteratorType erase(IteratorType first, IteratorType last)
+ {
+ // make sure iterator fits the current value
+ if (JSON_UNLIKELY(this != first.m_object or this != last.m_object))
+ {
+ JSON_THROW(invalid_iterator::create(203, "iterators do not fit current value"));
+ }
+
+ IteratorType result = end();
+
+ switch (m_type)
+ {
+ case value_t::boolean:
+ case value_t::number_float:
+ case value_t::number_integer:
+ case value_t::number_unsigned:
+ case value_t::string:
+ {
+ if (JSON_LIKELY(not first.m_it.primitive_iterator.is_begin()
+ or not last.m_it.primitive_iterator.is_end()))
+ {
+ JSON_THROW(invalid_iterator::create(204, "iterators out of range"));
+ }
+
+ if (is_string())
+ {
+ AllocatorType<string_t> alloc;
+ std::allocator_traits<decltype(alloc)>::destroy(alloc, m_value.string);
+ std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.string, 1);
+ m_value.string = nullptr;
+ }
+
+ m_type = value_t::null;
+ assert_invariant();
+ break;
+ }
+
+ case value_t::object:
+ {
+ result.m_it.object_iterator = m_value.object->erase(first.m_it.object_iterator,
+ last.m_it.object_iterator);
+ break;
+ }
+
+ case value_t::array:
+ {
+ result.m_it.array_iterator = m_value.array->erase(first.m_it.array_iterator,
+ last.m_it.array_iterator);
+ break;
+ }
+
+ default:
+ JSON_THROW(type_error::create(307, "cannot use erase() with " + std::string(type_name())));
+ }
+
+ return result;
+ }
+
+ /*!
+ @brief remove element from a JSON object given a key
+
+ Removes elements from a JSON object with the key value @a key.
+
+ @param[in] key value of the elements to remove
+
+ @return Number of elements removed. If @a ObjectType is the default
+ `std::map` type, the return value will always be `0` (@a key was not
+ found) or `1` (@a key was found).
+
+ @post References and iterators to the erased elements are invalidated.
+ Other references and iterators are not affected.
+
+ @throw type_error.307 when called on a type other than JSON object;
+ example: `"cannot use erase() with null"`
+
+ @complexity `log(size()) + count(key)`
+
+ @liveexample{The example shows the effect of `erase()`.,erase__key_type}
+
+ @sa @ref erase(IteratorType) -- removes the element at a given position
+ @sa @ref erase(IteratorType, IteratorType) -- removes the elements in
+ the given range
+ @sa @ref erase(const size_type) -- removes the element from an array at
+ the given index
+
+ @since version 1.0.0
+ */
+ size_type erase(const typename object_t::key_type& key)
+ {
+ // this erase only works for objects
+ if (JSON_LIKELY(is_object()))
+ {
+ return m_value.object->erase(key);
+ }
+
+ JSON_THROW(type_error::create(307, "cannot use erase() with " + std::string(type_name())));
+ }
+
+ /*!
+ @brief remove element from a JSON array given an index
+
+ Removes element from a JSON array at the index @a idx.
+
+ @param[in] idx index of the element to remove
+
+ @throw type_error.307 when called on a type other than JSON object;
+ example: `"cannot use erase() with null"`
+ @throw out_of_range.401 when `idx >= size()`; example: `"array index 17
+ is out of range"`
+
+ @complexity Linear in distance between @a idx and the end of the container.
+
+ @liveexample{The example shows the effect of `erase()`.,erase__size_type}
+
+ @sa @ref erase(IteratorType) -- removes the element at a given position
+ @sa @ref erase(IteratorType, IteratorType) -- removes the elements in
+ the given range
+ @sa @ref erase(const typename object_t::key_type&) -- removes the element
+ from an object at the given key
+
+ @since version 1.0.0
+ */
+ void erase(const size_type idx)
+ {
+ // this erase only works for arrays
+ if (JSON_LIKELY(is_array()))
+ {
+ if (JSON_UNLIKELY(idx >= size()))
+ {
+ JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range"));
+ }
+
+ m_value.array->erase(m_value.array->begin() + static_cast<difference_type>(idx));
+ }
+ else
+ {
+ JSON_THROW(type_error::create(307, "cannot use erase() with " + std::string(type_name())));
+ }
+ }
+
+ /// @}
+
+
+ ////////////
+ // lookup //
+ ////////////
+
+ /// @name lookup
+ /// @{
+
+ /*!
+ @brief find an element in a JSON object
+
+ Finds an element in a JSON object with key equivalent to @a key. If the
+ element is not found or the JSON value is not an object, end() is
+ returned.
+
+ @note This method always returns @ref end() when executed on a JSON type
+ that is not an object.
+
+ @param[in] key key value of the element to search for.
+
+ @return Iterator to an element with key equivalent to @a key. If no such
+ element is found or the JSON value is not an object, past-the-end (see
+ @ref end()) iterator is returned.
+
+ @complexity Logarithmic in the size of the JSON object.
+
+ @liveexample{The example shows how `find()` is used.,find__key_type}
+
+ @sa @ref contains(KeyT&&) const -- checks whether a key exists
+
+ @since version 1.0.0
+ */
+ template<typename KeyT>
+ iterator find(KeyT&& key)
+ {
+ auto result = end();
+
+ if (is_object())
+ {
+ result.m_it.object_iterator = m_value.object->find(std::forward<KeyT>(key));
+ }
+
+ return result;
+ }
+
+ /*!
+ @brief find an element in a JSON object
+ @copydoc find(KeyT&&)
+ */
+ template<typename KeyT>
+ const_iterator find(KeyT&& key) const
+ {
+ auto result = cend();
+
+ if (is_object())
+ {
+ result.m_it.object_iterator = m_value.object->find(std::forward<KeyT>(key));
+ }
+
+ return result;
+ }
+
+ /*!
+ @brief returns the number of occurrences of a key in a JSON object
+
+ Returns the number of elements with key @a key. If ObjectType is the
+ default `std::map` type, the return value will always be `0` (@a key was
+ not found) or `1` (@a key was found).
+
+ @note This method always returns `0` when executed on a JSON type that is
+ not an object.
+
+ @param[in] key key value of the element to count
+
+ @return Number of elements with key @a key. If the JSON value is not an
+ object, the return value will be `0`.
+
+ @complexity Logarithmic in the size of the JSON object.
+
+ @liveexample{The example shows how `count()` is used.,count}
+
+ @since version 1.0.0
+ */
+ template<typename KeyT>
+ size_type count(KeyT&& key) const
+ {
+ // return 0 for all nonobject types
+ return is_object() ? m_value.object->count(std::forward<KeyT>(key)) : 0;
+ }
+
+ /*!
+ @brief check the existence of an element in a JSON object
+
+ Check whether an element exists in a JSON object with key equivalent to
+ @a key. If the element is not found or the JSON value is not an object,
+ false is returned.
+
+ @note This method always returns false when executed on a JSON type
+ that is not an object.
+
+ @param[in] key key value to check its existence.
+
+ @return true if an element with specified @a key exists. If no such
+ element with such key is found or the JSON value is not an object,
+ false is returned.
+
+ @complexity Logarithmic in the size of the JSON object.
+
+ @liveexample{The following code shows an example for `contains()`.,contains}
+
+ @sa @ref find(KeyT&&) -- returns an iterator to an object element
+
+ @since version 3.6.0
+ */
+ template<typename KeyT>
+ bool contains(KeyT&& key) const
+ {
+ return is_object() and m_value.object->find(std::forward<KeyT>(key)) != m_value.object->end();
+ }
+
+ /// @}
+
+
+ ///////////////
+ // iterators //
+ ///////////////
+
+ /// @name iterators
+ /// @{
+
+ /*!
+ @brief returns an iterator to the first element
+
+ Returns an iterator to the first element.
+
+ @image html range-begin-end.svg "Illustration from cppreference.com"
+
+ @return iterator to the first element
+
+ @complexity Constant.
+
+ @requirement This function helps `basic_json` satisfying the
+ [Container](https://en.cppreference.com/w/cpp/named_req/Container)
+ requirements:
+ - The complexity is constant.
+
+ @liveexample{The following code shows an example for `begin()`.,begin}
+
+ @sa @ref cbegin() -- returns a const iterator to the beginning
+ @sa @ref end() -- returns an iterator to the end
+ @sa @ref cend() -- returns a const iterator to the end
+
+ @since version 1.0.0
+ */
+ iterator begin() noexcept
+ {
+ iterator result(this);
+ result.set_begin();
+ return result;
+ }
+
+ /*!
+ @copydoc basic_json::cbegin()
+ */
+ const_iterator begin() const noexcept
+ {
+ return cbegin();
+ }
+
+ /*!
+ @brief returns a const iterator to the first element
+
+ Returns a const iterator to the first element.
+
+ @image html range-begin-end.svg "Illustration from cppreference.com"
+
+ @return const iterator to the first element
+
+ @complexity Constant.
+
+ @requirement This function helps `basic_json` satisfying the
+ [Container](https://en.cppreference.com/w/cpp/named_req/Container)
+ requirements:
+ - The complexity is constant.
+ - Has the semantics of `const_cast<const basic_json&>(*this).begin()`.
+
+ @liveexample{The following code shows an example for `cbegin()`.,cbegin}
+
+ @sa @ref begin() -- returns an iterator to the beginning
+ @sa @ref end() -- returns an iterator to the end
+ @sa @ref cend() -- returns a const iterator to the end
+
+ @since version 1.0.0
+ */
+ const_iterator cbegin() const noexcept
+ {
+ const_iterator result(this);
+ result.set_begin();
+ return result;
+ }
+
+ /*!
+ @brief returns an iterator to one past the last element
+
+ Returns an iterator to one past the last element.
+
+ @image html range-begin-end.svg "Illustration from cppreference.com"
+
+ @return iterator one past the last element
+
+ @complexity Constant.
+
+ @requirement This function helps `basic_json` satisfying the
+ [Container](https://en.cppreference.com/w/cpp/named_req/Container)
+ requirements:
+ - The complexity is constant.
+
+ @liveexample{The following code shows an example for `end()`.,end}
+
+ @sa @ref cend() -- returns a const iterator to the end
+ @sa @ref begin() -- returns an iterator to the beginning
+ @sa @ref cbegin() -- returns a const iterator to the beginning
+
+ @since version 1.0.0
+ */
+ iterator end() noexcept
+ {
+ iterator result(this);
+ result.set_end();
+ return result;
+ }
+
+ /*!
+ @copydoc basic_json::cend()
+ */
+ const_iterator end() const noexcept
+ {
+ return cend();
+ }
+
+ /*!
+ @brief returns a const iterator to one past the last element
+
+ Returns a const iterator to one past the last element.
+
+ @image html range-begin-end.svg "Illustration from cppreference.com"
+
+ @return const iterator one past the last element
+
+ @complexity Constant.
+
+ @requirement This function helps `basic_json` satisfying the
+ [Container](https://en.cppreference.com/w/cpp/named_req/Container)
+ requirements:
+ - The complexity is constant.
+ - Has the semantics of `const_cast<const basic_json&>(*this).end()`.
+
+ @liveexample{The following code shows an example for `cend()`.,cend}
+
+ @sa @ref end() -- returns an iterator to the end
+ @sa @ref begin() -- returns an iterator to the beginning
+ @sa @ref cbegin() -- returns a const iterator to the beginning
+
+ @since version 1.0.0
+ */
+ const_iterator cend() const noexcept
+ {
+ const_iterator result(this);
+ result.set_end();
+ return result;
+ }
+
+ /*!
+ @brief returns an iterator to the reverse-beginning
+
+ Returns an iterator to the reverse-beginning; that is, the last element.
+
+ @image html range-rbegin-rend.svg "Illustration from cppreference.com"
+
+ @complexity Constant.
+
+ @requirement This function helps `basic_json` satisfying the
+ [ReversibleContainer](https://en.cppreference.com/w/cpp/named_req/ReversibleContainer)
+ requirements:
+ - The complexity is constant.
+ - Has the semantics of `reverse_iterator(end())`.
+
+ @liveexample{The following code shows an example for `rbegin()`.,rbegin}
+
+ @sa @ref crbegin() -- returns a const reverse iterator to the beginning
+ @sa @ref rend() -- returns a reverse iterator to the end
+ @sa @ref crend() -- returns a const reverse iterator to the end
+
+ @since version 1.0.0
+ */
+ reverse_iterator rbegin() noexcept
+ {
+ return reverse_iterator(end());
+ }
+
+ /*!
+ @copydoc basic_json::crbegin()
+ */
+ const_reverse_iterator rbegin() const noexcept
+ {
+ return crbegin();
+ }
+
+ /*!
+ @brief returns an iterator to the reverse-end
+
+ Returns an iterator to the reverse-end; that is, one before the first
+ element.
+
+ @image html range-rbegin-rend.svg "Illustration from cppreference.com"
+
+ @complexity Constant.
+
+ @requirement This function helps `basic_json` satisfying the
+ [ReversibleContainer](https://en.cppreference.com/w/cpp/named_req/ReversibleContainer)
+ requirements:
+ - The complexity is constant.
+ - Has the semantics of `reverse_iterator(begin())`.
+
+ @liveexample{The following code shows an example for `rend()`.,rend}
+
+ @sa @ref crend() -- returns a const reverse iterator to the end
+ @sa @ref rbegin() -- returns a reverse iterator to the beginning
+ @sa @ref crbegin() -- returns a const reverse iterator to the beginning
+
+ @since version 1.0.0
+ */
+ reverse_iterator rend() noexcept
+ {
+ return reverse_iterator(begin());
+ }
+
+ /*!
+ @copydoc basic_json::crend()
+ */
+ const_reverse_iterator rend() const noexcept
+ {
+ return crend();
+ }
+
+ /*!
+ @brief returns a const reverse iterator to the last element
+
+ Returns a const iterator to the reverse-beginning; that is, the last
+ element.
+
+ @image html range-rbegin-rend.svg "Illustration from cppreference.com"
+
+ @complexity Constant.
+
+ @requirement This function helps `basic_json` satisfying the
+ [ReversibleContainer](https://en.cppreference.com/w/cpp/named_req/ReversibleContainer)
+ requirements:
+ - The complexity is constant.
+ - Has the semantics of `const_cast<const basic_json&>(*this).rbegin()`.
+
+ @liveexample{The following code shows an example for `crbegin()`.,crbegin}
+
+ @sa @ref rbegin() -- returns a reverse iterator to the beginning
+ @sa @ref rend() -- returns a reverse iterator to the end
+ @sa @ref crend() -- returns a const reverse iterator to the end
+
+ @since version 1.0.0
+ */
+ const_reverse_iterator crbegin() const noexcept
+ {
+ return const_reverse_iterator(cend());
+ }
+
+ /*!
+ @brief returns a const reverse iterator to one before the first
+
+ Returns a const reverse iterator to the reverse-end; that is, one before
+ the first element.
+
+ @image html range-rbegin-rend.svg "Illustration from cppreference.com"
+
+ @complexity Constant.
+
+ @requirement This function helps `basic_json` satisfying the
+ [ReversibleContainer](https://en.cppreference.com/w/cpp/named_req/ReversibleContainer)
+ requirements:
+ - The complexity is constant.
+ - Has the semantics of `const_cast<const basic_json&>(*this).rend()`.
+
+ @liveexample{The following code shows an example for `crend()`.,crend}
+
+ @sa @ref rend() -- returns a reverse iterator to the end
+ @sa @ref rbegin() -- returns a reverse iterator to the beginning
+ @sa @ref crbegin() -- returns a const reverse iterator to the beginning
+
+ @since version 1.0.0
+ */
+ const_reverse_iterator crend() const noexcept
+ {
+ return const_reverse_iterator(cbegin());
+ }
+
+ public:
+ /*!
+ @brief wrapper to access iterator member functions in range-based for
+
+ This function allows to access @ref iterator::key() and @ref
+ iterator::value() during range-based for loops. In these loops, a
+ reference to the JSON values is returned, so there is no access to the
+ underlying iterator.
+
+ For loop without iterator_wrapper:
+
+ @code{cpp}
+ for (auto it = j_object.begin(); it != j_object.end(); ++it)
+ {
+ std::cout << "key: " << it.key() << ", value:" << it.value() << '\n';
+ }
+ @endcode
+
+ Range-based for loop without iterator proxy:
+
+ @code{cpp}
+ for (auto it : j_object)
+ {
+ // "it" is of type json::reference and has no key() member
+ std::cout << "value: " << it << '\n';
+ }
+ @endcode
+
+ Range-based for loop with iterator proxy:
+
+ @code{cpp}
+ for (auto it : json::iterator_wrapper(j_object))
+ {
+ std::cout << "key: " << it.key() << ", value:" << it.value() << '\n';
+ }
+ @endcode
+
+ @note When iterating over an array, `key()` will return the index of the
+ element as string (see example).
+
+ @param[in] ref reference to a JSON value
+ @return iteration proxy object wrapping @a ref with an interface to use in
+ range-based for loops
+
+ @liveexample{The following code shows how the wrapper is used,iterator_wrapper}
+
+ @exceptionsafety Strong guarantee: if an exception is thrown, there are no
+ changes in the JSON value.
+
+ @complexity Constant.
+
+ @note The name of this function is not yet final and may change in the
+ future.
+
+ @deprecated This stream operator is deprecated and will be removed in
+ future 4.0.0 of the library. Please use @ref items() instead;
+ that is, replace `json::iterator_wrapper(j)` with `j.items()`.
+ */
+ JSON_DEPRECATED
+ static iteration_proxy<iterator> iterator_wrapper(reference ref) noexcept
+ {
+ return ref.items();
+ }
+
+ /*!
+ @copydoc iterator_wrapper(reference)
+ */
+ JSON_DEPRECATED
+ static iteration_proxy<const_iterator> iterator_wrapper(const_reference ref) noexcept
+ {
+ return ref.items();
+ }
+
+ /*!
+ @brief helper to access iterator member functions in range-based for
+
+ This function allows to access @ref iterator::key() and @ref
+ iterator::value() during range-based for loops. In these loops, a
+ reference to the JSON values is returned, so there is no access to the
+ underlying iterator.
+
+ For loop without `items()` function:
+
+ @code{cpp}
+ for (auto it = j_object.begin(); it != j_object.end(); ++it)
+ {
+ std::cout << "key: " << it.key() << ", value:" << it.value() << '\n';
+ }
+ @endcode
+
+ Range-based for loop without `items()` function:
+
+ @code{cpp}
+ for (auto it : j_object)
+ {
+ // "it" is of type json::reference and has no key() member
+ std::cout << "value: " << it << '\n';
+ }
+ @endcode
+
+ Range-based for loop with `items()` function:
+
+ @code{cpp}
+ for (auto& el : j_object.items())
+ {
+ std::cout << "key: " << el.key() << ", value:" << el.value() << '\n';
+ }
+ @endcode
+
+ The `items()` function also allows to use
+ [structured bindings](https://en.cppreference.com/w/cpp/language/structured_binding)
+ (C++17):
+
+ @code{cpp}
+ for (auto& [key, val] : j_object.items())
+ {
+ std::cout << "key: " << key << ", value:" << val << '\n';
+ }
+ @endcode
+
+ @note When iterating over an array, `key()` will return the index of the
+ element as string (see example). For primitive types (e.g., numbers),
+ `key()` returns an empty string.
+
+ @return iteration proxy object wrapping @a ref with an interface to use in
+ range-based for loops
+
+ @liveexample{The following code shows how the function is used.,items}
+
+ @exceptionsafety Strong guarantee: if an exception is thrown, there are no
+ changes in the JSON value.
+
+ @complexity Constant.
+
+ @since version 3.1.0, structured bindings support since 3.5.0.
+ */
+ iteration_proxy<iterator> items() noexcept
+ {
+ return iteration_proxy<iterator>(*this);
+ }
+
+ /*!
+ @copydoc items()
+ */
+ iteration_proxy<const_iterator> items() const noexcept
+ {
+ return iteration_proxy<const_iterator>(*this);
+ }
+
+ /// @}
+
+
+ //////////////
+ // capacity //
+ //////////////
+
+ /// @name capacity
+ /// @{
+
+ /*!
+ @brief checks whether the container is empty.
+
+ Checks if a JSON value has no elements (i.e. whether its @ref size is `0`).
+
+ @return The return value depends on the different types and is
+ defined as follows:
+ Value type | return value
+ ----------- | -------------
+ null | `true`
+ boolean | `false`
+ string | `false`
+ number | `false`
+ object | result of function `object_t::empty()`
+ array | result of function `array_t::empty()`
+
+ @liveexample{The following code uses `empty()` to check if a JSON
+ object contains any elements.,empty}
+
+ @complexity Constant, as long as @ref array_t and @ref object_t satisfy
+ the Container concept; that is, their `empty()` functions have constant
+ complexity.
+
+ @iterators No changes.
+
+ @exceptionsafety No-throw guarantee: this function never throws exceptions.
+
+ @note This function does not return whether a string stored as JSON value
+ is empty - it returns whether the JSON container itself is empty which is
+ false in the case of a string.
+
+ @requirement This function helps `basic_json` satisfying the
+ [Container](https://en.cppreference.com/w/cpp/named_req/Container)
+ requirements:
+ - The complexity is constant.
+ - Has the semantics of `begin() == end()`.
+
+ @sa @ref size() -- returns the number of elements
+
+ @since version 1.0.0
+ */
+ bool empty() const noexcept
+ {
+ switch (m_type)
+ {
+ case value_t::null:
+ {
+ // null values are empty
+ return true;
+ }
+
+ case value_t::array:
+ {
+ // delegate call to array_t::empty()
+ return m_value.array->empty();
+ }
+
+ case value_t::object:
+ {
+ // delegate call to object_t::empty()
+ return m_value.object->empty();
+ }
+
+ default:
+ {
+ // all other types are nonempty
+ return false;
+ }
+ }
+ }
+
+ /*!
+ @brief returns the number of elements
+
+ Returns the number of elements in a JSON value.
+
+ @return The return value depends on the different types and is
+ defined as follows:
+ Value type | return value
+ ----------- | -------------
+ null | `0`
+ boolean | `1`
+ string | `1`
+ number | `1`
+ object | result of function object_t::size()
+ array | result of function array_t::size()
+
+ @liveexample{The following code calls `size()` on the different value
+ types.,size}
+
+ @complexity Constant, as long as @ref array_t and @ref object_t satisfy
+ the Container concept; that is, their size() functions have constant
+ complexity.
+
+ @iterators No changes.
+
+ @exceptionsafety No-throw guarantee: this function never throws exceptions.
+
+ @note This function does not return the length of a string stored as JSON
+ value - it returns the number of elements in the JSON value which is 1 in
+ the case of a string.
+
+ @requirement This function helps `basic_json` satisfying the
+ [Container](https://en.cppreference.com/w/cpp/named_req/Container)
+ requirements:
+ - The complexity is constant.
+ - Has the semantics of `std::distance(begin(), end())`.
+
+ @sa @ref empty() -- checks whether the container is empty
+ @sa @ref max_size() -- returns the maximal number of elements
+
+ @since version 1.0.0
+ */
+ size_type size() const noexcept
+ {
+ switch (m_type)
+ {
+ case value_t::null:
+ {
+ // null values are empty
+ return 0;
+ }
+
+ case value_t::array:
+ {
+ // delegate call to array_t::size()
+ return m_value.array->size();
+ }
+
+ case value_t::object:
+ {
+ // delegate call to object_t::size()
+ return m_value.object->size();
+ }
+
+ default:
+ {
+ // all other types have size 1
+ return 1;
+ }
+ }
+ }
+
+ /*!
+ @brief returns the maximum possible number of elements
+
+ Returns the maximum number of elements a JSON value is able to hold due to
+ system or library implementation limitations, i.e. `std::distance(begin(),
+ end())` for the JSON value.
+
+ @return The return value depends on the different types and is
+ defined as follows:
+ Value type | return value
+ ----------- | -------------
+ null | `0` (same as `size()`)
+ boolean | `1` (same as `size()`)
+ string | `1` (same as `size()`)
+ number | `1` (same as `size()`)
+ object | result of function `object_t::max_size()`
+ array | result of function `array_t::max_size()`
+
+ @liveexample{The following code calls `max_size()` on the different value
+ types. Note the output is implementation specific.,max_size}
+
+ @complexity Constant, as long as @ref array_t and @ref object_t satisfy
+ the Container concept; that is, their `max_size()` functions have constant
+ complexity.
+
+ @iterators No changes.
+
+ @exceptionsafety No-throw guarantee: this function never throws exceptions.
+
+ @requirement This function helps `basic_json` satisfying the
+ [Container](https://en.cppreference.com/w/cpp/named_req/Container)
+ requirements:
+ - The complexity is constant.
+ - Has the semantics of returning `b.size()` where `b` is the largest
+ possible JSON value.
+
+ @sa @ref size() -- returns the number of elements
+
+ @since version 1.0.0
+ */
+ size_type max_size() const noexcept
+ {
+ switch (m_type)
+ {
+ case value_t::array:
+ {
+ // delegate call to array_t::max_size()
+ return m_value.array->max_size();
+ }
+
+ case value_t::object:
+ {
+ // delegate call to object_t::max_size()
+ return m_value.object->max_size();
+ }
+
+ default:
+ {
+ // all other types have max_size() == size()
+ return size();
+ }
+ }
+ }
+
+ /// @}
+
+
+ ///////////////
+ // modifiers //
+ ///////////////
+
+ /// @name modifiers
+ /// @{
+
+ /*!
+ @brief clears the contents
+
+ Clears the content of a JSON value and resets it to the default value as
+ if @ref basic_json(value_t) would have been called with the current value
+ type from @ref type():
+
+ Value type | initial value
+ ----------- | -------------
+ null | `null`
+ boolean | `false`
+ string | `""`
+ number | `0`
+ object | `{}`
+ array | `[]`
+
+ @post Has the same effect as calling
+ @code {.cpp}
+ *this = basic_json(type());
+ @endcode
+
+ @liveexample{The example below shows the effect of `clear()` to different
+ JSON types.,clear}
+
+ @complexity Linear in the size of the JSON value.
+
+ @iterators All iterators, pointers and references related to this container
+ are invalidated.
+
+ @exceptionsafety No-throw guarantee: this function never throws exceptions.
+
+ @sa @ref basic_json(value_t) -- constructor that creates an object with the
+ same value than calling `clear()`
+
+ @since version 1.0.0
+ */
+ void clear() noexcept
+ {
+ switch (m_type)
+ {
+ case value_t::number_integer:
+ {
+ m_value.number_integer = 0;
+ break;
+ }
+
+ case value_t::number_unsigned:
+ {
+ m_value.number_unsigned = 0;
+ break;
+ }
+
+ case value_t::number_float:
+ {
+ m_value.number_float = 0.0;
+ break;
+ }
+
+ case value_t::boolean:
+ {
+ m_value.boolean = false;
+ break;
+ }
+
+ case value_t::string:
+ {
+ m_value.string->clear();
+ break;
+ }
+
+ case value_t::array:
+ {
+ m_value.array->clear();
+ break;
+ }
+
+ case value_t::object:
+ {
+ m_value.object->clear();
+ break;
+ }
+
+ default:
+ break;
+ }
+ }
+
+ /*!
+ @brief add an object to an array
+
+ Appends the given element @a val to the end of the JSON value. If the
+ function is called on a JSON null value, an empty array is created before
+ appending @a val.
+
+ @param[in] val the value to add to the JSON array
+
+ @throw type_error.308 when called on a type other than JSON array or
+ null; example: `"cannot use push_back() with number"`
+
+ @complexity Amortized constant.
+
+ @liveexample{The example shows how `push_back()` and `+=` can be used to
+ add elements to a JSON array. Note how the `null` value was silently
+ converted to a JSON array.,push_back}
+
+ @since version 1.0.0
+ */
+ void push_back(basic_json&& val)
+ {
+ // push_back only works for null objects or arrays
+ if (JSON_UNLIKELY(not(is_null() or is_array())))
+ {
+ JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name())));
+ }
+
+ // transform null object into an array
+ if (is_null())
+ {
+ m_type = value_t::array;
+ m_value = value_t::array;
+ assert_invariant();
+ }
+
+ // add element to array (move semantics)
+ m_value.array->push_back(std::move(val));
+ // invalidate object: mark it null so we do not call the destructor
+ // cppcheck-suppress accessMoved
+ val.m_type = value_t::null;
+ }
+
+ /*!
+ @brief add an object to an array
+ @copydoc push_back(basic_json&&)
+ */
+ reference operator+=(basic_json&& val)
+ {
+ push_back(std::move(val));
+ return *this;
+ }
+
+ /*!
+ @brief add an object to an array
+ @copydoc push_back(basic_json&&)
+ */
+ void push_back(const basic_json& val)
+ {
+ // push_back only works for null objects or arrays
+ if (JSON_UNLIKELY(not(is_null() or is_array())))
+ {
+ JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name())));
+ }
+
+ // transform null object into an array
+ if (is_null())
+ {
+ m_type = value_t::array;
+ m_value = value_t::array;
+ assert_invariant();
+ }
+
+ // add element to array
+ m_value.array->push_back(val);
+ }
+
+ /*!
+ @brief add an object to an array
+ @copydoc push_back(basic_json&&)
+ */
+ reference operator+=(const basic_json& val)
+ {
+ push_back(val);
+ return *this;
+ }
+
+ /*!
+ @brief add an object to an object
+
+ Inserts the given element @a val to the JSON object. If the function is
+ called on a JSON null value, an empty object is created before inserting
+ @a val.
+
+ @param[in] val the value to add to the JSON object
+
+ @throw type_error.308 when called on a type other than JSON object or
+ null; example: `"cannot use push_back() with number"`
+
+ @complexity Logarithmic in the size of the container, O(log(`size()`)).
+
+ @liveexample{The example shows how `push_back()` and `+=` can be used to
+ add elements to a JSON object. Note how the `null` value was silently
+ converted to a JSON object.,push_back__object_t__value}
+
+ @since version 1.0.0
+ */
+ void push_back(const typename object_t::value_type& val)
+ {
+ // push_back only works for null objects or objects
+ if (JSON_UNLIKELY(not(is_null() or is_object())))
+ {
+ JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name())));
+ }
+
+ // transform null object into an object
+ if (is_null())
+ {
+ m_type = value_t::object;
+ m_value = value_t::object;
+ assert_invariant();
+ }
+
+ // add element to array
+ m_value.object->insert(val);
+ }
+
+ /*!
+ @brief add an object to an object
+ @copydoc push_back(const typename object_t::value_type&)
+ */
+ reference operator+=(const typename object_t::value_type& val)
+ {
+ push_back(val);
+ return *this;
+ }
+
+ /*!
+ @brief add an object to an object
+
+ This function allows to use `push_back` with an initializer list. In case
+
+ 1. the current value is an object,
+ 2. the initializer list @a init contains only two elements, and
+ 3. the first element of @a init is a string,
+
+ @a init is converted into an object element and added using
+ @ref push_back(const typename object_t::value_type&). Otherwise, @a init
+ is converted to a JSON value and added using @ref push_back(basic_json&&).
+
+ @param[in] init an initializer list
+
+ @complexity Linear in the size of the initializer list @a init.
+
+ @note This function is required to resolve an ambiguous overload error,
+ because pairs like `{"key", "value"}` can be both interpreted as
+ `object_t::value_type` or `std::initializer_list<basic_json>`, see
+ https://github.com/nlohmann/json/issues/235 for more information.
+
+ @liveexample{The example shows how initializer lists are treated as
+ objects when possible.,push_back__initializer_list}
+ */
+ void push_back(initializer_list_t init)
+ {
+ if (is_object() and init.size() == 2 and (*init.begin())->is_string())
+ {
+ basic_json&& key = init.begin()->moved_or_copied();
+ push_back(typename object_t::value_type(
+ std::move(key.get_ref<string_t&>()), (init.begin() + 1)->moved_or_copied()));
+ }
+ else
+ {
+ push_back(basic_json(init));
+ }
+ }
+
+ /*!
+ @brief add an object to an object
+ @copydoc push_back(initializer_list_t)
+ */
+ reference operator+=(initializer_list_t init)
+ {
+ push_back(init);
+ return *this;
+ }
+
+ /*!
+ @brief add an object to an array
+
+ Creates a JSON value from the passed parameters @a args to the end of the
+ JSON value. If the function is called on a JSON null value, an empty array
+ is created before appending the value created from @a args.
+
+ @param[in] args arguments to forward to a constructor of @ref basic_json
+ @tparam Args compatible types to create a @ref basic_json object
+
+ @throw type_error.311 when called on a type other than JSON array or
+ null; example: `"cannot use emplace_back() with number"`
+
+ @complexity Amortized constant.
+
+ @liveexample{The example shows how `push_back()` can be used to add
+ elements to a JSON array. Note how the `null` value was silently converted
+ to a JSON array.,emplace_back}
+
+ @since version 2.0.8
+ */
+ template<class... Args>
+ void emplace_back(Args&& ... args)
+ {
+ // emplace_back only works for null objects or arrays
+ if (JSON_UNLIKELY(not(is_null() or is_array())))
+ {
+ JSON_THROW(type_error::create(311, "cannot use emplace_back() with " + std::string(type_name())));
+ }
+
+ // transform null object into an array
+ if (is_null())
+ {
+ m_type = value_t::array;
+ m_value = value_t::array;
+ assert_invariant();
+ }
+
+ // add element to array (perfect forwarding)
+ m_value.array->emplace_back(std::forward<Args>(args)...);
+ }
+
+ /*!
+ @brief add an object to an object if key does not exist
+
+ Inserts a new element into a JSON object constructed in-place with the
+ given @a args if there is no element with the key in the container. If the
+ function is called on a JSON null value, an empty object is created before
+ appending the value created from @a args.
+
+ @param[in] args arguments to forward to a constructor of @ref basic_json
+ @tparam Args compatible types to create a @ref basic_json object
+
+ @return a pair consisting of an iterator to the inserted element, or the
+ already-existing element if no insertion happened, and a bool
+ denoting whether the insertion took place.
+
+ @throw type_error.311 when called on a type other than JSON object or
+ null; example: `"cannot use emplace() with number"`
+
+ @complexity Logarithmic in the size of the container, O(log(`size()`)).
+
+ @liveexample{The example shows how `emplace()` can be used to add elements
+ to a JSON object. Note how the `null` value was silently converted to a
+ JSON object. Further note how no value is added if there was already one
+ value stored with the same key.,emplace}
+
+ @since version 2.0.8
+ */
+ template<class... Args>
+ std::pair<iterator, bool> emplace(Args&& ... args)
+ {
+ // emplace only works for null objects or arrays
+ if (JSON_UNLIKELY(not(is_null() or is_object())))
+ {
+ JSON_THROW(type_error::create(311, "cannot use emplace() with " + std::string(type_name())));
+ }
+
+ // transform null object into an object
+ if (is_null())
+ {
+ m_type = value_t::object;
+ m_value = value_t::object;
+ assert_invariant();
+ }
+
+ // add element to array (perfect forwarding)
+ auto res = m_value.object->emplace(std::forward<Args>(args)...);
+ // create result iterator and set iterator to the result of emplace
+ auto it = begin();
+ it.m_it.object_iterator = res.first;
+
+ // return pair of iterator and boolean
+ return {it, res.second};
+ }
+
+ /// Helper for insertion of an iterator
+ /// @note: This uses std::distance to support GCC 4.8,
+ /// see https://github.com/nlohmann/json/pull/1257
+ template<typename... Args>
+ iterator insert_iterator(const_iterator pos, Args&& ... args)
+ {
+ iterator result(this);
+ assert(m_value.array != nullptr);
+
+ auto insert_pos = std::distance(m_value.array->begin(), pos.m_it.array_iterator);
+ m_value.array->insert(pos.m_it.array_iterator, std::forward<Args>(args)...);
+ result.m_it.array_iterator = m_value.array->begin() + insert_pos;
+
+ // This could have been written as:
+ // result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, cnt, val);
+ // but the return value of insert is missing in GCC 4.8, so it is written this way instead.
+
+ return result;
+ }
+
+ /*!
+ @brief inserts element
+
+ Inserts element @a val before iterator @a pos.
+
+ @param[in] pos iterator before which the content will be inserted; may be
+ the end() iterator
+ @param[in] val element to insert
+ @return iterator pointing to the inserted @a val.
+
+ @throw type_error.309 if called on JSON values other than arrays;
+ example: `"cannot use insert() with string"`
+ @throw invalid_iterator.202 if @a pos is not an iterator of *this;
+ example: `"iterator does not fit current value"`
+
+ @complexity Constant plus linear in the distance between @a pos and end of
+ the container.
+
+ @liveexample{The example shows how `insert()` is used.,insert}
+
+ @since version 1.0.0
+ */
+ iterator insert(const_iterator pos, const basic_json& val)
+ {
+ // insert only works for arrays
+ if (JSON_LIKELY(is_array()))
+ {
+ // check if iterator pos fits to this JSON value
+ if (JSON_UNLIKELY(pos.m_object != this))
+ {
+ JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value"));
+ }
+
+ // insert to array and return iterator
+ return insert_iterator(pos, val);
+ }
+
+ JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name())));
+ }
+
+ /*!
+ @brief inserts element
+ @copydoc insert(const_iterator, const basic_json&)
+ */
+ iterator insert(const_iterator pos, basic_json&& val)
+ {
+ return insert(pos, val);
+ }
+
+ /*!
+ @brief inserts elements
+
+ Inserts @a cnt copies of @a val before iterator @a pos.
+
+ @param[in] pos iterator before which the content will be inserted; may be
+ the end() iterator
+ @param[in] cnt number of copies of @a val to insert
+ @param[in] val element to insert
+ @return iterator pointing to the first element inserted, or @a pos if
+ `cnt==0`
+
+ @throw type_error.309 if called on JSON values other than arrays; example:
+ `"cannot use insert() with string"`
+ @throw invalid_iterator.202 if @a pos is not an iterator of *this;
+ example: `"iterator does not fit current value"`
+
+ @complexity Linear in @a cnt plus linear in the distance between @a pos
+ and end of the container.
+
+ @liveexample{The example shows how `insert()` is used.,insert__count}
+
+ @since version 1.0.0
+ */
+ iterator insert(const_iterator pos, size_type cnt, const basic_json& val)
+ {
+ // insert only works for arrays
+ if (JSON_LIKELY(is_array()))
+ {
+ // check if iterator pos fits to this JSON value
+ if (JSON_UNLIKELY(pos.m_object != this))
+ {
+ JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value"));
+ }
+
+ // insert to array and return iterator
+ return insert_iterator(pos, cnt, val);
+ }
+
+ JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name())));
+ }
+
+ /*!
+ @brief inserts elements
+
+ Inserts elements from range `[first, last)` before iterator @a pos.
+
+ @param[in] pos iterator before which the content will be inserted; may be
+ the end() iterator
+ @param[in] first begin of the range of elements to insert
+ @param[in] last end of the range of elements to insert
+
+ @throw type_error.309 if called on JSON values other than arrays; example:
+ `"cannot use insert() with string"`
+ @throw invalid_iterator.202 if @a pos is not an iterator of *this;
+ example: `"iterator does not fit current value"`
+ @throw invalid_iterator.210 if @a first and @a last do not belong to the
+ same JSON value; example: `"iterators do not fit"`
+ @throw invalid_iterator.211 if @a first or @a last are iterators into
+ container for which insert is called; example: `"passed iterators may not
+ belong to container"`
+
+ @return iterator pointing to the first element inserted, or @a pos if
+ `first==last`
+
+ @complexity Linear in `std::distance(first, last)` plus linear in the
+ distance between @a pos and end of the container.
+
+ @liveexample{The example shows how `insert()` is used.,insert__range}
+
+ @since version 1.0.0
+ */
+ iterator insert(const_iterator pos, const_iterator first, const_iterator last)
+ {
+ // insert only works for arrays
+ if (JSON_UNLIKELY(not is_array()))
+ {
+ JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name())));
+ }
+
+ // check if iterator pos fits to this JSON value
+ if (JSON_UNLIKELY(pos.m_object != this))
+ {
+ JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value"));
+ }
+
+ // check if range iterators belong to the same JSON object
+ if (JSON_UNLIKELY(first.m_object != last.m_object))
+ {
+ JSON_THROW(invalid_iterator::create(210, "iterators do not fit"));
+ }
+
+ if (JSON_UNLIKELY(first.m_object == this))
+ {
+ JSON_THROW(invalid_iterator::create(211, "passed iterators may not belong to container"));
+ }
+
+ // insert to array and return iterator
+ return insert_iterator(pos, first.m_it.array_iterator, last.m_it.array_iterator);
+ }
+
+ /*!
+ @brief inserts elements
+
+ Inserts elements from initializer list @a ilist before iterator @a pos.
+
+ @param[in] pos iterator before which the content will be inserted; may be
+ the end() iterator
+ @param[in] ilist initializer list to insert the values from
+
+ @throw type_error.309 if called on JSON values other than arrays; example:
+ `"cannot use insert() with string"`
+ @throw invalid_iterator.202 if @a pos is not an iterator of *this;
+ example: `"iterator does not fit current value"`
+
+ @return iterator pointing to the first element inserted, or @a pos if
+ `ilist` is empty
+
+ @complexity Linear in `ilist.size()` plus linear in the distance between
+ @a pos and end of the container.
+
+ @liveexample{The example shows how `insert()` is used.,insert__ilist}
+
+ @since version 1.0.0
+ */
+ iterator insert(const_iterator pos, initializer_list_t ilist)
+ {
+ // insert only works for arrays
+ if (JSON_UNLIKELY(not is_array()))
+ {
+ JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name())));
+ }
+
+ // check if iterator pos fits to this JSON value
+ if (JSON_UNLIKELY(pos.m_object != this))
+ {
+ JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value"));
+ }
+
+ // insert to array and return iterator
+ return insert_iterator(pos, ilist.begin(), ilist.end());
+ }
+
+ /*!
+ @brief inserts elements
+
+ Inserts elements from range `[first, last)`.
+
+ @param[in] first begin of the range of elements to insert
+ @param[in] last end of the range of elements to insert
+
+ @throw type_error.309 if called on JSON values other than objects; example:
+ `"cannot use insert() with string"`
+ @throw invalid_iterator.202 if iterator @a first or @a last does does not
+ point to an object; example: `"iterators first and last must point to
+ objects"`
+ @throw invalid_iterator.210 if @a first and @a last do not belong to the
+ same JSON value; example: `"iterators do not fit"`
+
+ @complexity Logarithmic: `O(N*log(size() + N))`, where `N` is the number
+ of elements to insert.
+
+ @liveexample{The example shows how `insert()` is used.,insert__range_object}
+
+ @since version 3.0.0
+ */
+ void insert(const_iterator first, const_iterator last)
+ {
+ // insert only works for objects
+ if (JSON_UNLIKELY(not is_object()))
+ {
+ JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name())));
+ }
+
+ // check if range iterators belong to the same JSON object
+ if (JSON_UNLIKELY(first.m_object != last.m_object))
+ {
+ JSON_THROW(invalid_iterator::create(210, "iterators do not fit"));
+ }
+
+ // passed iterators must belong to objects
+ if (JSON_UNLIKELY(not first.m_object->is_object()))
+ {
+ JSON_THROW(invalid_iterator::create(202, "iterators first and last must point to objects"));
+ }
+
+ m_value.object->insert(first.m_it.object_iterator, last.m_it.object_iterator);
+ }
+
+ /*!
+ @brief updates a JSON object from another object, overwriting existing keys
+
+ Inserts all values from JSON object @a j and overwrites existing keys.
+
+ @param[in] j JSON object to read values from
+
+ @throw type_error.312 if called on JSON values other than objects; example:
+ `"cannot use update() with string"`
+
+ @complexity O(N*log(size() + N)), where N is the number of elements to
+ insert.
+
+ @liveexample{The example shows how `update()` is used.,update}
+
+ @sa https://docs.python.org/3.6/library/stdtypes.html#dict.update
+
+ @since version 3.0.0
+ */
+ void update(const_reference j)
+ {
+ // implicitly convert null value to an empty object
+ if (is_null())
+ {
+ m_type = value_t::object;
+ m_value.object = create<object_t>();
+ assert_invariant();
+ }
+
+ if (JSON_UNLIKELY(not is_object()))
+ {
+ JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(type_name())));
+ }
+ if (JSON_UNLIKELY(not j.is_object()))
+ {
+ JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(j.type_name())));
+ }
+
+ for (auto it = j.cbegin(); it != j.cend(); ++it)
+ {
+ m_value.object->operator[](it.key()) = it.value();
+ }
+ }
+
+ /*!
+ @brief updates a JSON object from another object, overwriting existing keys
+
+ Inserts all values from from range `[first, last)` and overwrites existing
+ keys.
+
+ @param[in] first begin of the range of elements to insert
+ @param[in] last end of the range of elements to insert
+
+ @throw type_error.312 if called on JSON values other than objects; example:
+ `"cannot use update() with string"`
+ @throw invalid_iterator.202 if iterator @a first or @a last does does not
+ point to an object; example: `"iterators first and last must point to
+ objects"`
+ @throw invalid_iterator.210 if @a first and @a last do not belong to the
+ same JSON value; example: `"iterators do not fit"`
+
+ @complexity O(N*log(size() + N)), where N is the number of elements to
+ insert.
+
+ @liveexample{The example shows how `update()` is used__range.,update}
+
+ @sa https://docs.python.org/3.6/library/stdtypes.html#dict.update
+
+ @since version 3.0.0
+ */
+ void update(const_iterator first, const_iterator last)
+ {
+ // implicitly convert null value to an empty object
+ if (is_null())
+ {
+ m_type = value_t::object;
+ m_value.object = create<object_t>();
+ assert_invariant();
+ }
+
+ if (JSON_UNLIKELY(not is_object()))
+ {
+ JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(type_name())));
+ }
+
+ // check if range iterators belong to the same JSON object
+ if (JSON_UNLIKELY(first.m_object != last.m_object))
+ {
+ JSON_THROW(invalid_iterator::create(210, "iterators do not fit"));
+ }
+
+ // passed iterators must belong to objects
+ if (JSON_UNLIKELY(not first.m_object->is_object()
+ or not last.m_object->is_object()))
+ {
+ JSON_THROW(invalid_iterator::create(202, "iterators first and last must point to objects"));
+ }
+
+ for (auto it = first; it != last; ++it)
+ {
+ m_value.object->operator[](it.key()) = it.value();
+ }
+ }
+
+ /*!
+ @brief exchanges the values
+
+ Exchanges the contents of the JSON value with those of @a other. Does not
+ invoke any move, copy, or swap operations on individual elements. All
+ iterators and references remain valid. The past-the-end iterator is
+ invalidated.
+
+ @param[in,out] other JSON value to exchange the contents with
+
+ @complexity Constant.
+
+ @liveexample{The example below shows how JSON values can be swapped with
+ `swap()`.,swap__reference}
+
+ @since version 1.0.0
+ */
+ void swap(reference other) noexcept (
+ std::is_nothrow_move_constructible<value_t>::value and
+ std::is_nothrow_move_assignable<value_t>::value and
+ std::is_nothrow_move_constructible<json_value>::value and
+ std::is_nothrow_move_assignable<json_value>::value
+ )
+ {
+ std::swap(m_type, other.m_type);
+ std::swap(m_value, other.m_value);
+ assert_invariant();
+ }
+
+ /*!
+ @brief exchanges the values
+
+ Exchanges the contents of a JSON array with those of @a other. Does not
+ invoke any move, copy, or swap operations on individual elements. All
+ iterators and references remain valid. The past-the-end iterator is
+ invalidated.
+
+ @param[in,out] other array to exchange the contents with
+
+ @throw type_error.310 when JSON value is not an array; example: `"cannot
+ use swap() with string"`
+
+ @complexity Constant.
+
+ @liveexample{The example below shows how arrays can be swapped with
+ `swap()`.,swap__array_t}
+
+ @since version 1.0.0
+ */
+ void swap(array_t& other)
+ {
+ // swap only works for arrays
+ if (JSON_LIKELY(is_array()))
+ {
+ std::swap(*(m_value.array), other);
+ }
+ else
+ {
+ JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name())));
+ }
+ }
+
+ /*!
+ @brief exchanges the values
+
+ Exchanges the contents of a JSON object with those of @a other. Does not
+ invoke any move, copy, or swap operations on individual elements. All
+ iterators and references remain valid. The past-the-end iterator is
+ invalidated.
+
+ @param[in,out] other object to exchange the contents with
+
+ @throw type_error.310 when JSON value is not an object; example:
+ `"cannot use swap() with string"`
+
+ @complexity Constant.
+
+ @liveexample{The example below shows how objects can be swapped with
+ `swap()`.,swap__object_t}
+
+ @since version 1.0.0
+ */
+ void swap(object_t& other)
+ {
+ // swap only works for objects
+ if (JSON_LIKELY(is_object()))
+ {
+ std::swap(*(m_value.object), other);
+ }
+ else
+ {
+ JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name())));
+ }
+ }
+
+ /*!
+ @brief exchanges the values
+
+ Exchanges the contents of a JSON string with those of @a other. Does not
+ invoke any move, copy, or swap operations on individual elements. All
+ iterators and references remain valid. The past-the-end iterator is
+ invalidated.
+
+ @param[in,out] other string to exchange the contents with
+
+ @throw type_error.310 when JSON value is not a string; example: `"cannot
+ use swap() with boolean"`
+
+ @complexity Constant.
+
+ @liveexample{The example below shows how strings can be swapped with
+ `swap()`.,swap__string_t}
+
+ @since version 1.0.0
+ */
+ void swap(string_t& other)
+ {
+ // swap only works for strings
+ if (JSON_LIKELY(is_string()))
+ {
+ std::swap(*(m_value.string), other);
+ }
+ else
+ {
+ JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name())));
+ }
+ }
+
+ /// @}
+
+ public:
+ //////////////////////////////////////////
+ // lexicographical comparison operators //
+ //////////////////////////////////////////
+
+ /// @name lexicographical comparison operators
+ /// @{
+
+ /*!
+ @brief comparison: equal
+
+ Compares two JSON values for equality according to the following rules:
+ - Two JSON values are equal if (1) they are from the same type and (2)
+ their stored values are the same according to their respective
+ `operator==`.
+ - Integer and floating-point numbers are automatically converted before
+ comparison. Note than two NaN values are always treated as unequal.
+ - Two JSON null values are equal.
+
+ @note Floating-point inside JSON values numbers are compared with
+ `json::number_float_t::operator==` which is `double::operator==` by
+ default. To compare floating-point while respecting an epsilon, an alternative
+ [comparison function](https://github.com/mariokonrad/marnav/blob/master/src/marnav/math/floatingpoint.hpp#L34-#L39)
+ could be used, for instance
+ @code {.cpp}
+ template<typename T, typename = typename std::enable_if<std::is_floating_point<T>::value, T>::type>
+ inline bool is_same(T a, T b, T epsilon = std::numeric_limits<T>::epsilon()) noexcept
+ {
+ return std::abs(a - b) <= epsilon;
+ }
+ @endcode
+
+ @note NaN values never compare equal to themselves or to other NaN values.
+
+ @param[in] lhs first JSON value to consider
+ @param[in] rhs second JSON value to consider
+ @return whether the values @a lhs and @a rhs are equal
+
+ @exceptionsafety No-throw guarantee: this function never throws exceptions.
+
+ @complexity Linear.
+
+ @liveexample{The example demonstrates comparing several JSON
+ types.,operator__equal}
+
+ @since version 1.0.0
+ */
+ friend bool operator==(const_reference lhs, const_reference rhs) noexcept
+ {
+ const auto lhs_type = lhs.type();
+ const auto rhs_type = rhs.type();
+
+ if (lhs_type == rhs_type)
+ {
+ switch (lhs_type)
+ {
+ case value_t::array:
+ return *lhs.m_value.array == *rhs.m_value.array;
+
+ case value_t::object:
+ return *lhs.m_value.object == *rhs.m_value.object;
+
+ case value_t::null:
+ return true;
+
+ case value_t::string:
+ return *lhs.m_value.string == *rhs.m_value.string;
+
+ case value_t::boolean:
+ return lhs.m_value.boolean == rhs.m_value.boolean;
+
+ case value_t::number_integer:
+ return lhs.m_value.number_integer == rhs.m_value.number_integer;
+
+ case value_t::number_unsigned:
+ return lhs.m_value.number_unsigned == rhs.m_value.number_unsigned;
+
+ case value_t::number_float:
+ return lhs.m_value.number_float == rhs.m_value.number_float;
+
+ default:
+ return false;
+ }
+ }
+ else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_float)
+ {
+ return static_cast<number_float_t>(lhs.m_value.number_integer) == rhs.m_value.number_float;
+ }
+ else if (lhs_type == value_t::number_float and rhs_type == value_t::number_integer)
+ {
+ return lhs.m_value.number_float == static_cast<number_float_t>(rhs.m_value.number_integer);
+ }
+ else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_float)
+ {
+ return static_cast<number_float_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_float;
+ }
+ else if (lhs_type == value_t::number_float and rhs_type == value_t::number_unsigned)
+ {
+ return lhs.m_value.number_float == static_cast<number_float_t>(rhs.m_value.number_unsigned);
+ }
+ else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_integer)
+ {
+ return static_cast<number_integer_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_integer;
+ }
+ else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_unsigned)
+ {
+ return lhs.m_value.number_integer == static_cast<number_integer_t>(rhs.m_value.number_unsigned);
+ }
+
+ return false;
+ }
+
+ /*!
+ @brief comparison: equal
+ @copydoc operator==(const_reference, const_reference)
+ */
+ template<typename ScalarType, typename std::enable_if<
+ std::is_scalar<ScalarType>::value, int>::type = 0>
+ friend bool operator==(const_reference lhs, const ScalarType rhs) noexcept
+ {
+ return lhs == basic_json(rhs);
+ }
+
+ /*!
+ @brief comparison: equal
+ @copydoc operator==(const_reference, const_reference)
+ */
+ template<typename ScalarType, typename std::enable_if<
+ std::is_scalar<ScalarType>::value, int>::type = 0>
+ friend bool operator==(const ScalarType lhs, const_reference rhs) noexcept
+ {
+ return basic_json(lhs) == rhs;
+ }
+
+ /*!
+ @brief comparison: not equal
+
+ Compares two JSON values for inequality by calculating `not (lhs == rhs)`.
+
+ @param[in] lhs first JSON value to consider
+ @param[in] rhs second JSON value to consider
+ @return whether the values @a lhs and @a rhs are not equal
+
+ @complexity Linear.
+
+ @exceptionsafety No-throw guarantee: this function never throws exceptions.
+
+ @liveexample{The example demonstrates comparing several JSON
+ types.,operator__notequal}
+
+ @since version 1.0.0
+ */
+ friend bool operator!=(const_reference lhs, const_reference rhs) noexcept
+ {
+ return not (lhs == rhs);
+ }
+
+ /*!
+ @brief comparison: not equal
+ @copydoc operator!=(const_reference, const_reference)
+ */
+ template<typename ScalarType, typename std::enable_if<
+ std::is_scalar<ScalarType>::value, int>::type = 0>
+ friend bool operator!=(const_reference lhs, const ScalarType rhs) noexcept
+ {
+ return lhs != basic_json(rhs);
+ }
+
+ /*!
+ @brief comparison: not equal
+ @copydoc operator!=(const_reference, const_reference)
+ */
+ template<typename ScalarType, typename std::enable_if<
+ std::is_scalar<ScalarType>::value, int>::type = 0>
+ friend bool operator!=(const ScalarType lhs, const_reference rhs) noexcept
+ {
+ return basic_json(lhs) != rhs;
+ }
+
+ /*!
+ @brief comparison: less than
+
+ Compares whether one JSON value @a lhs is less than another JSON value @a
+ rhs according to the following rules:
+ - If @a lhs and @a rhs have the same type, the values are compared using
+ the default `<` operator.
+ - Integer and floating-point numbers are automatically converted before
+ comparison
+ - In case @a lhs and @a rhs have different types, the values are ignored
+ and the order of the types is considered, see
+ @ref operator<(const value_t, const value_t).
+
+ @param[in] lhs first JSON value to consider
+ @param[in] rhs second JSON value to consider
+ @return whether @a lhs is less than @a rhs
+
+ @complexity Linear.
+
+ @exceptionsafety No-throw guarantee: this function never throws exceptions.
+
+ @liveexample{The example demonstrates comparing several JSON
+ types.,operator__less}
+
+ @since version 1.0.0
+ */
+ friend bool operator<(const_reference lhs, const_reference rhs) noexcept
+ {
+ const auto lhs_type = lhs.type();
+ const auto rhs_type = rhs.type();
+
+ if (lhs_type == rhs_type)
+ {
+ switch (lhs_type)
+ {
+ case value_t::array:
+ // note parentheses are necessary, see
+ // https://github.com/nlohmann/json/issues/1530
+ return (*lhs.m_value.array) < (*rhs.m_value.array);
+
+ case value_t::object:
+ return *lhs.m_value.object < *rhs.m_value.object;
+
+ case value_t::null:
+ return false;
+
+ case value_t::string:
+ return *lhs.m_value.string < *rhs.m_value.string;
+
+ case value_t::boolean:
+ return lhs.m_value.boolean < rhs.m_value.boolean;
+
+ case value_t::number_integer:
+ return lhs.m_value.number_integer < rhs.m_value.number_integer;
+
+ case value_t::number_unsigned:
+ return lhs.m_value.number_unsigned < rhs.m_value.number_unsigned;
+
+ case value_t::number_float:
+ return lhs.m_value.number_float < rhs.m_value.number_float;
+
+ default:
+ return false;
+ }
+ }
+ else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_float)
+ {
+ return static_cast<number_float_t>(lhs.m_value.number_integer) < rhs.m_value.number_float;
+ }
+ else if (lhs_type == value_t::number_float and rhs_type == value_t::number_integer)
+ {
+ return lhs.m_value.number_float < static_cast<number_float_t>(rhs.m_value.number_integer);
+ }
+ else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_float)
+ {
+ return static_cast<number_float_t>(lhs.m_value.number_unsigned) < rhs.m_value.number_float;
+ }
+ else if (lhs_type == value_t::number_float and rhs_type == value_t::number_unsigned)
+ {
+ return lhs.m_value.number_float < static_cast<number_float_t>(rhs.m_value.number_unsigned);
+ }
+ else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_unsigned)
+ {
+ return lhs.m_value.number_integer < static_cast<number_integer_t>(rhs.m_value.number_unsigned);
+ }
+ else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_integer)
+ {
+ return static_cast<number_integer_t>(lhs.m_value.number_unsigned) < rhs.m_value.number_integer;
+ }
+
+ // We only reach this line if we cannot compare values. In that case,
+ // we compare types. Note we have to call the operator explicitly,
+ // because MSVC has problems otherwise.
+ return operator<(lhs_type, rhs_type);
+ }
+
+ /*!
+ @brief comparison: less than
+ @copydoc operator<(const_reference, const_reference)
+ */
+ template<typename ScalarType, typename std::enable_if<
+ std::is_scalar<ScalarType>::value, int>::type = 0>
+ friend bool operator<(const_reference lhs, const ScalarType rhs) noexcept
+ {
+ return lhs < basic_json(rhs);
+ }
+
+ /*!
+ @brief comparison: less than
+ @copydoc operator<(const_reference, const_reference)
+ */
+ template<typename ScalarType, typename std::enable_if<
+ std::is_scalar<ScalarType>::value, int>::type = 0>
+ friend bool operator<(const ScalarType lhs, const_reference rhs) noexcept
+ {
+ return basic_json(lhs) < rhs;
+ }
+
+ /*!
+ @brief comparison: less than or equal
+
+ Compares whether one JSON value @a lhs is less than or equal to another
+ JSON value by calculating `not (rhs < lhs)`.
+
+ @param[in] lhs first JSON value to consider
+ @param[in] rhs second JSON value to consider
+ @return whether @a lhs is less than or equal to @a rhs
+
+ @complexity Linear.
+
+ @exceptionsafety No-throw guarantee: this function never throws exceptions.
+
+ @liveexample{The example demonstrates comparing several JSON
+ types.,operator__greater}
+
+ @since version 1.0.0
+ */
+ friend bool operator<=(const_reference lhs, const_reference rhs) noexcept
+ {
+ return not (rhs < lhs);
+ }
+
+ /*!
+ @brief comparison: less than or equal
+ @copydoc operator<=(const_reference, const_reference)
+ */
+ template<typename ScalarType, typename std::enable_if<
+ std::is_scalar<ScalarType>::value, int>::type = 0>
+ friend bool operator<=(const_reference lhs, const ScalarType rhs) noexcept
+ {
+ return lhs <= basic_json(rhs);
+ }
+
+ /*!
+ @brief comparison: less than or equal
+ @copydoc operator<=(const_reference, const_reference)
+ */
+ template<typename ScalarType, typename std::enable_if<
+ std::is_scalar<ScalarType>::value, int>::type = 0>
+ friend bool operator<=(const ScalarType lhs, const_reference rhs) noexcept
+ {
+ return basic_json(lhs) <= rhs;
+ }
+
+ /*!
+ @brief comparison: greater than
+
+ Compares whether one JSON value @a lhs is greater than another
+ JSON value by calculating `not (lhs <= rhs)`.
+
+ @param[in] lhs first JSON value to consider
+ @param[in] rhs second JSON value to consider
+ @return whether @a lhs is greater than to @a rhs
+
+ @complexity Linear.
+
+ @exceptionsafety No-throw guarantee: this function never throws exceptions.
+
+ @liveexample{The example demonstrates comparing several JSON
+ types.,operator__lessequal}
+
+ @since version 1.0.0
+ */
+ friend bool operator>(const_reference lhs, const_reference rhs) noexcept
+ {
+ return not (lhs <= rhs);
+ }
+
+ /*!
+ @brief comparison: greater than
+ @copydoc operator>(const_reference, const_reference)
+ */
+ template<typename ScalarType, typename std::enable_if<
+ std::is_scalar<ScalarType>::value, int>::type = 0>
+ friend bool operator>(const_reference lhs, const ScalarType rhs) noexcept
+ {
+ return lhs > basic_json(rhs);
+ }
+
+ /*!
+ @brief comparison: greater than
+ @copydoc operator>(const_reference, const_reference)
+ */
+ template<typename ScalarType, typename std::enable_if<
+ std::is_scalar<ScalarType>::value, int>::type = 0>
+ friend bool operator>(const ScalarType lhs, const_reference rhs) noexcept
+ {
+ return basic_json(lhs) > rhs;
+ }
+
+ /*!
+ @brief comparison: greater than or equal
+
+ Compares whether one JSON value @a lhs is greater than or equal to another
+ JSON value by calculating `not (lhs < rhs)`.
+
+ @param[in] lhs first JSON value to consider
+ @param[in] rhs second JSON value to consider
+ @return whether @a lhs is greater than or equal to @a rhs
+
+ @complexity Linear.
+
+ @exceptionsafety No-throw guarantee: this function never throws exceptions.
+
+ @liveexample{The example demonstrates comparing several JSON
+ types.,operator__greaterequal}
+
+ @since version 1.0.0
+ */
+ friend bool operator>=(const_reference lhs, const_reference rhs) noexcept
+ {
+ return not (lhs < rhs);
+ }
+
+ /*!
+ @brief comparison: greater than or equal
+ @copydoc operator>=(const_reference, const_reference)
+ */
+ template<typename ScalarType, typename std::enable_if<
+ std::is_scalar<ScalarType>::value, int>::type = 0>
+ friend bool operator>=(const_reference lhs, const ScalarType rhs) noexcept
+ {
+ return lhs >= basic_json(rhs);
+ }
+
+ /*!
+ @brief comparison: greater than or equal
+ @copydoc operator>=(const_reference, const_reference)
+ */
+ template<typename ScalarType, typename std::enable_if<
+ std::is_scalar<ScalarType>::value, int>::type = 0>
+ friend bool operator>=(const ScalarType lhs, const_reference rhs) noexcept
+ {
+ return basic_json(lhs) >= rhs;
+ }
+
+ /// @}
+
+ ///////////////////
+ // serialization //
+ ///////////////////
+
+ /// @name serialization
+ /// @{
+
+ /*!
+ @brief serialize to stream
+
+ Serialize the given JSON value @a j to the output stream @a o. The JSON
+ value will be serialized using the @ref dump member function.
+
+ - The indentation of the output can be controlled with the member variable
+ `width` of the output stream @a o. For instance, using the manipulator
+ `std::setw(4)` on @a o sets the indentation level to `4` and the
+ serialization result is the same as calling `dump(4)`.
+
+ - The indentation character can be controlled with the member variable
+ `fill` of the output stream @a o. For instance, the manipulator
+ `std::setfill('\\t')` sets indentation to use a tab character rather than
+ the default space character.
+
+ @param[in,out] o stream to serialize to
+ @param[in] j JSON value to serialize
+
+ @return the stream @a o
+
+ @throw type_error.316 if a string stored inside the JSON value is not
+ UTF-8 encoded
+
+ @complexity Linear.
+
+ @liveexample{The example below shows the serialization with different
+ parameters to `width` to adjust the indentation level.,operator_serialize}
+
+ @since version 1.0.0; indentation character added in version 3.0.0
+ */
+ friend std::ostream& operator<<(std::ostream& o, const basic_json& j)
+ {
+ // read width member and use it as indentation parameter if nonzero
+ const bool pretty_print = o.width() > 0;
+ const auto indentation = pretty_print ? o.width() : 0;
+
+ // reset width to 0 for subsequent calls to this stream
+ o.width(0);
+
+ // do the actual serialization
+ serializer s(detail::output_adapter<char>(o), o.fill());
+ s.dump(j, pretty_print, false, static_cast<unsigned int>(indentation));
+ return o;
+ }
+
+ /*!
+ @brief serialize to stream
+ @deprecated This stream operator is deprecated and will be removed in
+ future 4.0.0 of the library. Please use
+ @ref operator<<(std::ostream&, const basic_json&)
+ instead; that is, replace calls like `j >> o;` with `o << j;`.
+ @since version 1.0.0; deprecated since version 3.0.0
+ */
+ JSON_DEPRECATED
+ friend std::ostream& operator>>(const basic_json& j, std::ostream& o)
+ {
+ return o << j;
+ }
+
+ /// @}
+
+
+ /////////////////////
+ // deserialization //
+ /////////////////////
+
+ /// @name deserialization
+ /// @{
+
+ /*!
+ @brief deserialize from a compatible input
+
+ This function reads from a compatible input. Examples are:
+ - an array of 1-byte values
+ - strings with character/literal type with size of 1 byte
+ - input streams
+ - container with contiguous storage of 1-byte values. Compatible container
+ types include `std::vector`, `std::string`, `std::array`,
+ `std::valarray`, and `std::initializer_list`. Furthermore, C-style
+ arrays can be used with `std::begin()`/`std::end()`. User-defined
+ containers can be used as long as they implement random-access iterators
+ and a contiguous storage.
+
+ @pre Each element of the container has a size of 1 byte. Violating this
+ precondition yields undefined behavior. **This precondition is enforced
+ with a static assertion.**
+
+ @pre The container storage is contiguous. Violating this precondition
+ yields undefined behavior. **This precondition is enforced with an
+ assertion.**
+
+ @warning There is no way to enforce all preconditions at compile-time. If
+ the function is called with a noncompliant container and with
+ assertions switched off, the behavior is undefined and will most
+ likely yield segmentation violation.
+
+ @param[in] i input to read from
+ @param[in] cb a parser callback function of type @ref parser_callback_t
+ which is used to control the deserialization by filtering unwanted values
+ (optional)
+ @param[in] allow_exceptions whether to throw exceptions in case of a
+ parse error (optional, true by default)
+
+ @return deserialized JSON value; in case of a parse error and
+ @a allow_exceptions set to `false`, the return value will be
+ value_t::discarded.
+
+ @throw parse_error.101 if a parse error occurs; example: `""unexpected end
+ of input; expected string literal""`
+ @throw parse_error.102 if to_unicode fails or surrogate error
+ @throw parse_error.103 if to_unicode fails
+
+ @complexity Linear in the length of the input. The parser is a predictive
+ LL(1) parser. The complexity can be higher if the parser callback function
+ @a cb has a super-linear complexity.
+
+ @note A UTF-8 byte order mark is silently ignored.
+
+ @liveexample{The example below demonstrates the `parse()` function reading
+ from an array.,parse__array__parser_callback_t}
+
+ @liveexample{The example below demonstrates the `parse()` function with
+ and without callback function.,parse__string__parser_callback_t}
+
+ @liveexample{The example below demonstrates the `parse()` function with
+ and without callback function.,parse__istream__parser_callback_t}
+
+ @liveexample{The example below demonstrates the `parse()` function reading
+ from a contiguous container.,parse__contiguouscontainer__parser_callback_t}
+
+ @since version 2.0.3 (contiguous containers)
+ */
+ JSON_NODISCARD
+ static basic_json parse(detail::input_adapter&& i,
+ const parser_callback_t cb = nullptr,
+ const bool allow_exceptions = true)
+ {
+ basic_json result;
+ parser(i, cb, allow_exceptions).parse(true, result);
+ return result;
+ }
+
+ static bool accept(detail::input_adapter&& i)
+ {
+ return parser(i).accept(true);
+ }
+
+ /*!
+ @brief generate SAX events
+
+ The SAX event lister must follow the interface of @ref json_sax.
+
+ This function reads from a compatible input. Examples are:
+ - an array of 1-byte values
+ - strings with character/literal type with size of 1 byte
+ - input streams
+ - container with contiguous storage of 1-byte values. Compatible container
+ types include `std::vector`, `std::string`, `std::array`,
+ `std::valarray`, and `std::initializer_list`. Furthermore, C-style
+ arrays can be used with `std::begin()`/`std::end()`. User-defined
+ containers can be used as long as they implement random-access iterators
+ and a contiguous storage.
+
+ @pre Each element of the container has a size of 1 byte. Violating this
+ precondition yields undefined behavior. **This precondition is enforced
+ with a static assertion.**
+
+ @pre The container storage is contiguous. Violating this precondition
+ yields undefined behavior. **This precondition is enforced with an
+ assertion.**
+
+ @warning There is no way to enforce all preconditions at compile-time. If
+ the function is called with a noncompliant container and with
+ assertions switched off, the behavior is undefined and will most
+ likely yield segmentation violation.
+
+ @param[in] i input to read from
+ @param[in,out] sax SAX event listener
+ @param[in] format the format to parse (JSON, CBOR, MessagePack, or UBJSON)
+ @param[in] strict whether the input has to be consumed completely
+
+ @return return value of the last processed SAX event
+
+ @throw parse_error.101 if a parse error occurs; example: `""unexpected end
+ of input; expected string literal""`
+ @throw parse_error.102 if to_unicode fails or surrogate error
+ @throw parse_error.103 if to_unicode fails
+
+ @complexity Linear in the length of the input. The parser is a predictive
+ LL(1) parser. The complexity can be higher if the SAX consumer @a sax has
+ a super-linear complexity.
+
+ @note A UTF-8 byte order mark is silently ignored.
+
+ @liveexample{The example below demonstrates the `sax_parse()` function
+ reading from string and processing the events with a user-defined SAX
+ event consumer.,sax_parse}
+
+ @since version 3.2.0
+ */
+ template <typename SAX>
+ static bool sax_parse(detail::input_adapter&& i, SAX* sax,
+ input_format_t format = input_format_t::json,
+ const bool strict = true)
+ {
+ assert(sax);
+ return format == input_format_t::json
+ ? parser(std::move(i)).sax_parse(sax, strict)
+ : detail::binary_reader<basic_json, SAX>(std::move(i)).sax_parse(format, sax, strict);
+ }
+
+ /*!
+ @brief deserialize from an iterator range with contiguous storage
+
+ This function reads from an iterator range of a container with contiguous
+ storage of 1-byte values. Compatible container types include
+ `std::vector`, `std::string`, `std::array`, `std::valarray`, and
+ `std::initializer_list`. Furthermore, C-style arrays can be used with
+ `std::begin()`/`std::end()`. User-defined containers can be used as long
+ as they implement random-access iterators and a contiguous storage.
+
+ @pre The iterator range is contiguous. Violating this precondition yields
+ undefined behavior. **This precondition is enforced with an assertion.**
+ @pre Each element in the range has a size of 1 byte. Violating this
+ precondition yields undefined behavior. **This precondition is enforced
+ with a static assertion.**
+
+ @warning There is no way to enforce all preconditions at compile-time. If
+ the function is called with noncompliant iterators and with
+ assertions switched off, the behavior is undefined and will most
+ likely yield segmentation violation.
+
+ @tparam IteratorType iterator of container with contiguous storage
+ @param[in] first begin of the range to parse (included)
+ @param[in] last end of the range to parse (excluded)
+ @param[in] cb a parser callback function of type @ref parser_callback_t
+ which is used to control the deserialization by filtering unwanted values
+ (optional)
+ @param[in] allow_exceptions whether to throw exceptions in case of a
+ parse error (optional, true by default)
+
+ @return deserialized JSON value; in case of a parse error and
+ @a allow_exceptions set to `false`, the return value will be
+ value_t::discarded.
+
+ @throw parse_error.101 in case of an unexpected token
+ @throw parse_error.102 if to_unicode fails or surrogate error
+ @throw parse_error.103 if to_unicode fails
+
+ @complexity Linear in the length of the input. The parser is a predictive
+ LL(1) parser. The complexity can be higher if the parser callback function
+ @a cb has a super-linear complexity.
+
+ @note A UTF-8 byte order mark is silently ignored.
+
+ @liveexample{The example below demonstrates the `parse()` function reading
+ from an iterator range.,parse__iteratortype__parser_callback_t}
+
+ @since version 2.0.3
+ */
+ template<class IteratorType, typename std::enable_if<
+ std::is_base_of<
+ std::random_access_iterator_tag,
+ typename std::iterator_traits<IteratorType>::iterator_category>::value, int>::type = 0>
+ static basic_json parse(IteratorType first, IteratorType last,
+ const parser_callback_t cb = nullptr,
+ const bool allow_exceptions = true)
+ {
+ basic_json result;
+ parser(detail::input_adapter(first, last), cb, allow_exceptions).parse(true, result);
+ return result;
+ }
+
+ template<class IteratorType, typename std::enable_if<
+ std::is_base_of<
+ std::random_access_iterator_tag,
+ typename std::iterator_traits<IteratorType>::iterator_category>::value, int>::type = 0>
+ static bool accept(IteratorType first, IteratorType last)
+ {
+ return parser(detail::input_adapter(first, last)).accept(true);
+ }
+
+ template<class IteratorType, class SAX, typename std::enable_if<
+ std::is_base_of<
+ std::random_access_iterator_tag,
+ typename std::iterator_traits<IteratorType>::iterator_category>::value, int>::type = 0>
+ static bool sax_parse(IteratorType first, IteratorType last, SAX* sax)
+ {
+ return parser(detail::input_adapter(first, last)).sax_parse(sax);
+ }
+
+ /*!
+ @brief deserialize from stream
+ @deprecated This stream operator is deprecated and will be removed in
+ version 4.0.0 of the library. Please use
+ @ref operator>>(std::istream&, basic_json&)
+ instead; that is, replace calls like `j << i;` with `i >> j;`.
+ @since version 1.0.0; deprecated since version 3.0.0
+ */
+ JSON_DEPRECATED
+ friend std::istream& operator<<(basic_json& j, std::istream& i)
+ {
+ return operator>>(i, j);
+ }
+
+ /*!
+ @brief deserialize from stream
+
+ Deserializes an input stream to a JSON value.
+
+ @param[in,out] i input stream to read a serialized JSON value from
+ @param[in,out] j JSON value to write the deserialized input to
+
+ @throw parse_error.101 in case of an unexpected token
+ @throw parse_error.102 if to_unicode fails or surrogate error
+ @throw parse_error.103 if to_unicode fails
+
+ @complexity Linear in the length of the input. The parser is a predictive
+ LL(1) parser.
+
+ @note A UTF-8 byte order mark is silently ignored.
+
+ @liveexample{The example below shows how a JSON value is constructed by
+ reading a serialization from a stream.,operator_deserialize}
+
+ @sa parse(std::istream&, const parser_callback_t) for a variant with a
+ parser callback function to filter values while parsing
+
+ @since version 1.0.0
+ */
+ friend std::istream& operator>>(std::istream& i, basic_json& j)
+ {
+ parser(detail::input_adapter(i)).parse(false, j);
+ return i;
+ }
+
+ /// @}
+
+ ///////////////////////////
+ // convenience functions //
+ ///////////////////////////
+
+ /*!
+ @brief return the type as string
+
+ Returns the type name as string to be used in error messages - usually to
+ indicate that a function was called on a wrong JSON type.
+
+ @return a string representation of a the @a m_type member:
+ Value type | return value
+ ----------- | -------------
+ null | `"null"`
+ boolean | `"boolean"`
+ string | `"string"`
+ number | `"number"` (for all number types)
+ object | `"object"`
+ array | `"array"`
+ discarded | `"discarded"`
+
+ @exceptionsafety No-throw guarantee: this function never throws exceptions.
+
+ @complexity Constant.
+
+ @liveexample{The following code exemplifies `type_name()` for all JSON
+ types.,type_name}
+
+ @sa @ref type() -- return the type of the JSON value
+ @sa @ref operator value_t() -- return the type of the JSON value (implicit)
+
+ @since version 1.0.0, public since 2.1.0, `const char*` and `noexcept`
+ since 3.0.0
+ */
+ const char* type_name() const noexcept
+ {
+ {
+ switch (m_type)
+ {
+ case value_t::null:
+ return "null";
+ case value_t::object:
+ return "object";
+ case value_t::array:
+ return "array";
+ case value_t::string:
+ return "string";
+ case value_t::boolean:
+ return "boolean";
+ case value_t::discarded:
+ return "discarded";
+ default:
+ return "number";
+ }
+ }
+ }
+
+
+ private:
+ //////////////////////
+ // member variables //
+ //////////////////////
+
+ /// the type of the current element
+ value_t m_type = value_t::null;
+
+ /// the value of the current element
+ json_value m_value = {};
+
+ //////////////////////////////////////////
+ // binary serialization/deserialization //
+ //////////////////////////////////////////
+
+ /// @name binary serialization/deserialization support
+ /// @{
+
+ public:
+ /*!
+ @brief create a CBOR serialization of a given JSON value
+
+ Serializes a given JSON value @a j to a byte vector using the CBOR (Concise
+ Binary Object Representation) serialization format. CBOR is a binary
+ serialization format which aims to be more compact than JSON itself, yet
+ more efficient to parse.
+
+ The library uses the following mapping from JSON values types to
+ CBOR types according to the CBOR specification (RFC 7049):
+
+ JSON value type | value/range | CBOR type | first byte
+ --------------- | ------------------------------------------ | ---------------------------------- | ---------------
+ null | `null` | Null | 0xF6
+ boolean | `true` | True | 0xF5
+ boolean | `false` | False | 0xF4
+ number_integer | -9223372036854775808..-2147483649 | Negative integer (8 bytes follow) | 0x3B
+ number_integer | -2147483648..-32769 | Negative integer (4 bytes follow) | 0x3A
+ number_integer | -32768..-129 | Negative integer (2 bytes follow) | 0x39
+ number_integer | -128..-25 | Negative integer (1 byte follow) | 0x38
+ number_integer | -24..-1 | Negative integer | 0x20..0x37
+ number_integer | 0..23 | Integer | 0x00..0x17
+ number_integer | 24..255 | Unsigned integer (1 byte follow) | 0x18
+ number_integer | 256..65535 | Unsigned integer (2 bytes follow) | 0x19
+ number_integer | 65536..4294967295 | Unsigned integer (4 bytes follow) | 0x1A
+ number_integer | 4294967296..18446744073709551615 | Unsigned integer (8 bytes follow) | 0x1B
+ number_unsigned | 0..23 | Integer | 0x00..0x17
+ number_unsigned | 24..255 | Unsigned integer (1 byte follow) | 0x18
+ number_unsigned | 256..65535 | Unsigned integer (2 bytes follow) | 0x19
+ number_unsigned | 65536..4294967295 | Unsigned integer (4 bytes follow) | 0x1A
+ number_unsigned | 4294967296..18446744073709551615 | Unsigned integer (8 bytes follow) | 0x1B
+ number_float | *any value* | Double-Precision Float | 0xFB
+ string | *length*: 0..23 | UTF-8 string | 0x60..0x77
+ string | *length*: 23..255 | UTF-8 string (1 byte follow) | 0x78
+ string | *length*: 256..65535 | UTF-8 string (2 bytes follow) | 0x79
+ string | *length*: 65536..4294967295 | UTF-8 string (4 bytes follow) | 0x7A
+ string | *length*: 4294967296..18446744073709551615 | UTF-8 string (8 bytes follow) | 0x7B
+ array | *size*: 0..23 | array | 0x80..0x97
+ array | *size*: 23..255 | array (1 byte follow) | 0x98
+ array | *size*: 256..65535 | array (2 bytes follow) | 0x99
+ array | *size*: 65536..4294967295 | array (4 bytes follow) | 0x9A
+ array | *size*: 4294967296..18446744073709551615 | array (8 bytes follow) | 0x9B
+ object | *size*: 0..23 | map | 0xA0..0xB7
+ object | *size*: 23..255 | map (1 byte follow) | 0xB8
+ object | *size*: 256..65535 | map (2 bytes follow) | 0xB9
+ object | *size*: 65536..4294967295 | map (4 bytes follow) | 0xBA
+ object | *size*: 4294967296..18446744073709551615 | map (8 bytes follow) | 0xBB
+
+ @note The mapping is **complete** in the sense that any JSON value type
+ can be converted to a CBOR value.
+
+ @note If NaN or Infinity are stored inside a JSON number, they are
+ serialized properly. This behavior differs from the @ref dump()
+ function which serializes NaN or Infinity to `null`.
+
+ @note The following CBOR types are not used in the conversion:
+ - byte strings (0x40..0x5F)
+ - UTF-8 strings terminated by "break" (0x7F)
+ - arrays terminated by "break" (0x9F)
+ - maps terminated by "break" (0xBF)
+ - date/time (0xC0..0xC1)
+ - bignum (0xC2..0xC3)
+ - decimal fraction (0xC4)
+ - bigfloat (0xC5)
+ - tagged items (0xC6..0xD4, 0xD8..0xDB)
+ - expected conversions (0xD5..0xD7)
+ - simple values (0xE0..0xF3, 0xF8)
+ - undefined (0xF7)
+ - half and single-precision floats (0xF9-0xFA)
+ - break (0xFF)
+
+ @param[in] j JSON value to serialize
+ @return MessagePack serialization as byte vector
+
+ @complexity Linear in the size of the JSON value @a j.
+
+ @liveexample{The example shows the serialization of a JSON value to a byte
+ vector in CBOR format.,to_cbor}
+
+ @sa http://cbor.io
+ @sa @ref from_cbor(detail::input_adapter&&, const bool, const bool) for the
+ analogous deserialization
+ @sa @ref to_msgpack(const basic_json&) for the related MessagePack format
+ @sa @ref to_ubjson(const basic_json&, const bool, const bool) for the
+ related UBJSON format
+
+ @since version 2.0.9
+ */
+ static std::vector<uint8_t> to_cbor(const basic_json& j)
+ {
+ std::vector<uint8_t> result;
+ to_cbor(j, result);
+ return result;
+ }
+
+ static void to_cbor(const basic_json& j, detail::output_adapter<uint8_t> o)
+ {
+ binary_writer<uint8_t>(o).write_cbor(j);
+ }
+
+ static void to_cbor(const basic_json& j, detail::output_adapter<char> o)
+ {
+ binary_writer<char>(o).write_cbor(j);
+ }
+
+ /*!
+ @brief create a MessagePack serialization of a given JSON value
+
+ Serializes a given JSON value @a j to a byte vector using the MessagePack
+ serialization format. MessagePack is a binary serialization format which
+ aims to be more compact than JSON itself, yet more efficient to parse.
+
+ The library uses the following mapping from JSON values types to
+ MessagePack types according to the MessagePack specification:
+
+ JSON value type | value/range | MessagePack type | first byte
+ --------------- | --------------------------------- | ---------------- | ----------
+ null | `null` | nil | 0xC0
+ boolean | `true` | true | 0xC3
+ boolean | `false` | false | 0xC2
+ number_integer | -9223372036854775808..-2147483649 | int64 | 0xD3
+ number_integer | -2147483648..-32769 | int32 | 0xD2
+ number_integer | -32768..-129 | int16 | 0xD1
+ number_integer | -128..-33 | int8 | 0xD0
+ number_integer | -32..-1 | negative fixint | 0xE0..0xFF
+ number_integer | 0..127 | positive fixint | 0x00..0x7F
+ number_integer | 128..255 | uint 8 | 0xCC
+ number_integer | 256..65535 | uint 16 | 0xCD
+ number_integer | 65536..4294967295 | uint 32 | 0xCE
+ number_integer | 4294967296..18446744073709551615 | uint 64 | 0xCF
+ number_unsigned | 0..127 | positive fixint | 0x00..0x7F
+ number_unsigned | 128..255 | uint 8 | 0xCC
+ number_unsigned | 256..65535 | uint 16 | 0xCD
+ number_unsigned | 65536..4294967295 | uint 32 | 0xCE
+ number_unsigned | 4294967296..18446744073709551615 | uint 64 | 0xCF
+ number_float | *any value* | float 64 | 0xCB
+ string | *length*: 0..31 | fixstr | 0xA0..0xBF
+ string | *length*: 32..255 | str 8 | 0xD9
+ string | *length*: 256..65535 | str 16 | 0xDA
+ string | *length*: 65536..4294967295 | str 32 | 0xDB
+ array | *size*: 0..15 | fixarray | 0x90..0x9F
+ array | *size*: 16..65535 | array 16 | 0xDC
+ array | *size*: 65536..4294967295 | array 32 | 0xDD
+ object | *size*: 0..15 | fix map | 0x80..0x8F
+ object | *size*: 16..65535 | map 16 | 0xDE
+ object | *size*: 65536..4294967295 | map 32 | 0xDF
+
+ @note The mapping is **complete** in the sense that any JSON value type
+ can be converted to a MessagePack value.
+
+ @note The following values can **not** be converted to a MessagePack value:
+ - strings with more than 4294967295 bytes
+ - arrays with more than 4294967295 elements
+ - objects with more than 4294967295 elements
+
+ @note The following MessagePack types are not used in the conversion:
+ - bin 8 - bin 32 (0xC4..0xC6)
+ - ext 8 - ext 32 (0xC7..0xC9)
+ - float 32 (0xCA)
+ - fixext 1 - fixext 16 (0xD4..0xD8)
+
+ @note Any MessagePack output created @ref to_msgpack can be successfully
+ parsed by @ref from_msgpack.
+
+ @note If NaN or Infinity are stored inside a JSON number, they are
+ serialized properly. This behavior differs from the @ref dump()
+ function which serializes NaN or Infinity to `null`.
+
+ @param[in] j JSON value to serialize
+ @return MessagePack serialization as byte vector
+
+ @complexity Linear in the size of the JSON value @a j.
+
+ @liveexample{The example shows the serialization of a JSON value to a byte
+ vector in MessagePack format.,to_msgpack}
+
+ @sa http://msgpack.org
+ @sa @ref from_msgpack for the analogous deserialization
+ @sa @ref to_cbor(const basic_json& for the related CBOR format
+ @sa @ref to_ubjson(const basic_json&, const bool, const bool) for the
+ related UBJSON format
+
+ @since version 2.0.9
+ */
+ static std::vector<uint8_t> to_msgpack(const basic_json& j)
+ {
+ std::vector<uint8_t> result;
+ to_msgpack(j, result);
+ return result;
+ }
+
+ static void to_msgpack(const basic_json& j, detail::output_adapter<uint8_t> o)
+ {
+ binary_writer<uint8_t>(o).write_msgpack(j);
+ }
+
+ static void to_msgpack(const basic_json& j, detail::output_adapter<char> o)
+ {
+ binary_writer<char>(o).write_msgpack(j);
+ }
+
+ /*!
+ @brief create a UBJSON serialization of a given JSON value
+
+ Serializes a given JSON value @a j to a byte vector using the UBJSON
+ (Universal Binary JSON) serialization format. UBJSON aims to be more compact
+ than JSON itself, yet more efficient to parse.
+
+ The library uses the following mapping from JSON values types to
+ UBJSON types according to the UBJSON specification:
+
+ JSON value type | value/range | UBJSON type | marker
+ --------------- | --------------------------------- | ----------- | ------
+ null | `null` | null | `Z`
+ boolean | `true` | true | `T`
+ boolean | `false` | false | `F`
+ number_integer | -9223372036854775808..-2147483649 | int64 | `L`
+ number_integer | -2147483648..-32769 | int32 | `l`
+ number_integer | -32768..-129 | int16 | `I`
+ number_integer | -128..127 | int8 | `i`
+ number_integer | 128..255 | uint8 | `U`
+ number_integer | 256..32767 | int16 | `I`
+ number_integer | 32768..2147483647 | int32 | `l`
+ number_integer | 2147483648..9223372036854775807 | int64 | `L`
+ number_unsigned | 0..127 | int8 | `i`
+ number_unsigned | 128..255 | uint8 | `U`
+ number_unsigned | 256..32767 | int16 | `I`
+ number_unsigned | 32768..2147483647 | int32 | `l`
+ number_unsigned | 2147483648..9223372036854775807 | int64 | `L`
+ number_float | *any value* | float64 | `D`
+ string | *with shortest length indicator* | string | `S`
+ array | *see notes on optimized format* | array | `[`
+ object | *see notes on optimized format* | map | `{`
+
+ @note The mapping is **complete** in the sense that any JSON value type
+ can be converted to a UBJSON value.
+
+ @note The following values can **not** be converted to a UBJSON value:
+ - strings with more than 9223372036854775807 bytes (theoretical)
+ - unsigned integer numbers above 9223372036854775807
+
+ @note The following markers are not used in the conversion:
+ - `Z`: no-op values are not created.
+ - `C`: single-byte strings are serialized with `S` markers.
+
+ @note Any UBJSON output created @ref to_ubjson can be successfully parsed
+ by @ref from_ubjson.
+
+ @note If NaN or Infinity are stored inside a JSON number, they are
+ serialized properly. This behavior differs from the @ref dump()
+ function which serializes NaN or Infinity to `null`.
+
+ @note The optimized formats for containers are supported: Parameter
+ @a use_size adds size information to the beginning of a container and
+ removes the closing marker. Parameter @a use_type further checks
+ whether all elements of a container have the same type and adds the
+ type marker to the beginning of the container. The @a use_type
+ parameter must only be used together with @a use_size = true. Note
+ that @a use_size = true alone may result in larger representations -
+ the benefit of this parameter is that the receiving side is
+ immediately informed on the number of elements of the container.
+
+ @param[in] j JSON value to serialize
+ @param[in] use_size whether to add size annotations to container types
+ @param[in] use_type whether to add type annotations to container types
+ (must be combined with @a use_size = true)
+ @return UBJSON serialization as byte vector
+
+ @complexity Linear in the size of the JSON value @a j.
+
+ @liveexample{The example shows the serialization of a JSON value to a byte
+ vector in UBJSON format.,to_ubjson}
+
+ @sa http://ubjson.org
+ @sa @ref from_ubjson(detail::input_adapter&&, const bool, const bool) for the
+ analogous deserialization
+ @sa @ref to_cbor(const basic_json& for the related CBOR format
+ @sa @ref to_msgpack(const basic_json&) for the related MessagePack format
+
+ @since version 3.1.0
+ */
+ static std::vector<uint8_t> to_ubjson(const basic_json& j,
+ const bool use_size = false,
+ const bool use_type = false)
+ {
+ std::vector<uint8_t> result;
+ to_ubjson(j, result, use_size, use_type);
+ return result;
+ }
+
+ static void to_ubjson(const basic_json& j, detail::output_adapter<uint8_t> o,
+ const bool use_size = false, const bool use_type = false)
+ {
+ binary_writer<uint8_t>(o).write_ubjson(j, use_size, use_type);
+ }
+
+ static void to_ubjson(const basic_json& j, detail::output_adapter<char> o,
+ const bool use_size = false, const bool use_type = false)
+ {
+ binary_writer<char>(o).write_ubjson(j, use_size, use_type);
+ }
+
+
+ /*!
+ @brief Serializes the given JSON object `j` to BSON and returns a vector
+ containing the corresponding BSON-representation.
+
+ BSON (Binary JSON) is a binary format in which zero or more ordered key/value pairs are
+ stored as a single entity (a so-called document).
+
+ The library uses the following mapping from JSON values types to BSON types:
+
+ JSON value type | value/range | BSON type | marker
+ --------------- | --------------------------------- | ----------- | ------
+ null | `null` | null | 0x0A
+ boolean | `true`, `false` | boolean | 0x08
+ number_integer | -9223372036854775808..-2147483649 | int64 | 0x12
+ number_integer | -2147483648..2147483647 | int32 | 0x10
+ number_integer | 2147483648..9223372036854775807 | int64 | 0x12
+ number_unsigned | 0..2147483647 | int32 | 0x10
+ number_unsigned | 2147483648..9223372036854775807 | int64 | 0x12
+ number_unsigned | 9223372036854775808..18446744073709551615| -- | --
+ number_float | *any value* | double | 0x01
+ string | *any value* | string | 0x02
+ array | *any value* | document | 0x04
+ object | *any value* | document | 0x03
+
+ @warning The mapping is **incomplete**, since only JSON-objects (and things
+ contained therein) can be serialized to BSON.
+ Also, integers larger than 9223372036854775807 cannot be serialized to BSON,
+ and the keys may not contain U+0000, since they are serialized a
+ zero-terminated c-strings.
+
+ @throw out_of_range.407 if `j.is_number_unsigned() && j.get<std::uint64_t>() > 9223372036854775807`
+ @throw out_of_range.409 if a key in `j` contains a NULL (U+0000)
+ @throw type_error.317 if `!j.is_object()`
+
+ @pre The input `j` is required to be an object: `j.is_object() == true`.
+
+ @note Any BSON output created via @ref to_bson can be successfully parsed
+ by @ref from_bson.
+
+ @param[in] j JSON value to serialize
+ @return BSON serialization as byte vector
+
+ @complexity Linear in the size of the JSON value @a j.
+
+ @liveexample{The example shows the serialization of a JSON value to a byte
+ vector in BSON format.,to_bson}
+
+ @sa http://bsonspec.org/spec.html
+ @sa @ref from_bson(detail::input_adapter&&, const bool strict) for the
+ analogous deserialization
+ @sa @ref to_ubjson(const basic_json&, const bool, const bool) for the
+ related UBJSON format
+ @sa @ref to_cbor(const basic_json&) for the related CBOR format
+ @sa @ref to_msgpack(const basic_json&) for the related MessagePack format
+ */
+ static std::vector<uint8_t> to_bson(const basic_json& j)
+ {
+ std::vector<uint8_t> result;
+ to_bson(j, result);
+ return result;
+ }
+
+ /*!
+ @brief Serializes the given JSON object `j` to BSON and forwards the
+ corresponding BSON-representation to the given output_adapter `o`.
+ @param j The JSON object to convert to BSON.
+ @param o The output adapter that receives the binary BSON representation.
+ @pre The input `j` shall be an object: `j.is_object() == true`
+ @sa @ref to_bson(const basic_json&)
+ */
+ static void to_bson(const basic_json& j, detail::output_adapter<uint8_t> o)
+ {
+ binary_writer<uint8_t>(o).write_bson(j);
+ }
+
+ /*!
+ @copydoc to_bson(const basic_json&, detail::output_adapter<uint8_t>)
+ */
+ static void to_bson(const basic_json& j, detail::output_adapter<char> o)
+ {
+ binary_writer<char>(o).write_bson(j);
+ }
+
+
+ /*!
+ @brief create a JSON value from an input in CBOR format
+
+ Deserializes a given input @a i to a JSON value using the CBOR (Concise
+ Binary Object Representation) serialization format.
+
+ The library maps CBOR types to JSON value types as follows:
+
+ CBOR type | JSON value type | first byte
+ ---------------------- | --------------- | ----------
+ Integer | number_unsigned | 0x00..0x17
+ Unsigned integer | number_unsigned | 0x18
+ Unsigned integer | number_unsigned | 0x19
+ Unsigned integer | number_unsigned | 0x1A
+ Unsigned integer | number_unsigned | 0x1B
+ Negative integer | number_integer | 0x20..0x37
+ Negative integer | number_integer | 0x38
+ Negative integer | number_integer | 0x39
+ Negative integer | number_integer | 0x3A
+ Negative integer | number_integer | 0x3B
+ Negative integer | number_integer | 0x40..0x57
+ UTF-8 string | string | 0x60..0x77
+ UTF-8 string | string | 0x78
+ UTF-8 string | string | 0x79
+ UTF-8 string | string | 0x7A
+ UTF-8 string | string | 0x7B
+ UTF-8 string | string | 0x7F
+ array | array | 0x80..0x97
+ array | array | 0x98
+ array | array | 0x99
+ array | array | 0x9A
+ array | array | 0x9B
+ array | array | 0x9F
+ map | object | 0xA0..0xB7
+ map | object | 0xB8
+ map | object | 0xB9
+ map | object | 0xBA
+ map | object | 0xBB
+ map | object | 0xBF
+ False | `false` | 0xF4
+ True | `true` | 0xF5
+ Null | `null` | 0xF6
+ Half-Precision Float | number_float | 0xF9
+ Single-Precision Float | number_float | 0xFA
+ Double-Precision Float | number_float | 0xFB
+
+ @warning The mapping is **incomplete** in the sense that not all CBOR
+ types can be converted to a JSON value. The following CBOR types
+ are not supported and will yield parse errors (parse_error.112):
+ - byte strings (0x40..0x5F)
+ - date/time (0xC0..0xC1)
+ - bignum (0xC2..0xC3)
+ - decimal fraction (0xC4)
+ - bigfloat (0xC5)
+ - tagged items (0xC6..0xD4, 0xD8..0xDB)
+ - expected conversions (0xD5..0xD7)
+ - simple values (0xE0..0xF3, 0xF8)
+ - undefined (0xF7)
+
+ @warning CBOR allows map keys of any type, whereas JSON only allows
+ strings as keys in object values. Therefore, CBOR maps with keys
+ other than UTF-8 strings are rejected (parse_error.113).
+
+ @note Any CBOR output created @ref to_cbor can be successfully parsed by
+ @ref from_cbor.
+
+ @param[in] i an input in CBOR format convertible to an input adapter
+ @param[in] strict whether to expect the input to be consumed until EOF
+ (true by default)
+ @param[in] allow_exceptions whether to throw exceptions in case of a
+ parse error (optional, true by default)
+
+ @return deserialized JSON value; in case of a parse error and
+ @a allow_exceptions set to `false`, the return value will be
+ value_t::discarded.
+
+ @throw parse_error.110 if the given input ends prematurely or the end of
+ file was not reached when @a strict was set to true
+ @throw parse_error.112 if unsupported features from CBOR were
+ used in the given input @a v or if the input is not valid CBOR
+ @throw parse_error.113 if a string was expected as map key, but not found
+
+ @complexity Linear in the size of the input @a i.
+
+ @liveexample{The example shows the deserialization of a byte vector in CBOR
+ format to a JSON value.,from_cbor}
+
+ @sa http://cbor.io
+ @sa @ref to_cbor(const basic_json&) for the analogous serialization
+ @sa @ref from_msgpack(detail::input_adapter&&, const bool, const bool) for the
+ related MessagePack format
+ @sa @ref from_ubjson(detail::input_adapter&&, const bool, const bool) for the
+ related UBJSON format
+
+ @since version 2.0.9; parameter @a start_index since 2.1.1; changed to
+ consume input adapters, removed start_index parameter, and added
+ @a strict parameter since 3.0.0; added @a allow_exceptions parameter
+ since 3.2.0
+ */
+ JSON_NODISCARD
+ static basic_json from_cbor(detail::input_adapter&& i,
+ const bool strict = true,
+ const bool allow_exceptions = true)
+ {
+ basic_json result;
+ detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
+ const bool res = binary_reader(detail::input_adapter(i)).sax_parse(input_format_t::cbor, &sdp, strict);
+ return res ? result : basic_json(value_t::discarded);
+ }
+
+ /*!
+ @copydoc from_cbor(detail::input_adapter&&, const bool, const bool)
+ */
+ template<typename A1, typename A2,
+ detail::enable_if_t<std::is_constructible<detail::input_adapter, A1, A2>::value, int> = 0>
+ JSON_NODISCARD
+ static basic_json from_cbor(A1 && a1, A2 && a2,
+ const bool strict = true,
+ const bool allow_exceptions = true)
+ {
+ basic_json result;
+ detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
+ const bool res = binary_reader(detail::input_adapter(std::forward<A1>(a1), std::forward<A2>(a2))).sax_parse(input_format_t::cbor, &sdp, strict);
+ return res ? result : basic_json(value_t::discarded);
+ }
+
+ /*!
+ @brief create a JSON value from an input in MessagePack format
+
+ Deserializes a given input @a i to a JSON value using the MessagePack
+ serialization format.
+
+ The library maps MessagePack types to JSON value types as follows:
+
+ MessagePack type | JSON value type | first byte
+ ---------------- | --------------- | ----------
+ positive fixint | number_unsigned | 0x00..0x7F
+ fixmap | object | 0x80..0x8F
+ fixarray | array | 0x90..0x9F
+ fixstr | string | 0xA0..0xBF
+ nil | `null` | 0xC0
+ false | `false` | 0xC2
+ true | `true` | 0xC3
+ float 32 | number_float | 0xCA
+ float 64 | number_float | 0xCB
+ uint 8 | number_unsigned | 0xCC
+ uint 16 | number_unsigned | 0xCD
+ uint 32 | number_unsigned | 0xCE
+ uint 64 | number_unsigned | 0xCF
+ int 8 | number_integer | 0xD0
+ int 16 | number_integer | 0xD1
+ int 32 | number_integer | 0xD2
+ int 64 | number_integer | 0xD3
+ str 8 | string | 0xD9
+ str 16 | string | 0xDA
+ str 32 | string | 0xDB
+ array 16 | array | 0xDC
+ array 32 | array | 0xDD
+ map 16 | object | 0xDE
+ map 32 | object | 0xDF
+ negative fixint | number_integer | 0xE0-0xFF
+
+ @warning The mapping is **incomplete** in the sense that not all
+ MessagePack types can be converted to a JSON value. The following
+ MessagePack types are not supported and will yield parse errors:
+ - bin 8 - bin 32 (0xC4..0xC6)
+ - ext 8 - ext 32 (0xC7..0xC9)
+ - fixext 1 - fixext 16 (0xD4..0xD8)
+
+ @note Any MessagePack output created @ref to_msgpack can be successfully
+ parsed by @ref from_msgpack.
+
+ @param[in] i an input in MessagePack format convertible to an input
+ adapter
+ @param[in] strict whether to expect the input to be consumed until EOF
+ (true by default)
+ @param[in] allow_exceptions whether to throw exceptions in case of a
+ parse error (optional, true by default)
+
+ @return deserialized JSON value; in case of a parse error and
+ @a allow_exceptions set to `false`, the return value will be
+ value_t::discarded.
+
+ @throw parse_error.110 if the given input ends prematurely or the end of
+ file was not reached when @a strict was set to true
+ @throw parse_error.112 if unsupported features from MessagePack were
+ used in the given input @a i or if the input is not valid MessagePack
+ @throw parse_error.113 if a string was expected as map key, but not found
+
+ @complexity Linear in the size of the input @a i.
+
+ @liveexample{The example shows the deserialization of a byte vector in
+ MessagePack format to a JSON value.,from_msgpack}
+
+ @sa http://msgpack.org
+ @sa @ref to_msgpack(const basic_json&) for the analogous serialization
+ @sa @ref from_cbor(detail::input_adapter&&, const bool, const bool) for the
+ related CBOR format
+ @sa @ref from_ubjson(detail::input_adapter&&, const bool, const bool) for
+ the related UBJSON format
+ @sa @ref from_bson(detail::input_adapter&&, const bool, const bool) for
+ the related BSON format
+
+ @since version 2.0.9; parameter @a start_index since 2.1.1; changed to
+ consume input adapters, removed start_index parameter, and added
+ @a strict parameter since 3.0.0; added @a allow_exceptions parameter
+ since 3.2.0
+ */
+ JSON_NODISCARD
+ static basic_json from_msgpack(detail::input_adapter&& i,
+ const bool strict = true,
+ const bool allow_exceptions = true)
+ {
+ basic_json result;
+ detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
+ const bool res = binary_reader(detail::input_adapter(i)).sax_parse(input_format_t::msgpack, &sdp, strict);
+ return res ? result : basic_json(value_t::discarded);
+ }
+
+ /*!
+ @copydoc from_msgpack(detail::input_adapter&&, const bool, const bool)
+ */
+ template<typename A1, typename A2,
+ detail::enable_if_t<std::is_constructible<detail::input_adapter, A1, A2>::value, int> = 0>
+ JSON_NODISCARD
+ static basic_json from_msgpack(A1 && a1, A2 && a2,
+ const bool strict = true,
+ const bool allow_exceptions = true)
+ {
+ basic_json result;
+ detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
+ const bool res = binary_reader(detail::input_adapter(std::forward<A1>(a1), std::forward<A2>(a2))).sax_parse(input_format_t::msgpack, &sdp, strict);
+ return res ? result : basic_json(value_t::discarded);
+ }
+
+ /*!
+ @brief create a JSON value from an input in UBJSON format
+
+ Deserializes a given input @a i to a JSON value using the UBJSON (Universal
+ Binary JSON) serialization format.
+
+ The library maps UBJSON types to JSON value types as follows:
+
+ UBJSON type | JSON value type | marker
+ ----------- | --------------------------------------- | ------
+ no-op | *no value, next value is read* | `N`
+ null | `null` | `Z`
+ false | `false` | `F`
+ true | `true` | `T`
+ float32 | number_float | `d`
+ float64 | number_float | `D`
+ uint8 | number_unsigned | `U`
+ int8 | number_integer | `i`
+ int16 | number_integer | `I`
+ int32 | number_integer | `l`
+ int64 | number_integer | `L`
+ string | string | `S`
+ char | string | `C`
+ array | array (optimized values are supported) | `[`
+ object | object (optimized values are supported) | `{`
+
+ @note The mapping is **complete** in the sense that any UBJSON value can
+ be converted to a JSON value.
+
+ @param[in] i an input in UBJSON format convertible to an input adapter
+ @param[in] strict whether to expect the input to be consumed until EOF
+ (true by default)
+ @param[in] allow_exceptions whether to throw exceptions in case of a
+ parse error (optional, true by default)
+
+ @return deserialized JSON value; in case of a parse error and
+ @a allow_exceptions set to `false`, the return value will be
+ value_t::discarded.
+
+ @throw parse_error.110 if the given input ends prematurely or the end of
+ file was not reached when @a strict was set to true
+ @throw parse_error.112 if a parse error occurs
+ @throw parse_error.113 if a string could not be parsed successfully
+
+ @complexity Linear in the size of the input @a i.
+
+ @liveexample{The example shows the deserialization of a byte vector in
+ UBJSON format to a JSON value.,from_ubjson}
+
+ @sa http://ubjson.org
+ @sa @ref to_ubjson(const basic_json&, const bool, const bool) for the
+ analogous serialization
+ @sa @ref from_cbor(detail::input_adapter&&, const bool, const bool) for the
+ related CBOR format
+ @sa @ref from_msgpack(detail::input_adapter&&, const bool, const bool) for
+ the related MessagePack format
+ @sa @ref from_bson(detail::input_adapter&&, const bool, const bool) for
+ the related BSON format
+
+ @since version 3.1.0; added @a allow_exceptions parameter since 3.2.0
+ */
+ JSON_NODISCARD
+ static basic_json from_ubjson(detail::input_adapter&& i,
+ const bool strict = true,
+ const bool allow_exceptions = true)
+ {
+ basic_json result;
+ detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
+ const bool res = binary_reader(detail::input_adapter(i)).sax_parse(input_format_t::ubjson, &sdp, strict);
+ return res ? result : basic_json(value_t::discarded);
+ }
+
+ /*!
+ @copydoc from_ubjson(detail::input_adapter&&, const bool, const bool)
+ */
+ template<typename A1, typename A2,
+ detail::enable_if_t<std::is_constructible<detail::input_adapter, A1, A2>::value, int> = 0>
+ JSON_NODISCARD
+ static basic_json from_ubjson(A1 && a1, A2 && a2,
+ const bool strict = true,
+ const bool allow_exceptions = true)
+ {
+ basic_json result;
+ detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
+ const bool res = binary_reader(detail::input_adapter(std::forward<A1>(a1), std::forward<A2>(a2))).sax_parse(input_format_t::ubjson, &sdp, strict);
+ return res ? result : basic_json(value_t::discarded);
+ }
+
+ /*!
+ @brief Create a JSON value from an input in BSON format
+
+ Deserializes a given input @a i to a JSON value using the BSON (Binary JSON)
+ serialization format.
+
+ The library maps BSON record types to JSON value types as follows:
+
+ BSON type | BSON marker byte | JSON value type
+ --------------- | ---------------- | ---------------------------
+ double | 0x01 | number_float
+ string | 0x02 | string
+ document | 0x03 | object
+ array | 0x04 | array
+ binary | 0x05 | still unsupported
+ undefined | 0x06 | still unsupported
+ ObjectId | 0x07 | still unsupported
+ boolean | 0x08 | boolean
+ UTC Date-Time | 0x09 | still unsupported
+ null | 0x0A | null
+ Regular Expr. | 0x0B | still unsupported
+ DB Pointer | 0x0C | still unsupported
+ JavaScript Code | 0x0D | still unsupported
+ Symbol | 0x0E | still unsupported
+ JavaScript Code | 0x0F | still unsupported
+ int32 | 0x10 | number_integer
+ Timestamp | 0x11 | still unsupported
+ 128-bit decimal float | 0x13 | still unsupported
+ Max Key | 0x7F | still unsupported
+ Min Key | 0xFF | still unsupported
+
+ @warning The mapping is **incomplete**. The unsupported mappings
+ are indicated in the table above.
+
+ @param[in] i an input in BSON format convertible to an input adapter
+ @param[in] strict whether to expect the input to be consumed until EOF
+ (true by default)
+ @param[in] allow_exceptions whether to throw exceptions in case of a
+ parse error (optional, true by default)
+
+ @return deserialized JSON value; in case of a parse error and
+ @a allow_exceptions set to `false`, the return value will be
+ value_t::discarded.
+
+ @throw parse_error.114 if an unsupported BSON record type is encountered
+
+ @complexity Linear in the size of the input @a i.
+
+ @liveexample{The example shows the deserialization of a byte vector in
+ BSON format to a JSON value.,from_bson}
+
+ @sa http://bsonspec.org/spec.html
+ @sa @ref to_bson(const basic_json&) for the analogous serialization
+ @sa @ref from_cbor(detail::input_adapter&&, const bool, const bool) for the
+ related CBOR format
+ @sa @ref from_msgpack(detail::input_adapter&&, const bool, const bool) for
+ the related MessagePack format
+ @sa @ref from_ubjson(detail::input_adapter&&, const bool, const bool) for the
+ related UBJSON format
+ */
+ JSON_NODISCARD
+ static basic_json from_bson(detail::input_adapter&& i,
+ const bool strict = true,
+ const bool allow_exceptions = true)
+ {
+ basic_json result;
+ detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
+ const bool res = binary_reader(detail::input_adapter(i)).sax_parse(input_format_t::bson, &sdp, strict);
+ return res ? result : basic_json(value_t::discarded);
+ }
+
+ /*!
+ @copydoc from_bson(detail::input_adapter&&, const bool, const bool)
+ */
+ template<typename A1, typename A2,
+ detail::enable_if_t<std::is_constructible<detail::input_adapter, A1, A2>::value, int> = 0>
+ JSON_NODISCARD
+ static basic_json from_bson(A1 && a1, A2 && a2,
+ const bool strict = true,
+ const bool allow_exceptions = true)
+ {
+ basic_json result;
+ detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
+ const bool res = binary_reader(detail::input_adapter(std::forward<A1>(a1), std::forward<A2>(a2))).sax_parse(input_format_t::bson, &sdp, strict);
+ return res ? result : basic_json(value_t::discarded);
+ }
+
+
+
+ /// @}
+
+ //////////////////////////
+ // JSON Pointer support //
+ //////////////////////////
+
+ /// @name JSON Pointer functions
+ /// @{
+
+ /*!
+ @brief access specified element via JSON Pointer
+
+ Uses a JSON pointer to retrieve a reference to the respective JSON value.
+ No bound checking is performed. Similar to @ref operator[](const typename
+ object_t::key_type&), `null` values are created in arrays and objects if
+ necessary.
+
+ In particular:
+ - If the JSON pointer points to an object key that does not exist, it
+ is created an filled with a `null` value before a reference to it
+ is returned.
+ - If the JSON pointer points to an array index that does not exist, it
+ is created an filled with a `null` value before a reference to it
+ is returned. All indices between the current maximum and the given
+ index are also filled with `null`.
+ - The special value `-` is treated as a synonym for the index past the
+ end.
+
+ @param[in] ptr a JSON pointer
+
+ @return reference to the element pointed to by @a ptr
+
+ @complexity Constant.
+
+ @throw parse_error.106 if an array index begins with '0'
+ @throw parse_error.109 if an array index was not a number
+ @throw out_of_range.404 if the JSON pointer can not be resolved
+
+ @liveexample{The behavior is shown in the example.,operatorjson_pointer}
+
+ @since version 2.0.0
+ */
+ reference operator[](const json_pointer& ptr)
+ {
+ return ptr.get_unchecked(this);
+ }
+
+ /*!
+ @brief access specified element via JSON Pointer
+
+ Uses a JSON pointer to retrieve a reference to the respective JSON value.
+ No bound checking is performed. The function does not change the JSON
+ value; no `null` values are created. In particular, the the special value
+ `-` yields an exception.
+
+ @param[in] ptr JSON pointer to the desired element
+
+ @return const reference to the element pointed to by @a ptr
+
+ @complexity Constant.
+
+ @throw parse_error.106 if an array index begins with '0'
+ @throw parse_error.109 if an array index was not a number
+ @throw out_of_range.402 if the array index '-' is used
+ @throw out_of_range.404 if the JSON pointer can not be resolved
+
+ @liveexample{The behavior is shown in the example.,operatorjson_pointer_const}
+
+ @since version 2.0.0
+ */
+ const_reference operator[](const json_pointer& ptr) const
+ {
+ return ptr.get_unchecked(this);
+ }
+
+ /*!
+ @brief access specified element via JSON Pointer
+
+ Returns a reference to the element at with specified JSON pointer @a ptr,
+ with bounds checking.
+
+ @param[in] ptr JSON pointer to the desired element
+
+ @return reference to the element pointed to by @a ptr
+
+ @throw parse_error.106 if an array index in the passed JSON pointer @a ptr
+ begins with '0'. See example below.
+
+ @throw parse_error.109 if an array index in the passed JSON pointer @a ptr
+ is not a number. See example below.
+
+ @throw out_of_range.401 if an array index in the passed JSON pointer @a ptr
+ is out of range. See example below.
+
+ @throw out_of_range.402 if the array index '-' is used in the passed JSON
+ pointer @a ptr. As `at` provides checked access (and no elements are
+ implicitly inserted), the index '-' is always invalid. See example below.
+
+ @throw out_of_range.403 if the JSON pointer describes a key of an object
+ which cannot be found. See example below.
+
+ @throw out_of_range.404 if the JSON pointer @a ptr can not be resolved.
+ See example below.
+
+ @exceptionsafety Strong guarantee: if an exception is thrown, there are no
+ changes in the JSON value.
+
+ @complexity Constant.
+
+ @since version 2.0.0
+
+ @liveexample{The behavior is shown in the example.,at_json_pointer}
+ */
+ reference at(const json_pointer& ptr)
+ {
+ return ptr.get_checked(this);
+ }
+
+ /*!
+ @brief access specified element via JSON Pointer
+
+ Returns a const reference to the element at with specified JSON pointer @a
+ ptr, with bounds checking.
+
+ @param[in] ptr JSON pointer to the desired element
+
+ @return reference to the element pointed to by @a ptr
+
+ @throw parse_error.106 if an array index in the passed JSON pointer @a ptr
+ begins with '0'. See example below.
+
+ @throw parse_error.109 if an array index in the passed JSON pointer @a ptr
+ is not a number. See example below.
+
+ @throw out_of_range.401 if an array index in the passed JSON pointer @a ptr
+ is out of range. See example below.
+
+ @throw out_of_range.402 if the array index '-' is used in the passed JSON
+ pointer @a ptr. As `at` provides checked access (and no elements are
+ implicitly inserted), the index '-' is always invalid. See example below.
+
+ @throw out_of_range.403 if the JSON pointer describes a key of an object
+ which cannot be found. See example below.
+
+ @throw out_of_range.404 if the JSON pointer @a ptr can not be resolved.
+ See example below.
+
+ @exceptionsafety Strong guarantee: if an exception is thrown, there are no
+ changes in the JSON value.
+
+ @complexity Constant.
+
+ @since version 2.0.0
+
+ @liveexample{The behavior is shown in the example.,at_json_pointer_const}
+ */
+ const_reference at(const json_pointer& ptr) const
+ {
+ return ptr.get_checked(this);
+ }
+
+ /*!
+ @brief return flattened JSON value
+
+ The function creates a JSON object whose keys are JSON pointers (see [RFC
+ 6901](https://tools.ietf.org/html/rfc6901)) and whose values are all
+ primitive. The original JSON value can be restored using the @ref
+ unflatten() function.
+
+ @return an object that maps JSON pointers to primitive values
+
+ @note Empty objects and arrays are flattened to `null` and will not be
+ reconstructed correctly by the @ref unflatten() function.
+
+ @complexity Linear in the size the JSON value.
+
+ @liveexample{The following code shows how a JSON object is flattened to an
+ object whose keys consist of JSON pointers.,flatten}
+
+ @sa @ref unflatten() for the reverse function
+
+ @since version 2.0.0
+ */
+ basic_json flatten() const
+ {
+ basic_json result(value_t::object);
+ json_pointer::flatten("", *this, result);
+ return result;
+ }
+
+ /*!
+ @brief unflatten a previously flattened JSON value
+
+ The function restores the arbitrary nesting of a JSON value that has been
+ flattened before using the @ref flatten() function. The JSON value must
+ meet certain constraints:
+ 1. The value must be an object.
+ 2. The keys must be JSON pointers (see
+ [RFC 6901](https://tools.ietf.org/html/rfc6901))
+ 3. The mapped values must be primitive JSON types.
+
+ @return the original JSON from a flattened version
+
+ @note Empty objects and arrays are flattened by @ref flatten() to `null`
+ values and can not unflattened to their original type. Apart from
+ this example, for a JSON value `j`, the following is always true:
+ `j == j.flatten().unflatten()`.
+
+ @complexity Linear in the size the JSON value.
+
+ @throw type_error.314 if value is not an object
+ @throw type_error.315 if object values are not primitive
+
+ @liveexample{The following code shows how a flattened JSON object is
+ unflattened into the original nested JSON object.,unflatten}
+
+ @sa @ref flatten() for the reverse function
+
+ @since version 2.0.0
+ */
+ basic_json unflatten() const
+ {
+ return json_pointer::unflatten(*this);
+ }
+
+ /// @}
+
+ //////////////////////////
+ // JSON Patch functions //
+ //////////////////////////
+
+ /// @name JSON Patch functions
+ /// @{
+
+ /*!
+ @brief applies a JSON patch
+
+ [JSON Patch](http://jsonpatch.com) defines a JSON document structure for
+ expressing a sequence of operations to apply to a JSON) document. With
+ this function, a JSON Patch is applied to the current JSON value by
+ executing all operations from the patch.
+
+ @param[in] json_patch JSON patch document
+ @return patched document
+
+ @note The application of a patch is atomic: Either all operations succeed
+ and the patched document is returned or an exception is thrown. In
+ any case, the original value is not changed: the patch is applied
+ to a copy of the value.
+
+ @throw parse_error.104 if the JSON patch does not consist of an array of
+ objects
+
+ @throw parse_error.105 if the JSON patch is malformed (e.g., mandatory
+ attributes are missing); example: `"operation add must have member path"`
+
+ @throw out_of_range.401 if an array index is out of range.
+
+ @throw out_of_range.403 if a JSON pointer inside the patch could not be
+ resolved successfully in the current JSON value; example: `"key baz not
+ found"`
+
+ @throw out_of_range.405 if JSON pointer has no parent ("add", "remove",
+ "move")
+
+ @throw other_error.501 if "test" operation was unsuccessful
+
+ @complexity Linear in the size of the JSON value and the length of the
+ JSON patch. As usually only a fraction of the JSON value is affected by
+ the patch, the complexity can usually be neglected.
+
+ @liveexample{The following code shows how a JSON patch is applied to a
+ value.,patch}
+
+ @sa @ref diff -- create a JSON patch by comparing two JSON values
+
+ @sa [RFC 6902 (JSON Patch)](https://tools.ietf.org/html/rfc6902)
+ @sa [RFC 6901 (JSON Pointer)](https://tools.ietf.org/html/rfc6901)
+
+ @since version 2.0.0
+ */
+ basic_json patch(const basic_json& json_patch) const
+ {
+ // make a working copy to apply the patch to
+ basic_json result = *this;
+
+ // the valid JSON Patch operations
+ enum class patch_operations {add, remove, replace, move, copy, test, invalid};
+
+ const auto get_op = [](const std::string & op)
+ {
+ if (op == "add")
+ {
+ return patch_operations::add;
+ }
+ if (op == "remove")
+ {
+ return patch_operations::remove;
+ }
+ if (op == "replace")
+ {
+ return patch_operations::replace;
+ }
+ if (op == "move")
+ {
+ return patch_operations::move;
+ }
+ if (op == "copy")
+ {
+ return patch_operations::copy;
+ }
+ if (op == "test")
+ {
+ return patch_operations::test;
+ }
+
+ return patch_operations::invalid;
+ };
+
+ // wrapper for "add" operation; add value at ptr
+ const auto operation_add = [&result](json_pointer & ptr, basic_json val)
+ {
+ // adding to the root of the target document means replacing it
+ if (ptr.empty())
+ {
+ result = val;
+ return;
+ }
+
+ // make sure the top element of the pointer exists
+ json_pointer top_pointer = ptr.top();
+ if (top_pointer != ptr)
+ {
+ result.at(top_pointer);
+ }
+
+ // get reference to parent of JSON pointer ptr
+ const auto last_path = ptr.back();
+ ptr.pop_back();
+ basic_json& parent = result[ptr];
+
+ switch (parent.m_type)
+ {
+ case value_t::null:
+ case value_t::object:
+ {
+ // use operator[] to add value
+ parent[last_path] = val;
+ break;
+ }
+
+ case value_t::array:
+ {
+ if (last_path == "-")
+ {
+ // special case: append to back
+ parent.push_back(val);
+ }
+ else
+ {
+ const auto idx = json_pointer::array_index(last_path);
+ if (JSON_UNLIKELY(static_cast<size_type>(idx) > parent.size()))
+ {
+ // avoid undefined behavior
+ JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range"));
+ }
+
+ // default case: insert add offset
+ parent.insert(parent.begin() + static_cast<difference_type>(idx), val);
+ }
+ break;
+ }
+
+ // if there exists a parent it cannot be primitive
+ default: // LCOV_EXCL_LINE
+ assert(false); // LCOV_EXCL_LINE
+ }
+ };
+
+ // wrapper for "remove" operation; remove value at ptr
+ const auto operation_remove = [&result](json_pointer & ptr)
+ {
+ // get reference to parent of JSON pointer ptr
+ const auto last_path = ptr.back();
+ ptr.pop_back();
+ basic_json& parent = result.at(ptr);
+
+ // remove child
+ if (parent.is_object())
+ {
+ // perform range check
+ auto it = parent.find(last_path);
+ if (JSON_LIKELY(it != parent.end()))
+ {
+ parent.erase(it);
+ }
+ else
+ {
+ JSON_THROW(out_of_range::create(403, "key '" + last_path + "' not found"));
+ }
+ }
+ else if (parent.is_array())
+ {
+ // note erase performs range check
+ parent.erase(static_cast<size_type>(json_pointer::array_index(last_path)));
+ }
+ };
+
+ // type check: top level value must be an array
+ if (JSON_UNLIKELY(not json_patch.is_array()))
+ {
+ JSON_THROW(parse_error::create(104, 0, "JSON patch must be an array of objects"));
+ }
+
+ // iterate and apply the operations
+ for (const auto& val : json_patch)
+ {
+ // wrapper to get a value for an operation
+ const auto get_value = [&val](const std::string & op,
+ const std::string & member,
+ bool string_type) -> basic_json &
+ {
+ // find value
+ auto it = val.m_value.object->find(member);
+
+ // context-sensitive error message
+ const auto error_msg = (op == "op") ? "operation" : "operation '" + op + "'";
+
+ // check if desired value is present
+ if (JSON_UNLIKELY(it == val.m_value.object->end()))
+ {
+ JSON_THROW(parse_error::create(105, 0, error_msg + " must have member '" + member + "'"));
+ }
+
+ // check if result is of type string
+ if (JSON_UNLIKELY(string_type and not it->second.is_string()))
+ {
+ JSON_THROW(parse_error::create(105, 0, error_msg + " must have string member '" + member + "'"));
+ }
+
+ // no error: return value
+ return it->second;
+ };
+
+ // type check: every element of the array must be an object
+ if (JSON_UNLIKELY(not val.is_object()))
+ {
+ JSON_THROW(parse_error::create(104, 0, "JSON patch must be an array of objects"));
+ }
+
+ // collect mandatory members
+ const std::string op = get_value("op", "op", true);
+ const std::string path = get_value(op, "path", true);
+ json_pointer ptr(path);
+
+ switch (get_op(op))
+ {
+ case patch_operations::add:
+ {
+ operation_add(ptr, get_value("add", "value", false));
+ break;
+ }
+
+ case patch_operations::remove:
+ {
+ operation_remove(ptr);
+ break;
+ }
+
+ case patch_operations::replace:
+ {
+ // the "path" location must exist - use at()
+ result.at(ptr) = get_value("replace", "value", false);
+ break;
+ }
+
+ case patch_operations::move:
+ {
+ const std::string from_path = get_value("move", "from", true);
+ json_pointer from_ptr(from_path);
+
+ // the "from" location must exist - use at()
+ basic_json v = result.at(from_ptr);
+
+ // The move operation is functionally identical to a
+ // "remove" operation on the "from" location, followed
+ // immediately by an "add" operation at the target
+ // location with the value that was just removed.
+ operation_remove(from_ptr);
+ operation_add(ptr, v);
+ break;
+ }
+
+ case patch_operations::copy:
+ {
+ const std::string from_path = get_value("copy", "from", true);
+ const json_pointer from_ptr(from_path);
+
+ // the "from" location must exist - use at()
+ basic_json v = result.at(from_ptr);
+
+ // The copy is functionally identical to an "add"
+ // operation at the target location using the value
+ // specified in the "from" member.
+ operation_add(ptr, v);
+ break;
+ }
+
+ case patch_operations::test:
+ {
+ bool success = false;
+ JSON_TRY
+ {
+ // check if "value" matches the one at "path"
+ // the "path" location must exist - use at()
+ success = (result.at(ptr) == get_value("test", "value", false));
+ }
+ JSON_INTERNAL_CATCH (out_of_range&)
+ {
+ // ignore out of range errors: success remains false
+ }
+
+ // throw an exception if test fails
+ if (JSON_UNLIKELY(not success))
+ {
+ JSON_THROW(other_error::create(501, "unsuccessful: " + val.dump()));
+ }
+
+ break;
+ }
+
+ default:
+ {
+ // op must be "add", "remove", "replace", "move", "copy", or
+ // "test"
+ JSON_THROW(parse_error::create(105, 0, "operation value '" + op + "' is invalid"));
+ }
+ }
+ }
+
+ return result;
+ }
+
+ /*!
+ @brief creates a diff as a JSON patch
+
+ Creates a [JSON Patch](http://jsonpatch.com) so that value @a source can
+ be changed into the value @a target by calling @ref patch function.
+
+ @invariant For two JSON values @a source and @a target, the following code
+ yields always `true`:
+ @code {.cpp}
+ source.patch(diff(source, target)) == target;
+ @endcode
+
+ @note Currently, only `remove`, `add`, and `replace` operations are
+ generated.
+
+ @param[in] source JSON value to compare from
+ @param[in] target JSON value to compare against
+ @param[in] path helper value to create JSON pointers
+
+ @return a JSON patch to convert the @a source to @a target
+
+ @complexity Linear in the lengths of @a source and @a target.
+
+ @liveexample{The following code shows how a JSON patch is created as a
+ diff for two JSON values.,diff}
+
+ @sa @ref patch -- apply a JSON patch
+ @sa @ref merge_patch -- apply a JSON Merge Patch
+
+ @sa [RFC 6902 (JSON Patch)](https://tools.ietf.org/html/rfc6902)
+
+ @since version 2.0.0
+ */
+ JSON_NODISCARD
+ static basic_json diff(const basic_json& source, const basic_json& target,
+ const std::string& path = "")
+ {
+ // the patch
+ basic_json result(value_t::array);
+
+ // if the values are the same, return empty patch
+ if (source == target)
+ {
+ return result;
+ }
+
+ if (source.type() != target.type())
+ {
+ // different types: replace value
+ result.push_back(
+ {
+ {"op", "replace"}, {"path", path}, {"value", target}
+ });
+ return result;
+ }
+
+ switch (source.type())
+ {
+ case value_t::array:
+ {
+ // first pass: traverse common elements
+ std::size_t i = 0;
+ while (i < source.size() and i < target.size())
+ {
+ // recursive call to compare array values at index i
+ auto temp_diff = diff(source[i], target[i], path + "/" + std::to_string(i));
+ result.insert(result.end(), temp_diff.begin(), temp_diff.end());
+ ++i;
+ }
+
+ // i now reached the end of at least one array
+ // in a second pass, traverse the remaining elements
+
+ // remove my remaining elements
+ const auto end_index = static_cast<difference_type>(result.size());
+ while (i < source.size())
+ {
+ // add operations in reverse order to avoid invalid
+ // indices
+ result.insert(result.begin() + end_index, object(
+ {
+ {"op", "remove"},
+ {"path", path + "/" + std::to_string(i)}
+ }));
+ ++i;
+ }
+
+ // add other remaining elements
+ while (i < target.size())
+ {
+ result.push_back(
+ {
+ {"op", "add"},
+ {"path", path + "/" + std::to_string(i)},
+ {"value", target[i]}
+ });
+ ++i;
+ }
+
+ break;
+ }
+
+ case value_t::object:
+ {
+ // first pass: traverse this object's elements
+ for (auto it = source.cbegin(); it != source.cend(); ++it)
+ {
+ // escape the key name to be used in a JSON patch
+ const auto key = json_pointer::escape(it.key());
+
+ if (target.find(it.key()) != target.end())
+ {
+ // recursive call to compare object values at key it
+ auto temp_diff = diff(it.value(), target[it.key()], path + "/" + key);
+ result.insert(result.end(), temp_diff.begin(), temp_diff.end());
+ }
+ else
+ {
+ // found a key that is not in o -> remove it
+ result.push_back(object(
+ {
+ {"op", "remove"}, {"path", path + "/" + key}
+ }));
+ }
+ }
+
+ // second pass: traverse other object's elements
+ for (auto it = target.cbegin(); it != target.cend(); ++it)
+ {
+ if (source.find(it.key()) == source.end())
+ {
+ // found a key that is not in this -> add it
+ const auto key = json_pointer::escape(it.key());
+ result.push_back(
+ {
+ {"op", "add"}, {"path", path + "/" + key},
+ {"value", it.value()}
+ });
+ }
+ }
+
+ break;
+ }
+
+ default:
+ {
+ // both primitive type: replace value
+ result.push_back(
+ {
+ {"op", "replace"}, {"path", path}, {"value", target}
+ });
+ break;
+ }
+ }
+
+ return result;
+ }
+
+ /// @}
+
+ ////////////////////////////////
+ // JSON Merge Patch functions //
+ ////////////////////////////////
+
+ /// @name JSON Merge Patch functions
+ /// @{
+
+ /*!
+ @brief applies a JSON Merge Patch
+
+ The merge patch format is primarily intended for use with the HTTP PATCH
+ method as a means of describing a set of modifications to a target
+ resource's content. This function applies a merge patch to the current
+ JSON value.
+
+ The function implements the following algorithm from Section 2 of
+ [RFC 7396 (JSON Merge Patch)](https://tools.ietf.org/html/rfc7396):
+
+ ```
+ define MergePatch(Target, Patch):
+ if Patch is an Object:
+ if Target is not an Object:
+ Target = {} // Ignore the contents and set it to an empty Object
+ for each Name/Value pair in Patch:
+ if Value is null:
+ if Name exists in Target:
+ remove the Name/Value pair from Target
+ else:
+ Target[Name] = MergePatch(Target[Name], Value)
+ return Target
+ else:
+ return Patch
+ ```
+
+ Thereby, `Target` is the current object; that is, the patch is applied to
+ the current value.
+
+ @param[in] apply_patch the patch to apply
+
+ @complexity Linear in the lengths of @a patch.
+
+ @liveexample{The following code shows how a JSON Merge Patch is applied to
+ a JSON document.,merge_patch}
+
+ @sa @ref patch -- apply a JSON patch
+ @sa [RFC 7396 (JSON Merge Patch)](https://tools.ietf.org/html/rfc7396)
+
+ @since version 3.0.0
+ */
+ void merge_patch(const basic_json& apply_patch)
+ {
+ if (apply_patch.is_object())
+ {
+ if (not is_object())
+ {
+ *this = object();
+ }
+ for (auto it = apply_patch.begin(); it != apply_patch.end(); ++it)
+ {
+ if (it.value().is_null())
+ {
+ erase(it.key());
+ }
+ else
+ {
+ operator[](it.key()).merge_patch(it.value());
+ }
+ }
+ }
+ else
+ {
+ *this = apply_patch;
+ }
+ }
+
+ /// @}
+};
+} // namespace nlohmann
+
+///////////////////////
+// nonmember support //
+///////////////////////
+
+// specialization of std::swap, and std::hash
+namespace std
+{
+
+/// hash value for JSON objects
+template<>
+struct hash<nlohmann::json>
+{
+ /*!
+ @brief return a hash value for a JSON object
+
+ @since version 1.0.0
+ */
+ std::size_t operator()(const nlohmann::json& j) const
+ {
+ // a naive hashing via the string representation
+ const auto& h = hash<nlohmann::json::string_t>();
+ return h(j.dump());
+ }
+};
+
+/// specialization for std::less<value_t>
+/// @note: do not remove the space after '<',
+/// see https://github.com/nlohmann/json/pull/679
+template<>
+struct less< ::nlohmann::detail::value_t>
+{
+ /*!
+ @brief compare two value_t enum values
+ @since version 3.0.0
+ */
+ bool operator()(nlohmann::detail::value_t lhs,
+ nlohmann::detail::value_t rhs) const noexcept
+ {
+ return nlohmann::detail::operator<(lhs, rhs);
+ }
+};
+
+/*!
+@brief exchanges the values of two JSON objects
+
+@since version 1.0.0
+*/
+template<>
+inline void swap<nlohmann::json>(nlohmann::json& j1, nlohmann::json& j2) noexcept(
+ is_nothrow_move_constructible<nlohmann::json>::value and
+ is_nothrow_move_assignable<nlohmann::json>::value
+)
+{
+ j1.swap(j2);
+}
+
+} // namespace std
+
+/*!
+@brief user-defined string literal for JSON values
+
+This operator implements a user-defined string literal for JSON objects. It
+can be used by adding `"_json"` to a string literal and returns a JSON object
+if no parse error occurred.
+
+@param[in] s a string representation of a JSON object
+@param[in] n the length of string @a s
+@return a JSON object
+
+@since version 1.0.0
+*/
+inline nlohmann::json operator "" _json(const char* s, std::size_t n)
+{
+ return nlohmann::json::parse(s, s + n);
+}
+
+/*!
+@brief user-defined string literal for JSON pointer
+
+This operator implements a user-defined string literal for JSON Pointers. It
+can be used by adding `"_json_pointer"` to a string literal and returns a JSON pointer
+object if no parse error occurred.
+
+@param[in] s a string representation of a JSON Pointer
+@param[in] n the length of string @a s
+@return a JSON pointer object
+
+@since version 2.0.0
+*/
+inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std::size_t n)
+{
+ return nlohmann::json::json_pointer(std::string(s, n));
+}
+
+// #include <nlohmann/detail/macro_unscope.hpp>
+
+
+// restore GCC/clang diagnostic settings
+#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
+ #pragma GCC diagnostic pop
+#endif
+#if defined(__clang__)
+ #pragma GCC diagnostic pop
+#endif
+
+// clean up
+#undef JSON_INTERNAL_CATCH
+#undef JSON_CATCH
+#undef JSON_THROW
+#undef JSON_TRY
+#undef JSON_LIKELY
+#undef JSON_UNLIKELY
+#undef JSON_DEPRECATED
+#undef JSON_NODISCARD
+#undef JSON_HAS_CPP_14
+#undef JSON_HAS_CPP_17
+#undef NLOHMANN_BASIC_JSON_TPL_DECLARATION
+#undef NLOHMANN_BASIC_JSON_TPL
+
+
+#endif // INCLUDE_NLOHMANN_JSON_HPP_
diff --git a/tools/mapjson/.gitignore b/tools/mapjson/.gitignore
index c382f9e..a5d5684 100644
--- a/tools/mapjson/.gitignore
+++ b/tools/mapjson/.gitignore
@@ -1 +1 @@
-mapjson
+mapjson
diff --git a/tools/mapjson/json11.cpp b/tools/mapjson/json11.cpp
index d66cb61..1da5302 100644
--- a/tools/mapjson/json11.cpp
+++ b/tools/mapjson/json11.cpp
@@ -1,786 +1,786 @@
-/* Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-#include "json11.h"
-#include <cassert>
-#include <cmath>
-#include <cstdlib>
-#include <cstdio>
-#include <limits>
-
-namespace json11 {
-
-static const int max_depth = 200;
-
-using std::string;
-using std::vector;
-using std::map;
-using std::make_shared;
-using std::initializer_list;
-using std::move;
-
-/* Helper for representing null - just a do-nothing struct, plus comparison
- * operators so the helpers in JsonValue work. We can't use nullptr_t because
- * it may not be orderable.
- */
-struct NullStruct {
- bool operator==(NullStruct) const { return true; }
- bool operator<(NullStruct) const { return false; }
-};
-
-/* * * * * * * * * * * * * * * * * * * *
- * Serialization
- */
-
-static void dump(NullStruct, string &out) {
- out += "null";
-}
-
-static void dump(double value, string &out) {
- if (std::isfinite(value)) {
- char buf[32];
- snprintf(buf, sizeof buf, "%.17g", value);
- out += buf;
- } else {
- out += "null";
- }
-}
-
-static void dump(int value, string &out) {
- char buf[32];
- snprintf(buf, sizeof buf, "%d", value);
- out += buf;
-}
-
-static void dump(bool value, string &out) {
- out += value ? "true" : "false";
-}
-
-static void dump(const string &value, string &out) {
- out += '"';
- for (size_t i = 0; i < value.length(); i++) {
- const char ch = value[i];
- if (ch == '\\') {
- out += "\\\\";
- } else if (ch == '"') {
- out += "\\\"";
- } else if (ch == '\b') {
- out += "\\b";
- } else if (ch == '\f') {
- out += "\\f";
- } else if (ch == '\n') {
- out += "\\n";
- } else if (ch == '\r') {
- out += "\\r";
- } else if (ch == '\t') {
- out += "\\t";
- } else if (static_cast<uint8_t>(ch) <= 0x1f) {
- char buf[8];
- snprintf(buf, sizeof buf, "\\u%04x", ch);
- out += buf;
- } else if (static_cast<uint8_t>(ch) == 0xe2 && static_cast<uint8_t>(value[i+1]) == 0x80
- && static_cast<uint8_t>(value[i+2]) == 0xa8) {
- out += "\\u2028";
- i += 2;
- } else if (static_cast<uint8_t>(ch) == 0xe2 && static_cast<uint8_t>(value[i+1]) == 0x80
- && static_cast<uint8_t>(value[i+2]) == 0xa9) {
- out += "\\u2029";
- i += 2;
- } else {
- out += ch;
- }
- }
- out += '"';
-}
-
-static void dump(const Json::array &values, string &out) {
- bool first = true;
- out += "[";
- for (const auto &value : values) {
- if (!first)
- out += ", ";
- value.dump(out);
- first = false;
- }
- out += "]";
-}
-
-static void dump(const Json::object &values, string &out) {
- bool first = true;
- out += "{";
- for (const auto &kv : values) {
- if (!first)
- out += ", ";
- dump(kv.first, out);
- out += ": ";
- kv.second.dump(out);
- first = false;
- }
- out += "}";
-}
-
-void Json::dump(string &out) const {
- m_ptr->dump(out);
-}
-
-/* * * * * * * * * * * * * * * * * * * *
- * Value wrappers
- */
-
-template <Json::Type tag, typename T>
-class Value : public JsonValue {
-protected:
-
- // Constructors
- explicit Value(const T &value) : m_value(value) {}
- explicit Value(T &&value) : m_value(move(value)) {}
-
- // Get type tag
- Json::Type type() const override {
- return tag;
- }
-
- // Comparisons
- bool equals(const JsonValue * other) const override {
- return m_value == static_cast<const Value<tag, T> *>(other)->m_value;
- }
- bool less(const JsonValue * other) const override {
- return m_value < static_cast<const Value<tag, T> *>(other)->m_value;
- }
-
- const T m_value;
- void dump(string &out) const override { json11::dump(m_value, out); }
-};
-
-class JsonDouble final : public Value<Json::NUMBER, double> {
- double number_value() const override { return m_value; }
- int int_value() const override { return static_cast<int>(m_value); }
- bool equals(const JsonValue * other) const override { return m_value == other->number_value(); }
- bool less(const JsonValue * other) const override { return m_value < other->number_value(); }
-public:
- explicit JsonDouble(double value) : Value(value) {}
-};
-
-class JsonInt final : public Value<Json::NUMBER, int> {
- double number_value() const override { return m_value; }
- int int_value() const override { return m_value; }
- bool equals(const JsonValue * other) const override { return m_value == other->number_value(); }
- bool less(const JsonValue * other) const override { return m_value < other->number_value(); }
-public:
- explicit JsonInt(int value) : Value(value) {}
-};
-
-class JsonBoolean final : public Value<Json::BOOL, bool> {
- bool bool_value() const override { return m_value; }
-public:
- explicit JsonBoolean(bool value) : Value(value) {}
-};
-
-class JsonString final : public Value<Json::STRING, string> {
- const string &string_value() const override { return m_value; }
-public:
- explicit JsonString(const string &value) : Value(value) {}
- explicit JsonString(string &&value) : Value(move(value)) {}
-};
-
-class JsonArray final : public Value<Json::ARRAY, Json::array> {
- const Json::array &array_items() const override { return m_value; }
- const Json & operator[](size_t i) const override;
-public:
- explicit JsonArray(const Json::array &value) : Value(value) {}
- explicit JsonArray(Json::array &&value) : Value(move(value)) {}
-};
-
-class JsonObject final : public Value<Json::OBJECT, Json::object> {
- const Json::object &object_items() const override { return m_value; }
- const Json & operator[](const string &key) const override;
-public:
- explicit JsonObject(const Json::object &value) : Value(value) {}
- explicit JsonObject(Json::object &&value) : Value(move(value)) {}
-};
-
-class JsonNull final : public Value<Json::NUL, NullStruct> {
-public:
- JsonNull() : Value({}) {}
-};
-
-/* * * * * * * * * * * * * * * * * * * *
- * Static globals - static-init-safe
- */
-struct Statics {
- const std::shared_ptr<JsonValue> null = make_shared<JsonNull>();
- const std::shared_ptr<JsonValue> t = make_shared<JsonBoolean>(true);
- const std::shared_ptr<JsonValue> f = make_shared<JsonBoolean>(false);
- const string empty_string;
- const vector<Json> empty_vector;
- const map<string, Json> empty_map;
- Statics() {}
-};
-
-static const Statics & statics() {
- static const Statics s {};
- return s;
-}
-
-static const Json & static_null() {
- // This has to be separate, not in Statics, because Json() accesses statics().null.
- static const Json json_null;
- return json_null;
-}
-
-/* * * * * * * * * * * * * * * * * * * *
- * Constructors
- */
-
-Json::Json() noexcept : m_ptr(statics().null) {}
-Json::Json(std::nullptr_t) noexcept : m_ptr(statics().null) {}
-Json::Json(double value) : m_ptr(make_shared<JsonDouble>(value)) {}
-Json::Json(int value) : m_ptr(make_shared<JsonInt>(value)) {}
-Json::Json(bool value) : m_ptr(value ? statics().t : statics().f) {}
-Json::Json(const string &value) : m_ptr(make_shared<JsonString>(value)) {}
-Json::Json(string &&value) : m_ptr(make_shared<JsonString>(move(value))) {}
-Json::Json(const char * value) : m_ptr(make_shared<JsonString>(value)) {}
-Json::Json(const Json::array &values) : m_ptr(make_shared<JsonArray>(values)) {}
-Json::Json(Json::array &&values) : m_ptr(make_shared<JsonArray>(move(values))) {}
-Json::Json(const Json::object &values) : m_ptr(make_shared<JsonObject>(values)) {}
-Json::Json(Json::object &&values) : m_ptr(make_shared<JsonObject>(move(values))) {}
-
-/* * * * * * * * * * * * * * * * * * * *
- * Accessors
- */
-
-Json::Type Json::type() const { return m_ptr->type(); }
-double Json::number_value() const { return m_ptr->number_value(); }
-int Json::int_value() const { return m_ptr->int_value(); }
-bool Json::bool_value() const { return m_ptr->bool_value(); }
-const string & Json::string_value() const { return m_ptr->string_value(); }
-const vector<Json> & Json::array_items() const { return m_ptr->array_items(); }
-const map<string, Json> & Json::object_items() const { return m_ptr->object_items(); }
-const Json & Json::operator[] (size_t i) const { return (*m_ptr)[i]; }
-const Json & Json::operator[] (const string &key) const { return (*m_ptr)[key]; }
-
-double JsonValue::number_value() const { return 0; }
-int JsonValue::int_value() const { return 0; }
-bool JsonValue::bool_value() const { return false; }
-const string & JsonValue::string_value() const { return statics().empty_string; }
-const vector<Json> & JsonValue::array_items() const { return statics().empty_vector; }
-const map<string, Json> & JsonValue::object_items() const { return statics().empty_map; }
-const Json & JsonValue::operator[] (size_t) const { return static_null(); }
-const Json & JsonValue::operator[] (const string &) const { return static_null(); }
-
-const Json & JsonObject::operator[] (const string &key) const {
- auto iter = m_value.find(key);
- return (iter == m_value.end()) ? static_null() : iter->second;
-}
-const Json & JsonArray::operator[] (size_t i) const {
- if (i >= m_value.size()) return static_null();
- else return m_value[i];
-}
-
-/* * * * * * * * * * * * * * * * * * * *
- * Comparison
- */
-
-bool Json::operator== (const Json &other) const {
- if (m_ptr == other.m_ptr)
- return true;
- if (m_ptr->type() != other.m_ptr->type())
- return false;
-
- return m_ptr->equals(other.m_ptr.get());
-}
-
-bool Json::operator< (const Json &other) const {
- if (m_ptr == other.m_ptr)
- return false;
- if (m_ptr->type() != other.m_ptr->type())
- return m_ptr->type() < other.m_ptr->type();
-
- return m_ptr->less(other.m_ptr.get());
-}
-
-/* * * * * * * * * * * * * * * * * * * *
- * Parsing
- */
-
-/* esc(c)
- *
- * Format char c suitable for printing in an error message.
- */
-static inline string esc(char c) {
- char buf[12];
- if (static_cast<uint8_t>(c) >= 0x20 && static_cast<uint8_t>(c) <= 0x7f) {
- snprintf(buf, sizeof buf, "'%c' (%d)", c, c);
- } else {
- snprintf(buf, sizeof buf, "(%d)", c);
- }
- return string(buf);
-}
-
-static inline bool in_range(long x, long lower, long upper) {
- return (x >= lower && x <= upper);
-}
-
-namespace {
-/* JsonParser
- *
- * Object that tracks all state of an in-progress parse.
- */
-struct JsonParser final {
-
- /* State
- */
- const string &str;
- size_t i;
- string &err;
- bool failed;
- const JsonParse strategy;
-
- /* fail(msg, err_ret = Json())
- *
- * Mark this parse as failed.
- */
- Json fail(string &&msg) {
- return fail(move(msg), Json());
- }
-
- template <typename T>
- T fail(string &&msg, const T err_ret) {
- if (!failed)
- err = std::move(msg);
- failed = true;
- return err_ret;
- }
-
- /* consume_whitespace()
- *
- * Advance until the current character is non-whitespace.
- */
- void consume_whitespace() {
- while (str[i] == ' ' || str[i] == '\r' || str[i] == '\n' || str[i] == '\t')
- i++;
- }
-
- /* consume_comment()
- *
- * Advance comments (c-style inline and multiline).
- */
- bool consume_comment() {
- bool comment_found = false;
- if (str[i] == '/') {
- i++;
- if (i == str.size())
- return fail("unexpected end of input after start of comment", false);
- if (str[i] == '/') { // inline comment
- i++;
- // advance until next line, or end of input
- while (i < str.size() && str[i] != '\n') {
- i++;
- }
- comment_found = true;
- }
- else if (str[i] == '*') { // multiline comment
- i++;
- if (i > str.size()-2)
- return fail("unexpected end of input inside multi-line comment", false);
- // advance until closing tokens
- while (!(str[i] == '*' && str[i+1] == '/')) {
- i++;
- if (i > str.size()-2)
- return fail(
- "unexpected end of input inside multi-line comment", false);
- }
- i += 2;
- comment_found = true;
- }
- else
- return fail("malformed comment", false);
- }
- return comment_found;
- }
-
- /* consume_garbage()
- *
- * Advance until the current character is non-whitespace and non-comment.
- */
- void consume_garbage() {
- consume_whitespace();
- if(strategy == JsonParse::COMMENTS) {
- bool comment_found = false;
- do {
- comment_found = consume_comment();
- if (failed) return;
- consume_whitespace();
- }
- while(comment_found);
- }
- }
-
- /* get_next_token()
- *
- * Return the next non-whitespace character. If the end of the input is reached,
- * flag an error and return 0.
- */
- char get_next_token() {
- consume_garbage();
- if (failed) return static_cast<char>(0);
- if (i == str.size())
- return fail("unexpected end of input", static_cast<char>(0));
-
- return str[i++];
- }
-
- /* encode_utf8(pt, out)
- *
- * Encode pt as UTF-8 and add it to out.
- */
- void encode_utf8(long pt, string & out) {
- if (pt < 0)
- return;
-
- if (pt < 0x80) {
- out += static_cast<char>(pt);
- } else if (pt < 0x800) {
- out += static_cast<char>((pt >> 6) | 0xC0);
- out += static_cast<char>((pt & 0x3F) | 0x80);
- } else if (pt < 0x10000) {
- out += static_cast<char>((pt >> 12) | 0xE0);
- out += static_cast<char>(((pt >> 6) & 0x3F) | 0x80);
- out += static_cast<char>((pt & 0x3F) | 0x80);
- } else {
- out += static_cast<char>((pt >> 18) | 0xF0);
- out += static_cast<char>(((pt >> 12) & 0x3F) | 0x80);
- out += static_cast<char>(((pt >> 6) & 0x3F) | 0x80);
- out += static_cast<char>((pt & 0x3F) | 0x80);
- }
- }
-
- /* parse_string()
- *
- * Parse a string, starting at the current position.
- */
- string parse_string() {
- string out;
- long last_escaped_codepoint = -1;
- while (true) {
- if (i == str.size())
- return fail("unexpected end of input in string", "");
-
- char ch = str[i++];
-
- if (ch == '"') {
- encode_utf8(last_escaped_codepoint, out);
- return out;
- }
-
- if (in_range(ch, 0, 0x1f))
- return fail("unescaped " + esc(ch) + " in string", "");
-
- // The usual case: non-escaped characters
- if (ch != '\\') {
- encode_utf8(last_escaped_codepoint, out);
- last_escaped_codepoint = -1;
- out += ch;
- continue;
- }
-
- // Handle escapes
- if (i == str.size())
- return fail("unexpected end of input in string", "");
-
- ch = str[i++];
-
- if (ch == 'u') {
- // Extract 4-byte escape sequence
- string esc = str.substr(i, 4);
- // Explicitly check length of the substring. The following loop
- // relies on std::string returning the terminating NUL when
- // accessing str[length]. Checking here reduces brittleness.
- if (esc.length() < 4) {
- return fail("bad \\u escape: " + esc, "");
- }
- for (size_t j = 0; j < 4; j++) {
- if (!in_range(esc[j], 'a', 'f') && !in_range(esc[j], 'A', 'F')
- && !in_range(esc[j], '0', '9'))
- return fail("bad \\u escape: " + esc, "");
- }
-
- long codepoint = strtol(esc.data(), nullptr, 16);
-
- // JSON specifies that characters outside the BMP shall be encoded as a pair
- // of 4-hex-digit \u escapes encoding their surrogate pair components. Check
- // whether we're in the middle of such a beast: the previous codepoint was an
- // escaped lead (high) surrogate, and this is a trail (low) surrogate.
- if (in_range(last_escaped_codepoint, 0xD800, 0xDBFF)
- && in_range(codepoint, 0xDC00, 0xDFFF)) {
- // Reassemble the two surrogate pairs into one astral-plane character, per
- // the UTF-16 algorithm.
- encode_utf8((((last_escaped_codepoint - 0xD800) << 10)
- | (codepoint - 0xDC00)) + 0x10000, out);
- last_escaped_codepoint = -1;
- } else {
- encode_utf8(last_escaped_codepoint, out);
- last_escaped_codepoint = codepoint;
- }
-
- i += 4;
- continue;
- }
-
- encode_utf8(last_escaped_codepoint, out);
- last_escaped_codepoint = -1;
-
- if (ch == 'b') {
- out += '\b';
- } else if (ch == 'f') {
- out += '\f';
- } else if (ch == 'n') {
- out += '\n';
- } else if (ch == 'r') {
- out += '\r';
- } else if (ch == 't') {
- out += '\t';
- } else if (ch == '"' || ch == '\\' || ch == '/') {
- out += ch;
- } else {
- return fail("invalid escape character " + esc(ch), "");
- }
- }
- }
-
- /* parse_number()
- *
- * Parse a double.
- */
- Json parse_number() {
- size_t start_pos = i;
-
- if (str[i] == '-')
- i++;
-
- // Integer part
- if (str[i] == '0') {
- i++;
- if (in_range(str[i], '0', '9'))
- return fail("leading 0s not permitted in numbers");
- } else if (in_range(str[i], '1', '9')) {
- i++;
- while (in_range(str[i], '0', '9'))
- i++;
- } else {
- return fail("invalid " + esc(str[i]) + " in number");
- }
-
- if (str[i] != '.' && str[i] != 'e' && str[i] != 'E'
- && (i - start_pos) <= static_cast<size_t>(std::numeric_limits<int>::digits10)) {
- return std::atoi(str.c_str() + start_pos);
- }
-
- // Decimal part
- if (str[i] == '.') {
- i++;
- if (!in_range(str[i], '0', '9'))
- return fail("at least one digit required in fractional part");
-
- while (in_range(str[i], '0', '9'))
- i++;
- }
-
- // Exponent part
- if (str[i] == 'e' || str[i] == 'E') {
- i++;
-
- if (str[i] == '+' || str[i] == '-')
- i++;
-
- if (!in_range(str[i], '0', '9'))
- return fail("at least one digit required in exponent");
-
- while (in_range(str[i], '0', '9'))
- i++;
- }
-
- return std::strtod(str.c_str() + start_pos, nullptr);
- }
-
- /* expect(str, res)
- *
- * Expect that 'str' starts at the character that was just read. If it does, advance
- * the input and return res. If not, flag an error.
- */
- Json expect(const string &expected, Json res) {
- assert(i != 0);
- i--;
- if (str.compare(i, expected.length(), expected) == 0) {
- i += expected.length();
- return res;
- } else {
- return fail("parse error: expected " + expected + ", got " + str.substr(i, expected.length()));
- }
- }
-
- /* parse_json()
- *
- * Parse a JSON object.
- */
- Json parse_json(int depth) {
- if (depth > max_depth) {
- return fail("exceeded maximum nesting depth");
- }
-
- char ch = get_next_token();
- if (failed)
- return Json();
-
- if (ch == '-' || (ch >= '0' && ch <= '9')) {
- i--;
- return parse_number();
- }
-
- if (ch == 't')
- return expect("true", true);
-
- if (ch == 'f')
- return expect("false", false);
-
- if (ch == 'n')
- return expect("null", Json());
-
- if (ch == '"')
- return parse_string();
-
- if (ch == '{') {
- map<string, Json> data;
- ch = get_next_token();
- if (ch == '}')
- return data;
-
- while (1) {
- if (ch != '"')
- return fail("expected '\"' in object, got " + esc(ch));
-
- string key = parse_string();
- if (failed)
- return Json();
-
- ch = get_next_token();
- if (ch != ':')
- return fail("expected ':' in object, got " + esc(ch));
-
- data[std::move(key)] = parse_json(depth + 1);
- if (failed)
- return Json();
-
- ch = get_next_token();
- if (ch == '}')
- break;
- if (ch != ',')
- return fail("expected ',' in object, got " + esc(ch));
-
- ch = get_next_token();
- }
- return data;
- }
-
- if (ch == '[') {
- vector<Json> data;
- ch = get_next_token();
- if (ch == ']')
- return data;
-
- while (1) {
- i--;
- data.push_back(parse_json(depth + 1));
- if (failed)
- return Json();
-
- ch = get_next_token();
- if (ch == ']')
- break;
- if (ch != ',')
- return fail("expected ',' in list, got " + esc(ch));
-
- ch = get_next_token();
- (void)ch;
- }
- return data;
- }
-
- return fail("expected value, got " + esc(ch));
- }
-};
-}//namespace {
-
-Json Json::parse(const string &in, string &err, JsonParse strategy) {
- JsonParser parser { in, 0, err, false, strategy };
- Json result = parser.parse_json(0);
-
- // Check for any trailing garbage
- parser.consume_garbage();
- if (parser.failed)
- return Json();
- if (parser.i != in.size())
- return parser.fail("unexpected trailing " + esc(in[parser.i]));
-
- return result;
-}
-
-// Documented in json11.hpp
-vector<Json> Json::parse_multi(const string &in,
- std::string::size_type &parser_stop_pos,
- string &err,
- JsonParse strategy) {
- JsonParser parser { in, 0, err, false, strategy };
- parser_stop_pos = 0;
- vector<Json> json_vec;
- while (parser.i != in.size() && !parser.failed) {
- json_vec.push_back(parser.parse_json(0));
- if (parser.failed)
- break;
-
- // Check for another object
- parser.consume_garbage();
- if (parser.failed)
- break;
- parser_stop_pos = parser.i;
- }
- return json_vec;
-}
-
-/* * * * * * * * * * * * * * * * * * * *
- * Shape-checking
- */
-
-bool Json::has_shape(const shape & types, string & err) const {
- if (!is_object()) {
- err = "expected JSON object, got " + dump();
- return false;
- }
-
- for (auto & item : types) {
- if ((*this)[item.first].type() != item.second) {
- err = "bad type for " + item.first + " in " + dump();
- return false;
- }
- }
-
- return true;
-}
-
-} // namespace json11
+/* Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "json11.h"
+#include <cassert>
+#include <cmath>
+#include <cstdlib>
+#include <cstdio>
+#include <limits>
+
+namespace json11 {
+
+static const int max_depth = 200;
+
+using std::string;
+using std::vector;
+using std::map;
+using std::make_shared;
+using std::initializer_list;
+using std::move;
+
+/* Helper for representing null - just a do-nothing struct, plus comparison
+ * operators so the helpers in JsonValue work. We can't use nullptr_t because
+ * it may not be orderable.
+ */
+struct NullStruct {
+ bool operator==(NullStruct) const { return true; }
+ bool operator<(NullStruct) const { return false; }
+};
+
+/* * * * * * * * * * * * * * * * * * * *
+ * Serialization
+ */
+
+static void dump(NullStruct, string &out) {
+ out += "null";
+}
+
+static void dump(double value, string &out) {
+ if (std::isfinite(value)) {
+ char buf[32];
+ snprintf(buf, sizeof buf, "%.17g", value);
+ out += buf;
+ } else {
+ out += "null";
+ }
+}
+
+static void dump(int value, string &out) {
+ char buf[32];
+ snprintf(buf, sizeof buf, "%d", value);
+ out += buf;
+}
+
+static void dump(bool value, string &out) {
+ out += value ? "true" : "false";
+}
+
+static void dump(const string &value, string &out) {
+ out += '"';
+ for (size_t i = 0; i < value.length(); i++) {
+ const char ch = value[i];
+ if (ch == '\\') {
+ out += "\\\\";
+ } else if (ch == '"') {
+ out += "\\\"";
+ } else if (ch == '\b') {
+ out += "\\b";
+ } else if (ch == '\f') {
+ out += "\\f";
+ } else if (ch == '\n') {
+ out += "\\n";
+ } else if (ch == '\r') {
+ out += "\\r";
+ } else if (ch == '\t') {
+ out += "\\t";
+ } else if (static_cast<uint8_t>(ch) <= 0x1f) {
+ char buf[8];
+ snprintf(buf, sizeof buf, "\\u%04x", ch);
+ out += buf;
+ } else if (static_cast<uint8_t>(ch) == 0xe2 && static_cast<uint8_t>(value[i+1]) == 0x80
+ && static_cast<uint8_t>(value[i+2]) == 0xa8) {
+ out += "\\u2028";
+ i += 2;
+ } else if (static_cast<uint8_t>(ch) == 0xe2 && static_cast<uint8_t>(value[i+1]) == 0x80
+ && static_cast<uint8_t>(value[i+2]) == 0xa9) {
+ out += "\\u2029";
+ i += 2;
+ } else {
+ out += ch;
+ }
+ }
+ out += '"';
+}
+
+static void dump(const Json::array &values, string &out) {
+ bool first = true;
+ out += "[";
+ for (const auto &value : values) {
+ if (!first)
+ out += ", ";
+ value.dump(out);
+ first = false;
+ }
+ out += "]";
+}
+
+static void dump(const Json::object &values, string &out) {
+ bool first = true;
+ out += "{";
+ for (const auto &kv : values) {
+ if (!first)
+ out += ", ";
+ dump(kv.first, out);
+ out += ": ";
+ kv.second.dump(out);
+ first = false;
+ }
+ out += "}";
+}
+
+void Json::dump(string &out) const {
+ m_ptr->dump(out);
+}
+
+/* * * * * * * * * * * * * * * * * * * *
+ * Value wrappers
+ */
+
+template <Json::Type tag, typename T>
+class Value : public JsonValue {
+protected:
+
+ // Constructors
+ explicit Value(const T &value) : m_value(value) {}
+ explicit Value(T &&value) : m_value(move(value)) {}
+
+ // Get type tag
+ Json::Type type() const override {
+ return tag;
+ }
+
+ // Comparisons
+ bool equals(const JsonValue * other) const override {
+ return m_value == static_cast<const Value<tag, T> *>(other)->m_value;
+ }
+ bool less(const JsonValue * other) const override {
+ return m_value < static_cast<const Value<tag, T> *>(other)->m_value;
+ }
+
+ const T m_value;
+ void dump(string &out) const override { json11::dump(m_value, out); }
+};
+
+class JsonDouble final : public Value<Json::NUMBER, double> {
+ double number_value() const override { return m_value; }
+ int int_value() const override { return static_cast<int>(m_value); }
+ bool equals(const JsonValue * other) const override { return m_value == other->number_value(); }
+ bool less(const JsonValue * other) const override { return m_value < other->number_value(); }
+public:
+ explicit JsonDouble(double value) : Value(value) {}
+};
+
+class JsonInt final : public Value<Json::NUMBER, int> {
+ double number_value() const override { return m_value; }
+ int int_value() const override { return m_value; }
+ bool equals(const JsonValue * other) const override { return m_value == other->number_value(); }
+ bool less(const JsonValue * other) const override { return m_value < other->number_value(); }
+public:
+ explicit JsonInt(int value) : Value(value) {}
+};
+
+class JsonBoolean final : public Value<Json::BOOL, bool> {
+ bool bool_value() const override { return m_value; }
+public:
+ explicit JsonBoolean(bool value) : Value(value) {}
+};
+
+class JsonString final : public Value<Json::STRING, string> {
+ const string &string_value() const override { return m_value; }
+public:
+ explicit JsonString(const string &value) : Value(value) {}
+ explicit JsonString(string &&value) : Value(move(value)) {}
+};
+
+class JsonArray final : public Value<Json::ARRAY, Json::array> {
+ const Json::array &array_items() const override { return m_value; }
+ const Json & operator[](size_t i) const override;
+public:
+ explicit JsonArray(const Json::array &value) : Value(value) {}
+ explicit JsonArray(Json::array &&value) : Value(move(value)) {}
+};
+
+class JsonObject final : public Value<Json::OBJECT, Json::object> {
+ const Json::object &object_items() const override { return m_value; }
+ const Json & operator[](const string &key) const override;
+public:
+ explicit JsonObject(const Json::object &value) : Value(value) {}
+ explicit JsonObject(Json::object &&value) : Value(move(value)) {}
+};
+
+class JsonNull final : public Value<Json::NUL, NullStruct> {
+public:
+ JsonNull() : Value({}) {}
+};
+
+/* * * * * * * * * * * * * * * * * * * *
+ * Static globals - static-init-safe
+ */
+struct Statics {
+ const std::shared_ptr<JsonValue> null = make_shared<JsonNull>();
+ const std::shared_ptr<JsonValue> t = make_shared<JsonBoolean>(true);
+ const std::shared_ptr<JsonValue> f = make_shared<JsonBoolean>(false);
+ const string empty_string;
+ const vector<Json> empty_vector;
+ const map<string, Json> empty_map;
+ Statics() {}
+};
+
+static const Statics & statics() {
+ static const Statics s {};
+ return s;
+}
+
+static const Json & static_null() {
+ // This has to be separate, not in Statics, because Json() accesses statics().null.
+ static const Json json_null;
+ return json_null;
+}
+
+/* * * * * * * * * * * * * * * * * * * *
+ * Constructors
+ */
+
+Json::Json() noexcept : m_ptr(statics().null) {}
+Json::Json(std::nullptr_t) noexcept : m_ptr(statics().null) {}
+Json::Json(double value) : m_ptr(make_shared<JsonDouble>(value)) {}
+Json::Json(int value) : m_ptr(make_shared<JsonInt>(value)) {}
+Json::Json(bool value) : m_ptr(value ? statics().t : statics().f) {}
+Json::Json(const string &value) : m_ptr(make_shared<JsonString>(value)) {}
+Json::Json(string &&value) : m_ptr(make_shared<JsonString>(move(value))) {}
+Json::Json(const char * value) : m_ptr(make_shared<JsonString>(value)) {}
+Json::Json(const Json::array &values) : m_ptr(make_shared<JsonArray>(values)) {}
+Json::Json(Json::array &&values) : m_ptr(make_shared<JsonArray>(move(values))) {}
+Json::Json(const Json::object &values) : m_ptr(make_shared<JsonObject>(values)) {}
+Json::Json(Json::object &&values) : m_ptr(make_shared<JsonObject>(move(values))) {}
+
+/* * * * * * * * * * * * * * * * * * * *
+ * Accessors
+ */
+
+Json::Type Json::type() const { return m_ptr->type(); }
+double Json::number_value() const { return m_ptr->number_value(); }
+int Json::int_value() const { return m_ptr->int_value(); }
+bool Json::bool_value() const { return m_ptr->bool_value(); }
+const string & Json::string_value() const { return m_ptr->string_value(); }
+const vector<Json> & Json::array_items() const { return m_ptr->array_items(); }
+const map<string, Json> & Json::object_items() const { return m_ptr->object_items(); }
+const Json & Json::operator[] (size_t i) const { return (*m_ptr)[i]; }
+const Json & Json::operator[] (const string &key) const { return (*m_ptr)[key]; }
+
+double JsonValue::number_value() const { return 0; }
+int JsonValue::int_value() const { return 0; }
+bool JsonValue::bool_value() const { return false; }
+const string & JsonValue::string_value() const { return statics().empty_string; }
+const vector<Json> & JsonValue::array_items() const { return statics().empty_vector; }
+const map<string, Json> & JsonValue::object_items() const { return statics().empty_map; }
+const Json & JsonValue::operator[] (size_t) const { return static_null(); }
+const Json & JsonValue::operator[] (const string &) const { return static_null(); }
+
+const Json & JsonObject::operator[] (const string &key) const {
+ auto iter = m_value.find(key);
+ return (iter == m_value.end()) ? static_null() : iter->second;
+}
+const Json & JsonArray::operator[] (size_t i) const {
+ if (i >= m_value.size()) return static_null();
+ else return m_value[i];
+}
+
+/* * * * * * * * * * * * * * * * * * * *
+ * Comparison
+ */
+
+bool Json::operator== (const Json &other) const {
+ if (m_ptr == other.m_ptr)
+ return true;
+ if (m_ptr->type() != other.m_ptr->type())
+ return false;
+
+ return m_ptr->equals(other.m_ptr.get());
+}
+
+bool Json::operator< (const Json &other) const {
+ if (m_ptr == other.m_ptr)
+ return false;
+ if (m_ptr->type() != other.m_ptr->type())
+ return m_ptr->type() < other.m_ptr->type();
+
+ return m_ptr->less(other.m_ptr.get());
+}
+
+/* * * * * * * * * * * * * * * * * * * *
+ * Parsing
+ */
+
+/* esc(c)
+ *
+ * Format char c suitable for printing in an error message.
+ */
+static inline string esc(char c) {
+ char buf[12];
+ if (static_cast<uint8_t>(c) >= 0x20 && static_cast<uint8_t>(c) <= 0x7f) {
+ snprintf(buf, sizeof buf, "'%c' (%d)", c, c);
+ } else {
+ snprintf(buf, sizeof buf, "(%d)", c);
+ }
+ return string(buf);
+}
+
+static inline bool in_range(long x, long lower, long upper) {
+ return (x >= lower && x <= upper);
+}
+
+namespace {
+/* JsonParser
+ *
+ * Object that tracks all state of an in-progress parse.
+ */
+struct JsonParser final {
+
+ /* State
+ */
+ const string &str;
+ size_t i;
+ string &err;
+ bool failed;
+ const JsonParse strategy;
+
+ /* fail(msg, err_ret = Json())
+ *
+ * Mark this parse as failed.
+ */
+ Json fail(string &&msg) {
+ return fail(move(msg), Json());
+ }
+
+ template <typename T>
+ T fail(string &&msg, const T err_ret) {
+ if (!failed)
+ err = std::move(msg);
+ failed = true;
+ return err_ret;
+ }
+
+ /* consume_whitespace()
+ *
+ * Advance until the current character is non-whitespace.
+ */
+ void consume_whitespace() {
+ while (str[i] == ' ' || str[i] == '\r' || str[i] == '\n' || str[i] == '\t')
+ i++;
+ }
+
+ /* consume_comment()
+ *
+ * Advance comments (c-style inline and multiline).
+ */
+ bool consume_comment() {
+ bool comment_found = false;
+ if (str[i] == '/') {
+ i++;
+ if (i == str.size())
+ return fail("unexpected end of input after start of comment", false);
+ if (str[i] == '/') { // inline comment
+ i++;
+ // advance until next line, or end of input
+ while (i < str.size() && str[i] != '\n') {
+ i++;
+ }
+ comment_found = true;
+ }
+ else if (str[i] == '*') { // multiline comment
+ i++;
+ if (i > str.size()-2)
+ return fail("unexpected end of input inside multi-line comment", false);
+ // advance until closing tokens
+ while (!(str[i] == '*' && str[i+1] == '/')) {
+ i++;
+ if (i > str.size()-2)
+ return fail(
+ "unexpected end of input inside multi-line comment", false);
+ }
+ i += 2;
+ comment_found = true;
+ }
+ else
+ return fail("malformed comment", false);
+ }
+ return comment_found;
+ }
+
+ /* consume_garbage()
+ *
+ * Advance until the current character is non-whitespace and non-comment.
+ */
+ void consume_garbage() {
+ consume_whitespace();
+ if(strategy == JsonParse::COMMENTS) {
+ bool comment_found = false;
+ do {
+ comment_found = consume_comment();
+ if (failed) return;
+ consume_whitespace();
+ }
+ while(comment_found);
+ }
+ }
+
+ /* get_next_token()
+ *
+ * Return the next non-whitespace character. If the end of the input is reached,
+ * flag an error and return 0.
+ */
+ char get_next_token() {
+ consume_garbage();
+ if (failed) return static_cast<char>(0);
+ if (i == str.size())
+ return fail("unexpected end of input", static_cast<char>(0));
+
+ return str[i++];
+ }
+
+ /* encode_utf8(pt, out)
+ *
+ * Encode pt as UTF-8 and add it to out.
+ */
+ void encode_utf8(long pt, string & out) {
+ if (pt < 0)
+ return;
+
+ if (pt < 0x80) {
+ out += static_cast<char>(pt);
+ } else if (pt < 0x800) {
+ out += static_cast<char>((pt >> 6) | 0xC0);
+ out += static_cast<char>((pt & 0x3F) | 0x80);
+ } else if (pt < 0x10000) {
+ out += static_cast<char>((pt >> 12) | 0xE0);
+ out += static_cast<char>(((pt >> 6) & 0x3F) | 0x80);
+ out += static_cast<char>((pt & 0x3F) | 0x80);
+ } else {
+ out += static_cast<char>((pt >> 18) | 0xF0);
+ out += static_cast<char>(((pt >> 12) & 0x3F) | 0x80);
+ out += static_cast<char>(((pt >> 6) & 0x3F) | 0x80);
+ out += static_cast<char>((pt & 0x3F) | 0x80);
+ }
+ }
+
+ /* parse_string()
+ *
+ * Parse a string, starting at the current position.
+ */
+ string parse_string() {
+ string out;
+ long last_escaped_codepoint = -1;
+ while (true) {
+ if (i == str.size())
+ return fail("unexpected end of input in string", "");
+
+ char ch = str[i++];
+
+ if (ch == '"') {
+ encode_utf8(last_escaped_codepoint, out);
+ return out;
+ }
+
+ if (in_range(ch, 0, 0x1f))
+ return fail("unescaped " + esc(ch) + " in string", "");
+
+ // The usual case: non-escaped characters
+ if (ch != '\\') {
+ encode_utf8(last_escaped_codepoint, out);
+ last_escaped_codepoint = -1;
+ out += ch;
+ continue;
+ }
+
+ // Handle escapes
+ if (i == str.size())
+ return fail("unexpected end of input in string", "");
+
+ ch = str[i++];
+
+ if (ch == 'u') {
+ // Extract 4-byte escape sequence
+ string esc = str.substr(i, 4);
+ // Explicitly check length of the substring. The following loop
+ // relies on std::string returning the terminating NUL when
+ // accessing str[length]. Checking here reduces brittleness.
+ if (esc.length() < 4) {
+ return fail("bad \\u escape: " + esc, "");
+ }
+ for (size_t j = 0; j < 4; j++) {
+ if (!in_range(esc[j], 'a', 'f') && !in_range(esc[j], 'A', 'F')
+ && !in_range(esc[j], '0', '9'))
+ return fail("bad \\u escape: " + esc, "");
+ }
+
+ long codepoint = strtol(esc.data(), nullptr, 16);
+
+ // JSON specifies that characters outside the BMP shall be encoded as a pair
+ // of 4-hex-digit \u escapes encoding their surrogate pair components. Check
+ // whether we're in the middle of such a beast: the previous codepoint was an
+ // escaped lead (high) surrogate, and this is a trail (low) surrogate.
+ if (in_range(last_escaped_codepoint, 0xD800, 0xDBFF)
+ && in_range(codepoint, 0xDC00, 0xDFFF)) {
+ // Reassemble the two surrogate pairs into one astral-plane character, per
+ // the UTF-16 algorithm.
+ encode_utf8((((last_escaped_codepoint - 0xD800) << 10)
+ | (codepoint - 0xDC00)) + 0x10000, out);
+ last_escaped_codepoint = -1;
+ } else {
+ encode_utf8(last_escaped_codepoint, out);
+ last_escaped_codepoint = codepoint;
+ }
+
+ i += 4;
+ continue;
+ }
+
+ encode_utf8(last_escaped_codepoint, out);
+ last_escaped_codepoint = -1;
+
+ if (ch == 'b') {
+ out += '\b';
+ } else if (ch == 'f') {
+ out += '\f';
+ } else if (ch == 'n') {
+ out += '\n';
+ } else if (ch == 'r') {
+ out += '\r';
+ } else if (ch == 't') {
+ out += '\t';
+ } else if (ch == '"' || ch == '\\' || ch == '/') {
+ out += ch;
+ } else {
+ return fail("invalid escape character " + esc(ch), "");
+ }
+ }
+ }
+
+ /* parse_number()
+ *
+ * Parse a double.
+ */
+ Json parse_number() {
+ size_t start_pos = i;
+
+ if (str[i] == '-')
+ i++;
+
+ // Integer part
+ if (str[i] == '0') {
+ i++;
+ if (in_range(str[i], '0', '9'))
+ return fail("leading 0s not permitted in numbers");
+ } else if (in_range(str[i], '1', '9')) {
+ i++;
+ while (in_range(str[i], '0', '9'))
+ i++;
+ } else {
+ return fail("invalid " + esc(str[i]) + " in number");
+ }
+
+ if (str[i] != '.' && str[i] != 'e' && str[i] != 'E'
+ && (i - start_pos) <= static_cast<size_t>(std::numeric_limits<int>::digits10)) {
+ return std::atoi(str.c_str() + start_pos);
+ }
+
+ // Decimal part
+ if (str[i] == '.') {
+ i++;
+ if (!in_range(str[i], '0', '9'))
+ return fail("at least one digit required in fractional part");
+
+ while (in_range(str[i], '0', '9'))
+ i++;
+ }
+
+ // Exponent part
+ if (str[i] == 'e' || str[i] == 'E') {
+ i++;
+
+ if (str[i] == '+' || str[i] == '-')
+ i++;
+
+ if (!in_range(str[i], '0', '9'))
+ return fail("at least one digit required in exponent");
+
+ while (in_range(str[i], '0', '9'))
+ i++;
+ }
+
+ return std::strtod(str.c_str() + start_pos, nullptr);
+ }
+
+ /* expect(str, res)
+ *
+ * Expect that 'str' starts at the character that was just read. If it does, advance
+ * the input and return res. If not, flag an error.
+ */
+ Json expect(const string &expected, Json res) {
+ assert(i != 0);
+ i--;
+ if (str.compare(i, expected.length(), expected) == 0) {
+ i += expected.length();
+ return res;
+ } else {
+ return fail("parse error: expected " + expected + ", got " + str.substr(i, expected.length()));
+ }
+ }
+
+ /* parse_json()
+ *
+ * Parse a JSON object.
+ */
+ Json parse_json(int depth) {
+ if (depth > max_depth) {
+ return fail("exceeded maximum nesting depth");
+ }
+
+ char ch = get_next_token();
+ if (failed)
+ return Json();
+
+ if (ch == '-' || (ch >= '0' && ch <= '9')) {
+ i--;
+ return parse_number();
+ }
+
+ if (ch == 't')
+ return expect("true", true);
+
+ if (ch == 'f')
+ return expect("false", false);
+
+ if (ch == 'n')
+ return expect("null", Json());
+
+ if (ch == '"')
+ return parse_string();
+
+ if (ch == '{') {
+ map<string, Json> data;
+ ch = get_next_token();
+ if (ch == '}')
+ return data;
+
+ while (1) {
+ if (ch != '"')
+ return fail("expected '\"' in object, got " + esc(ch));
+
+ string key = parse_string();
+ if (failed)
+ return Json();
+
+ ch = get_next_token();
+ if (ch != ':')
+ return fail("expected ':' in object, got " + esc(ch));
+
+ data[std::move(key)] = parse_json(depth + 1);
+ if (failed)
+ return Json();
+
+ ch = get_next_token();
+ if (ch == '}')
+ break;
+ if (ch != ',')
+ return fail("expected ',' in object, got " + esc(ch));
+
+ ch = get_next_token();
+ }
+ return data;
+ }
+
+ if (ch == '[') {
+ vector<Json> data;
+ ch = get_next_token();
+ if (ch == ']')
+ return data;
+
+ while (1) {
+ i--;
+ data.push_back(parse_json(depth + 1));
+ if (failed)
+ return Json();
+
+ ch = get_next_token();
+ if (ch == ']')
+ break;
+ if (ch != ',')
+ return fail("expected ',' in list, got " + esc(ch));
+
+ ch = get_next_token();
+ (void)ch;
+ }
+ return data;
+ }
+
+ return fail("expected value, got " + esc(ch));
+ }
+};
+}//namespace {
+
+Json Json::parse(const string &in, string &err, JsonParse strategy) {
+ JsonParser parser { in, 0, err, false, strategy };
+ Json result = parser.parse_json(0);
+
+ // Check for any trailing garbage
+ parser.consume_garbage();
+ if (parser.failed)
+ return Json();
+ if (parser.i != in.size())
+ return parser.fail("unexpected trailing " + esc(in[parser.i]));
+
+ return result;
+}
+
+// Documented in json11.hpp
+vector<Json> Json::parse_multi(const string &in,
+ std::string::size_type &parser_stop_pos,
+ string &err,
+ JsonParse strategy) {
+ JsonParser parser { in, 0, err, false, strategy };
+ parser_stop_pos = 0;
+ vector<Json> json_vec;
+ while (parser.i != in.size() && !parser.failed) {
+ json_vec.push_back(parser.parse_json(0));
+ if (parser.failed)
+ break;
+
+ // Check for another object
+ parser.consume_garbage();
+ if (parser.failed)
+ break;
+ parser_stop_pos = parser.i;
+ }
+ return json_vec;
+}
+
+/* * * * * * * * * * * * * * * * * * * *
+ * Shape-checking
+ */
+
+bool Json::has_shape(const shape & types, string & err) const {
+ if (!is_object()) {
+ err = "expected JSON object, got " + dump();
+ return false;
+ }
+
+ for (auto & item : types) {
+ if ((*this)[item.first].type() != item.second) {
+ err = "bad type for " + item.first + " in " + dump();
+ return false;
+ }
+ }
+
+ return true;
+}
+
+} // namespace json11
diff --git a/tools/mapjson/mapjson.cpp b/tools/mapjson/mapjson.cpp
index 472a8a0..55335e3 100644
--- a/tools/mapjson/mapjson.cpp
+++ b/tools/mapjson/mapjson.cpp
@@ -1,538 +1,538 @@
-// mapjson.cpp
-
-#include <iostream>
-using std::cout; using std::endl;
-
-#include <string>
-using std::string;
-
-#include <vector>
-using std::vector;
-
-#include <algorithm>
-using std::sort; using std::find;
-
-#include <map>
-using std::map;
-
-#include <fstream>
-using std::ofstream; using std::ifstream;
-
-#include <sstream>
-using std::ostringstream;
-
-#include <limits>
-using std::numeric_limits;
-
-#include "json11.h"
-using json11::Json;
-
-#include "mapjson.h"
-
-
-string read_text_file(string filepath) {
- ifstream in_file(filepath);
-
- if (!in_file.is_open())
- FATAL_ERROR("Cannot open file %s for reading.\n", filepath.c_str());
-
- string text;
-
- in_file.seekg(0, std::ios::end);
- text.resize(in_file.tellg());
-
- in_file.seekg(0, std::ios::beg);
- in_file.read(&text[0], text.size());
-
- in_file.close();
-
- return text;
-}
-
-void write_text_file(string filepath, string text) {
- ofstream out_file(filepath, std::ofstream::binary);
-
- if (!out_file.is_open())
- FATAL_ERROR("Cannot open file %s for writing.\n", filepath.c_str());
-
- out_file << text;
-
- out_file.close();
-}
-
-string generate_map_header_text(Json map_data, Json layouts_data, string version) {
- string map_layout_id = map_data["layout"].string_value();
-
- vector<Json> matched;
-
- for (auto &field : layouts_data["layouts"].array_items()) {
- if (map_layout_id == field["id"].string_value())
- matched.push_back(field);
- }
-
- if (matched.size() != 1)
- FATAL_ERROR("Failed to find matching layout for %s.\n", map_layout_id.c_str());
-
- Json layout = matched[0];
-
- ostringstream text;
-
- text << map_data["name"].string_value() << ":\n"
- << "\t.4byte " << layout["name"].string_value() << "\n";
-
- if (map_data.object_items().find("shared_events_map") != map_data.object_items().end())
- text << "\t.4byte " << map_data["shared_events_map"].string_value() << "_MapEvents\n";
- else
- text << "\t.4byte " << map_data["name"].string_value() << "_MapEvents\n";
-
- if (map_data.object_items().find("shared_scripts_map") != map_data.object_items().end())
- text << "\t.4byte " << map_data["shared_scripts_map"].string_value() << "_MapScripts\n";
- else
- text << "\t.4byte " << map_data["name"].string_value() << "_MapScripts\n";
-
- if (map_data.object_items().find("connections") != map_data.object_items().end()
- && map_data["connections"].array_items().size() > 0)
- text << "\t.4byte " << map_data["name"].string_value() << "_MapConnections\n";
- else
- text << "\t.4byte 0x0\n";
-
- text << "\t.2byte " << map_data["music"].string_value() << "\n"
- << "\t.2byte " << layout["id"].string_value() << "\n"
- << "\t.byte " << map_data["region_map_section"].string_value() << "\n"
- << "\t.byte " << map_data["requires_flash"].bool_value() << "\n"
- << "\t.byte " << map_data["weather"].string_value() << "\n"
- << "\t.byte " << map_data["map_type"].string_value() << "\n"
- << "\t.2byte 0\n";
-
- if (version == "ruby")
- text << "\t.byte " << map_data["show_map_name"].bool_value() << "\n";
- else if (version == "emerald")
- text << "\tmap_header_flags "
- << "allow_cycling=" << map_data["allow_cycling"].bool_value() << ", "
- << "allow_escaping=" << map_data["allow_escaping"].bool_value() << ", "
- << "allow_running=" << map_data["allow_running"].bool_value() << ", "
- << "show_map_name=" << map_data["show_map_name"].bool_value() << "\n";
-
- text << "\t.byte " << map_data["battle_scene"].string_value() << "\n\n";
-
- return text.str();
-}
-
-string generate_map_connections_text(Json map_data) {
- if (map_data["connections"] == Json())
- return string("\n");
-
- ostringstream text;
-
- text << map_data["name"].string_value() << "_MapConnectionsList:\n";
-
- for (auto &connection : map_data["connections"].array_items()) {
- text << "\tconnection "
- << connection["direction"].string_value() << ", "
- << connection["offset"].int_value() << ", "
- << connection["map"].string_value() << "\n";
- }
-
- text << "\n" << map_data["name"].string_value() << "_MapConnections:\n"
- << "\t.4byte " << map_data["connections"].array_items().size() << "\n"
- << "\t.4byte " << map_data["name"].string_value() << "_MapConnectionsList\n\n";
-
- return text.str();
-}
-
-string generate_map_events_text(Json map_data) {
- if (map_data.object_items().find("shared_events_map") != map_data.object_items().end())
- return string("\n");
-
- ostringstream text;
-
- string objects_label, warps_label, coords_label, bgs_label;
-
- if (map_data["object_events"].array_items().size() > 0) {
- objects_label = map_data["name"].string_value() + "_ObjectEvents";
- text << objects_label << ":\n";
- for (unsigned int i = 0; i < map_data["object_events"].array_items().size(); i++) {
- auto obj_event = map_data["object_events"].array_items()[i];
- text << "\tobject_event " << i + 1 << ", "
- << obj_event["graphics_id"].string_value() << ", 0, "
- << obj_event["x"].int_value() << ", "
- << obj_event["y"].int_value() << ", "
- << obj_event["elevation"].int_value() << ", "
- << obj_event["movement_type"].string_value() << ", "
- << obj_event["movement_range_x"].int_value() << ", "
- << obj_event["movement_range_y"].int_value() << ", "
- << obj_event["trainer_type"].string_value() << ", "
- << obj_event["trainer_sight_or_berry_tree_id"].string_value() << ", "
- << obj_event["script"].string_value() << ", "
- << obj_event["flag"].string_value() << "\n";
- }
- text << "\n";
- } else {
- objects_label = "0x0";
- }
-
- if (map_data["warp_events"].array_items().size() > 0) {
- warps_label = map_data["name"].string_value() + "_MapWarps";
- text << warps_label << ":\n";
- for (auto &warp_event : map_data["warp_events"].array_items()) {
- text << "\twarp_def "
- << warp_event["x"].int_value() << ", "
- << warp_event["y"].int_value() << ", "
- << warp_event["elevation"].int_value() << ", "
- << warp_event["dest_warp_id"].int_value() << ", "
- << warp_event["dest_map"].string_value() << "\n";
- }
- text << "\n";
- } else {
- warps_label = "0x0";
- }
-
- if (map_data["coord_events"].array_items().size() > 0) {
- coords_label = map_data["name"].string_value() + "_MapCoordEvents";
- text << coords_label << ":\n";
- for (auto &coord_event : map_data["coord_events"].array_items()) {
- if (coord_event["type"].string_value() == "trigger") {
- text << "\tcoord_event "
- << coord_event["x"].int_value() << ", "
- << coord_event["y"].int_value() << ", "
- << coord_event["elevation"].int_value() << ", "
- << coord_event["var"].string_value() << ", "
- << coord_event["var_value"].string_value() << ", "
- << coord_event["script"].string_value() << "\n";
- }
- else if (coord_event["type"] == "weather") {
- text << "\tcoord_weather_event "
- << coord_event["x"].int_value() << ", "
- << coord_event["y"].int_value() << ", "
- << coord_event["elevation"].int_value() << ", "
- << coord_event["weather"].string_value() << "\n";
- }
- }
- text << "\n";
- } else {
- coords_label = "0x0";
- }
-
- if (map_data["bg_events"].array_items().size() > 0) {
- bgs_label = map_data["name"].string_value() + "_MapBGEvents";
- text << bgs_label << ":\n";
- for (auto &bg_event : map_data["bg_events"].array_items()) {
- if (bg_event["type"] == "sign") {
- text << "\tbg_event "
- << bg_event["x"].int_value() << ", "
- << bg_event["y"].int_value() << ", "
- << bg_event["elevation"].int_value() << ", "
- << bg_event["player_facing_dir"].string_value() << ", "
- << bg_event["script"].string_value() << "\n";
- }
- else if (bg_event["type"] == "hidden_item") {
- text << "\tbg_hidden_item_event "
- << bg_event["x"].int_value() << ", "
- << bg_event["y"].int_value() << ", "
- << bg_event["elevation"].int_value() << ", "
- << bg_event["item"].string_value() << ", "
- << bg_event["flag"].string_value() << "\n";
- }
- else if (bg_event["type"] == "secret_base") {
- text << "\tbg_secret_base_event "
- << bg_event["x"].int_value() << ", "
- << bg_event["y"].int_value() << ", "
- << bg_event["elevation"].int_value() << ", "
- << bg_event["secret_base_id"].string_value() << "\n";
- }
- }
- text << "\n";
- } else {
- bgs_label = "0x0";
- }
-
- text << map_data["name"].string_value() << "_MapEvents::\n"
- << "\tmap_events " << objects_label << ", " << warps_label << ", "
- << coords_label << ", " << bgs_label << "\n\n";
-
- return text.str();
-}
-
-string get_directory_name(string filename) {
- size_t dir_pos = filename.find_last_of("/\\");
-
- return filename.substr(0, dir_pos + 1);
-}
-
-void process_map(string map_filepath, string layouts_filepath, string version) {
- string mapdata_err, layouts_err;
-
- string mapdata_json_text = read_text_file(map_filepath);
- string layouts_json_text = read_text_file(layouts_filepath);
-
- Json map_data = Json::parse(mapdata_json_text, mapdata_err);
- if (map_data == Json())
- FATAL_ERROR("%s\n", mapdata_err.c_str());
-
- Json layouts_data = Json::parse(layouts_json_text, layouts_err);
- if (layouts_data == Json())
- FATAL_ERROR("%s\n", layouts_err.c_str());
-
- string header_text = generate_map_header_text(map_data, layouts_data, version);
- string events_text = generate_map_events_text(map_data);
- string connections_text = generate_map_connections_text(map_data);
-
- string files_dir = get_directory_name(map_filepath);
- write_text_file(files_dir + "header.inc", header_text);
- write_text_file(files_dir + "events.inc", events_text);
- write_text_file(files_dir + "connections.inc", connections_text);
-}
-
-string generate_groups_text(Json groups_data) {
- ostringstream text;
-
- for (auto &key : groups_data["group_order"].array_items()) {
- string group = key.string_value();
- text << group << "::\n";
- auto maps = groups_data[group].array_items();
- for (Json &map_name : maps)
- text << "\t.4byte " << map_name.string_value() << "\n";
- text << "\n";
- }
-
- text << "\t.align 2\n" << "gMapGroups::\n";
- for (auto &group : groups_data["group_order"].array_items())
- text << "\t.4byte " << group.string_value() << "\n";
- text << "\n";
-
- return text.str();
-}
-
-string generate_connections_text(Json groups_data) {
- vector<Json> map_names;
-
- for (auto &group : groups_data["group_order"].array_items())
- for (auto map_name : groups_data[group.string_value()].array_items())
- map_names.push_back(map_name);
-
- vector<Json> connections_include_order = groups_data["connections_include_order"].array_items();
-
- if (connections_include_order.size() > 0)
- sort(map_names.begin(), map_names.end(), [connections_include_order](const Json &a, const Json &b) {
- auto iter_a = find(connections_include_order.begin(), connections_include_order.end(), a);
- if (iter_a == connections_include_order.end())
- iter_a = connections_include_order.begin() + numeric_limits<int>::max();
- auto iter_b = find(connections_include_order.begin(), connections_include_order.end(), b);
- if (iter_b == connections_include_order.end())
- iter_b = connections_include_order.begin() + numeric_limits<int>::max();
- return iter_a < iter_b;
- });
-
- ostringstream text;
-
- for (Json map_name : map_names)
- text << "\t.include \"data/maps/" << map_name.string_value() << "/connections.inc\"\n";
-
- return text.str();
-}
-
-string generate_headers_text(Json groups_data) {
- vector<string> map_names;
-
- for (auto &group : groups_data["group_order"].array_items())
- for (auto map_name : groups_data[group.string_value()].array_items())
- map_names.push_back(map_name.string_value());
-
- ostringstream text;
-
- for (string map_name : map_names)
- text << "\t.include \"data/maps/" << map_name << "/header.inc\"\n";
-
- return text.str();
-}
-
-string generate_events_text(Json groups_data) {
- vector<string> map_names;
-
- for (auto &group : groups_data["group_order"].array_items())
- for (auto map_name : groups_data[group.string_value()].array_items())
- map_names.push_back(map_name.string_value());
-
- ostringstream text;
-
- for (string map_name : map_names)
- text << "\t.include \"data/maps/" << map_name << "/events.inc\"\n";
-
- return text.str();
-}
-
-string generate_map_constants_text(string groups_filepath, Json groups_data) {
- string file_dir = get_directory_name(groups_filepath);
- char dir_separator = file_dir.back();
-
- ostringstream text;
-
- text << "#ifndef GUARD_CONSTANTS_MAP_GROUPS_H\n"
- << "#define GUARD_CONSTANTS_MAP_GROUPS_H\n\n";
-
- int group_num = 0;
-
- for (auto &group : groups_data["group_order"].array_items()) {
- text << "// Map Group " << group_num << "\n";
- vector<Json> map_ids;
- size_t max_length = 0;
-
- for (auto &map_name : groups_data[group.string_value()].array_items()) {
- string header_filepath = file_dir + map_name.string_value() + dir_separator + "map.json";
- string err_str;
- Json map_data = Json::parse(read_text_file(header_filepath), err_str);
- map_ids.push_back(map_data["id"]);
- if (map_data["id"].string_value().length() > max_length)
- max_length = map_data["id"].string_value().length();
- }
-
- int map_id_num = 0;
- for (Json map_id : map_ids) {
- text << "#define " << map_id.string_value() << string((max_length - map_id.string_value().length() + 1), ' ')
- << "(" << map_id_num++ << " | (" << group_num << " << 8))\n";
- }
- text << "\n";
-
- group_num++;
- }
-
- text << "#define MAP_GROUPS_COUNT " << group_num << "\n\n";
- text << "#endif // GUARD_CONSTANTS_MAP_GROUPS_H\n";
-
- return text.str();
-}
-
-void process_groups(string groups_filepath) {
- string err;
- Json groups_data = Json::parse(read_text_file(groups_filepath), err);
-
- if (groups_data == Json())
- FATAL_ERROR("%s\n", err.c_str());
-
- string groups_text = generate_groups_text(groups_data);
- string connections_text = generate_connections_text(groups_data);
- string headers_text = generate_headers_text(groups_data);
- string events_text = generate_events_text(groups_data);
- string map_header_text = generate_map_constants_text(groups_filepath, groups_data);
-
- string file_dir = get_directory_name(groups_filepath);
- char s = file_dir.back();
-
- write_text_file(file_dir + "groups.inc", groups_text);
- write_text_file(file_dir + "connections.inc", connections_text);
- write_text_file(file_dir + "headers.inc", headers_text);
- write_text_file(file_dir + "events.inc", events_text);
- write_text_file(file_dir + ".." + s + ".." + s + "include" + s + "constants" + s + "map_groups.h", map_header_text);
-}
-
-string generate_layout_headers_text(Json layouts_data) {
- ostringstream text;
-
- for (auto &layout : layouts_data["layouts"].array_items()) {
- string border_label = layout["name"].string_value() + "_Border";
- string blockdata_label = layout["name"].string_value() + "_Blockdata";
- text << border_label << "::\n"
- << "\t.incbin \"" << layout["border_filepath"].string_value() << "\"\n\n"
- << blockdata_label << "::\n"
- << "\t.incbin \"" << layout["blockdata_filepath"].string_value() << "\"\n\n"
- << "\t.align 2\n"
- << layout["name"].string_value() << "::\n"
- << "\t.4byte " << layout["width"].int_value() << "\n"
- << "\t.4byte " << layout["height"].int_value() << "\n"
- << "\t.4byte " << border_label << "\n"
- << "\t.4byte " << blockdata_label << "\n"
- << "\t.4byte " << layout["primary_tileset"].string_value() << "\n"
- << "\t.4byte " << layout["secondary_tileset"].string_value() << "\n\n";
- }
-
- return text.str();
-}
-
-string generate_layouts_table_text(Json layouts_data) {
- ostringstream text;
-
- text << "\t.align 2\n"
- << layouts_data["layouts_table_label"].string_value() << "::\n";
-
- for (auto &layout : layouts_data["layouts"].array_items())
- text << "\t.4byte " << layout["name"].string_value() << "\n";
-
- return text.str();
-}
-
-string generate_layouts_constants_text(Json layouts_data) {
- ostringstream text;
-
- text << "#ifndef GUARD_CONSTANTS_LAYOUTS_H\n"
- << "#define GUARD_CONSTANTS_LAYOUTS_H\n\n";
-
- int i = 0;
- for (auto &layout : layouts_data["layouts"].array_items())
- text << "#define " << layout["id"].string_value() << " " << ++i << "\n";
-
- text << "\n#endif // GUARD_CONSTANTS_LAYOUTS_H\n";
-
- return text.str();
-}
-
-void process_layouts(string layouts_filepath) {
- string err;
- Json layouts_data = Json::parse(read_text_file(layouts_filepath), err);
-
- if (layouts_data == Json())
- FATAL_ERROR("%s\n", err.c_str());
-
- string layout_headers_text = generate_layout_headers_text(layouts_data);
- string layouts_table_text = generate_layouts_table_text(layouts_data);
- string layouts_constants_text = generate_layouts_constants_text(layouts_data);
-
- string file_dir = get_directory_name(layouts_filepath);
- char s = file_dir.back();
-
- write_text_file(file_dir + "layouts.inc", layout_headers_text);
- write_text_file(file_dir + "layouts_table.inc", layouts_table_text);
- write_text_file(file_dir + ".." + s + ".." + s + "include" + s + "constants" + s + "layouts.h", layouts_constants_text);
-}
-
-int main(int argc, char *argv[]) {
- if (argc < 3)
- FATAL_ERROR("USAGE: mapjson <mode> <game-version> [options]\n");
-
- char *version_arg = argv[2];
- string version(version_arg);
- if (version != "emerald" && version != "ruby")
- FATAL_ERROR("ERROR: <game-version> must be 'emerald' or 'ruby'.\n");
-
- char *mode_arg = argv[1];
- string mode(mode_arg);
- if (mode != "layouts" && mode != "map" && mode != "groups")
- FATAL_ERROR("ERROR: <mode> must be 'layouts', 'map', or 'groups'.\n");
-
- if (mode == "map") {
- if (argc != 5)
- FATAL_ERROR("USAGE: mapjson map <game-version> <map_file> <layouts_file>\n");
-
- string filepath(argv[3]);
- string layouts_filepath(argv[4]);
-
- process_map(filepath, layouts_filepath, version);
- }
- else if (mode == "groups") {
- if (argc != 4)
- FATAL_ERROR("USAGE: mapjson groups <game-version> <groups_file>\n");
-
- string filepath(argv[3]);
-
- process_groups(filepath);
- }
- else if (mode == "layouts") {
- if (argc != 4)
- FATAL_ERROR("USAGE: mapjson layouts <game-version> <layouts_file>\n");
-
- string filepath(argv[3]);
-
- process_layouts(filepath);
- }
-
- return 0;
-}
+// mapjson.cpp
+
+#include <iostream>
+using std::cout; using std::endl;
+
+#include <string>
+using std::string;
+
+#include <vector>
+using std::vector;
+
+#include <algorithm>
+using std::sort; using std::find;
+
+#include <map>
+using std::map;
+
+#include <fstream>
+using std::ofstream; using std::ifstream;
+
+#include <sstream>
+using std::ostringstream;
+
+#include <limits>
+using std::numeric_limits;
+
+#include "json11.h"
+using json11::Json;
+
+#include "mapjson.h"
+
+
+string read_text_file(string filepath) {
+ ifstream in_file(filepath);
+
+ if (!in_file.is_open())
+ FATAL_ERROR("Cannot open file %s for reading.\n", filepath.c_str());
+
+ string text;
+
+ in_file.seekg(0, std::ios::end);
+ text.resize(in_file.tellg());
+
+ in_file.seekg(0, std::ios::beg);
+ in_file.read(&text[0], text.size());
+
+ in_file.close();
+
+ return text;
+}
+
+void write_text_file(string filepath, string text) {
+ ofstream out_file(filepath, std::ofstream::binary);
+
+ if (!out_file.is_open())
+ FATAL_ERROR("Cannot open file %s for writing.\n", filepath.c_str());
+
+ out_file << text;
+
+ out_file.close();
+}
+
+string generate_map_header_text(Json map_data, Json layouts_data, string version) {
+ string map_layout_id = map_data["layout"].string_value();
+
+ vector<Json> matched;
+
+ for (auto &field : layouts_data["layouts"].array_items()) {
+ if (map_layout_id == field["id"].string_value())
+ matched.push_back(field);
+ }
+
+ if (matched.size() != 1)
+ FATAL_ERROR("Failed to find matching layout for %s.\n", map_layout_id.c_str());
+
+ Json layout = matched[0];
+
+ ostringstream text;
+
+ text << map_data["name"].string_value() << ":\n"
+ << "\t.4byte " << layout["name"].string_value() << "\n";
+
+ if (map_data.object_items().find("shared_events_map") != map_data.object_items().end())
+ text << "\t.4byte " << map_data["shared_events_map"].string_value() << "_MapEvents\n";
+ else
+ text << "\t.4byte " << map_data["name"].string_value() << "_MapEvents\n";
+
+ if (map_data.object_items().find("shared_scripts_map") != map_data.object_items().end())
+ text << "\t.4byte " << map_data["shared_scripts_map"].string_value() << "_MapScripts\n";
+ else
+ text << "\t.4byte " << map_data["name"].string_value() << "_MapScripts\n";
+
+ if (map_data.object_items().find("connections") != map_data.object_items().end()
+ && map_data["connections"].array_items().size() > 0)
+ text << "\t.4byte " << map_data["name"].string_value() << "_MapConnections\n";
+ else
+ text << "\t.4byte 0x0\n";
+
+ text << "\t.2byte " << map_data["music"].string_value() << "\n"
+ << "\t.2byte " << layout["id"].string_value() << "\n"
+ << "\t.byte " << map_data["region_map_section"].string_value() << "\n"
+ << "\t.byte " << map_data["requires_flash"].bool_value() << "\n"
+ << "\t.byte " << map_data["weather"].string_value() << "\n"
+ << "\t.byte " << map_data["map_type"].string_value() << "\n"
+ << "\t.2byte 0\n";
+
+ if (version == "ruby")
+ text << "\t.byte " << map_data["show_map_name"].bool_value() << "\n";
+ else if (version == "emerald")
+ text << "\tmap_header_flags "
+ << "allow_cycling=" << map_data["allow_cycling"].bool_value() << ", "
+ << "allow_escaping=" << map_data["allow_escaping"].bool_value() << ", "
+ << "allow_running=" << map_data["allow_running"].bool_value() << ", "
+ << "show_map_name=" << map_data["show_map_name"].bool_value() << "\n";
+
+ text << "\t.byte " << map_data["battle_scene"].string_value() << "\n\n";
+
+ return text.str();
+}
+
+string generate_map_connections_text(Json map_data) {
+ if (map_data["connections"] == Json())
+ return string("\n");
+
+ ostringstream text;
+
+ text << map_data["name"].string_value() << "_MapConnectionsList:\n";
+
+ for (auto &connection : map_data["connections"].array_items()) {
+ text << "\tconnection "
+ << connection["direction"].string_value() << ", "
+ << connection["offset"].int_value() << ", "
+ << connection["map"].string_value() << "\n";
+ }
+
+ text << "\n" << map_data["name"].string_value() << "_MapConnections:\n"
+ << "\t.4byte " << map_data["connections"].array_items().size() << "\n"
+ << "\t.4byte " << map_data["name"].string_value() << "_MapConnectionsList\n\n";
+
+ return text.str();
+}
+
+string generate_map_events_text(Json map_data) {
+ if (map_data.object_items().find("shared_events_map") != map_data.object_items().end())
+ return string("\n");
+
+ ostringstream text;
+
+ string objects_label, warps_label, coords_label, bgs_label;
+
+ if (map_data["object_events"].array_items().size() > 0) {
+ objects_label = map_data["name"].string_value() + "_ObjectEvents";
+ text << objects_label << ":\n";
+ for (unsigned int i = 0; i < map_data["object_events"].array_items().size(); i++) {
+ auto obj_event = map_data["object_events"].array_items()[i];
+ text << "\tobject_event " << i + 1 << ", "
+ << obj_event["graphics_id"].string_value() << ", 0, "
+ << obj_event["x"].int_value() << ", "
+ << obj_event["y"].int_value() << ", "
+ << obj_event["elevation"].int_value() << ", "
+ << obj_event["movement_type"].string_value() << ", "
+ << obj_event["movement_range_x"].int_value() << ", "
+ << obj_event["movement_range_y"].int_value() << ", "
+ << obj_event["trainer_type"].string_value() << ", "
+ << obj_event["trainer_sight_or_berry_tree_id"].string_value() << ", "
+ << obj_event["script"].string_value() << ", "
+ << obj_event["flag"].string_value() << "\n";
+ }
+ text << "\n";
+ } else {
+ objects_label = "0x0";
+ }
+
+ if (map_data["warp_events"].array_items().size() > 0) {
+ warps_label = map_data["name"].string_value() + "_MapWarps";
+ text << warps_label << ":\n";
+ for (auto &warp_event : map_data["warp_events"].array_items()) {
+ text << "\twarp_def "
+ << warp_event["x"].int_value() << ", "
+ << warp_event["y"].int_value() << ", "
+ << warp_event["elevation"].int_value() << ", "
+ << warp_event["dest_warp_id"].int_value() << ", "
+ << warp_event["dest_map"].string_value() << "\n";
+ }
+ text << "\n";
+ } else {
+ warps_label = "0x0";
+ }
+
+ if (map_data["coord_events"].array_items().size() > 0) {
+ coords_label = map_data["name"].string_value() + "_MapCoordEvents";
+ text << coords_label << ":\n";
+ for (auto &coord_event : map_data["coord_events"].array_items()) {
+ if (coord_event["type"].string_value() == "trigger") {
+ text << "\tcoord_event "
+ << coord_event["x"].int_value() << ", "
+ << coord_event["y"].int_value() << ", "
+ << coord_event["elevation"].int_value() << ", "
+ << coord_event["var"].string_value() << ", "
+ << coord_event["var_value"].string_value() << ", "
+ << coord_event["script"].string_value() << "\n";
+ }
+ else if (coord_event["type"] == "weather") {
+ text << "\tcoord_weather_event "
+ << coord_event["x"].int_value() << ", "
+ << coord_event["y"].int_value() << ", "
+ << coord_event["elevation"].int_value() << ", "
+ << coord_event["weather"].string_value() << "\n";
+ }
+ }
+ text << "\n";
+ } else {
+ coords_label = "0x0";
+ }
+
+ if (map_data["bg_events"].array_items().size() > 0) {
+ bgs_label = map_data["name"].string_value() + "_MapBGEvents";
+ text << bgs_label << ":\n";
+ for (auto &bg_event : map_data["bg_events"].array_items()) {
+ if (bg_event["type"] == "sign") {
+ text << "\tbg_event "
+ << bg_event["x"].int_value() << ", "
+ << bg_event["y"].int_value() << ", "
+ << bg_event["elevation"].int_value() << ", "
+ << bg_event["player_facing_dir"].string_value() << ", "
+ << bg_event["script"].string_value() << "\n";
+ }
+ else if (bg_event["type"] == "hidden_item") {
+ text << "\tbg_hidden_item_event "
+ << bg_event["x"].int_value() << ", "
+ << bg_event["y"].int_value() << ", "
+ << bg_event["elevation"].int_value() << ", "
+ << bg_event["item"].string_value() << ", "
+ << bg_event["flag"].string_value() << "\n";
+ }
+ else if (bg_event["type"] == "secret_base") {
+ text << "\tbg_secret_base_event "
+ << bg_event["x"].int_value() << ", "
+ << bg_event["y"].int_value() << ", "
+ << bg_event["elevation"].int_value() << ", "
+ << bg_event["secret_base_id"].string_value() << "\n";
+ }
+ }
+ text << "\n";
+ } else {
+ bgs_label = "0x0";
+ }
+
+ text << map_data["name"].string_value() << "_MapEvents::\n"
+ << "\tmap_events " << objects_label << ", " << warps_label << ", "
+ << coords_label << ", " << bgs_label << "\n\n";
+
+ return text.str();
+}
+
+string get_directory_name(string filename) {
+ size_t dir_pos = filename.find_last_of("/\\");
+
+ return filename.substr(0, dir_pos + 1);
+}
+
+void process_map(string map_filepath, string layouts_filepath, string version) {
+ string mapdata_err, layouts_err;
+
+ string mapdata_json_text = read_text_file(map_filepath);
+ string layouts_json_text = read_text_file(layouts_filepath);
+
+ Json map_data = Json::parse(mapdata_json_text, mapdata_err);
+ if (map_data == Json())
+ FATAL_ERROR("%s\n", mapdata_err.c_str());
+
+ Json layouts_data = Json::parse(layouts_json_text, layouts_err);
+ if (layouts_data == Json())
+ FATAL_ERROR("%s\n", layouts_err.c_str());
+
+ string header_text = generate_map_header_text(map_data, layouts_data, version);
+ string events_text = generate_map_events_text(map_data);
+ string connections_text = generate_map_connections_text(map_data);
+
+ string files_dir = get_directory_name(map_filepath);
+ write_text_file(files_dir + "header.inc", header_text);
+ write_text_file(files_dir + "events.inc", events_text);
+ write_text_file(files_dir + "connections.inc", connections_text);
+}
+
+string generate_groups_text(Json groups_data) {
+ ostringstream text;
+
+ for (auto &key : groups_data["group_order"].array_items()) {
+ string group = key.string_value();
+ text << group << "::\n";
+ auto maps = groups_data[group].array_items();
+ for (Json &map_name : maps)
+ text << "\t.4byte " << map_name.string_value() << "\n";
+ text << "\n";
+ }
+
+ text << "\t.align 2\n" << "gMapGroups::\n";
+ for (auto &group : groups_data["group_order"].array_items())
+ text << "\t.4byte " << group.string_value() << "\n";
+ text << "\n";
+
+ return text.str();
+}
+
+string generate_connections_text(Json groups_data) {
+ vector<Json> map_names;
+
+ for (auto &group : groups_data["group_order"].array_items())
+ for (auto map_name : groups_data[group.string_value()].array_items())
+ map_names.push_back(map_name);
+
+ vector<Json> connections_include_order = groups_data["connections_include_order"].array_items();
+
+ if (connections_include_order.size() > 0)
+ sort(map_names.begin(), map_names.end(), [connections_include_order](const Json &a, const Json &b) {
+ auto iter_a = find(connections_include_order.begin(), connections_include_order.end(), a);
+ if (iter_a == connections_include_order.end())
+ iter_a = connections_include_order.begin() + numeric_limits<int>::max();
+ auto iter_b = find(connections_include_order.begin(), connections_include_order.end(), b);
+ if (iter_b == connections_include_order.end())
+ iter_b = connections_include_order.begin() + numeric_limits<int>::max();
+ return iter_a < iter_b;
+ });
+
+ ostringstream text;
+
+ for (Json map_name : map_names)
+ text << "\t.include \"data/maps/" << map_name.string_value() << "/connections.inc\"\n";
+
+ return text.str();
+}
+
+string generate_headers_text(Json groups_data) {
+ vector<string> map_names;
+
+ for (auto &group : groups_data["group_order"].array_items())
+ for (auto map_name : groups_data[group.string_value()].array_items())
+ map_names.push_back(map_name.string_value());
+
+ ostringstream text;
+
+ for (string map_name : map_names)
+ text << "\t.include \"data/maps/" << map_name << "/header.inc\"\n";
+
+ return text.str();
+}
+
+string generate_events_text(Json groups_data) {
+ vector<string> map_names;
+
+ for (auto &group : groups_data["group_order"].array_items())
+ for (auto map_name : groups_data[group.string_value()].array_items())
+ map_names.push_back(map_name.string_value());
+
+ ostringstream text;
+
+ for (string map_name : map_names)
+ text << "\t.include \"data/maps/" << map_name << "/events.inc\"\n";
+
+ return text.str();
+}
+
+string generate_map_constants_text(string groups_filepath, Json groups_data) {
+ string file_dir = get_directory_name(groups_filepath);
+ char dir_separator = file_dir.back();
+
+ ostringstream text;
+
+ text << "#ifndef GUARD_CONSTANTS_MAP_GROUPS_H\n"
+ << "#define GUARD_CONSTANTS_MAP_GROUPS_H\n\n";
+
+ int group_num = 0;
+
+ for (auto &group : groups_data["group_order"].array_items()) {
+ text << "// Map Group " << group_num << "\n";
+ vector<Json> map_ids;
+ size_t max_length = 0;
+
+ for (auto &map_name : groups_data[group.string_value()].array_items()) {
+ string header_filepath = file_dir + map_name.string_value() + dir_separator + "map.json";
+ string err_str;
+ Json map_data = Json::parse(read_text_file(header_filepath), err_str);
+ map_ids.push_back(map_data["id"]);
+ if (map_data["id"].string_value().length() > max_length)
+ max_length = map_data["id"].string_value().length();
+ }
+
+ int map_id_num = 0;
+ for (Json map_id : map_ids) {
+ text << "#define " << map_id.string_value() << string((max_length - map_id.string_value().length() + 1), ' ')
+ << "(" << map_id_num++ << " | (" << group_num << " << 8))\n";
+ }
+ text << "\n";
+
+ group_num++;
+ }
+
+ text << "#define MAP_GROUPS_COUNT " << group_num << "\n\n";
+ text << "#endif // GUARD_CONSTANTS_MAP_GROUPS_H\n";
+
+ return text.str();
+}
+
+void process_groups(string groups_filepath) {
+ string err;
+ Json groups_data = Json::parse(read_text_file(groups_filepath), err);
+
+ if (groups_data == Json())
+ FATAL_ERROR("%s\n", err.c_str());
+
+ string groups_text = generate_groups_text(groups_data);
+ string connections_text = generate_connections_text(groups_data);
+ string headers_text = generate_headers_text(groups_data);
+ string events_text = generate_events_text(groups_data);
+ string map_header_text = generate_map_constants_text(groups_filepath, groups_data);
+
+ string file_dir = get_directory_name(groups_filepath);
+ char s = file_dir.back();
+
+ write_text_file(file_dir + "groups.inc", groups_text);
+ write_text_file(file_dir + "connections.inc", connections_text);
+ write_text_file(file_dir + "headers.inc", headers_text);
+ write_text_file(file_dir + "events.inc", events_text);
+ write_text_file(file_dir + ".." + s + ".." + s + "include" + s + "constants" + s + "map_groups.h", map_header_text);
+}
+
+string generate_layout_headers_text(Json layouts_data) {
+ ostringstream text;
+
+ for (auto &layout : layouts_data["layouts"].array_items()) {
+ string border_label = layout["name"].string_value() + "_Border";
+ string blockdata_label = layout["name"].string_value() + "_Blockdata";
+ text << border_label << "::\n"
+ << "\t.incbin \"" << layout["border_filepath"].string_value() << "\"\n\n"
+ << blockdata_label << "::\n"
+ << "\t.incbin \"" << layout["blockdata_filepath"].string_value() << "\"\n\n"
+ << "\t.align 2\n"
+ << layout["name"].string_value() << "::\n"
+ << "\t.4byte " << layout["width"].int_value() << "\n"
+ << "\t.4byte " << layout["height"].int_value() << "\n"
+ << "\t.4byte " << border_label << "\n"
+ << "\t.4byte " << blockdata_label << "\n"
+ << "\t.4byte " << layout["primary_tileset"].string_value() << "\n"
+ << "\t.4byte " << layout["secondary_tileset"].string_value() << "\n\n";
+ }
+
+ return text.str();
+}
+
+string generate_layouts_table_text(Json layouts_data) {
+ ostringstream text;
+
+ text << "\t.align 2\n"
+ << layouts_data["layouts_table_label"].string_value() << "::\n";
+
+ for (auto &layout : layouts_data["layouts"].array_items())
+ text << "\t.4byte " << layout["name"].string_value() << "\n";
+
+ return text.str();
+}
+
+string generate_layouts_constants_text(Json layouts_data) {
+ ostringstream text;
+
+ text << "#ifndef GUARD_CONSTANTS_LAYOUTS_H\n"
+ << "#define GUARD_CONSTANTS_LAYOUTS_H\n\n";
+
+ int i = 0;
+ for (auto &layout : layouts_data["layouts"].array_items())
+ text << "#define " << layout["id"].string_value() << " " << ++i << "\n";
+
+ text << "\n#endif // GUARD_CONSTANTS_LAYOUTS_H\n";
+
+ return text.str();
+}
+
+void process_layouts(string layouts_filepath) {
+ string err;
+ Json layouts_data = Json::parse(read_text_file(layouts_filepath), err);
+
+ if (layouts_data == Json())
+ FATAL_ERROR("%s\n", err.c_str());
+
+ string layout_headers_text = generate_layout_headers_text(layouts_data);
+ string layouts_table_text = generate_layouts_table_text(layouts_data);
+ string layouts_constants_text = generate_layouts_constants_text(layouts_data);
+
+ string file_dir = get_directory_name(layouts_filepath);
+ char s = file_dir.back();
+
+ write_text_file(file_dir + "layouts.inc", layout_headers_text);
+ write_text_file(file_dir + "layouts_table.inc", layouts_table_text);
+ write_text_file(file_dir + ".." + s + ".." + s + "include" + s + "constants" + s + "layouts.h", layouts_constants_text);
+}
+
+int main(int argc, char *argv[]) {
+ if (argc < 3)
+ FATAL_ERROR("USAGE: mapjson <mode> <game-version> [options]\n");
+
+ char *version_arg = argv[2];
+ string version(version_arg);
+ if (version != "emerald" && version != "ruby")
+ FATAL_ERROR("ERROR: <game-version> must be 'emerald' or 'ruby'.\n");
+
+ char *mode_arg = argv[1];
+ string mode(mode_arg);
+ if (mode != "layouts" && mode != "map" && mode != "groups")
+ FATAL_ERROR("ERROR: <mode> must be 'layouts', 'map', or 'groups'.\n");
+
+ if (mode == "map") {
+ if (argc != 5)
+ FATAL_ERROR("USAGE: mapjson map <game-version> <map_file> <layouts_file>\n");
+
+ string filepath(argv[3]);
+ string layouts_filepath(argv[4]);
+
+ process_map(filepath, layouts_filepath, version);
+ }
+ else if (mode == "groups") {
+ if (argc != 4)
+ FATAL_ERROR("USAGE: mapjson groups <game-version> <groups_file>\n");
+
+ string filepath(argv[3]);
+
+ process_groups(filepath);
+ }
+ else if (mode == "layouts") {
+ if (argc != 4)
+ FATAL_ERROR("USAGE: mapjson layouts <game-version> <layouts_file>\n");
+
+ string filepath(argv[3]);
+
+ process_layouts(filepath);
+ }
+
+ return 0;
+}
diff --git a/tools/mid2agb/.gitignore b/tools/mid2agb/.gitignore
index e5cd12e..0e7264c 100644
--- a/tools/mid2agb/.gitignore
+++ b/tools/mid2agb/.gitignore
@@ -1 +1 @@
-mid2agb
+mid2agb
diff --git a/tools/mid2agb/agb.cpp b/tools/mid2agb/agb.cpp
index 9c9d030..d4d79f1 100644
--- a/tools/mid2agb/agb.cpp
+++ b/tools/mid2agb/agb.cpp
@@ -1,547 +1,547 @@
-// Copyright(c) 2016 YamaArashi
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#include <cstdio>
-#include <cstdarg>
-#include <cstring>
-#include <vector>
-#include "agb.h"
-#include "main.h"
-#include "midi.h"
-#include "tables.h"
-
-int g_agbTrack;
-
-static std::string s_lastOpName;
-static int s_blockNum;
-static bool s_keepLastOpName;
-static int s_lastNote;
-static int s_lastVelocity;
-static bool s_noteChanged;
-static bool s_velocityChanged;
-static bool s_inPattern;
-static int s_extendedCommand;
-static int s_memaccOp;
-static int s_memaccParam1;
-static int s_memaccParam2;
-
-void PrintAgbHeader()
-{
- std::fprintf(g_outputFile, "\t.include \"MPlayDef.s\"\n\n");
- std::fprintf(g_outputFile, "\t.equ\t%s_grp, voicegroup%03u\n", g_asmLabel.c_str(), g_voiceGroup);
- std::fprintf(g_outputFile, "\t.equ\t%s_pri, %u\n", g_asmLabel.c_str(), g_priority);
-
- if (g_reverb >= 0)
- std::fprintf(g_outputFile, "\t.equ\t%s_rev, reverb_set+%u\n", g_asmLabel.c_str(), g_reverb);
- else
- std::fprintf(g_outputFile, "\t.equ\t%s_rev, 0\n", g_asmLabel.c_str());
-
- std::fprintf(g_outputFile, "\t.equ\t%s_mvl, %u\n", g_asmLabel.c_str(), g_masterVolume);
- std::fprintf(g_outputFile, "\t.equ\t%s_key, %u\n", g_asmLabel.c_str(), 0);
- std::fprintf(g_outputFile, "\t.equ\t%s_tbs, %u\n", g_asmLabel.c_str(), g_clocksPerBeat);
- std::fprintf(g_outputFile, "\t.equ\t%s_exg, %u\n", g_asmLabel.c_str(), g_exactGateTime);
- std::fprintf(g_outputFile, "\t.equ\t%s_cmp, %u\n", g_asmLabel.c_str(), g_compressionEnabled);
-
- std::fprintf(g_outputFile, "\n\t.section .rodata\n");
- std::fprintf(g_outputFile, "\t.global\t%s\n", g_asmLabel.c_str());
-
- std::fprintf(g_outputFile, "\t.align\t2\n");
-}
-
-void ResetTrackVars()
-{
- s_lastVelocity = -1;
- s_lastNote = -1;
- s_velocityChanged = false;
- s_noteChanged = false;
- s_keepLastOpName = false;
- s_lastOpName = "";
- s_inPattern = false;
-}
-
-void PrintWait(int wait)
-{
- if (wait > 0)
- {
- std::fprintf(g_outputFile, "\t.byte\tW%02d\n", wait);
- s_velocityChanged = true;
- s_noteChanged = true;
- s_keepLastOpName = true;
- }
-}
-
-void PrintOp(int wait, std::string name, const char *format, ...)
-{
- std::va_list args;
- va_start(args, format);
- std::fprintf(g_outputFile, "\t.byte\t\t");
-
- if (format != nullptr)
- {
- if (!g_compressionEnabled || s_lastOpName != name)
- {
- std::fprintf(g_outputFile, "%s, ", name.c_str());
- s_lastOpName = name;
- }
- else
- {
- std::fprintf(g_outputFile, " ");
- }
- std::vfprintf(g_outputFile, format, args);
- }
- else
- {
- std::fputs(name.c_str(), g_outputFile);
- s_lastOpName = name;
- }
-
- std::fprintf(g_outputFile, "\n");
-
- va_end(args);
-
- PrintWait(wait);
-}
-
-void PrintByte(const char *format, ...)
-{
- std::va_list args;
- va_start(args, format);
- std::fprintf(g_outputFile, "\t.byte\t");
- std::vfprintf(g_outputFile, format, args);
- std::fprintf(g_outputFile, "\n");
- s_velocityChanged = true;
- s_noteChanged = true;
- s_keepLastOpName = true;
- va_end(args);
-}
-
-void PrintWord(const char *format, ...)
-{
- std::va_list args;
- va_start(args, format);
- std::fprintf(g_outputFile, "\t .word\t");
- std::vfprintf(g_outputFile, format, args);
- std::fprintf(g_outputFile, "\n");
- va_end(args);
-}
-
-void PrintNote(const Event& event)
-{
- int note = event.note;
- int velocity = g_noteVelocityLUT[event.param1];
- int duration = -1;
-
- if (event.param2 != -1)
- duration = g_noteDurationLUT[event.param2];
-
- int gateTimeParam = 0;
-
- if (g_exactGateTime && duration != -1)
- gateTimeParam = event.param2 - duration;
-
- char gtpBuf[16];
-
- if (gateTimeParam > 0)
- std::snprintf(gtpBuf, sizeof(gtpBuf), ", gtp%u", gateTimeParam);
- else
- gtpBuf[0] = 0;
-
- char opName[16];
-
- if (duration == -1)
- std::strcpy(opName, "TIE ");
- else
- std::snprintf(opName, sizeof(opName), "N%02u ", duration);
-
- bool noteChanged = true;
- bool velocityChanged = true;
-
- if (g_compressionEnabled)
- {
- noteChanged = (note != s_lastNote);
- velocityChanged = (velocity != s_lastVelocity);
- }
-
- if (s_keepLastOpName)
- s_keepLastOpName = false;
- else
- s_lastOpName = "";
-
- if (noteChanged || velocityChanged || (gateTimeParam > 0))
- {
- s_lastNote = note;
-
- char noteBuf[16];
-
- if (note >= 24)
- std::snprintf(noteBuf, sizeof(noteBuf), g_noteTable[note % 12], note / 12 - 2);
- else
- std::snprintf(noteBuf, sizeof(noteBuf), g_minusNoteTable[note % 12], note / -12 + 2);
-
- char velocityBuf[16];
-
- if (velocityChanged || (gateTimeParam > 0))
- {
- s_lastVelocity = velocity;
- std::snprintf(velocityBuf, sizeof(velocityBuf), ", v%03u", velocity);
- }
- else
- {
- velocityBuf[0] = 0;
- }
-
- PrintOp(event.time, opName, "%s%s%s", noteBuf, velocityBuf, gtpBuf);
- }
- else
- {
- PrintOp(event.time, opName, 0);
- }
-
- s_noteChanged = noteChanged;
- s_velocityChanged = velocityChanged;
-}
-
-void PrintEndOfTieOp(const Event& event)
-{
- int note = event.note;
- bool noteChanged = (note != s_lastNote);
-
- if (!noteChanged || !s_noteChanged)
- s_lastOpName = "";
-
- if (!noteChanged && g_compressionEnabled)
- {
- PrintOp(event.time, "EOT ", nullptr);
- }
- else
- {
- s_lastNote = note;
- if (note >= 24)
- PrintOp(event.time, "EOT ", g_noteTable[note % 12], note / 12 - 2);
- else
- PrintOp(event.time, "EOT ", g_minusNoteTable[note % 12], note / -12 + 2);
- }
-
- s_noteChanged = noteChanged;
-}
-
-void PrintSeqLoopLabel(const Event& event)
-{
- s_blockNum = event.param1 + 1;
- std::fprintf(g_outputFile, "%s_%u_B%u:\n", g_asmLabel.c_str(), g_agbTrack, s_blockNum);
- PrintWait(event.time);
- ResetTrackVars();
-}
-
-void PrintMemAcc(const Event& event)
-{
- switch (s_memaccOp)
- {
- case 0x00:
- PrintByte("MEMACC, mem_set, 0x%02X, %u", s_memaccParam1, event.param2);
- break;
- case 0x01:
- PrintByte("MEMACC, mem_add, 0x%02X, %u", s_memaccParam1, event.param2);
- break;
- case 0x02:
- PrintByte("MEMACC, mem_sub, 0x%02X, %u", s_memaccParam1, event.param2);
- break;
- case 0x03:
- PrintByte("MEMACC, mem_mem_set, 0x%02X, 0x%02X", s_memaccParam1, event.param2);
- break;
- case 0x04:
- PrintByte("MEMACC, mem_mem_add, 0x%02X, 0x%02X", s_memaccParam1, event.param2);
- break;
- case 0x05:
- PrintByte("MEMACC, mem_mem_sub, 0x%02X, 0x%02X", s_memaccParam1, event.param2);
- break;
- // TODO: everything else
- case 0x06:
- break;
- case 0x07:
- break;
- case 0x08:
- break;
- case 0x09:
- break;
- case 0x0A:
- break;
- case 0x0B:
- break;
- case 0x0C:
- break;
- case 0x0D:
- break;
- case 0x0E:
- break;
- case 0x0F:
- break;
- case 0x10:
- break;
- case 0x11:
- break;
- case 0x46:
- break;
- case 0x47:
- break;
- case 0x48:
- break;
- case 0x49:
- break;
- case 0x4A:
- break;
- case 0x4B:
- break;
- case 0x4C:
- break;
- case 0x4D:
- break;
- case 0x4E:
- break;
- case 0x4F:
- break;
- case 0x50:
- break;
- case 0x51:
- break;
- default:
- break;
- }
-
- PrintWait(event.time);
-}
-
-void PrintExtendedOp(const Event& event)
-{
- // TODO: support for other extended commands
-
- switch (s_extendedCommand)
- {
- case 0x08:
- PrintOp(event.time, "XCMD ", "xIECV , %u", event.param2);
- break;
- case 0x09:
- PrintOp(event.time, "XCMD ", "xIECL , %u", event.param2);
- break;
- default:
- PrintWait(event.time);
- break;
- }
-}
-
-void PrintControllerOp(const Event& event)
-{
- switch (event.param1)
- {
- case 0x01:
- PrintOp(event.time, "MOD ", "%u", event.param2);
- break;
- case 0x07:
- PrintOp(event.time, "VOL ", "%u*%s_mvl/mxv", event.param2, g_asmLabel.c_str());
- break;
- case 0x0A:
- PrintOp(event.time, "PAN ", "c_v%+d", event.param2 - 64);
- break;
- case 0x0C:
- case 0x10:
- PrintMemAcc(event);
- break;
- case 0x0D:
- s_memaccOp = event.param2;
- PrintWait(event.time);
- break;
- case 0x0E:
- s_memaccParam1 = event.param2;
- PrintWait(event.time);
- break;
- case 0x0F:
- s_memaccParam2 = event.param2;
- PrintWait(event.time);
- break;
- case 0x11:
- std::fprintf(g_outputFile, "%s_%u_L%u:\n", g_asmLabel.c_str(), g_agbTrack, event.param2);
- PrintWait(event.time);
- ResetTrackVars();
- break;
- case 0x14:
- PrintOp(event.time, "BENDR ", "%u", event.param2);
- break;
- case 0x15:
- PrintOp(event.time, "LFOS ", "%u", event.param2);
- break;
- case 0x16:
- PrintOp(event.time, "MODT ", "%u", event.param2);
- break;
- case 0x18:
- PrintOp(event.time, "TUNE ", "c_v%+d", event.param2 - 64);
- break;
- case 0x1A:
- PrintOp(event.time, "LFODL ", "%u", event.param2);
- break;
- case 0x1D:
- case 0x1F:
- PrintExtendedOp(event);
- break;
- case 0x1E:
- s_extendedCommand = event.param2;
- // TODO: loop op
- break;
- case 0x21:
- case 0x27:
- PrintByte("PRIO , %u", event.param2);
- PrintWait(event.time);
- break;
- default:
- PrintWait(event.time);
- break;
- }
-}
-
-void PrintAgbTrack(std::vector<Event>& events)
-{
- std::fprintf(g_outputFile, "\n@**************** Track %u (Midi-Chn.%u) ****************@\n\n", g_agbTrack, g_midiChan + 1);
- std::fprintf(g_outputFile, "%s_%u:\n", g_asmLabel.c_str(), g_agbTrack);
-
- int wholeNoteCount = 0;
- int loopEndBlockNum = 0;
-
- ResetTrackVars();
-
- bool foundVolBeforeNote = false;
-
- for (const Event& event : events)
- {
- if (event.type == EventType::Note)
- break;
-
- if (event.type == EventType::Controller && event.param1 == 0x07)
- {
- foundVolBeforeNote = true;
- break;
- }
- }
-
- if (!foundVolBeforeNote)
- PrintByte("\tVOL , 127*%s_mvl/mxv", g_asmLabel.c_str());
-
- PrintWait(g_initialWait);
- PrintByte("KEYSH , %s_key%+d", g_asmLabel.c_str(), 0);
-
- for (unsigned i = 0; events[i].type != EventType::EndOfTrack; i++)
- {
- const Event& event = events[i];
-
- if (IsPatternBoundary(event.type))
- {
- if (s_inPattern)
- PrintByte("PEND");
- s_inPattern = false;
- }
-
- if (event.type == EventType::WholeNoteMark || event.type == EventType::Pattern)
- std::fprintf(g_outputFile, "@ %03d ----------------------------------------\n", wholeNoteCount++);
-
- switch (event.type)
- {
- case EventType::Note:
- PrintNote(event);
- break;
- case EventType::EndOfTie:
- PrintEndOfTieOp(event);
- break;
- case EventType::Label:
- PrintSeqLoopLabel(event);
- break;
- case EventType::LoopEnd:
- PrintByte("GOTO");
- PrintWord("%s_%u_B%u", g_asmLabel.c_str(), g_agbTrack, loopEndBlockNum);
- PrintSeqLoopLabel(event);
- break;
- case EventType::LoopEndBegin:
- PrintByte("GOTO");
- PrintWord("%s_%u_B%u", g_asmLabel.c_str(), g_agbTrack, loopEndBlockNum);
- PrintSeqLoopLabel(event);
- loopEndBlockNum = s_blockNum;
- break;
- case EventType::LoopBegin:
- PrintSeqLoopLabel(event);
- loopEndBlockNum = s_blockNum;
- break;
- case EventType::WholeNoteMark:
- if (event.param2 & 0x80000000)
- {
- std::fprintf(g_outputFile, "%s_%u_%03lu:\n", g_asmLabel.c_str(), g_agbTrack, (unsigned long)(event.param2 & 0x7FFFFFFF));
- ResetTrackVars();
- s_inPattern = true;
- }
- PrintWait(event.time);
- break;
- case EventType::Pattern:
- PrintByte("PATT");
- PrintWord("%s_%u_%03lu", g_asmLabel.c_str(), g_agbTrack, event.param2);
-
- while (!IsPatternBoundary(events[i + 1].type))
- i++;
-
- ResetTrackVars();
- break;
- case EventType::Tempo:
- PrintByte("TEMPO , %u*%s_tbs/2", 60000000 / event.param2, g_asmLabel.c_str());
- PrintWait(event.time);
- break;
- case EventType::InstrumentChange:
- PrintOp(event.time, "VOICE ", "%u", event.param1);
- break;
- case EventType::PitchBend:
- PrintOp(event.time, "BEND ", "c_v%+d", event.param2 - 64);
- break;
- case EventType::Controller:
- PrintControllerOp(event);
- break;
- default:
- PrintWait(event.time);
- break;
- }
- }
-
- PrintByte("FINE");
-}
-
-void PrintAgbFooter()
-{
- int trackCount = g_agbTrack - 1;
-
- std::fprintf(g_outputFile, "\n@******************************************************@\n");
- std::fprintf(g_outputFile, "\t.align\t2\n");
- std::fprintf(g_outputFile, "\n%s:\n", g_asmLabel.c_str());
- std::fprintf(g_outputFile, "\t.byte\t%u\t@ NumTrks\n", trackCount);
- std::fprintf(g_outputFile, "\t.byte\t%u\t@ NumBlks\n", 0);
- std::fprintf(g_outputFile, "\t.byte\t%s_pri\t@ Priority\n", g_asmLabel.c_str());
- std::fprintf(g_outputFile, "\t.byte\t%s_rev\t@ Reverb.\n", g_asmLabel.c_str());
- std::fprintf(g_outputFile, "\n");
- std::fprintf(g_outputFile, "\t.word\t%s_grp\n", g_asmLabel.c_str());
- std::fprintf(g_outputFile, "\n");
-
- // track pointers
- for (int i = 1; i <= trackCount; i++)
- std::fprintf(g_outputFile, "\t.word\t%s_%u\n", g_asmLabel.c_str(), i);
-
- std::fprintf(g_outputFile, "\n\t.end\n");
-}
+// Copyright(c) 2016 YamaArashi
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#include <cstdio>
+#include <cstdarg>
+#include <cstring>
+#include <vector>
+#include "agb.h"
+#include "main.h"
+#include "midi.h"
+#include "tables.h"
+
+int g_agbTrack;
+
+static std::string s_lastOpName;
+static int s_blockNum;
+static bool s_keepLastOpName;
+static int s_lastNote;
+static int s_lastVelocity;
+static bool s_noteChanged;
+static bool s_velocityChanged;
+static bool s_inPattern;
+static int s_extendedCommand;
+static int s_memaccOp;
+static int s_memaccParam1;
+static int s_memaccParam2;
+
+void PrintAgbHeader()
+{
+ std::fprintf(g_outputFile, "\t.include \"MPlayDef.s\"\n\n");
+ std::fprintf(g_outputFile, "\t.equ\t%s_grp, voicegroup%03u\n", g_asmLabel.c_str(), g_voiceGroup);
+ std::fprintf(g_outputFile, "\t.equ\t%s_pri, %u\n", g_asmLabel.c_str(), g_priority);
+
+ if (g_reverb >= 0)
+ std::fprintf(g_outputFile, "\t.equ\t%s_rev, reverb_set+%u\n", g_asmLabel.c_str(), g_reverb);
+ else
+ std::fprintf(g_outputFile, "\t.equ\t%s_rev, 0\n", g_asmLabel.c_str());
+
+ std::fprintf(g_outputFile, "\t.equ\t%s_mvl, %u\n", g_asmLabel.c_str(), g_masterVolume);
+ std::fprintf(g_outputFile, "\t.equ\t%s_key, %u\n", g_asmLabel.c_str(), 0);
+ std::fprintf(g_outputFile, "\t.equ\t%s_tbs, %u\n", g_asmLabel.c_str(), g_clocksPerBeat);
+ std::fprintf(g_outputFile, "\t.equ\t%s_exg, %u\n", g_asmLabel.c_str(), g_exactGateTime);
+ std::fprintf(g_outputFile, "\t.equ\t%s_cmp, %u\n", g_asmLabel.c_str(), g_compressionEnabled);
+
+ std::fprintf(g_outputFile, "\n\t.section .rodata\n");
+ std::fprintf(g_outputFile, "\t.global\t%s\n", g_asmLabel.c_str());
+
+ std::fprintf(g_outputFile, "\t.align\t2\n");
+}
+
+void ResetTrackVars()
+{
+ s_lastVelocity = -1;
+ s_lastNote = -1;
+ s_velocityChanged = false;
+ s_noteChanged = false;
+ s_keepLastOpName = false;
+ s_lastOpName = "";
+ s_inPattern = false;
+}
+
+void PrintWait(int wait)
+{
+ if (wait > 0)
+ {
+ std::fprintf(g_outputFile, "\t.byte\tW%02d\n", wait);
+ s_velocityChanged = true;
+ s_noteChanged = true;
+ s_keepLastOpName = true;
+ }
+}
+
+void PrintOp(int wait, std::string name, const char *format, ...)
+{
+ std::va_list args;
+ va_start(args, format);
+ std::fprintf(g_outputFile, "\t.byte\t\t");
+
+ if (format != nullptr)
+ {
+ if (!g_compressionEnabled || s_lastOpName != name)
+ {
+ std::fprintf(g_outputFile, "%s, ", name.c_str());
+ s_lastOpName = name;
+ }
+ else
+ {
+ std::fprintf(g_outputFile, " ");
+ }
+ std::vfprintf(g_outputFile, format, args);
+ }
+ else
+ {
+ std::fputs(name.c_str(), g_outputFile);
+ s_lastOpName = name;
+ }
+
+ std::fprintf(g_outputFile, "\n");
+
+ va_end(args);
+
+ PrintWait(wait);
+}
+
+void PrintByte(const char *format, ...)
+{
+ std::va_list args;
+ va_start(args, format);
+ std::fprintf(g_outputFile, "\t.byte\t");
+ std::vfprintf(g_outputFile, format, args);
+ std::fprintf(g_outputFile, "\n");
+ s_velocityChanged = true;
+ s_noteChanged = true;
+ s_keepLastOpName = true;
+ va_end(args);
+}
+
+void PrintWord(const char *format, ...)
+{
+ std::va_list args;
+ va_start(args, format);
+ std::fprintf(g_outputFile, "\t .word\t");
+ std::vfprintf(g_outputFile, format, args);
+ std::fprintf(g_outputFile, "\n");
+ va_end(args);
+}
+
+void PrintNote(const Event& event)
+{
+ int note = event.note;
+ int velocity = g_noteVelocityLUT[event.param1];
+ int duration = -1;
+
+ if (event.param2 != -1)
+ duration = g_noteDurationLUT[event.param2];
+
+ int gateTimeParam = 0;
+
+ if (g_exactGateTime && duration != -1)
+ gateTimeParam = event.param2 - duration;
+
+ char gtpBuf[16];
+
+ if (gateTimeParam > 0)
+ std::snprintf(gtpBuf, sizeof(gtpBuf), ", gtp%u", gateTimeParam);
+ else
+ gtpBuf[0] = 0;
+
+ char opName[16];
+
+ if (duration == -1)
+ std::strcpy(opName, "TIE ");
+ else
+ std::snprintf(opName, sizeof(opName), "N%02u ", duration);
+
+ bool noteChanged = true;
+ bool velocityChanged = true;
+
+ if (g_compressionEnabled)
+ {
+ noteChanged = (note != s_lastNote);
+ velocityChanged = (velocity != s_lastVelocity);
+ }
+
+ if (s_keepLastOpName)
+ s_keepLastOpName = false;
+ else
+ s_lastOpName = "";
+
+ if (noteChanged || velocityChanged || (gateTimeParam > 0))
+ {
+ s_lastNote = note;
+
+ char noteBuf[16];
+
+ if (note >= 24)
+ std::snprintf(noteBuf, sizeof(noteBuf), g_noteTable[note % 12], note / 12 - 2);
+ else
+ std::snprintf(noteBuf, sizeof(noteBuf), g_minusNoteTable[note % 12], note / -12 + 2);
+
+ char velocityBuf[16];
+
+ if (velocityChanged || (gateTimeParam > 0))
+ {
+ s_lastVelocity = velocity;
+ std::snprintf(velocityBuf, sizeof(velocityBuf), ", v%03u", velocity);
+ }
+ else
+ {
+ velocityBuf[0] = 0;
+ }
+
+ PrintOp(event.time, opName, "%s%s%s", noteBuf, velocityBuf, gtpBuf);
+ }
+ else
+ {
+ PrintOp(event.time, opName, 0);
+ }
+
+ s_noteChanged = noteChanged;
+ s_velocityChanged = velocityChanged;
+}
+
+void PrintEndOfTieOp(const Event& event)
+{
+ int note = event.note;
+ bool noteChanged = (note != s_lastNote);
+
+ if (!noteChanged || !s_noteChanged)
+ s_lastOpName = "";
+
+ if (!noteChanged && g_compressionEnabled)
+ {
+ PrintOp(event.time, "EOT ", nullptr);
+ }
+ else
+ {
+ s_lastNote = note;
+ if (note >= 24)
+ PrintOp(event.time, "EOT ", g_noteTable[note % 12], note / 12 - 2);
+ else
+ PrintOp(event.time, "EOT ", g_minusNoteTable[note % 12], note / -12 + 2);
+ }
+
+ s_noteChanged = noteChanged;
+}
+
+void PrintSeqLoopLabel(const Event& event)
+{
+ s_blockNum = event.param1 + 1;
+ std::fprintf(g_outputFile, "%s_%u_B%u:\n", g_asmLabel.c_str(), g_agbTrack, s_blockNum);
+ PrintWait(event.time);
+ ResetTrackVars();
+}
+
+void PrintMemAcc(const Event& event)
+{
+ switch (s_memaccOp)
+ {
+ case 0x00:
+ PrintByte("MEMACC, mem_set, 0x%02X, %u", s_memaccParam1, event.param2);
+ break;
+ case 0x01:
+ PrintByte("MEMACC, mem_add, 0x%02X, %u", s_memaccParam1, event.param2);
+ break;
+ case 0x02:
+ PrintByte("MEMACC, mem_sub, 0x%02X, %u", s_memaccParam1, event.param2);
+ break;
+ case 0x03:
+ PrintByte("MEMACC, mem_mem_set, 0x%02X, 0x%02X", s_memaccParam1, event.param2);
+ break;
+ case 0x04:
+ PrintByte("MEMACC, mem_mem_add, 0x%02X, 0x%02X", s_memaccParam1, event.param2);
+ break;
+ case 0x05:
+ PrintByte("MEMACC, mem_mem_sub, 0x%02X, 0x%02X", s_memaccParam1, event.param2);
+ break;
+ // TODO: everything else
+ case 0x06:
+ break;
+ case 0x07:
+ break;
+ case 0x08:
+ break;
+ case 0x09:
+ break;
+ case 0x0A:
+ break;
+ case 0x0B:
+ break;
+ case 0x0C:
+ break;
+ case 0x0D:
+ break;
+ case 0x0E:
+ break;
+ case 0x0F:
+ break;
+ case 0x10:
+ break;
+ case 0x11:
+ break;
+ case 0x46:
+ break;
+ case 0x47:
+ break;
+ case 0x48:
+ break;
+ case 0x49:
+ break;
+ case 0x4A:
+ break;
+ case 0x4B:
+ break;
+ case 0x4C:
+ break;
+ case 0x4D:
+ break;
+ case 0x4E:
+ break;
+ case 0x4F:
+ break;
+ case 0x50:
+ break;
+ case 0x51:
+ break;
+ default:
+ break;
+ }
+
+ PrintWait(event.time);
+}
+
+void PrintExtendedOp(const Event& event)
+{
+ // TODO: support for other extended commands
+
+ switch (s_extendedCommand)
+ {
+ case 0x08:
+ PrintOp(event.time, "XCMD ", "xIECV , %u", event.param2);
+ break;
+ case 0x09:
+ PrintOp(event.time, "XCMD ", "xIECL , %u", event.param2);
+ break;
+ default:
+ PrintWait(event.time);
+ break;
+ }
+}
+
+void PrintControllerOp(const Event& event)
+{
+ switch (event.param1)
+ {
+ case 0x01:
+ PrintOp(event.time, "MOD ", "%u", event.param2);
+ break;
+ case 0x07:
+ PrintOp(event.time, "VOL ", "%u*%s_mvl/mxv", event.param2, g_asmLabel.c_str());
+ break;
+ case 0x0A:
+ PrintOp(event.time, "PAN ", "c_v%+d", event.param2 - 64);
+ break;
+ case 0x0C:
+ case 0x10:
+ PrintMemAcc(event);
+ break;
+ case 0x0D:
+ s_memaccOp = event.param2;
+ PrintWait(event.time);
+ break;
+ case 0x0E:
+ s_memaccParam1 = event.param2;
+ PrintWait(event.time);
+ break;
+ case 0x0F:
+ s_memaccParam2 = event.param2;
+ PrintWait(event.time);
+ break;
+ case 0x11:
+ std::fprintf(g_outputFile, "%s_%u_L%u:\n", g_asmLabel.c_str(), g_agbTrack, event.param2);
+ PrintWait(event.time);
+ ResetTrackVars();
+ break;
+ case 0x14:
+ PrintOp(event.time, "BENDR ", "%u", event.param2);
+ break;
+ case 0x15:
+ PrintOp(event.time, "LFOS ", "%u", event.param2);
+ break;
+ case 0x16:
+ PrintOp(event.time, "MODT ", "%u", event.param2);
+ break;
+ case 0x18:
+ PrintOp(event.time, "TUNE ", "c_v%+d", event.param2 - 64);
+ break;
+ case 0x1A:
+ PrintOp(event.time, "LFODL ", "%u", event.param2);
+ break;
+ case 0x1D:
+ case 0x1F:
+ PrintExtendedOp(event);
+ break;
+ case 0x1E:
+ s_extendedCommand = event.param2;
+ // TODO: loop op
+ break;
+ case 0x21:
+ case 0x27:
+ PrintByte("PRIO , %u", event.param2);
+ PrintWait(event.time);
+ break;
+ default:
+ PrintWait(event.time);
+ break;
+ }
+}
+
+void PrintAgbTrack(std::vector<Event>& events)
+{
+ std::fprintf(g_outputFile, "\n@**************** Track %u (Midi-Chn.%u) ****************@\n\n", g_agbTrack, g_midiChan + 1);
+ std::fprintf(g_outputFile, "%s_%u:\n", g_asmLabel.c_str(), g_agbTrack);
+
+ int wholeNoteCount = 0;
+ int loopEndBlockNum = 0;
+
+ ResetTrackVars();
+
+ bool foundVolBeforeNote = false;
+
+ for (const Event& event : events)
+ {
+ if (event.type == EventType::Note)
+ break;
+
+ if (event.type == EventType::Controller && event.param1 == 0x07)
+ {
+ foundVolBeforeNote = true;
+ break;
+ }
+ }
+
+ if (!foundVolBeforeNote)
+ PrintByte("\tVOL , 127*%s_mvl/mxv", g_asmLabel.c_str());
+
+ PrintWait(g_initialWait);
+ PrintByte("KEYSH , %s_key%+d", g_asmLabel.c_str(), 0);
+
+ for (unsigned i = 0; events[i].type != EventType::EndOfTrack; i++)
+ {
+ const Event& event = events[i];
+
+ if (IsPatternBoundary(event.type))
+ {
+ if (s_inPattern)
+ PrintByte("PEND");
+ s_inPattern = false;
+ }
+
+ if (event.type == EventType::WholeNoteMark || event.type == EventType::Pattern)
+ std::fprintf(g_outputFile, "@ %03d ----------------------------------------\n", wholeNoteCount++);
+
+ switch (event.type)
+ {
+ case EventType::Note:
+ PrintNote(event);
+ break;
+ case EventType::EndOfTie:
+ PrintEndOfTieOp(event);
+ break;
+ case EventType::Label:
+ PrintSeqLoopLabel(event);
+ break;
+ case EventType::LoopEnd:
+ PrintByte("GOTO");
+ PrintWord("%s_%u_B%u", g_asmLabel.c_str(), g_agbTrack, loopEndBlockNum);
+ PrintSeqLoopLabel(event);
+ break;
+ case EventType::LoopEndBegin:
+ PrintByte("GOTO");
+ PrintWord("%s_%u_B%u", g_asmLabel.c_str(), g_agbTrack, loopEndBlockNum);
+ PrintSeqLoopLabel(event);
+ loopEndBlockNum = s_blockNum;
+ break;
+ case EventType::LoopBegin:
+ PrintSeqLoopLabel(event);
+ loopEndBlockNum = s_blockNum;
+ break;
+ case EventType::WholeNoteMark:
+ if (event.param2 & 0x80000000)
+ {
+ std::fprintf(g_outputFile, "%s_%u_%03lu:\n", g_asmLabel.c_str(), g_agbTrack, (unsigned long)(event.param2 & 0x7FFFFFFF));
+ ResetTrackVars();
+ s_inPattern = true;
+ }
+ PrintWait(event.time);
+ break;
+ case EventType::Pattern:
+ PrintByte("PATT");
+ PrintWord("%s_%u_%03lu", g_asmLabel.c_str(), g_agbTrack, event.param2);
+
+ while (!IsPatternBoundary(events[i + 1].type))
+ i++;
+
+ ResetTrackVars();
+ break;
+ case EventType::Tempo:
+ PrintByte("TEMPO , %u*%s_tbs/2", 60000000 / event.param2, g_asmLabel.c_str());
+ PrintWait(event.time);
+ break;
+ case EventType::InstrumentChange:
+ PrintOp(event.time, "VOICE ", "%u", event.param1);
+ break;
+ case EventType::PitchBend:
+ PrintOp(event.time, "BEND ", "c_v%+d", event.param2 - 64);
+ break;
+ case EventType::Controller:
+ PrintControllerOp(event);
+ break;
+ default:
+ PrintWait(event.time);
+ break;
+ }
+ }
+
+ PrintByte("FINE");
+}
+
+void PrintAgbFooter()
+{
+ int trackCount = g_agbTrack - 1;
+
+ std::fprintf(g_outputFile, "\n@******************************************************@\n");
+ std::fprintf(g_outputFile, "\t.align\t2\n");
+ std::fprintf(g_outputFile, "\n%s:\n", g_asmLabel.c_str());
+ std::fprintf(g_outputFile, "\t.byte\t%u\t@ NumTrks\n", trackCount);
+ std::fprintf(g_outputFile, "\t.byte\t%u\t@ NumBlks\n", 0);
+ std::fprintf(g_outputFile, "\t.byte\t%s_pri\t@ Priority\n", g_asmLabel.c_str());
+ std::fprintf(g_outputFile, "\t.byte\t%s_rev\t@ Reverb.\n", g_asmLabel.c_str());
+ std::fprintf(g_outputFile, "\n");
+ std::fprintf(g_outputFile, "\t.word\t%s_grp\n", g_asmLabel.c_str());
+ std::fprintf(g_outputFile, "\n");
+
+ // track pointers
+ for (int i = 1; i <= trackCount; i++)
+ std::fprintf(g_outputFile, "\t.word\t%s_%u\n", g_asmLabel.c_str(), i);
+
+ std::fprintf(g_outputFile, "\n\t.end\n");
+}
diff --git a/tools/mid2agb/error.cpp b/tools/mid2agb/error.cpp
index c4a1184..13e38ff 100644
--- a/tools/mid2agb/error.cpp
+++ b/tools/mid2agb/error.cpp
@@ -1,36 +1,36 @@
-// Copyright(c) 2016 YamaArashi
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#include <cstdio>
-#include <cstdlib>
-#include <cstdarg>
-
-// Reports an error diagnostic and terminates the program.
-[[noreturn]] void RaiseError(const char* format, ...)
-{
- const int bufferSize = 1024;
- char buffer[bufferSize];
- std::va_list args;
- va_start(args, format);
- std::vsnprintf(buffer, bufferSize, format, args);
- std::fprintf(stderr, "error: %s\n", buffer);
- va_end(args);
- std::exit(1);
-}
+// Copyright(c) 2016 YamaArashi
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#include <cstdio>
+#include <cstdlib>
+#include <cstdarg>
+
+// Reports an error diagnostic and terminates the program.
+[[noreturn]] void RaiseError(const char* format, ...)
+{
+ const int bufferSize = 1024;
+ char buffer[bufferSize];
+ std::va_list args;
+ va_start(args, format);
+ std::vsnprintf(buffer, bufferSize, format, args);
+ std::fprintf(stderr, "error: %s\n", buffer);
+ va_end(args);
+ std::exit(1);
+}
diff --git a/tools/mid2agb/main.cpp b/tools/mid2agb/main.cpp
index d1f1960..ea2b294 100644
--- a/tools/mid2agb/main.cpp
+++ b/tools/mid2agb/main.cpp
@@ -1,233 +1,233 @@
-// Copyright(c) 2016 YamaArashi
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#include <cstdio>
-#include <cstdlib>
-#include <cstring>
-#include <cctype>
-#include <cassert>
-#include <string>
-#include <set>
-#include "main.h"
-#include "error.h"
-#include "midi.h"
-#include "agb.h"
-
-FILE* g_inputFile = nullptr;
-FILE* g_outputFile = nullptr;
-
-std::string g_asmLabel;
-int g_masterVolume = 127;
-int g_voiceGroup = 0;
-int g_priority = 0;
-int g_reverb = -1;
-int g_clocksPerBeat = 1;
-bool g_exactGateTime = false;
-bool g_compressionEnabled = true;
-
-[[noreturn]] static void PrintUsage()
-{
- std::printf(
- "Usage: MID2AGB name [options]\n"
- "\n"
- " input_file filename(.mid) of MIDI file\n"
- " output_file filename(.s) for AGB file (default:input_file)\n"
- "\n"
- "options -L??? label for assembler (default:output_file)\n"
- " -V??? master volume (default:127)\n"
- " -G??? voice group number (default:0)\n"
- " -P??? priority (default:0)\n"
- " -R??? reverb (default:off)\n"
- " -X 48 clocks/beat (default:24 clocks/beat)\n"
- " -E exact gate-time\n"
- " -N no compression\n"
- );
- std::exit(1);
-}
-
-static std::string StripExtension(std::string s)
-{
- std::size_t pos = s.find_last_of('.');
-
- if (pos > 0 && pos != std::string::npos)
- {
- s = s.substr(0, pos);
- }
-
- return s;
-}
-
-static std::string GetExtension(std::string s)
-{
- std::size_t pos = s.find_last_of('.');
-
- if (pos > 0 && pos != std::string::npos)
- {
- return s.substr(pos + 1);
- }
-
- return "";
-}
-
-static std::string BaseName(std::string s)
-{
- std::size_t posAfterSlash = s.find_last_of("/\\");
-
- if (posAfterSlash == std::string::npos)
- posAfterSlash = 0;
- else
- posAfterSlash++;
-
- std::size_t dotPos = s.find_first_of('.', posAfterSlash);
- if (dotPos > posAfterSlash && dotPos != std::string::npos)
- s = s.substr(posAfterSlash, dotPos - posAfterSlash);
-
- return s;
-}
-
-static const char *GetArgument(int argc, char **argv, int& index)
-{
- assert(index >= 0 && index < argc);
-
- const char *option = argv[index];
-
- assert(option != nullptr);
- assert(option[0] == '-');
-
- // If there is text following the letter, return that.
- if (std::strlen(option) >= 3)
- return option + 2;
-
- // Otherwise, try to get the next arg.
- if (index + 1 < argc)
- {
- index++;
- return argv[index];
- }
- else
- {
- return nullptr;
- }
-}
-
-int main(int argc, char** argv)
-{
- std::string inputFilename;
- std::string outputFilename;
-
- for (int i = 1; i < argc; i++)
- {
- const char *option = argv[i];
-
- if (option[0] == '-' && option[1] != '\0')
- {
- const char *arg;
-
- switch (std::toupper(option[1]))
- {
- case 'E':
- g_exactGateTime = true;
- break;
- case 'G':
- arg = GetArgument(argc, argv, i);
- if (arg == nullptr)
- PrintUsage();
- g_voiceGroup = std::stoi(arg);
- break;
- case 'L':
- arg = GetArgument(argc, argv, i);
- if (arg == nullptr)
- PrintUsage();
- g_asmLabel = arg;
- break;
- case 'N':
- g_compressionEnabled = false;
- break;
- case 'P':
- arg = GetArgument(argc, argv, i);
- if (arg == nullptr)
- PrintUsage();
- g_priority = std::stoi(arg);
- break;
- case 'R':
- arg = GetArgument(argc, argv, i);
- if (arg == nullptr)
- PrintUsage();
- g_reverb = std::stoi(arg);
- break;
- case 'V':
- arg = GetArgument(argc, argv, i);
- if (arg == nullptr)
- PrintUsage();
- g_masterVolume = std::stoi(arg);
- break;
- case 'X':
- g_clocksPerBeat = 2;
- break;
- default:
- PrintUsage();
- }
- }
- else
- {
- if (inputFilename.empty())
- inputFilename = argv[i];
- else if (outputFilename.empty())
- outputFilename = argv[i];
- else
- PrintUsage();
- }
- }
-
- if (inputFilename.empty())
- PrintUsage();
-
- if (GetExtension(inputFilename) != "mid")
- RaiseError("input filename extension is not \"mid\"");
-
- if (outputFilename.empty())
- outputFilename = StripExtension(inputFilename) + ".s";
-
- if (GetExtension(outputFilename) != "s")
- RaiseError("output filename extension is not \"s\"");
-
- if (g_asmLabel.empty())
- g_asmLabel = BaseName(outputFilename);
-
- g_inputFile = std::fopen(inputFilename.c_str(), "rb");
-
- if (g_inputFile == nullptr)
- RaiseError("failed to open \"%s\" for reading", inputFilename.c_str());
-
- g_outputFile = std::fopen(outputFilename.c_str(), "w");
-
- if (g_outputFile == nullptr)
- RaiseError("failed to open \"%s\" for writing", outputFilename.c_str());
-
- ReadMidiFileHeader();
- PrintAgbHeader();
- ReadMidiTracks();
- PrintAgbFooter();
-
- std::fclose(g_inputFile);
- std::fclose(g_outputFile);
-
- return 0;
-}
+// Copyright(c) 2016 YamaArashi
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <cctype>
+#include <cassert>
+#include <string>
+#include <set>
+#include "main.h"
+#include "error.h"
+#include "midi.h"
+#include "agb.h"
+
+FILE* g_inputFile = nullptr;
+FILE* g_outputFile = nullptr;
+
+std::string g_asmLabel;
+int g_masterVolume = 127;
+int g_voiceGroup = 0;
+int g_priority = 0;
+int g_reverb = -1;
+int g_clocksPerBeat = 1;
+bool g_exactGateTime = false;
+bool g_compressionEnabled = true;
+
+[[noreturn]] static void PrintUsage()
+{
+ std::printf(
+ "Usage: MID2AGB name [options]\n"
+ "\n"
+ " input_file filename(.mid) of MIDI file\n"
+ " output_file filename(.s) for AGB file (default:input_file)\n"
+ "\n"
+ "options -L??? label for assembler (default:output_file)\n"
+ " -V??? master volume (default:127)\n"
+ " -G??? voice group number (default:0)\n"
+ " -P??? priority (default:0)\n"
+ " -R??? reverb (default:off)\n"
+ " -X 48 clocks/beat (default:24 clocks/beat)\n"
+ " -E exact gate-time\n"
+ " -N no compression\n"
+ );
+ std::exit(1);
+}
+
+static std::string StripExtension(std::string s)
+{
+ std::size_t pos = s.find_last_of('.');
+
+ if (pos > 0 && pos != std::string::npos)
+ {
+ s = s.substr(0, pos);
+ }
+
+ return s;
+}
+
+static std::string GetExtension(std::string s)
+{
+ std::size_t pos = s.find_last_of('.');
+
+ if (pos > 0 && pos != std::string::npos)
+ {
+ return s.substr(pos + 1);
+ }
+
+ return "";
+}
+
+static std::string BaseName(std::string s)
+{
+ std::size_t posAfterSlash = s.find_last_of("/\\");
+
+ if (posAfterSlash == std::string::npos)
+ posAfterSlash = 0;
+ else
+ posAfterSlash++;
+
+ std::size_t dotPos = s.find_first_of('.', posAfterSlash);
+ if (dotPos > posAfterSlash && dotPos != std::string::npos)
+ s = s.substr(posAfterSlash, dotPos - posAfterSlash);
+
+ return s;
+}
+
+static const char *GetArgument(int argc, char **argv, int& index)
+{
+ assert(index >= 0 && index < argc);
+
+ const char *option = argv[index];
+
+ assert(option != nullptr);
+ assert(option[0] == '-');
+
+ // If there is text following the letter, return that.
+ if (std::strlen(option) >= 3)
+ return option + 2;
+
+ // Otherwise, try to get the next arg.
+ if (index + 1 < argc)
+ {
+ index++;
+ return argv[index];
+ }
+ else
+ {
+ return nullptr;
+ }
+}
+
+int main(int argc, char** argv)
+{
+ std::string inputFilename;
+ std::string outputFilename;
+
+ for (int i = 1; i < argc; i++)
+ {
+ const char *option = argv[i];
+
+ if (option[0] == '-' && option[1] != '\0')
+ {
+ const char *arg;
+
+ switch (std::toupper(option[1]))
+ {
+ case 'E':
+ g_exactGateTime = true;
+ break;
+ case 'G':
+ arg = GetArgument(argc, argv, i);
+ if (arg == nullptr)
+ PrintUsage();
+ g_voiceGroup = std::stoi(arg);
+ break;
+ case 'L':
+ arg = GetArgument(argc, argv, i);
+ if (arg == nullptr)
+ PrintUsage();
+ g_asmLabel = arg;
+ break;
+ case 'N':
+ g_compressionEnabled = false;
+ break;
+ case 'P':
+ arg = GetArgument(argc, argv, i);
+ if (arg == nullptr)
+ PrintUsage();
+ g_priority = std::stoi(arg);
+ break;
+ case 'R':
+ arg = GetArgument(argc, argv, i);
+ if (arg == nullptr)
+ PrintUsage();
+ g_reverb = std::stoi(arg);
+ break;
+ case 'V':
+ arg = GetArgument(argc, argv, i);
+ if (arg == nullptr)
+ PrintUsage();
+ g_masterVolume = std::stoi(arg);
+ break;
+ case 'X':
+ g_clocksPerBeat = 2;
+ break;
+ default:
+ PrintUsage();
+ }
+ }
+ else
+ {
+ if (inputFilename.empty())
+ inputFilename = argv[i];
+ else if (outputFilename.empty())
+ outputFilename = argv[i];
+ else
+ PrintUsage();
+ }
+ }
+
+ if (inputFilename.empty())
+ PrintUsage();
+
+ if (GetExtension(inputFilename) != "mid")
+ RaiseError("input filename extension is not \"mid\"");
+
+ if (outputFilename.empty())
+ outputFilename = StripExtension(inputFilename) + ".s";
+
+ if (GetExtension(outputFilename) != "s")
+ RaiseError("output filename extension is not \"s\"");
+
+ if (g_asmLabel.empty())
+ g_asmLabel = BaseName(outputFilename);
+
+ g_inputFile = std::fopen(inputFilename.c_str(), "rb");
+
+ if (g_inputFile == nullptr)
+ RaiseError("failed to open \"%s\" for reading", inputFilename.c_str());
+
+ g_outputFile = std::fopen(outputFilename.c_str(), "w");
+
+ if (g_outputFile == nullptr)
+ RaiseError("failed to open \"%s\" for writing", outputFilename.c_str());
+
+ ReadMidiFileHeader();
+ PrintAgbHeader();
+ ReadMidiTracks();
+ PrintAgbFooter();
+
+ std::fclose(g_inputFile);
+ std::fclose(g_outputFile);
+
+ return 0;
+}
diff --git a/tools/mid2agb/midi.cpp b/tools/mid2agb/midi.cpp
index 2adbd52..fa7d9ce 100644
--- a/tools/mid2agb/midi.cpp
+++ b/tools/mid2agb/midi.cpp
@@ -1,964 +1,964 @@
-// Copyright(c) 2016 YamaArashi
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#include <cstdio>
-#include <cassert>
-#include <string>
-#include <vector>
-#include <algorithm>
-#include <memory>
-#include "midi.h"
-#include "main.h"
-#include "error.h"
-#include "agb.h"
-#include "tables.h"
-
-enum class MidiEventCategory
-{
- Control,
- SysEx,
- Meta,
- Invalid,
-};
-
-MidiFormat g_midiFormat;
-std::int_fast32_t g_midiTrackCount;
-std::int16_t g_midiTimeDiv;
-
-int g_midiChan;
-std::int32_t g_initialWait;
-
-static long s_trackDataStart;
-static std::vector<Event> s_seqEvents;
-static std::vector<Event> s_trackEvents;
-static std::int32_t s_absoluteTime;
-static int s_blockCount = 0;
-static int s_minNote;
-static int s_maxNote;
-static int s_runningStatus;
-
-void Seek(long offset)
-{
- if (std::fseek(g_inputFile, offset, SEEK_SET) != 0)
- RaiseError("failed to seek to %l", offset);
-}
-
-void Skip(long offset)
-{
- if (std::fseek(g_inputFile, offset, SEEK_CUR) != 0)
- RaiseError("failed to skip %l bytes", offset);
-}
-
-std::string ReadSignature()
-{
- char signature[4];
-
- if (std::fread(signature, 4, 1, g_inputFile) != 1)
- RaiseError("failed to read signature");
-
- return std::string(signature, 4);
-}
-
-std::uint32_t ReadInt8()
-{
- int c = std::fgetc(g_inputFile);
-
- if (c < 0)
- RaiseError("unexpected EOF");
-
- return c;
-}
-
-std::uint32_t ReadInt16()
-{
- std::uint32_t val = 0;
- val |= ReadInt8() << 8;
- val |= ReadInt8();
- return val;
-}
-
-std::uint32_t ReadInt24()
-{
- std::uint32_t val = 0;
- val |= ReadInt8() << 16;
- val |= ReadInt8() << 8;
- val |= ReadInt8();
- return val;
-}
-
-std::uint32_t ReadInt32()
-{
- std::uint32_t val = 0;
- val |= ReadInt8() << 24;
- val |= ReadInt8() << 16;
- val |= ReadInt8() << 8;
- val |= ReadInt8();
- return val;
-}
-
-std::uint32_t ReadVLQ()
-{
- std::uint32_t val = 0;
- std::uint32_t c;
-
- do
- {
- c = ReadInt8();
- val <<= 7;
- val |= (c & 0x7F);
- } while (c & 0x80);
-
- return val;
-}
-
-void ReadMidiFileHeader()
-{
- Seek(0);
-
- if (ReadSignature() != "MThd")
- RaiseError("MIDI file header signature didn't match \"MThd\"");
-
- std::uint32_t headerLength = ReadInt32();
-
- if (headerLength != 6)
- RaiseError("MIDI file header length isn't 6");
-
- std::uint16_t midiFormat = ReadInt16();
-
- if (midiFormat >= 2)
- RaiseError("unsupported MIDI format (%u)", midiFormat);
-
- g_midiFormat = (MidiFormat)midiFormat;
- g_midiTrackCount = ReadInt16();
- g_midiTimeDiv = ReadInt16();
-
- if (g_midiTimeDiv < 0)
- RaiseError("unsupported MIDI time division (%d)", g_midiTimeDiv);
-}
-
-long ReadMidiTrackHeader(long offset)
-{
- Seek(offset);
-
- if (ReadSignature() != "MTrk")
- RaiseError("MIDI track header signature didn't match \"MTrk\"");
-
- long size = ReadInt32();
-
- s_trackDataStart = std::ftell(g_inputFile);
-
- return size + 8;
-}
-
-void StartTrack()
-{
- Seek(s_trackDataStart);
- s_absoluteTime = 0;
- s_runningStatus = 0;
-}
-
-void SkipEventData()
-{
- Skip(ReadVLQ());
-}
-
-void DetermineEventCategory(MidiEventCategory& category, int& typeChan, int& size)
-{
- typeChan = ReadInt8();
-
- if (typeChan < 0x80)
- {
- // If data byte was found, use the running status.
- ungetc(typeChan, g_inputFile);
- typeChan = s_runningStatus;
- }
-
- if (typeChan == 0xFF)
- {
- category = MidiEventCategory::Meta;
- size = 0;
- s_runningStatus = 0;
- }
- else if (typeChan >= 0xF0)
- {
- category = MidiEventCategory::SysEx;
- size = 0;
- s_runningStatus = 0;
- }
- else if (typeChan >= 0x80)
- {
- category = MidiEventCategory::Control;
-
- switch (typeChan >> 4)
- {
- case 0xC:
- case 0xD:
- size = 1;
- break;
- default:
- size = 2;
- break;
- }
- s_runningStatus = typeChan;
- }
- else
- {
- category = MidiEventCategory::Invalid;
- }
-}
-
-void MakeBlockEvent(Event& event, EventType type)
-{
- event.type = type;
- event.param1 = s_blockCount++;
- event.param2 = 0;
-}
-
-std::string ReadEventText()
-{
- char buffer[2];
- std::uint32_t length = ReadVLQ();
-
- if (length <= 2)
- {
- if (fread(buffer, length, 1, g_inputFile) != 1)
- RaiseError("failed to read event text");
- }
- else
- {
- Skip(length);
- length = 0;
- }
-
- return std::string(buffer, length);
-}
-
-bool ReadSeqEvent(Event& event)
-{
- s_absoluteTime += ReadVLQ();
- event.time = s_absoluteTime;
-
- MidiEventCategory category;
- int typeChan;
- int size;
-
- DetermineEventCategory(category, typeChan, size);
-
- if (category == MidiEventCategory::Control)
- {
- Skip(size);
- return false;
- }
-
- if (category == MidiEventCategory::SysEx)
- {
- SkipEventData();
- return false;
- }
-
- if (category == MidiEventCategory::Invalid)
- RaiseError("invalid event");
-
- // meta event
- int metaEventType = ReadInt8();
-
- if (metaEventType >= 1 && metaEventType <= 7)
- {
- // text event
- std::string text = ReadEventText();
-
- if (text == "[")
- MakeBlockEvent(event, EventType::LoopBegin);
- else if (text == "][")
- MakeBlockEvent(event, EventType::LoopEndBegin);
- else if (text == "]")
- MakeBlockEvent(event, EventType::LoopEnd);
- else if (text == ":")
- MakeBlockEvent(event, EventType::Label);
- else
- return false;
- }
- else
- {
- switch (metaEventType)
- {
- case 0x2F: // end of track
- SkipEventData();
- event.type = EventType::EndOfTrack;
- event.param1 = 0;
- event.param2 = 0;
- break;
- case 0x51: // tempo
- if (ReadVLQ() != 3)
- RaiseError("invalid tempo size");
-
- event.type = EventType::Tempo;
- event.param1 = 0;
- event.param2 = ReadInt24();
- break;
- case 0x58: // time signature
- {
- if (ReadVLQ() != 4)
- RaiseError("invalid time signature size");
-
- int numerator = ReadInt8();
- int denominatorExponent = ReadInt8();
-
- if (denominatorExponent >= 16)
- RaiseError("invalid time signature denominator");
-
- Skip(2); // ignore other values
-
- int clockTicks = 96 * numerator * g_clocksPerBeat;
- int denominator = 1 << denominatorExponent;
- int timeSig = clockTicks / denominator;
-
- if (timeSig <= 0 || timeSig >= 0x10000)
- RaiseError("invalid time signature");
-
- event.type = EventType::TimeSignature;
- event.param1 = 0;
- event.param2 = timeSig;
- break;
- }
- default:
- SkipEventData();
- return false;
- }
- }
-
- return true;
-}
-
-void ReadSeqEvents()
-{
- StartTrack();
-
- for (;;)
- {
- Event event = {};
-
- if (ReadSeqEvent(event))
- {
- s_seqEvents.push_back(event);
-
- if (event.type == EventType::EndOfTrack)
- return;
- }
- }
-}
-
-bool CheckNoteEnd(Event& event)
-{
- event.param2 += ReadVLQ();
-
- MidiEventCategory category;
- int typeChan;
- int size;
-
- DetermineEventCategory(category, typeChan, size);
-
- if (category == MidiEventCategory::Control)
- {
- int chan = typeChan & 0xF;
-
- if (chan != g_midiChan)
- {
- Skip(size);
- return false;
- }
-
- switch (typeChan & 0xF0)
- {
- case 0x80: // note off
- {
- int note = ReadInt8();
- ReadInt8(); // ignore velocity
- if (note == event.note)
- return true;
- break;
- }
- case 0x90: // note on
- {
- int note = ReadInt8();
- int velocity = ReadInt8();
- if (velocity == 0 && note == event.note)
- return true;
- break;
- }
- default:
- Skip(size);
- break;
- }
-
- return false;
- }
-
- if (category == MidiEventCategory::SysEx)
- {
- SkipEventData();
- return false;
- }
-
- if (category == MidiEventCategory::Meta)
- {
- int metaEventType = ReadInt8();
- SkipEventData();
-
- if (metaEventType == 0x2F)
- RaiseError("note doesn't end");
-
- return false;
- }
-
- RaiseError("invalid event");
-}
-
-void FindNoteEnd(Event& event)
-{
- // Save the current file position and running status
- // which get modified by CheckNoteEnd.
- long startPos = ftell(g_inputFile);
- int savedRunningStatus = s_runningStatus;
-
- event.param2 = 0;
-
- while (!CheckNoteEnd(event))
- ;
-
- Seek(startPos);
- s_runningStatus = savedRunningStatus;
-}
-
-bool ReadTrackEvent(Event& event)
-{
- s_absoluteTime += ReadVLQ();
- event.time = s_absoluteTime;
-
- MidiEventCategory category;
- int typeChan;
- int size;
-
- DetermineEventCategory(category, typeChan, size);
-
- if (category == MidiEventCategory::Control)
- {
- int chan = typeChan & 0xF;
-
- if (chan != g_midiChan)
- {
- Skip(size);
- return false;
- }
-
- switch (typeChan & 0xF0)
- {
- case 0x90: // note on
- {
- int note = ReadInt8();
- int velocity = ReadInt8();
-
- if (velocity != 0)
- {
- event.type = EventType::Note;
- event.note = note;
- event.param1 = velocity;
- FindNoteEnd(event);
- if (event.param2 > 0)
- {
- if (note < s_minNote)
- s_minNote = note;
- if (note > s_maxNote)
- s_maxNote = note;
- }
- }
- break;
- }
- case 0xB0: // controller event
- event.type = EventType::Controller;
- event.param1 = ReadInt8(); // controller index
- event.param2 = ReadInt8(); // value
- break;
- case 0xC0: // instrument change
- event.type = EventType::InstrumentChange;
- event.param1 = ReadInt8(); // instrument
- event.param2 = 0;
- break;
- case 0xE0: // pitch bend
- event.type = EventType::PitchBend;
- event.param1 = ReadInt8();
- event.param2 = ReadInt8();
- break;
- default:
- Skip(size);
- return false;
- }
-
- return true;
- }
-
- if (category == MidiEventCategory::SysEx)
- {
- SkipEventData();
- return false;
- }
-
- if (category == MidiEventCategory::Meta)
- {
- int metaEventType = ReadInt8();
- SkipEventData();
-
- if (metaEventType == 0x2F)
- {
- event.type = EventType::EndOfTrack;
- event.param1 = 0;
- event.param2 = 0;
- return true;
- }
-
- return false;
- }
-
- RaiseError("invalid event");
-}
-
-void ReadTrackEvents()
-{
- StartTrack();
-
- s_trackEvents.clear();
-
- s_minNote = 0xFF;
- s_maxNote = 0;
-
- for (;;)
- {
- Event event = {};
-
- if (ReadTrackEvent(event))
- {
- s_trackEvents.push_back(event);
-
- if (event.type == EventType::EndOfTrack)
- return;
- }
- }
-}
-
-bool EventCompare(const Event& event1, const Event& event2)
-{
- if (event1.time < event2.time)
- return true;
-
- if (event1.time > event2.time)
- return false;
-
- unsigned event1Type = (unsigned)event1.type;
- unsigned event2Type = (unsigned)event2.type;
-
- if (event1.type == EventType::Note)
- event1Type += event1.note;
-
- if (event2.type == EventType::Note)
- event2Type += event2.note;
-
- if (event1Type < event2Type)
- return true;
-
- if (event1Type > event2Type)
- return false;
-
- if (event1.type == EventType::EndOfTie)
- {
- if (event1.note < event2.note)
- return true;
-
- if (event1.note > event2.note)
- return false;
- }
-
- return false;
-}
-
-std::unique_ptr<std::vector<Event>> MergeEvents()
-{
- std::unique_ptr<std::vector<Event>> events(new std::vector<Event>());
-
- unsigned trackEventPos = 0;
- unsigned seqEventPos = 0;
-
- while (s_trackEvents[trackEventPos].type != EventType::EndOfTrack
- && s_seqEvents[seqEventPos].type != EventType::EndOfTrack)
- {
- if (EventCompare(s_trackEvents[trackEventPos], s_seqEvents[seqEventPos]))
- events->push_back(s_trackEvents[trackEventPos++]);
- else
- events->push_back(s_seqEvents[seqEventPos++]);
- }
-
- while (s_trackEvents[trackEventPos].type != EventType::EndOfTrack)
- events->push_back(s_trackEvents[trackEventPos++]);
-
- while (s_seqEvents[seqEventPos].type != EventType::EndOfTrack)
- events->push_back(s_seqEvents[seqEventPos++]);
-
- // Push the EndOfTrack event with the larger time.
- if (EventCompare(s_trackEvents[trackEventPos], s_seqEvents[seqEventPos]))
- events->push_back(s_seqEvents[seqEventPos]);
- else
- events->push_back(s_trackEvents[trackEventPos]);
-
- return events;
-}
-
-void ConvertTimes(std::vector<Event>& events)
-{
- for (Event& event : events)
- {
- event.time = (24 * g_clocksPerBeat * event.time) / g_midiTimeDiv;
-
- if (event.type == EventType::Note)
- {
- event.param1 = g_noteVelocityLUT[event.param1];
-
- std::uint32_t duration = (24 * g_clocksPerBeat * event.param2) / g_midiTimeDiv;
-
- if (duration == 0)
- duration = 1;
-
- if (!g_exactGateTime && duration < 96)
- duration = g_noteDurationLUT[duration];
-
- event.param2 = duration;
- }
- }
-}
-
-std::unique_ptr<std::vector<Event>> InsertTimingEvents(std::vector<Event>& inEvents)
-{
- std::unique_ptr<std::vector<Event>> outEvents(new std::vector<Event>());
-
- Event timingEvent = {};
- timingEvent.time = 0;
- timingEvent.type = EventType::TimeSignature;
- timingEvent.param2 = 96 * g_clocksPerBeat;
-
- for (const Event& event : inEvents)
- {
- while (EventCompare(timingEvent, event))
- {
- outEvents->push_back(timingEvent);
- timingEvent.time += timingEvent.param2;
- }
-
- if (event.type == EventType::TimeSignature)
- {
- if (g_agbTrack == 1 && event.param2 != timingEvent.param2)
- {
- Event originalTimingEvent = event;
- originalTimingEvent.type = EventType::OriginalTimeSignature;
- outEvents->push_back(originalTimingEvent);
- }
- timingEvent.param2 = event.param2;
- timingEvent.time = event.time + timingEvent.param2;
- }
-
- outEvents->push_back(event);
- }
-
- return outEvents;
-}
-
-std::unique_ptr<std::vector<Event>> SplitTime(std::vector<Event>& inEvents)
-{
- std::unique_ptr<std::vector<Event>> outEvents(new std::vector<Event>());
-
- std::int32_t time = 0;
-
- for (const Event& event : inEvents)
- {
- std::int32_t diff = event.time - time;
-
- if (diff > 96)
- {
- int wholeNoteCount = (diff - 1) / 96;
- diff -= 96 * wholeNoteCount;
-
- for (int i = 0; i < wholeNoteCount; i++)
- {
- time += 96;
- Event timeSplitEvent = {};
- timeSplitEvent.time = time;
- timeSplitEvent.type = EventType::TimeSplit;
- outEvents->push_back(timeSplitEvent);
- }
- }
-
- std::int32_t lutValue = g_noteDurationLUT[diff];
-
- if (lutValue != diff)
- {
- Event timeSplitEvent = {};
- timeSplitEvent.time = time + lutValue;
- timeSplitEvent.type = EventType::TimeSplit;
- outEvents->push_back(timeSplitEvent);
- }
-
- time = event.time;
-
- outEvents->push_back(event);
- }
-
- return outEvents;
-}
-
-std::unique_ptr<std::vector<Event>> CreateTies(std::vector<Event>& inEvents)
-{
- std::unique_ptr<std::vector<Event>> outEvents(new std::vector<Event>());
-
- for (const Event& event : inEvents)
- {
- if (event.type == EventType::Note && event.param2 > 96)
- {
- Event tieEvent = event;
- tieEvent.param2 = -1;
- outEvents->push_back(tieEvent);
-
- Event eotEvent = {};
- eotEvent.time = event.time + event.param2;
- eotEvent.type = EventType::EndOfTie;
- eotEvent.note = event.note;
- outEvents->push_back(eotEvent);
- }
- else
- {
- outEvents->push_back(event);
- }
- }
-
- return outEvents;
-}
-
-void CalculateWaits(std::vector<Event>& events)
-{
- g_initialWait = events[0].time;
- int wholeNoteCount = 0;
-
- for (unsigned i = 0; i < events.size() && events[i].type != EventType::EndOfTrack; i++)
- {
- events[i].time = events[i + 1].time - events[i].time;
-
- if (events[i].type == EventType::TimeSignature)
- {
- events[i].type = EventType::WholeNoteMark;
- events[i].param2 = wholeNoteCount++;
- }
- }
-}
-
-int CalculateCompressionScore(std::vector<Event>& events, int index)
-{
- int score = 0;
- std::uint8_t lastParam1 = events[index].param1;
- std::uint8_t lastVelocity = 0x80u;
- EventType lastType = events[index].type;
- std::int32_t lastDuration = 0x80000000;
- std::uint8_t lastNote = 0x40u;
-
- if (events[index].time > 0)
- score++;
-
- for (int i = index + 1; !IsPatternBoundary(events[i].type); i++)
- {
- if (events[i].type == EventType::Note)
- {
- int val = 0;
-
- if (events[i].note != lastNote)
- {
- val++;
- lastNote = events[i].note;
- }
-
- if (events[i].param1 != lastVelocity)
- {
- val++;
- lastVelocity = events[i].param1;
- }
-
- std::int32_t duration = events[i].param2;
-
- if (g_noteDurationLUT[duration] != lastDuration)
- {
- val++;
- lastDuration = g_noteDurationLUT[duration];
- }
-
- if (duration != lastDuration)
- val++;
-
- if (val == 0)
- val = 1;
-
- score += val;
- }
- else
- {
- lastDuration = 0x80000000;
-
- if (events[i].type == lastType)
- {
- if ((lastType != EventType::Controller && (int)lastType != 0x25 && lastType != EventType::EndOfTie) || events[i].param1 == lastParam1)
- {
- score++;
- }
- else
- {
- score += 2;
- }
- }
- else
- {
- score += 2;
- }
- }
-
- lastParam1 = events[i].param1;
- lastType = events[i].type;
-
- if (events[i].time)
- score++;
- }
-
- return score;
-}
-
-bool IsCompressionMatch(std::vector<Event>& events, int index1, int index2)
-{
- if (events[index1].type != events[index2].type ||
- events[index1].note != events[index2].note ||
- events[index1].param1 != events[index2].param1 ||
- events[index1].time != events[index2].time)
- return false;
-
- index1++;
- index2++;
-
- do
- {
- if (events[index1] != events[index2])
- return false;
-
- index1++;
- index2++;
- } while (!IsPatternBoundary(events[index1].type));
-
- return IsPatternBoundary(events[index2].type);
-}
-
-void CompressWholeNote(std::vector<Event>& events, int index)
-{
- for (int j = index + 1; events[j].type != EventType::EndOfTrack; j++)
- {
- while (events[j].type != EventType::WholeNoteMark)
- {
- j++;
-
- if (events[j].type == EventType::EndOfTrack)
- return;
- }
-
- if (IsCompressionMatch(events, index, j))
- {
- events[j].type = EventType::Pattern;
- events[j].param2 = events[index].param2 & 0x7FFFFFFF;
- events[index].param2 |= 0x80000000;
- }
- }
-}
-
-void Compress(std::vector<Event>& events)
-{
- for (int i = 0; events[i].type != EventType::EndOfTrack; i++)
- {
- while (events[i].type != EventType::WholeNoteMark)
- {
- i++;
-
- if (events[i].type == EventType::EndOfTrack)
- return;
- }
-
- if (CalculateCompressionScore(events, i) >= 6)
- {
- CompressWholeNote(events, i);
- }
- }
-}
-
-void ReadMidiTracks()
-{
- long trackHeaderStart = 14;
-
- ReadMidiTrackHeader(trackHeaderStart);
- ReadSeqEvents();
-
- g_agbTrack = 1;
-
- for (int midiTrack = 0; midiTrack < g_midiTrackCount; midiTrack++)
- {
- trackHeaderStart += ReadMidiTrackHeader(trackHeaderStart);
-
- for (g_midiChan = 0; g_midiChan < 16; g_midiChan++)
- {
- ReadTrackEvents();
-
- if (s_minNote != 0xFF)
- {
-#ifdef DEBUG
- printf("Track%d = Midi-Ch.%d\n", g_agbTrack, g_midiChan + 1);
-#endif
-
- std::unique_ptr<std::vector<Event>> events(MergeEvents());
-
- // We don't need TEMPO in anything but track 1.
- if (g_agbTrack == 1)
- {
- auto it = std::remove_if(s_seqEvents.begin(), s_seqEvents.end(), [](const Event& event) { return event.type == EventType::Tempo; });
- s_seqEvents.erase(it, s_seqEvents.end());
- }
-
- ConvertTimes(*events);
- events = InsertTimingEvents(*events);
- events = CreateTies(*events);
- std::stable_sort(events->begin(), events->end(), EventCompare);
- events = SplitTime(*events);
- CalculateWaits(*events);
-
- if (g_compressionEnabled)
- Compress(*events);
-
- PrintAgbTrack(*events);
-
- g_agbTrack++;
- }
- }
- }
-}
+// Copyright(c) 2016 YamaArashi
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#include <cstdio>
+#include <cassert>
+#include <string>
+#include <vector>
+#include <algorithm>
+#include <memory>
+#include "midi.h"
+#include "main.h"
+#include "error.h"
+#include "agb.h"
+#include "tables.h"
+
+enum class MidiEventCategory
+{
+ Control,
+ SysEx,
+ Meta,
+ Invalid,
+};
+
+MidiFormat g_midiFormat;
+std::int_fast32_t g_midiTrackCount;
+std::int16_t g_midiTimeDiv;
+
+int g_midiChan;
+std::int32_t g_initialWait;
+
+static long s_trackDataStart;
+static std::vector<Event> s_seqEvents;
+static std::vector<Event> s_trackEvents;
+static std::int32_t s_absoluteTime;
+static int s_blockCount = 0;
+static int s_minNote;
+static int s_maxNote;
+static int s_runningStatus;
+
+void Seek(long offset)
+{
+ if (std::fseek(g_inputFile, offset, SEEK_SET) != 0)
+ RaiseError("failed to seek to %l", offset);
+}
+
+void Skip(long offset)
+{
+ if (std::fseek(g_inputFile, offset, SEEK_CUR) != 0)
+ RaiseError("failed to skip %l bytes", offset);
+}
+
+std::string ReadSignature()
+{
+ char signature[4];
+
+ if (std::fread(signature, 4, 1, g_inputFile) != 1)
+ RaiseError("failed to read signature");
+
+ return std::string(signature, 4);
+}
+
+std::uint32_t ReadInt8()
+{
+ int c = std::fgetc(g_inputFile);
+
+ if (c < 0)
+ RaiseError("unexpected EOF");
+
+ return c;
+}
+
+std::uint32_t ReadInt16()
+{
+ std::uint32_t val = 0;
+ val |= ReadInt8() << 8;
+ val |= ReadInt8();
+ return val;
+}
+
+std::uint32_t ReadInt24()
+{
+ std::uint32_t val = 0;
+ val |= ReadInt8() << 16;
+ val |= ReadInt8() << 8;
+ val |= ReadInt8();
+ return val;
+}
+
+std::uint32_t ReadInt32()
+{
+ std::uint32_t val = 0;
+ val |= ReadInt8() << 24;
+ val |= ReadInt8() << 16;
+ val |= ReadInt8() << 8;
+ val |= ReadInt8();
+ return val;
+}
+
+std::uint32_t ReadVLQ()
+{
+ std::uint32_t val = 0;
+ std::uint32_t c;
+
+ do
+ {
+ c = ReadInt8();
+ val <<= 7;
+ val |= (c & 0x7F);
+ } while (c & 0x80);
+
+ return val;
+}
+
+void ReadMidiFileHeader()
+{
+ Seek(0);
+
+ if (ReadSignature() != "MThd")
+ RaiseError("MIDI file header signature didn't match \"MThd\"");
+
+ std::uint32_t headerLength = ReadInt32();
+
+ if (headerLength != 6)
+ RaiseError("MIDI file header length isn't 6");
+
+ std::uint16_t midiFormat = ReadInt16();
+
+ if (midiFormat >= 2)
+ RaiseError("unsupported MIDI format (%u)", midiFormat);
+
+ g_midiFormat = (MidiFormat)midiFormat;
+ g_midiTrackCount = ReadInt16();
+ g_midiTimeDiv = ReadInt16();
+
+ if (g_midiTimeDiv < 0)
+ RaiseError("unsupported MIDI time division (%d)", g_midiTimeDiv);
+}
+
+long ReadMidiTrackHeader(long offset)
+{
+ Seek(offset);
+
+ if (ReadSignature() != "MTrk")
+ RaiseError("MIDI track header signature didn't match \"MTrk\"");
+
+ long size = ReadInt32();
+
+ s_trackDataStart = std::ftell(g_inputFile);
+
+ return size + 8;
+}
+
+void StartTrack()
+{
+ Seek(s_trackDataStart);
+ s_absoluteTime = 0;
+ s_runningStatus = 0;
+}
+
+void SkipEventData()
+{
+ Skip(ReadVLQ());
+}
+
+void DetermineEventCategory(MidiEventCategory& category, int& typeChan, int& size)
+{
+ typeChan = ReadInt8();
+
+ if (typeChan < 0x80)
+ {
+ // If data byte was found, use the running status.
+ ungetc(typeChan, g_inputFile);
+ typeChan = s_runningStatus;
+ }
+
+ if (typeChan == 0xFF)
+ {
+ category = MidiEventCategory::Meta;
+ size = 0;
+ s_runningStatus = 0;
+ }
+ else if (typeChan >= 0xF0)
+ {
+ category = MidiEventCategory::SysEx;
+ size = 0;
+ s_runningStatus = 0;
+ }
+ else if (typeChan >= 0x80)
+ {
+ category = MidiEventCategory::Control;
+
+ switch (typeChan >> 4)
+ {
+ case 0xC:
+ case 0xD:
+ size = 1;
+ break;
+ default:
+ size = 2;
+ break;
+ }
+ s_runningStatus = typeChan;
+ }
+ else
+ {
+ category = MidiEventCategory::Invalid;
+ }
+}
+
+void MakeBlockEvent(Event& event, EventType type)
+{
+ event.type = type;
+ event.param1 = s_blockCount++;
+ event.param2 = 0;
+}
+
+std::string ReadEventText()
+{
+ char buffer[2];
+ std::uint32_t length = ReadVLQ();
+
+ if (length <= 2)
+ {
+ if (fread(buffer, length, 1, g_inputFile) != 1)
+ RaiseError("failed to read event text");
+ }
+ else
+ {
+ Skip(length);
+ length = 0;
+ }
+
+ return std::string(buffer, length);
+}
+
+bool ReadSeqEvent(Event& event)
+{
+ s_absoluteTime += ReadVLQ();
+ event.time = s_absoluteTime;
+
+ MidiEventCategory category;
+ int typeChan;
+ int size;
+
+ DetermineEventCategory(category, typeChan, size);
+
+ if (category == MidiEventCategory::Control)
+ {
+ Skip(size);
+ return false;
+ }
+
+ if (category == MidiEventCategory::SysEx)
+ {
+ SkipEventData();
+ return false;
+ }
+
+ if (category == MidiEventCategory::Invalid)
+ RaiseError("invalid event");
+
+ // meta event
+ int metaEventType = ReadInt8();
+
+ if (metaEventType >= 1 && metaEventType <= 7)
+ {
+ // text event
+ std::string text = ReadEventText();
+
+ if (text == "[")
+ MakeBlockEvent(event, EventType::LoopBegin);
+ else if (text == "][")
+ MakeBlockEvent(event, EventType::LoopEndBegin);
+ else if (text == "]")
+ MakeBlockEvent(event, EventType::LoopEnd);
+ else if (text == ":")
+ MakeBlockEvent(event, EventType::Label);
+ else
+ return false;
+ }
+ else
+ {
+ switch (metaEventType)
+ {
+ case 0x2F: // end of track
+ SkipEventData();
+ event.type = EventType::EndOfTrack;
+ event.param1 = 0;
+ event.param2 = 0;
+ break;
+ case 0x51: // tempo
+ if (ReadVLQ() != 3)
+ RaiseError("invalid tempo size");
+
+ event.type = EventType::Tempo;
+ event.param1 = 0;
+ event.param2 = ReadInt24();
+ break;
+ case 0x58: // time signature
+ {
+ if (ReadVLQ() != 4)
+ RaiseError("invalid time signature size");
+
+ int numerator = ReadInt8();
+ int denominatorExponent = ReadInt8();
+
+ if (denominatorExponent >= 16)
+ RaiseError("invalid time signature denominator");
+
+ Skip(2); // ignore other values
+
+ int clockTicks = 96 * numerator * g_clocksPerBeat;
+ int denominator = 1 << denominatorExponent;
+ int timeSig = clockTicks / denominator;
+
+ if (timeSig <= 0 || timeSig >= 0x10000)
+ RaiseError("invalid time signature");
+
+ event.type = EventType::TimeSignature;
+ event.param1 = 0;
+ event.param2 = timeSig;
+ break;
+ }
+ default:
+ SkipEventData();
+ return false;
+ }
+ }
+
+ return true;
+}
+
+void ReadSeqEvents()
+{
+ StartTrack();
+
+ for (;;)
+ {
+ Event event = {};
+
+ if (ReadSeqEvent(event))
+ {
+ s_seqEvents.push_back(event);
+
+ if (event.type == EventType::EndOfTrack)
+ return;
+ }
+ }
+}
+
+bool CheckNoteEnd(Event& event)
+{
+ event.param2 += ReadVLQ();
+
+ MidiEventCategory category;
+ int typeChan;
+ int size;
+
+ DetermineEventCategory(category, typeChan, size);
+
+ if (category == MidiEventCategory::Control)
+ {
+ int chan = typeChan & 0xF;
+
+ if (chan != g_midiChan)
+ {
+ Skip(size);
+ return false;
+ }
+
+ switch (typeChan & 0xF0)
+ {
+ case 0x80: // note off
+ {
+ int note = ReadInt8();
+ ReadInt8(); // ignore velocity
+ if (note == event.note)
+ return true;
+ break;
+ }
+ case 0x90: // note on
+ {
+ int note = ReadInt8();
+ int velocity = ReadInt8();
+ if (velocity == 0 && note == event.note)
+ return true;
+ break;
+ }
+ default:
+ Skip(size);
+ break;
+ }
+
+ return false;
+ }
+
+ if (category == MidiEventCategory::SysEx)
+ {
+ SkipEventData();
+ return false;
+ }
+
+ if (category == MidiEventCategory::Meta)
+ {
+ int metaEventType = ReadInt8();
+ SkipEventData();
+
+ if (metaEventType == 0x2F)
+ RaiseError("note doesn't end");
+
+ return false;
+ }
+
+ RaiseError("invalid event");
+}
+
+void FindNoteEnd(Event& event)
+{
+ // Save the current file position and running status
+ // which get modified by CheckNoteEnd.
+ long startPos = ftell(g_inputFile);
+ int savedRunningStatus = s_runningStatus;
+
+ event.param2 = 0;
+
+ while (!CheckNoteEnd(event))
+ ;
+
+ Seek(startPos);
+ s_runningStatus = savedRunningStatus;
+}
+
+bool ReadTrackEvent(Event& event)
+{
+ s_absoluteTime += ReadVLQ();
+ event.time = s_absoluteTime;
+
+ MidiEventCategory category;
+ int typeChan;
+ int size;
+
+ DetermineEventCategory(category, typeChan, size);
+
+ if (category == MidiEventCategory::Control)
+ {
+ int chan = typeChan & 0xF;
+
+ if (chan != g_midiChan)
+ {
+ Skip(size);
+ return false;
+ }
+
+ switch (typeChan & 0xF0)
+ {
+ case 0x90: // note on
+ {
+ int note = ReadInt8();
+ int velocity = ReadInt8();
+
+ if (velocity != 0)
+ {
+ event.type = EventType::Note;
+ event.note = note;
+ event.param1 = velocity;
+ FindNoteEnd(event);
+ if (event.param2 > 0)
+ {
+ if (note < s_minNote)
+ s_minNote = note;
+ if (note > s_maxNote)
+ s_maxNote = note;
+ }
+ }
+ break;
+ }
+ case 0xB0: // controller event
+ event.type = EventType::Controller;
+ event.param1 = ReadInt8(); // controller index
+ event.param2 = ReadInt8(); // value
+ break;
+ case 0xC0: // instrument change
+ event.type = EventType::InstrumentChange;
+ event.param1 = ReadInt8(); // instrument
+ event.param2 = 0;
+ break;
+ case 0xE0: // pitch bend
+ event.type = EventType::PitchBend;
+ event.param1 = ReadInt8();
+ event.param2 = ReadInt8();
+ break;
+ default:
+ Skip(size);
+ return false;
+ }
+
+ return true;
+ }
+
+ if (category == MidiEventCategory::SysEx)
+ {
+ SkipEventData();
+ return false;
+ }
+
+ if (category == MidiEventCategory::Meta)
+ {
+ int metaEventType = ReadInt8();
+ SkipEventData();
+
+ if (metaEventType == 0x2F)
+ {
+ event.type = EventType::EndOfTrack;
+ event.param1 = 0;
+ event.param2 = 0;
+ return true;
+ }
+
+ return false;
+ }
+
+ RaiseError("invalid event");
+}
+
+void ReadTrackEvents()
+{
+ StartTrack();
+
+ s_trackEvents.clear();
+
+ s_minNote = 0xFF;
+ s_maxNote = 0;
+
+ for (;;)
+ {
+ Event event = {};
+
+ if (ReadTrackEvent(event))
+ {
+ s_trackEvents.push_back(event);
+
+ if (event.type == EventType::EndOfTrack)
+ return;
+ }
+ }
+}
+
+bool EventCompare(const Event& event1, const Event& event2)
+{
+ if (event1.time < event2.time)
+ return true;
+
+ if (event1.time > event2.time)
+ return false;
+
+ unsigned event1Type = (unsigned)event1.type;
+ unsigned event2Type = (unsigned)event2.type;
+
+ if (event1.type == EventType::Note)
+ event1Type += event1.note;
+
+ if (event2.type == EventType::Note)
+ event2Type += event2.note;
+
+ if (event1Type < event2Type)
+ return true;
+
+ if (event1Type > event2Type)
+ return false;
+
+ if (event1.type == EventType::EndOfTie)
+ {
+ if (event1.note < event2.note)
+ return true;
+
+ if (event1.note > event2.note)
+ return false;
+ }
+
+ return false;
+}
+
+std::unique_ptr<std::vector<Event>> MergeEvents()
+{
+ std::unique_ptr<std::vector<Event>> events(new std::vector<Event>());
+
+ unsigned trackEventPos = 0;
+ unsigned seqEventPos = 0;
+
+ while (s_trackEvents[trackEventPos].type != EventType::EndOfTrack
+ && s_seqEvents[seqEventPos].type != EventType::EndOfTrack)
+ {
+ if (EventCompare(s_trackEvents[trackEventPos], s_seqEvents[seqEventPos]))
+ events->push_back(s_trackEvents[trackEventPos++]);
+ else
+ events->push_back(s_seqEvents[seqEventPos++]);
+ }
+
+ while (s_trackEvents[trackEventPos].type != EventType::EndOfTrack)
+ events->push_back(s_trackEvents[trackEventPos++]);
+
+ while (s_seqEvents[seqEventPos].type != EventType::EndOfTrack)
+ events->push_back(s_seqEvents[seqEventPos++]);
+
+ // Push the EndOfTrack event with the larger time.
+ if (EventCompare(s_trackEvents[trackEventPos], s_seqEvents[seqEventPos]))
+ events->push_back(s_seqEvents[seqEventPos]);
+ else
+ events->push_back(s_trackEvents[trackEventPos]);
+
+ return events;
+}
+
+void ConvertTimes(std::vector<Event>& events)
+{
+ for (Event& event : events)
+ {
+ event.time = (24 * g_clocksPerBeat * event.time) / g_midiTimeDiv;
+
+ if (event.type == EventType::Note)
+ {
+ event.param1 = g_noteVelocityLUT[event.param1];
+
+ std::uint32_t duration = (24 * g_clocksPerBeat * event.param2) / g_midiTimeDiv;
+
+ if (duration == 0)
+ duration = 1;
+
+ if (!g_exactGateTime && duration < 96)
+ duration = g_noteDurationLUT[duration];
+
+ event.param2 = duration;
+ }
+ }
+}
+
+std::unique_ptr<std::vector<Event>> InsertTimingEvents(std::vector<Event>& inEvents)
+{
+ std::unique_ptr<std::vector<Event>> outEvents(new std::vector<Event>());
+
+ Event timingEvent = {};
+ timingEvent.time = 0;
+ timingEvent.type = EventType::TimeSignature;
+ timingEvent.param2 = 96 * g_clocksPerBeat;
+
+ for (const Event& event : inEvents)
+ {
+ while (EventCompare(timingEvent, event))
+ {
+ outEvents->push_back(timingEvent);
+ timingEvent.time += timingEvent.param2;
+ }
+
+ if (event.type == EventType::TimeSignature)
+ {
+ if (g_agbTrack == 1 && event.param2 != timingEvent.param2)
+ {
+ Event originalTimingEvent = event;
+ originalTimingEvent.type = EventType::OriginalTimeSignature;
+ outEvents->push_back(originalTimingEvent);
+ }
+ timingEvent.param2 = event.param2;
+ timingEvent.time = event.time + timingEvent.param2;
+ }
+
+ outEvents->push_back(event);
+ }
+
+ return outEvents;
+}
+
+std::unique_ptr<std::vector<Event>> SplitTime(std::vector<Event>& inEvents)
+{
+ std::unique_ptr<std::vector<Event>> outEvents(new std::vector<Event>());
+
+ std::int32_t time = 0;
+
+ for (const Event& event : inEvents)
+ {
+ std::int32_t diff = event.time - time;
+
+ if (diff > 96)
+ {
+ int wholeNoteCount = (diff - 1) / 96;
+ diff -= 96 * wholeNoteCount;
+
+ for (int i = 0; i < wholeNoteCount; i++)
+ {
+ time += 96;
+ Event timeSplitEvent = {};
+ timeSplitEvent.time = time;
+ timeSplitEvent.type = EventType::TimeSplit;
+ outEvents->push_back(timeSplitEvent);
+ }
+ }
+
+ std::int32_t lutValue = g_noteDurationLUT[diff];
+
+ if (lutValue != diff)
+ {
+ Event timeSplitEvent = {};
+ timeSplitEvent.time = time + lutValue;
+ timeSplitEvent.type = EventType::TimeSplit;
+ outEvents->push_back(timeSplitEvent);
+ }
+
+ time = event.time;
+
+ outEvents->push_back(event);
+ }
+
+ return outEvents;
+}
+
+std::unique_ptr<std::vector<Event>> CreateTies(std::vector<Event>& inEvents)
+{
+ std::unique_ptr<std::vector<Event>> outEvents(new std::vector<Event>());
+
+ for (const Event& event : inEvents)
+ {
+ if (event.type == EventType::Note && event.param2 > 96)
+ {
+ Event tieEvent = event;
+ tieEvent.param2 = -1;
+ outEvents->push_back(tieEvent);
+
+ Event eotEvent = {};
+ eotEvent.time = event.time + event.param2;
+ eotEvent.type = EventType::EndOfTie;
+ eotEvent.note = event.note;
+ outEvents->push_back(eotEvent);
+ }
+ else
+ {
+ outEvents->push_back(event);
+ }
+ }
+
+ return outEvents;
+}
+
+void CalculateWaits(std::vector<Event>& events)
+{
+ g_initialWait = events[0].time;
+ int wholeNoteCount = 0;
+
+ for (unsigned i = 0; i < events.size() && events[i].type != EventType::EndOfTrack; i++)
+ {
+ events[i].time = events[i + 1].time - events[i].time;
+
+ if (events[i].type == EventType::TimeSignature)
+ {
+ events[i].type = EventType::WholeNoteMark;
+ events[i].param2 = wholeNoteCount++;
+ }
+ }
+}
+
+int CalculateCompressionScore(std::vector<Event>& events, int index)
+{
+ int score = 0;
+ std::uint8_t lastParam1 = events[index].param1;
+ std::uint8_t lastVelocity = 0x80u;
+ EventType lastType = events[index].type;
+ std::int32_t lastDuration = 0x80000000;
+ std::uint8_t lastNote = 0x40u;
+
+ if (events[index].time > 0)
+ score++;
+
+ for (int i = index + 1; !IsPatternBoundary(events[i].type); i++)
+ {
+ if (events[i].type == EventType::Note)
+ {
+ int val = 0;
+
+ if (events[i].note != lastNote)
+ {
+ val++;
+ lastNote = events[i].note;
+ }
+
+ if (events[i].param1 != lastVelocity)
+ {
+ val++;
+ lastVelocity = events[i].param1;
+ }
+
+ std::int32_t duration = events[i].param2;
+
+ if (g_noteDurationLUT[duration] != lastDuration)
+ {
+ val++;
+ lastDuration = g_noteDurationLUT[duration];
+ }
+
+ if (duration != lastDuration)
+ val++;
+
+ if (val == 0)
+ val = 1;
+
+ score += val;
+ }
+ else
+ {
+ lastDuration = 0x80000000;
+
+ if (events[i].type == lastType)
+ {
+ if ((lastType != EventType::Controller && (int)lastType != 0x25 && lastType != EventType::EndOfTie) || events[i].param1 == lastParam1)
+ {
+ score++;
+ }
+ else
+ {
+ score += 2;
+ }
+ }
+ else
+ {
+ score += 2;
+ }
+ }
+
+ lastParam1 = events[i].param1;
+ lastType = events[i].type;
+
+ if (events[i].time)
+ score++;
+ }
+
+ return score;
+}
+
+bool IsCompressionMatch(std::vector<Event>& events, int index1, int index2)
+{
+ if (events[index1].type != events[index2].type ||
+ events[index1].note != events[index2].note ||
+ events[index1].param1 != events[index2].param1 ||
+ events[index1].time != events[index2].time)
+ return false;
+
+ index1++;
+ index2++;
+
+ do
+ {
+ if (events[index1] != events[index2])
+ return false;
+
+ index1++;
+ index2++;
+ } while (!IsPatternBoundary(events[index1].type));
+
+ return IsPatternBoundary(events[index2].type);
+}
+
+void CompressWholeNote(std::vector<Event>& events, int index)
+{
+ for (int j = index + 1; events[j].type != EventType::EndOfTrack; j++)
+ {
+ while (events[j].type != EventType::WholeNoteMark)
+ {
+ j++;
+
+ if (events[j].type == EventType::EndOfTrack)
+ return;
+ }
+
+ if (IsCompressionMatch(events, index, j))
+ {
+ events[j].type = EventType::Pattern;
+ events[j].param2 = events[index].param2 & 0x7FFFFFFF;
+ events[index].param2 |= 0x80000000;
+ }
+ }
+}
+
+void Compress(std::vector<Event>& events)
+{
+ for (int i = 0; events[i].type != EventType::EndOfTrack; i++)
+ {
+ while (events[i].type != EventType::WholeNoteMark)
+ {
+ i++;
+
+ if (events[i].type == EventType::EndOfTrack)
+ return;
+ }
+
+ if (CalculateCompressionScore(events, i) >= 6)
+ {
+ CompressWholeNote(events, i);
+ }
+ }
+}
+
+void ReadMidiTracks()
+{
+ long trackHeaderStart = 14;
+
+ ReadMidiTrackHeader(trackHeaderStart);
+ ReadSeqEvents();
+
+ g_agbTrack = 1;
+
+ for (int midiTrack = 0; midiTrack < g_midiTrackCount; midiTrack++)
+ {
+ trackHeaderStart += ReadMidiTrackHeader(trackHeaderStart);
+
+ for (g_midiChan = 0; g_midiChan < 16; g_midiChan++)
+ {
+ ReadTrackEvents();
+
+ if (s_minNote != 0xFF)
+ {
+#ifdef DEBUG
+ printf("Track%d = Midi-Ch.%d\n", g_agbTrack, g_midiChan + 1);
+#endif
+
+ std::unique_ptr<std::vector<Event>> events(MergeEvents());
+
+ // We don't need TEMPO in anything but track 1.
+ if (g_agbTrack == 1)
+ {
+ auto it = std::remove_if(s_seqEvents.begin(), s_seqEvents.end(), [](const Event& event) { return event.type == EventType::Tempo; });
+ s_seqEvents.erase(it, s_seqEvents.end());
+ }
+
+ ConvertTimes(*events);
+ events = InsertTimingEvents(*events);
+ events = CreateTies(*events);
+ std::stable_sort(events->begin(), events->end(), EventCompare);
+ events = SplitTime(*events);
+ CalculateWaits(*events);
+
+ if (g_compressionEnabled)
+ Compress(*events);
+
+ PrintAgbTrack(*events);
+
+ g_agbTrack++;
+ }
+ }
+ }
+}
diff --git a/tools/mid2agb/tables.cpp b/tools/mid2agb/tables.cpp
index 025dcd2..f254664 100644
--- a/tools/mid2agb/tables.cpp
+++ b/tools/mid2agb/tables.cpp
@@ -1,286 +1,286 @@
-// Copyright(c) 2016 YamaArashi
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#include "tables.h"
-
-const int g_noteDurationLUT[] =
-{
- 0, // 0
- 1, // 1
- 2, // 2
- 3, // 3
- 4, // 4
- 5, // 5
- 6, // 6
- 7, // 7
- 8, // 8
- 9, // 9
- 10, // 10
- 11, // 11
- 12, // 12
- 13, // 13
- 14, // 14
- 15, // 15
- 16, // 16
- 17, // 17
- 18, // 18
- 19, // 19
- 20, // 20
- 21, // 21
- 22, // 22
- 23, // 23
- 24, // 24
- 24, // 25
- 24, // 26
- 24, // 27
- 28, // 28
- 28, // 29
- 30, // 30
- 30, // 31
- 32, // 32
- 32, // 33
- 32, // 34
- 32, // 35
- 36, // 36
- 36, // 37
- 36, // 38
- 36, // 39
- 40, // 40
- 40, // 41
- 42, // 42
- 42, // 43
- 44, // 44
- 44, // 45
- 44, // 46
- 44, // 47
- 48, // 48
- 48, // 49
- 48, // 50
- 48, // 51
- 52, // 52
- 52, // 53
- 54, // 54
- 54, // 55
- 56, // 56
- 56, // 57
- 56, // 58
- 56, // 59
- 60, // 60
- 60, // 61
- 60, // 62
- 60, // 63
- 64, // 64
- 64, // 65
- 66, // 66
- 66, // 67
- 68, // 68
- 68, // 69
- 68, // 70
- 68, // 71
- 72, // 72
- 72, // 73
- 72, // 74
- 72, // 75
- 76, // 76
- 76, // 77
- 78, // 78
- 78, // 79
- 80, // 80
- 80, // 81
- 80, // 82
- 80, // 83
- 84, // 84
- 84, // 85
- 84, // 86
- 84, // 87
- 88, // 88
- 88, // 89
- 90, // 90
- 90, // 91
- 92, // 92
- 92, // 93
- 92, // 94
- 92, // 95
- 96, // 96
-};
-
-const int g_noteVelocityLUT[] =
-{
- 0, // 0
- 4, // 1
- 4, // 2
- 4, // 3
- 4, // 4
- 8, // 5
- 8, // 6
- 8, // 7
- 8, // 8
- 12, // 9
- 12, // 10
- 12, // 11
- 12, // 12
- 16, // 13
- 16, // 14
- 16, // 15
- 16, // 16
- 20, // 17
- 20, // 18
- 20, // 19
- 20, // 20
- 24, // 21
- 24, // 22
- 24, // 23
- 24, // 24
- 28, // 25
- 28, // 26
- 28, // 27
- 28, // 28
- 32, // 29
- 32, // 30
- 32, // 31
- 32, // 32
- 36, // 33
- 36, // 34
- 36, // 35
- 36, // 36
- 40, // 37
- 40, // 38
- 40, // 39
- 40, // 40
- 44, // 41
- 44, // 42
- 44, // 43
- 44, // 44
- 48, // 45
- 48, // 46
- 48, // 47
- 48, // 48
- 52, // 49
- 52, // 50
- 52, // 51
- 52, // 52
- 56, // 53
- 56, // 54
- 56, // 55
- 56, // 56
- 60, // 57
- 60, // 58
- 60, // 59
- 60, // 60
- 64, // 61
- 64, // 62
- 64, // 63
- 64, // 64
- 68, // 65
- 68, // 66
- 68, // 67
- 68, // 68
- 72, // 69
- 72, // 70
- 72, // 71
- 72, // 72
- 76, // 73
- 76, // 74
- 76, // 75
- 76, // 76
- 80, // 77
- 80, // 78
- 80, // 79
- 80, // 80
- 84, // 81
- 84, // 82
- 84, // 83
- 84, // 84
- 88, // 85
- 88, // 86
- 88, // 87
- 88, // 88
- 92, // 89
- 92, // 90
- 92, // 91
- 92, // 92
- 96, // 93
- 96, // 94
- 96, // 95
- 96, // 96
- 100, // 97
- 100, // 98
- 100, // 99
- 100, // 100
- 104, // 101
- 104, // 102
- 104, // 103
- 104, // 104
- 108, // 105
- 108, // 106
- 108, // 107
- 108, // 108
- 112, // 109
- 112, // 110
- 112, // 111
- 112, // 112
- 116, // 113
- 116, // 114
- 116, // 115
- 116, // 116
- 120, // 117
- 120, // 118
- 120, // 119
- 120, // 120
- 124, // 121
- 124, // 122
- 124, // 123
- 124, // 124
- 127, // 125
- 127, // 126
- 127, // 127
-};
-
-const char* g_noteTable[] =
-{
- "Cn%01u ",
- "Cs%01u ",
- "Dn%01u ",
- "Ds%01u ",
- "En%01u ",
- "Fn%01u ",
- "Fs%01u ",
- "Gn%01u ",
- "Gs%01u ",
- "An%01u ",
- "As%01u ",
- "Bn%01u ",
-};
-
-const char* g_minusNoteTable[] =
-{
- "CnM%01u",
- "CsM%01u",
- "DnM%01u",
- "DsM%01u",
- "EnM%01u",
- "FnM%01u",
- "FsM%01u",
- "GnM%01u",
- "GsM%01u",
- "AnM%01u",
- "AsM%01u",
- "BnM%01u",
-};
+// Copyright(c) 2016 YamaArashi
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#include "tables.h"
+
+const int g_noteDurationLUT[] =
+{
+ 0, // 0
+ 1, // 1
+ 2, // 2
+ 3, // 3
+ 4, // 4
+ 5, // 5
+ 6, // 6
+ 7, // 7
+ 8, // 8
+ 9, // 9
+ 10, // 10
+ 11, // 11
+ 12, // 12
+ 13, // 13
+ 14, // 14
+ 15, // 15
+ 16, // 16
+ 17, // 17
+ 18, // 18
+ 19, // 19
+ 20, // 20
+ 21, // 21
+ 22, // 22
+ 23, // 23
+ 24, // 24
+ 24, // 25
+ 24, // 26
+ 24, // 27
+ 28, // 28
+ 28, // 29
+ 30, // 30
+ 30, // 31
+ 32, // 32
+ 32, // 33
+ 32, // 34
+ 32, // 35
+ 36, // 36
+ 36, // 37
+ 36, // 38
+ 36, // 39
+ 40, // 40
+ 40, // 41
+ 42, // 42
+ 42, // 43
+ 44, // 44
+ 44, // 45
+ 44, // 46
+ 44, // 47
+ 48, // 48
+ 48, // 49
+ 48, // 50
+ 48, // 51
+ 52, // 52
+ 52, // 53
+ 54, // 54
+ 54, // 55
+ 56, // 56
+ 56, // 57
+ 56, // 58
+ 56, // 59
+ 60, // 60
+ 60, // 61
+ 60, // 62
+ 60, // 63
+ 64, // 64
+ 64, // 65
+ 66, // 66
+ 66, // 67
+ 68, // 68
+ 68, // 69
+ 68, // 70
+ 68, // 71
+ 72, // 72
+ 72, // 73
+ 72, // 74
+ 72, // 75
+ 76, // 76
+ 76, // 77
+ 78, // 78
+ 78, // 79
+ 80, // 80
+ 80, // 81
+ 80, // 82
+ 80, // 83
+ 84, // 84
+ 84, // 85
+ 84, // 86
+ 84, // 87
+ 88, // 88
+ 88, // 89
+ 90, // 90
+ 90, // 91
+ 92, // 92
+ 92, // 93
+ 92, // 94
+ 92, // 95
+ 96, // 96
+};
+
+const int g_noteVelocityLUT[] =
+{
+ 0, // 0
+ 4, // 1
+ 4, // 2
+ 4, // 3
+ 4, // 4
+ 8, // 5
+ 8, // 6
+ 8, // 7
+ 8, // 8
+ 12, // 9
+ 12, // 10
+ 12, // 11
+ 12, // 12
+ 16, // 13
+ 16, // 14
+ 16, // 15
+ 16, // 16
+ 20, // 17
+ 20, // 18
+ 20, // 19
+ 20, // 20
+ 24, // 21
+ 24, // 22
+ 24, // 23
+ 24, // 24
+ 28, // 25
+ 28, // 26
+ 28, // 27
+ 28, // 28
+ 32, // 29
+ 32, // 30
+ 32, // 31
+ 32, // 32
+ 36, // 33
+ 36, // 34
+ 36, // 35
+ 36, // 36
+ 40, // 37
+ 40, // 38
+ 40, // 39
+ 40, // 40
+ 44, // 41
+ 44, // 42
+ 44, // 43
+ 44, // 44
+ 48, // 45
+ 48, // 46
+ 48, // 47
+ 48, // 48
+ 52, // 49
+ 52, // 50
+ 52, // 51
+ 52, // 52
+ 56, // 53
+ 56, // 54
+ 56, // 55
+ 56, // 56
+ 60, // 57
+ 60, // 58
+ 60, // 59
+ 60, // 60
+ 64, // 61
+ 64, // 62
+ 64, // 63
+ 64, // 64
+ 68, // 65
+ 68, // 66
+ 68, // 67
+ 68, // 68
+ 72, // 69
+ 72, // 70
+ 72, // 71
+ 72, // 72
+ 76, // 73
+ 76, // 74
+ 76, // 75
+ 76, // 76
+ 80, // 77
+ 80, // 78
+ 80, // 79
+ 80, // 80
+ 84, // 81
+ 84, // 82
+ 84, // 83
+ 84, // 84
+ 88, // 85
+ 88, // 86
+ 88, // 87
+ 88, // 88
+ 92, // 89
+ 92, // 90
+ 92, // 91
+ 92, // 92
+ 96, // 93
+ 96, // 94
+ 96, // 95
+ 96, // 96
+ 100, // 97
+ 100, // 98
+ 100, // 99
+ 100, // 100
+ 104, // 101
+ 104, // 102
+ 104, // 103
+ 104, // 104
+ 108, // 105
+ 108, // 106
+ 108, // 107
+ 108, // 108
+ 112, // 109
+ 112, // 110
+ 112, // 111
+ 112, // 112
+ 116, // 113
+ 116, // 114
+ 116, // 115
+ 116, // 116
+ 120, // 117
+ 120, // 118
+ 120, // 119
+ 120, // 120
+ 124, // 121
+ 124, // 122
+ 124, // 123
+ 124, // 124
+ 127, // 125
+ 127, // 126
+ 127, // 127
+};
+
+const char* g_noteTable[] =
+{
+ "Cn%01u ",
+ "Cs%01u ",
+ "Dn%01u ",
+ "Ds%01u ",
+ "En%01u ",
+ "Fn%01u ",
+ "Fs%01u ",
+ "Gn%01u ",
+ "Gs%01u ",
+ "An%01u ",
+ "As%01u ",
+ "Bn%01u ",
+};
+
+const char* g_minusNoteTable[] =
+{
+ "CnM%01u",
+ "CsM%01u",
+ "DnM%01u",
+ "DsM%01u",
+ "EnM%01u",
+ "FnM%01u",
+ "FsM%01u",
+ "GnM%01u",
+ "GsM%01u",
+ "AnM%01u",
+ "AsM%01u",
+ "BnM%01u",
+};
diff --git a/tools/preproc/.gitignore b/tools/preproc/.gitignore
index afa6b22..eb34708 100644
--- a/tools/preproc/.gitignore
+++ b/tools/preproc/.gitignore
@@ -1 +1 @@
-preproc
+preproc
diff --git a/tools/preproc/asm_file.cpp b/tools/preproc/asm_file.cpp
index ce0bf31..7756cad 100644
--- a/tools/preproc/asm_file.cpp
+++ b/tools/preproc/asm_file.cpp
@@ -1,532 +1,532 @@
-// Copyright(c) 2016 YamaArashi
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#include <cstdio>
-#include <cstdarg>
-#include <stdexcept>
-#include "preproc.h"
-#include "asm_file.h"
-#include "char_util.h"
-#include "utf8.h"
-#include "string_parser.h"
-
-AsmFile::AsmFile(std::string filename) : m_filename(filename)
-{
- FILE *fp = std::fopen(filename.c_str(), "rb");
-
- if (fp == NULL)
- FATAL_ERROR("Failed to open \"%s\" for reading.\n", filename.c_str());
-
- std::fseek(fp, 0, SEEK_END);
-
- m_size = std::ftell(fp);
-
- if (m_size < 0)
- FATAL_ERROR("File size of \"%s\" is less than zero.\n", filename.c_str());
-
- m_buffer = new char[m_size + 1];
-
- std::rewind(fp);
-
- if (std::fread(m_buffer, m_size, 1, fp) != 1)
- FATAL_ERROR("Failed to read \"%s\".\n", filename.c_str());
-
- m_buffer[m_size] = 0;
-
- std::fclose(fp);
-
- m_pos = 0;
- m_lineNum = 1;
- m_lineStart = 0;
-
- RemoveComments();
-}
-
-AsmFile::AsmFile(AsmFile&& other) : m_filename(std::move(other.m_filename))
-{
- m_buffer = other.m_buffer;
- m_pos = other.m_pos;
- m_size = other.m_size;
- m_lineNum = other.m_lineNum;
- m_lineStart = other.m_lineStart;
-
- other.m_buffer = nullptr;
-}
-
-AsmFile::~AsmFile()
-{
- delete[] m_buffer;
-}
-
-// Removes comments to simplify further processing.
-// It stops upon encountering a null character,
-// which may or may not be the end of file marker.
-// If it's not, the error will be caught later.
-void AsmFile::RemoveComments()
-{
- long pos = 0;
- char stringChar = 0;
-
- for (;;)
- {
- if (m_buffer[pos] == 0)
- return;
-
- if (stringChar != 0)
- {
- if (m_buffer[pos] == '\\' && m_buffer[pos + 1] == stringChar)
- {
- pos += 2;
- }
- else
- {
- if (m_buffer[pos] == stringChar)
- stringChar = 0;
- pos++;
- }
- }
- else if (m_buffer[pos] == '@' && (pos == 0 || m_buffer[pos - 1] != '\\'))
- {
- while (m_buffer[pos] != '\n' && m_buffer[pos] != 0)
- m_buffer[pos++] = ' ';
- }
- else if (m_buffer[pos] == '/' && m_buffer[pos + 1] == '*')
- {
- m_buffer[pos++] = ' ';
- m_buffer[pos++] = ' ';
-
- for (;;)
- {
- if (m_buffer[pos] == 0)
- return;
-
- if (m_buffer[pos] == '*' && m_buffer[pos + 1] == '/')
- {
- m_buffer[pos++] = ' ';
- m_buffer[pos++] = ' ';
- break;
- }
- else
- {
- if (m_buffer[pos] != '\n')
- m_buffer[pos] = ' ';
- pos++;
- }
- }
- }
- else
- {
- if (m_buffer[pos] == '"' || m_buffer[pos] == '\'')
- stringChar = m_buffer[pos];
- pos++;
- }
- }
-}
-
-// Checks if we're at a particular directive and if so, consumes it.
-// Returns whether the directive was found.
-bool AsmFile::CheckForDirective(std::string name)
-{
- long i;
- long length = static_cast<long>(name.length());
-
- for (i = 0; i < length && m_pos + i < m_size; i++)
- if (name[i] != m_buffer[m_pos + i])
- return false;
-
- if (i < length)
- return false;
-
- m_pos += length;
-
- return true;
-}
-
-// Checks if we're at a known directive and if so, consumes it.
-// Returns which directive was found.
-Directive AsmFile::GetDirective()
-{
- SkipWhitespace();
-
- if (CheckForDirective(".include"))
- return Directive::Include;
- else if (CheckForDirective(".string"))
- return Directive::String;
- else if (CheckForDirective(".braille"))
- return Directive::Braille;
- else
- return Directive::Unknown;
-}
-
-// Checks if we're at label that ends with '::'.
-// Returns the name if so and an empty string if not.
-std::string AsmFile::GetGlobalLabel()
-{
- long start = m_pos;
- long pos = m_pos;
-
- if (IsIdentifierStartingChar(m_buffer[pos]))
- {
- pos++;
-
- while (IsIdentifierChar(m_buffer[pos]))
- pos++;
- }
-
- if (m_buffer[pos] == ':' && m_buffer[pos + 1] == ':')
- {
- m_pos = pos + 2;
- ExpectEmptyRestOfLine();
- return std::string(&m_buffer[start], pos - start);
- }
-
- return std::string();
-}
-
-// Skips tabs and spaces.
-void AsmFile::SkipWhitespace()
-{
- while (m_buffer[m_pos] == '\t' || m_buffer[m_pos] == ' ')
- m_pos++;
-}
-
-// Reads include path.
-std::string AsmFile::ReadPath()
-{
- SkipWhitespace();
-
- if (m_buffer[m_pos] != '"')
- RaiseError("expected file path");
-
- m_pos++;
-
- int length = 0;
- long startPos = m_pos;
-
- while (m_buffer[m_pos] != '"')
- {
- unsigned char c = m_buffer[m_pos++];
-
- if (c == 0)
- {
- if (m_pos >= m_size)
- RaiseError("unexpected EOF in include string");
- else
- RaiseError("unexpected null character in include string");
- }
-
- if (!IsAsciiPrintable(c))
- RaiseError("unexpected character '\\x%02X' in include string", c);
-
- // Don't bother allowing any escape sequences.
- if (c == '\\')
- {
- c = m_buffer[m_pos];
- RaiseError("unexpected escape '\\%c' in include string", c);
- }
-
- length++;
-
- if (length > kMaxPath)
- RaiseError("path is too long");
- }
-
- m_pos++; // Go past the right quote.
-
- ExpectEmptyRestOfLine();
-
- return std::string(&m_buffer[startPos], length);
-}
-
-// Reads a charmap string.
-int AsmFile::ReadString(unsigned char* s)
-{
- SkipWhitespace();
-
- int length;
- StringParser stringParser(m_buffer, m_size);
-
- try
- {
- m_pos += stringParser.ParseString(m_pos, s, length);
- }
- catch (std::runtime_error& e)
- {
- RaiseError(e.what());
- }
-
- SkipWhitespace();
-
- if (ConsumeComma())
- {
- SkipWhitespace();
- int padLength = ReadPadLength();
-
- while (length < padLength)
- {
- s[length++] = 0;
- }
- }
-
- ExpectEmptyRestOfLine();
-
- return length;
-}
-
-int AsmFile::ReadBraille(unsigned char* s)
-{
- static std::map<char, unsigned char> encoding =
- {
- { 'A', 0x01 },
- { 'B', 0x05 },
- { 'C', 0x03 },
- { 'D', 0x0B },
- { 'E', 0x09 },
- { 'F', 0x07 },
- { 'G', 0x0F },
- { 'H', 0x0D },
- { 'I', 0x06 },
- { 'J', 0x0E },
- { 'K', 0x11 },
- { 'L', 0x15 },
- { 'M', 0x13 },
- { 'N', 0x1B },
- { 'O', 0x19 },
- { 'P', 0x17 },
- { 'Q', 0x1F },
- { 'R', 0x1D },
- { 'S', 0x16 },
- { 'T', 0x1E },
- { 'U', 0x31 },
- { 'V', 0x35 },
- { 'W', 0x2E },
- { 'X', 0x33 },
- { 'Y', 0x3B },
- { 'Z', 0x39 },
- { ' ', 0x00 },
- { ',', 0x04 },
- { '.', 0x2C },
- { '$', 0xFF },
- };
-
- SkipWhitespace();
-
- int length = 0;
-
- if (m_buffer[m_pos] != '"')
- RaiseError("expected braille string literal");
-
- m_pos++;
-
- while (m_buffer[m_pos] != '"')
- {
- if (length == kMaxStringLength)
- RaiseError("mapped string longer than %d bytes", kMaxStringLength);
-
- if (m_buffer[m_pos] == '\\' && m_buffer[m_pos + 1] == 'n')
- {
- s[length++] = 0xFE;
- m_pos += 2;
- }
- else
- {
- char c = m_buffer[m_pos];
-
- if (encoding.count(c) == 0)
- {
- if (IsAsciiPrintable(c))
- RaiseError("character '%c' not valid in braille string", m_buffer[m_pos]);
- else
- RaiseError("character '\\x%02X' not valid in braille string", m_buffer[m_pos]);
- }
-
- s[length++] = encoding[c];
- m_pos++;
- }
- }
-
- m_pos++; // Go past the right quote.
-
- ExpectEmptyRestOfLine();
-
- return length;
-}
-
-// If we're at a comma, consumes it.
-// Returns whether a comma was found.
-bool AsmFile::ConsumeComma()
-{
- if (m_buffer[m_pos] == ',')
- {
- m_pos++;
- return true;
- }
-
- return false;
-}
-
-// Converts digit character to numerical value.
-static int ConvertDigit(char c, int radix)
-{
- int digit;
-
- if (c >= '0' && c <= '9')
- digit = c - '0';
- else if (c >= 'A' && c <= 'F')
- digit = 10 + c - 'A';
- else if (c >= 'a' && c <= 'f')
- digit = 10 + c - 'a';
- else
- return -1;
-
- return (digit < radix) ? digit : -1;
-}
-
-// Reads an integer. If the integer is greater than maxValue, it returns -1.
-int AsmFile::ReadPadLength()
-{
- if (!IsAsciiDigit(m_buffer[m_pos]))
- RaiseError("expected integer");
-
- int radix = 10;
-
- if (m_buffer[m_pos] == '0' && m_buffer[m_pos + 1] == 'x')
- {
- radix = 16;
- m_pos += 2;
- }
-
- unsigned n = 0;
- int digit;
-
- while ((digit = ConvertDigit(m_buffer[m_pos], radix)) != -1)
- {
- n = n * radix + digit;
-
- if (n > kMaxStringLength)
- RaiseError("pad length greater than maximum length (%d)", kMaxStringLength);
-
- m_pos++;
- }
-
- return n;
-}
-
-// Outputs the current line and moves to the next one.
-void AsmFile::OutputLine()
-{
- while (m_buffer[m_pos] != '\n' && m_buffer[m_pos] != 0)
- m_pos++;
-
- if (m_buffer[m_pos] == 0)
- {
- if (m_pos >= m_size)
- {
- RaiseWarning("file doesn't end with newline");
- puts(&m_buffer[m_lineStart]);
- }
- else
- {
- RaiseError("unexpected null character");
- }
- }
- else
- {
- m_buffer[m_pos] = 0;
- puts(&m_buffer[m_lineStart]);
- m_buffer[m_pos] = '\n';
- m_pos++;
- m_lineStart = m_pos;
- m_lineNum++;
- }
-}
-
-// Asserts that the rest of the line is empty and moves to the next one.
-void AsmFile::ExpectEmptyRestOfLine()
-{
- SkipWhitespace();
-
- if (m_buffer[m_pos] == 0)
- {
- if (m_pos >= m_size)
- RaiseWarning("file doesn't end with newline");
- else
- RaiseError("unexpected null character");
- }
- else if (m_buffer[m_pos] == '\n')
- {
- m_pos++;
- m_lineStart = m_pos;
- m_lineNum++;
- }
- else if (m_buffer[m_pos] == '\r' && m_buffer[m_pos + 1] == '\n')
- {
- m_pos += 2;
- m_lineStart = m_pos;
- m_lineNum++;
- }
- else
- {
- RaiseError("junk at end of line");
- }
-}
-
-// Checks if we're at the end of the file.
-bool AsmFile::IsAtEnd()
-{
- return (m_pos >= m_size);
-}
-
-// Output the current location to set gas's logical file and line numbers.
-void AsmFile::OutputLocation()
-{
- std::printf("# %ld \"%s\"\n", m_lineNum, m_filename.c_str());
-}
-
-// Reports a diagnostic message.
-void AsmFile::ReportDiagnostic(const char* type, const char* format, std::va_list args)
-{
- const int bufferSize = 1024;
- char buffer[bufferSize];
- std::vsnprintf(buffer, bufferSize, format, args);
- std::fprintf(stderr, "%s:%ld: %s: %s\n", m_filename.c_str(), m_lineNum, type, buffer);
-}
-
-#define DO_REPORT(type) \
-do \
-{ \
- std::va_list args; \
- va_start(args, format); \
- ReportDiagnostic(type, format, args); \
- va_end(args); \
-} while (0)
-
-// Reports an error diagnostic and terminates the program.
-void AsmFile::RaiseError(const char* format, ...)
-{
- DO_REPORT("error");
- std::exit(1);
-}
-
-// Reports a warning diagnostic.
-void AsmFile::RaiseWarning(const char* format, ...)
-{
- DO_REPORT("warning");
-}
+// Copyright(c) 2016 YamaArashi
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#include <cstdio>
+#include <cstdarg>
+#include <stdexcept>
+#include "preproc.h"
+#include "asm_file.h"
+#include "char_util.h"
+#include "utf8.h"
+#include "string_parser.h"
+
+AsmFile::AsmFile(std::string filename) : m_filename(filename)
+{
+ FILE *fp = std::fopen(filename.c_str(), "rb");
+
+ if (fp == NULL)
+ FATAL_ERROR("Failed to open \"%s\" for reading.\n", filename.c_str());
+
+ std::fseek(fp, 0, SEEK_END);
+
+ m_size = std::ftell(fp);
+
+ if (m_size < 0)
+ FATAL_ERROR("File size of \"%s\" is less than zero.\n", filename.c_str());
+
+ m_buffer = new char[m_size + 1];
+
+ std::rewind(fp);
+
+ if (std::fread(m_buffer, m_size, 1, fp) != 1)
+ FATAL_ERROR("Failed to read \"%s\".\n", filename.c_str());
+
+ m_buffer[m_size] = 0;
+
+ std::fclose(fp);
+
+ m_pos = 0;
+ m_lineNum = 1;
+ m_lineStart = 0;
+
+ RemoveComments();
+}
+
+AsmFile::AsmFile(AsmFile&& other) : m_filename(std::move(other.m_filename))
+{
+ m_buffer = other.m_buffer;
+ m_pos = other.m_pos;
+ m_size = other.m_size;
+ m_lineNum = other.m_lineNum;
+ m_lineStart = other.m_lineStart;
+
+ other.m_buffer = nullptr;
+}
+
+AsmFile::~AsmFile()
+{
+ delete[] m_buffer;
+}
+
+// Removes comments to simplify further processing.
+// It stops upon encountering a null character,
+// which may or may not be the end of file marker.
+// If it's not, the error will be caught later.
+void AsmFile::RemoveComments()
+{
+ long pos = 0;
+ char stringChar = 0;
+
+ for (;;)
+ {
+ if (m_buffer[pos] == 0)
+ return;
+
+ if (stringChar != 0)
+ {
+ if (m_buffer[pos] == '\\' && m_buffer[pos + 1] == stringChar)
+ {
+ pos += 2;
+ }
+ else
+ {
+ if (m_buffer[pos] == stringChar)
+ stringChar = 0;
+ pos++;
+ }
+ }
+ else if (m_buffer[pos] == '@' && (pos == 0 || m_buffer[pos - 1] != '\\'))
+ {
+ while (m_buffer[pos] != '\n' && m_buffer[pos] != 0)
+ m_buffer[pos++] = ' ';
+ }
+ else if (m_buffer[pos] == '/' && m_buffer[pos + 1] == '*')
+ {
+ m_buffer[pos++] = ' ';
+ m_buffer[pos++] = ' ';
+
+ for (;;)
+ {
+ if (m_buffer[pos] == 0)
+ return;
+
+ if (m_buffer[pos] == '*' && m_buffer[pos + 1] == '/')
+ {
+ m_buffer[pos++] = ' ';
+ m_buffer[pos++] = ' ';
+ break;
+ }
+ else
+ {
+ if (m_buffer[pos] != '\n')
+ m_buffer[pos] = ' ';
+ pos++;
+ }
+ }
+ }
+ else
+ {
+ if (m_buffer[pos] == '"' || m_buffer[pos] == '\'')
+ stringChar = m_buffer[pos];
+ pos++;
+ }
+ }
+}
+
+// Checks if we're at a particular directive and if so, consumes it.
+// Returns whether the directive was found.
+bool AsmFile::CheckForDirective(std::string name)
+{
+ long i;
+ long length = static_cast<long>(name.length());
+
+ for (i = 0; i < length && m_pos + i < m_size; i++)
+ if (name[i] != m_buffer[m_pos + i])
+ return false;
+
+ if (i < length)
+ return false;
+
+ m_pos += length;
+
+ return true;
+}
+
+// Checks if we're at a known directive and if so, consumes it.
+// Returns which directive was found.
+Directive AsmFile::GetDirective()
+{
+ SkipWhitespace();
+
+ if (CheckForDirective(".include"))
+ return Directive::Include;
+ else if (CheckForDirective(".string"))
+ return Directive::String;
+ else if (CheckForDirective(".braille"))
+ return Directive::Braille;
+ else
+ return Directive::Unknown;
+}
+
+// Checks if we're at label that ends with '::'.
+// Returns the name if so and an empty string if not.
+std::string AsmFile::GetGlobalLabel()
+{
+ long start = m_pos;
+ long pos = m_pos;
+
+ if (IsIdentifierStartingChar(m_buffer[pos]))
+ {
+ pos++;
+
+ while (IsIdentifierChar(m_buffer[pos]))
+ pos++;
+ }
+
+ if (m_buffer[pos] == ':' && m_buffer[pos + 1] == ':')
+ {
+ m_pos = pos + 2;
+ ExpectEmptyRestOfLine();
+ return std::string(&m_buffer[start], pos - start);
+ }
+
+ return std::string();
+}
+
+// Skips tabs and spaces.
+void AsmFile::SkipWhitespace()
+{
+ while (m_buffer[m_pos] == '\t' || m_buffer[m_pos] == ' ')
+ m_pos++;
+}
+
+// Reads include path.
+std::string AsmFile::ReadPath()
+{
+ SkipWhitespace();
+
+ if (m_buffer[m_pos] != '"')
+ RaiseError("expected file path");
+
+ m_pos++;
+
+ int length = 0;
+ long startPos = m_pos;
+
+ while (m_buffer[m_pos] != '"')
+ {
+ unsigned char c = m_buffer[m_pos++];
+
+ if (c == 0)
+ {
+ if (m_pos >= m_size)
+ RaiseError("unexpected EOF in include string");
+ else
+ RaiseError("unexpected null character in include string");
+ }
+
+ if (!IsAsciiPrintable(c))
+ RaiseError("unexpected character '\\x%02X' in include string", c);
+
+ // Don't bother allowing any escape sequences.
+ if (c == '\\')
+ {
+ c = m_buffer[m_pos];
+ RaiseError("unexpected escape '\\%c' in include string", c);
+ }
+
+ length++;
+
+ if (length > kMaxPath)
+ RaiseError("path is too long");
+ }
+
+ m_pos++; // Go past the right quote.
+
+ ExpectEmptyRestOfLine();
+
+ return std::string(&m_buffer[startPos], length);
+}
+
+// Reads a charmap string.
+int AsmFile::ReadString(unsigned char* s)
+{
+ SkipWhitespace();
+
+ int length;
+ StringParser stringParser(m_buffer, m_size);
+
+ try
+ {
+ m_pos += stringParser.ParseString(m_pos, s, length);
+ }
+ catch (std::runtime_error& e)
+ {
+ RaiseError(e.what());
+ }
+
+ SkipWhitespace();
+
+ if (ConsumeComma())
+ {
+ SkipWhitespace();
+ int padLength = ReadPadLength();
+
+ while (length < padLength)
+ {
+ s[length++] = 0;
+ }
+ }
+
+ ExpectEmptyRestOfLine();
+
+ return length;
+}
+
+int AsmFile::ReadBraille(unsigned char* s)
+{
+ static std::map<char, unsigned char> encoding =
+ {
+ { 'A', 0x01 },
+ { 'B', 0x05 },
+ { 'C', 0x03 },
+ { 'D', 0x0B },
+ { 'E', 0x09 },
+ { 'F', 0x07 },
+ { 'G', 0x0F },
+ { 'H', 0x0D },
+ { 'I', 0x06 },
+ { 'J', 0x0E },
+ { 'K', 0x11 },
+ { 'L', 0x15 },
+ { 'M', 0x13 },
+ { 'N', 0x1B },
+ { 'O', 0x19 },
+ { 'P', 0x17 },
+ { 'Q', 0x1F },
+ { 'R', 0x1D },
+ { 'S', 0x16 },
+ { 'T', 0x1E },
+ { 'U', 0x31 },
+ { 'V', 0x35 },
+ { 'W', 0x2E },
+ { 'X', 0x33 },
+ { 'Y', 0x3B },
+ { 'Z', 0x39 },
+ { ' ', 0x00 },
+ { ',', 0x04 },
+ { '.', 0x2C },
+ { '$', 0xFF },
+ };
+
+ SkipWhitespace();
+
+ int length = 0;
+
+ if (m_buffer[m_pos] != '"')
+ RaiseError("expected braille string literal");
+
+ m_pos++;
+
+ while (m_buffer[m_pos] != '"')
+ {
+ if (length == kMaxStringLength)
+ RaiseError("mapped string longer than %d bytes", kMaxStringLength);
+
+ if (m_buffer[m_pos] == '\\' && m_buffer[m_pos + 1] == 'n')
+ {
+ s[length++] = 0xFE;
+ m_pos += 2;
+ }
+ else
+ {
+ char c = m_buffer[m_pos];
+
+ if (encoding.count(c) == 0)
+ {
+ if (IsAsciiPrintable(c))
+ RaiseError("character '%c' not valid in braille string", m_buffer[m_pos]);
+ else
+ RaiseError("character '\\x%02X' not valid in braille string", m_buffer[m_pos]);
+ }
+
+ s[length++] = encoding[c];
+ m_pos++;
+ }
+ }
+
+ m_pos++; // Go past the right quote.
+
+ ExpectEmptyRestOfLine();
+
+ return length;
+}
+
+// If we're at a comma, consumes it.
+// Returns whether a comma was found.
+bool AsmFile::ConsumeComma()
+{
+ if (m_buffer[m_pos] == ',')
+ {
+ m_pos++;
+ return true;
+ }
+
+ return false;
+}
+
+// Converts digit character to numerical value.
+static int ConvertDigit(char c, int radix)
+{
+ int digit;
+
+ if (c >= '0' && c <= '9')
+ digit = c - '0';
+ else if (c >= 'A' && c <= 'F')
+ digit = 10 + c - 'A';
+ else if (c >= 'a' && c <= 'f')
+ digit = 10 + c - 'a';
+ else
+ return -1;
+
+ return (digit < radix) ? digit : -1;
+}
+
+// Reads an integer. If the integer is greater than maxValue, it returns -1.
+int AsmFile::ReadPadLength()
+{
+ if (!IsAsciiDigit(m_buffer[m_pos]))
+ RaiseError("expected integer");
+
+ int radix = 10;
+
+ if (m_buffer[m_pos] == '0' && m_buffer[m_pos + 1] == 'x')
+ {
+ radix = 16;
+ m_pos += 2;
+ }
+
+ unsigned n = 0;
+ int digit;
+
+ while ((digit = ConvertDigit(m_buffer[m_pos], radix)) != -1)
+ {
+ n = n * radix + digit;
+
+ if (n > kMaxStringLength)
+ RaiseError("pad length greater than maximum length (%d)", kMaxStringLength);
+
+ m_pos++;
+ }
+
+ return n;
+}
+
+// Outputs the current line and moves to the next one.
+void AsmFile::OutputLine()
+{
+ while (m_buffer[m_pos] != '\n' && m_buffer[m_pos] != 0)
+ m_pos++;
+
+ if (m_buffer[m_pos] == 0)
+ {
+ if (m_pos >= m_size)
+ {
+ RaiseWarning("file doesn't end with newline");
+ puts(&m_buffer[m_lineStart]);
+ }
+ else
+ {
+ RaiseError("unexpected null character");
+ }
+ }
+ else
+ {
+ m_buffer[m_pos] = 0;
+ puts(&m_buffer[m_lineStart]);
+ m_buffer[m_pos] = '\n';
+ m_pos++;
+ m_lineStart = m_pos;
+ m_lineNum++;
+ }
+}
+
+// Asserts that the rest of the line is empty and moves to the next one.
+void AsmFile::ExpectEmptyRestOfLine()
+{
+ SkipWhitespace();
+
+ if (m_buffer[m_pos] == 0)
+ {
+ if (m_pos >= m_size)
+ RaiseWarning("file doesn't end with newline");
+ else
+ RaiseError("unexpected null character");
+ }
+ else if (m_buffer[m_pos] == '\n')
+ {
+ m_pos++;
+ m_lineStart = m_pos;
+ m_lineNum++;
+ }
+ else if (m_buffer[m_pos] == '\r' && m_buffer[m_pos + 1] == '\n')
+ {
+ m_pos += 2;
+ m_lineStart = m_pos;
+ m_lineNum++;
+ }
+ else
+ {
+ RaiseError("junk at end of line");
+ }
+}
+
+// Checks if we're at the end of the file.
+bool AsmFile::IsAtEnd()
+{
+ return (m_pos >= m_size);
+}
+
+// Output the current location to set gas's logical file and line numbers.
+void AsmFile::OutputLocation()
+{
+ std::printf("# %ld \"%s\"\n", m_lineNum, m_filename.c_str());
+}
+
+// Reports a diagnostic message.
+void AsmFile::ReportDiagnostic(const char* type, const char* format, std::va_list args)
+{
+ const int bufferSize = 1024;
+ char buffer[bufferSize];
+ std::vsnprintf(buffer, bufferSize, format, args);
+ std::fprintf(stderr, "%s:%ld: %s: %s\n", m_filename.c_str(), m_lineNum, type, buffer);
+}
+
+#define DO_REPORT(type) \
+do \
+{ \
+ std::va_list args; \
+ va_start(args, format); \
+ ReportDiagnostic(type, format, args); \
+ va_end(args); \
+} while (0)
+
+// Reports an error diagnostic and terminates the program.
+void AsmFile::RaiseError(const char* format, ...)
+{
+ DO_REPORT("error");
+ std::exit(1);
+}
+
+// Reports a warning diagnostic.
+void AsmFile::RaiseWarning(const char* format, ...)
+{
+ DO_REPORT("warning");
+}
diff --git a/tools/preproc/c_file.cpp b/tools/preproc/c_file.cpp
index 6213a8a..59426ef 100644
--- a/tools/preproc/c_file.cpp
+++ b/tools/preproc/c_file.cpp
@@ -1,430 +1,430 @@
-// Copyright(c) 2016 YamaArashi
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#include <cstdio>
-#include <cstdarg>
-#include <stdexcept>
-#include <string>
-#include <memory>
-#include "preproc.h"
-#include "c_file.h"
-#include "char_util.h"
-#include "utf8.h"
-#include "string_parser.h"
-
-CFile::CFile(std::string filename) : m_filename(filename)
-{
- FILE *fp = std::fopen(filename.c_str(), "rb");
-
- if (fp == NULL)
- FATAL_ERROR("Failed to open \"%s\" for reading.\n", filename.c_str());
-
- std::fseek(fp, 0, SEEK_END);
-
- m_size = std::ftell(fp);
-
- if (m_size < 0)
- FATAL_ERROR("File size of \"%s\" is less than zero.\n", filename.c_str());
-
- m_buffer = new char[m_size + 1];
-
- std::rewind(fp);
-
- if (std::fread(m_buffer, m_size, 1, fp) != 1)
- FATAL_ERROR("Failed to read \"%s\".\n", filename.c_str());
-
- m_buffer[m_size] = 0;
-
- std::fclose(fp);
-
- m_pos = 0;
- m_lineNum = 1;
-}
-
-CFile::CFile(CFile&& other) : m_filename(std::move(other.m_filename))
-{
- m_buffer = other.m_buffer;
- m_pos = other.m_pos;
- m_size = other.m_size;
- m_lineNum = other.m_lineNum;
-
- other.m_buffer = nullptr;
-}
-
-CFile::~CFile()
-{
- delete[] m_buffer;
-}
-
-void CFile::Preproc()
-{
- char stringChar = 0;
-
- while (m_pos < m_size)
- {
- if (stringChar)
- {
- if (m_buffer[m_pos] == stringChar)
- {
- std::putchar(stringChar);
- m_pos++;
- stringChar = 0;
- }
- else if (m_buffer[m_pos] == '\\' && m_buffer[m_pos + 1] == stringChar)
- {
- std::putchar('\\');
- std::putchar(stringChar);
- m_pos += 2;
- }
- else
- {
- if (m_buffer[m_pos] == '\n')
- m_lineNum++;
- std::putchar(m_buffer[m_pos]);
- m_pos++;
- }
- }
- else
- {
- TryConvertString();
- TryConvertIncbin();
-
- if (m_pos >= m_size)
- break;
-
- char c = m_buffer[m_pos++];
-
- std::putchar(c);
-
- if (c == '\n')
- m_lineNum++;
- else if (c == '"')
- stringChar = '"';
- else if (c == '\'')
- stringChar = '\'';
- }
- }
-}
-
-bool CFile::ConsumeHorizontalWhitespace()
-{
- if (m_buffer[m_pos] == '\t' || m_buffer[m_pos] == ' ')
- {
- m_pos++;
- return true;
- }
-
- return false;
-}
-
-bool CFile::ConsumeNewline()
-{
- if (m_buffer[m_pos] == '\r' && m_buffer[m_pos + 1] == '\n')
- {
- m_pos += 2;
- m_lineNum++;
- std::putchar('\n');
- return true;
- }
-
- if (m_buffer[m_pos] == '\n')
- {
- m_pos++;
- m_lineNum++;
- std::putchar('\n');
- return true;
- }
-
- return false;
-}
-
-void CFile::SkipWhitespace()
-{
- while (ConsumeHorizontalWhitespace() || ConsumeNewline())
- ;
-}
-
-void CFile::TryConvertString()
-{
- long oldPos = m_pos;
- long oldLineNum = m_lineNum;
- bool noTerminator = false;
-
- if (m_buffer[m_pos] != '_' || (m_pos > 0 && IsIdentifierChar(m_buffer[m_pos - 1])))
- return;
-
- m_pos++;
-
- if (m_buffer[m_pos] == '_')
- {
- noTerminator = true;
- m_pos++;
- }
-
- SkipWhitespace();
-
- if (m_buffer[m_pos] != '(')
- {
- m_pos = oldPos;
- m_lineNum = oldLineNum;
- return;
- }
-
- m_pos++;
-
- SkipWhitespace();
-
- std::printf("{ ");
-
- while (1)
- {
- SkipWhitespace();
-
- if (m_buffer[m_pos] == '"')
- {
- unsigned char s[kMaxStringLength];
- int length;
- StringParser stringParser(m_buffer, m_size);
-
- try
- {
- m_pos += stringParser.ParseString(m_pos, s, length);
- }
- catch (std::runtime_error& e)
- {
- RaiseError(e.what());
- }
-
- for (int i = 0; i < length; i++)
- printf("0x%02X, ", s[i]);
- }
- else if (m_buffer[m_pos] == ')')
- {
- m_pos++;
- break;
- }
- else
- {
- if (m_pos >= m_size)
- RaiseError("unexpected EOF");
- if (IsAsciiPrintable(m_buffer[m_pos]))
- RaiseError("unexpected character '%c'", m_buffer[m_pos]);
- else
- RaiseError("unexpected character '\\x%02X'", m_buffer[m_pos]);
- }
- }
-
- if (noTerminator)
- std::printf(" }");
- else
- std::printf("0x00 }");
-}
-
-bool CFile::CheckIdentifier(const std::string& ident)
-{
- unsigned int i;
-
- for (i = 0; i < ident.length() && m_pos + i < (unsigned)m_size; i++)
- if (ident[i] != m_buffer[m_pos + i])
- return false;
-
- return (i == ident.length());
-}
-
-std::unique_ptr<unsigned char[]> CFile::ReadWholeFile(const std::string& path, int& size)
-{
- FILE* fp = std::fopen(path.c_str(), "rb");
-
- if (fp == nullptr)
- RaiseError("Failed to open \"%s\" for reading.\n", path.c_str());
-
- std::fseek(fp, 0, SEEK_END);
-
- size = std::ftell(fp);
-
- std::unique_ptr<unsigned char[]> buffer = std::unique_ptr<unsigned char[]>(new unsigned char[size]);
-
- std::rewind(fp);
-
- if (std::fread(buffer.get(), size, 1, fp) != 1)
- RaiseError("Failed to read \"%s\".\n", path.c_str());
-
- std::fclose(fp);
-
- return buffer;
-}
-
-int ExtractData(const std::unique_ptr<unsigned char[]>& buffer, int offset, int size)
-{
- switch (size)
- {
- case 1:
- return buffer[offset];
- case 2:
- return (buffer[offset + 1] << 8)
- | buffer[offset];
- case 4:
- return (buffer[offset + 3] << 24)
- | (buffer[offset + 2] << 16)
- | (buffer[offset + 1] << 8)
- | buffer[offset];
- default:
- FATAL_ERROR("Invalid size passed to ExtractData.\n");
- }
-}
-
-void CFile::TryConvertIncbin()
-{
- std::string idents[6] = { "INCBIN_S8", "INCBIN_U8", "INCBIN_S16", "INCBIN_U16", "INCBIN_S32", "INCBIN_U32" };
- int incbinType = -1;
-
- for (int i = 0; i < 6; i++)
- {
- if (CheckIdentifier(idents[i]))
- {
- incbinType = i;
- break;
- }
- }
-
- if (incbinType == -1)
- return;
-
- int size = 1 << (incbinType / 2);
- bool isSigned = ((incbinType % 2) == 0);
-
- long oldPos = m_pos;
- long oldLineNum = m_lineNum;
-
- m_pos += idents[incbinType].length();
-
- SkipWhitespace();
-
- if (m_buffer[m_pos] != '(')
- {
- m_pos = oldPos;
- m_lineNum = oldLineNum;
- return;
- }
-
- m_pos++;
-
- std::printf("{");
-
- while (true)
- {
- SkipWhitespace();
-
- if (m_buffer[m_pos] != '"')
- RaiseError("expected double quote");
-
- m_pos++;
-
- int startPos = m_pos;
-
- while (m_buffer[m_pos] != '"')
- {
- if (m_buffer[m_pos] == 0)
- {
- if (m_pos >= m_size)
- RaiseError("unexpected EOF in path string");
- else
- RaiseError("unexpected null character in path string");
- }
-
- if (m_buffer[m_pos] == '\r' || m_buffer[m_pos] == '\n')
- RaiseError("unexpected end of line character in path string");
-
- if (m_buffer[m_pos] == '\\')
- RaiseError("unexpected escape in path string");
-
- m_pos++;
- }
-
- std::string path(&m_buffer[startPos], m_pos - startPos);
-
- m_pos++;
-
- int fileSize;
- std::unique_ptr<unsigned char[]> buffer = ReadWholeFile(path, fileSize);
-
- if ((fileSize % size) != 0)
- RaiseError("Size %d doesn't evenly divide file size %d.\n", size, fileSize);
-
- int count = fileSize / size;
- int offset = 0;
-
- for (int i = 0; i < count; i++)
- {
- int data = ExtractData(buffer, offset, size);
- offset += size;
-
- if (isSigned)
- std::printf("%d,", data);
- else
- std::printf("%uu,", data);
- }
-
- SkipWhitespace();
-
- if (m_buffer[m_pos] != ',')
- break;
-
- m_pos++;
- }
-
- if (m_buffer[m_pos] != ')')
- RaiseError("expected ')'");
-
- m_pos++;
-
- std::printf("}");
-}
-
-// Reports a diagnostic message.
-void CFile::ReportDiagnostic(const char* type, const char* format, std::va_list args)
-{
- const int bufferSize = 1024;
- char buffer[bufferSize];
- std::vsnprintf(buffer, bufferSize, format, args);
- std::fprintf(stderr, "%s:%ld: %s: %s\n", m_filename.c_str(), m_lineNum, type, buffer);
-}
-
-#define DO_REPORT(type) \
-do \
-{ \
- std::va_list args; \
- va_start(args, format); \
- ReportDiagnostic(type, format, args); \
- va_end(args); \
-} while (0)
-
-// Reports an error diagnostic and terminates the program.
-void CFile::RaiseError(const char* format, ...)
-{
- DO_REPORT("error");
- std::exit(1);
-}
-
-// Reports a warning diagnostic.
-void CFile::RaiseWarning(const char* format, ...)
-{
- DO_REPORT("warning");
-}
+// Copyright(c) 2016 YamaArashi
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#include <cstdio>
+#include <cstdarg>
+#include <stdexcept>
+#include <string>
+#include <memory>
+#include "preproc.h"
+#include "c_file.h"
+#include "char_util.h"
+#include "utf8.h"
+#include "string_parser.h"
+
+CFile::CFile(std::string filename) : m_filename(filename)
+{
+ FILE *fp = std::fopen(filename.c_str(), "rb");
+
+ if (fp == NULL)
+ FATAL_ERROR("Failed to open \"%s\" for reading.\n", filename.c_str());
+
+ std::fseek(fp, 0, SEEK_END);
+
+ m_size = std::ftell(fp);
+
+ if (m_size < 0)
+ FATAL_ERROR("File size of \"%s\" is less than zero.\n", filename.c_str());
+
+ m_buffer = new char[m_size + 1];
+
+ std::rewind(fp);
+
+ if (std::fread(m_buffer, m_size, 1, fp) != 1)
+ FATAL_ERROR("Failed to read \"%s\".\n", filename.c_str());
+
+ m_buffer[m_size] = 0;
+
+ std::fclose(fp);
+
+ m_pos = 0;
+ m_lineNum = 1;
+}
+
+CFile::CFile(CFile&& other) : m_filename(std::move(other.m_filename))
+{
+ m_buffer = other.m_buffer;
+ m_pos = other.m_pos;
+ m_size = other.m_size;
+ m_lineNum = other.m_lineNum;
+
+ other.m_buffer = nullptr;
+}
+
+CFile::~CFile()
+{
+ delete[] m_buffer;
+}
+
+void CFile::Preproc()
+{
+ char stringChar = 0;
+
+ while (m_pos < m_size)
+ {
+ if (stringChar)
+ {
+ if (m_buffer[m_pos] == stringChar)
+ {
+ std::putchar(stringChar);
+ m_pos++;
+ stringChar = 0;
+ }
+ else if (m_buffer[m_pos] == '\\' && m_buffer[m_pos + 1] == stringChar)
+ {
+ std::putchar('\\');
+ std::putchar(stringChar);
+ m_pos += 2;
+ }
+ else
+ {
+ if (m_buffer[m_pos] == '\n')
+ m_lineNum++;
+ std::putchar(m_buffer[m_pos]);
+ m_pos++;
+ }
+ }
+ else
+ {
+ TryConvertString();
+ TryConvertIncbin();
+
+ if (m_pos >= m_size)
+ break;
+
+ char c = m_buffer[m_pos++];
+
+ std::putchar(c);
+
+ if (c == '\n')
+ m_lineNum++;
+ else if (c == '"')
+ stringChar = '"';
+ else if (c == '\'')
+ stringChar = '\'';
+ }
+ }
+}
+
+bool CFile::ConsumeHorizontalWhitespace()
+{
+ if (m_buffer[m_pos] == '\t' || m_buffer[m_pos] == ' ')
+ {
+ m_pos++;
+ return true;
+ }
+
+ return false;
+}
+
+bool CFile::ConsumeNewline()
+{
+ if (m_buffer[m_pos] == '\r' && m_buffer[m_pos + 1] == '\n')
+ {
+ m_pos += 2;
+ m_lineNum++;
+ std::putchar('\n');
+ return true;
+ }
+
+ if (m_buffer[m_pos] == '\n')
+ {
+ m_pos++;
+ m_lineNum++;
+ std::putchar('\n');
+ return true;
+ }
+
+ return false;
+}
+
+void CFile::SkipWhitespace()
+{
+ while (ConsumeHorizontalWhitespace() || ConsumeNewline())
+ ;
+}
+
+void CFile::TryConvertString()
+{
+ long oldPos = m_pos;
+ long oldLineNum = m_lineNum;
+ bool noTerminator = false;
+
+ if (m_buffer[m_pos] != '_' || (m_pos > 0 && IsIdentifierChar(m_buffer[m_pos - 1])))
+ return;
+
+ m_pos++;
+
+ if (m_buffer[m_pos] == '_')
+ {
+ noTerminator = true;
+ m_pos++;
+ }
+
+ SkipWhitespace();
+
+ if (m_buffer[m_pos] != '(')
+ {
+ m_pos = oldPos;
+ m_lineNum = oldLineNum;
+ return;
+ }
+
+ m_pos++;
+
+ SkipWhitespace();
+
+ std::printf("{ ");
+
+ while (1)
+ {
+ SkipWhitespace();
+
+ if (m_buffer[m_pos] == '"')
+ {
+ unsigned char s[kMaxStringLength];
+ int length;
+ StringParser stringParser(m_buffer, m_size);
+
+ try
+ {
+ m_pos += stringParser.ParseString(m_pos, s, length);
+ }
+ catch (std::runtime_error& e)
+ {
+ RaiseError(e.what());
+ }
+
+ for (int i = 0; i < length; i++)
+ printf("0x%02X, ", s[i]);
+ }
+ else if (m_buffer[m_pos] == ')')
+ {
+ m_pos++;
+ break;
+ }
+ else
+ {
+ if (m_pos >= m_size)
+ RaiseError("unexpected EOF");
+ if (IsAsciiPrintable(m_buffer[m_pos]))
+ RaiseError("unexpected character '%c'", m_buffer[m_pos]);
+ else
+ RaiseError("unexpected character '\\x%02X'", m_buffer[m_pos]);
+ }
+ }
+
+ if (noTerminator)
+ std::printf(" }");
+ else
+ std::printf("0x00 }");
+}
+
+bool CFile::CheckIdentifier(const std::string& ident)
+{
+ unsigned int i;
+
+ for (i = 0; i < ident.length() && m_pos + i < (unsigned)m_size; i++)
+ if (ident[i] != m_buffer[m_pos + i])
+ return false;
+
+ return (i == ident.length());
+}
+
+std::unique_ptr<unsigned char[]> CFile::ReadWholeFile(const std::string& path, int& size)
+{
+ FILE* fp = std::fopen(path.c_str(), "rb");
+
+ if (fp == nullptr)
+ RaiseError("Failed to open \"%s\" for reading.\n", path.c_str());
+
+ std::fseek(fp, 0, SEEK_END);
+
+ size = std::ftell(fp);
+
+ std::unique_ptr<unsigned char[]> buffer = std::unique_ptr<unsigned char[]>(new unsigned char[size]);
+
+ std::rewind(fp);
+
+ if (std::fread(buffer.get(), size, 1, fp) != 1)
+ RaiseError("Failed to read \"%s\".\n", path.c_str());
+
+ std::fclose(fp);
+
+ return buffer;
+}
+
+int ExtractData(const std::unique_ptr<unsigned char[]>& buffer, int offset, int size)
+{
+ switch (size)
+ {
+ case 1:
+ return buffer[offset];
+ case 2:
+ return (buffer[offset + 1] << 8)
+ | buffer[offset];
+ case 4:
+ return (buffer[offset + 3] << 24)
+ | (buffer[offset + 2] << 16)
+ | (buffer[offset + 1] << 8)
+ | buffer[offset];
+ default:
+ FATAL_ERROR("Invalid size passed to ExtractData.\n");
+ }
+}
+
+void CFile::TryConvertIncbin()
+{
+ std::string idents[6] = { "INCBIN_S8", "INCBIN_U8", "INCBIN_S16", "INCBIN_U16", "INCBIN_S32", "INCBIN_U32" };
+ int incbinType = -1;
+
+ for (int i = 0; i < 6; i++)
+ {
+ if (CheckIdentifier(idents[i]))
+ {
+ incbinType = i;
+ break;
+ }
+ }
+
+ if (incbinType == -1)
+ return;
+
+ int size = 1 << (incbinType / 2);
+ bool isSigned = ((incbinType % 2) == 0);
+
+ long oldPos = m_pos;
+ long oldLineNum = m_lineNum;
+
+ m_pos += idents[incbinType].length();
+
+ SkipWhitespace();
+
+ if (m_buffer[m_pos] != '(')
+ {
+ m_pos = oldPos;
+ m_lineNum = oldLineNum;
+ return;
+ }
+
+ m_pos++;
+
+ std::printf("{");
+
+ while (true)
+ {
+ SkipWhitespace();
+
+ if (m_buffer[m_pos] != '"')
+ RaiseError("expected double quote");
+
+ m_pos++;
+
+ int startPos = m_pos;
+
+ while (m_buffer[m_pos] != '"')
+ {
+ if (m_buffer[m_pos] == 0)
+ {
+ if (m_pos >= m_size)
+ RaiseError("unexpected EOF in path string");
+ else
+ RaiseError("unexpected null character in path string");
+ }
+
+ if (m_buffer[m_pos] == '\r' || m_buffer[m_pos] == '\n')
+ RaiseError("unexpected end of line character in path string");
+
+ if (m_buffer[m_pos] == '\\')
+ RaiseError("unexpected escape in path string");
+
+ m_pos++;
+ }
+
+ std::string path(&m_buffer[startPos], m_pos - startPos);
+
+ m_pos++;
+
+ int fileSize;
+ std::unique_ptr<unsigned char[]> buffer = ReadWholeFile(path, fileSize);
+
+ if ((fileSize % size) != 0)
+ RaiseError("Size %d doesn't evenly divide file size %d.\n", size, fileSize);
+
+ int count = fileSize / size;
+ int offset = 0;
+
+ for (int i = 0; i < count; i++)
+ {
+ int data = ExtractData(buffer, offset, size);
+ offset += size;
+
+ if (isSigned)
+ std::printf("%d,", data);
+ else
+ std::printf("%uu,", data);
+ }
+
+ SkipWhitespace();
+
+ if (m_buffer[m_pos] != ',')
+ break;
+
+ m_pos++;
+ }
+
+ if (m_buffer[m_pos] != ')')
+ RaiseError("expected ')'");
+
+ m_pos++;
+
+ std::printf("}");
+}
+
+// Reports a diagnostic message.
+void CFile::ReportDiagnostic(const char* type, const char* format, std::va_list args)
+{
+ const int bufferSize = 1024;
+ char buffer[bufferSize];
+ std::vsnprintf(buffer, bufferSize, format, args);
+ std::fprintf(stderr, "%s:%ld: %s: %s\n", m_filename.c_str(), m_lineNum, type, buffer);
+}
+
+#define DO_REPORT(type) \
+do \
+{ \
+ std::va_list args; \
+ va_start(args, format); \
+ ReportDiagnostic(type, format, args); \
+ va_end(args); \
+} while (0)
+
+// Reports an error diagnostic and terminates the program.
+void CFile::RaiseError(const char* format, ...)
+{
+ DO_REPORT("error");
+ std::exit(1);
+}
+
+// Reports a warning diagnostic.
+void CFile::RaiseWarning(const char* format, ...)
+{
+ DO_REPORT("warning");
+}
diff --git a/tools/preproc/charmap.cpp b/tools/preproc/charmap.cpp
index 55366bc..a7bedfe 100644
--- a/tools/preproc/charmap.cpp
+++ b/tools/preproc/charmap.cpp
@@ -1,408 +1,408 @@
-// Copyright(c) 2016 YamaArashi
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#include <cstdio>
-#include <cstdint>
-#include <cstdarg>
-#include "preproc.h"
-#include "charmap.h"
-#include "char_util.h"
-#include "utf8.h"
-
-enum LhsType
-{
- Char,
- Escape,
- Constant,
- None
-};
-
-struct Lhs
-{
- LhsType type;
- std::string name;
- std::int32_t code;
-};
-
-class CharmapReader
-{
-public:
- CharmapReader(std::string filename);
- CharmapReader(const CharmapReader&) = delete;
- ~CharmapReader();
- Lhs ReadLhs();
- void ExpectEqualsSign();
- std::string ReadSequence();
- void ExpectEmptyRestOfLine();
- void RaiseError(const char* format, ...);
-
-private:
- char* m_buffer;
- long m_pos;
- long m_size;
- long m_lineNum;
- std::string m_filename;
-
- void RemoveComments();
- std::string ReadConstant();
- void SkipWhitespace();
-};
-
-CharmapReader::CharmapReader(std::string filename) : m_filename(filename)
-{
- FILE *fp = std::fopen(filename.c_str(), "rb");
-
- if (fp == NULL)
- FATAL_ERROR("Failed to open \"%s\" for reading.\n", filename.c_str());
-
- std::fseek(fp, 0, SEEK_END);
-
- m_size = std::ftell(fp);
-
- if (m_size < 0)
- FATAL_ERROR("File size of \"%s\" is less than zero.\n", filename.c_str());
-
- m_buffer = new char[m_size + 1];
-
- std::rewind(fp);
-
- if (std::fread(m_buffer, m_size, 1, fp) != 1)
- FATAL_ERROR("Failed to read \"%s\".\n", filename.c_str());
-
- m_buffer[m_size] = 0;
-
- std::fclose(fp);
-
- m_pos = 0;
- m_lineNum = 1;
-
- RemoveComments();
-}
-
-CharmapReader::~CharmapReader()
-{
- delete[] m_buffer;
-}
-
-Lhs CharmapReader::ReadLhs()
-{
- Lhs lhs;
-
- for (;;)
- {
- SkipWhitespace();
-
- if (m_buffer[m_pos] == '\n')
- {
- m_pos++;
- m_lineNum++;
- }
- else
- {
- break;
- }
- }
-
- if (m_buffer[m_pos] == '\'')
- {
- m_pos++;
-
- bool isEscape = (m_buffer[m_pos] == '\\');
-
- if (isEscape)
- {
- m_pos++;
- }
-
- unsigned char c = m_buffer[m_pos];
-
- if (c == 0)
- {
- if (m_pos >= m_size)
- RaiseError("unexpected EOF in UTF-8 character literal");
- else
- RaiseError("unexpected null character in UTF-8 character literal");
- }
-
- if (IsAscii(c) && !IsAsciiPrintable(c))
- RaiseError("unexpected character U+%X in UTF-8 character literal", c);
-
- UnicodeChar unicodeChar = DecodeUtf8(&m_buffer[m_pos]);
- std::int32_t code = unicodeChar.code;
-
- if (code == -1)
- RaiseError("invalid encoding in UTF-8 character literal");
-
- m_pos += unicodeChar.encodingLength;
-
- if (m_buffer[m_pos] != '\'')
- RaiseError("unterminated character literal");
-
- m_pos++;
-
- lhs.code = code;
-
- if (isEscape)
- {
- if (code >= 128)
- RaiseError("escapes using non-ASCII characters are invalid");
-
- switch (code)
- {
- case '\'':
- lhs.type = LhsType::Char;
- break;
- case '\\':
- lhs.type = LhsType::Char;
- case '"':
- RaiseError("cannot escape double quote");
- break;
- default:
- lhs.type = LhsType::Escape;
- }
- }
- else
- {
- if (code == '\'')
- RaiseError("empty character literal");
-
- lhs.type = LhsType::Char;
- }
- }
- else if (IsIdentifierStartingChar(m_buffer[m_pos]))
- {
- lhs.type = LhsType::Constant;
- lhs.name = ReadConstant();
- }
- else if (m_buffer[m_pos] == '\r')
- {
- RaiseError("only Unix-style LF newlines are supported");
- }
- else if (m_buffer[m_pos] == 0)
- {
- if (m_pos < m_size)
- RaiseError("unexpected null character");
- lhs.type = LhsType::None;
- }
- else
- {
- RaiseError("junk at start of line");
- }
-
- return lhs;
-}
-
-void CharmapReader::ExpectEqualsSign()
-{
- SkipWhitespace();
-
- if (m_buffer[m_pos] != '=')
- RaiseError("expected equals sign");
-
- m_pos++;
-}
-
-static unsigned int ConvertHexDigit(char c)
-{
- unsigned int digit = 0;
-
- if (c >= '0' && c <= '9')
- digit = c - '0';
- else if (c >= 'A' && c <= 'F')
- digit = 10 + c - 'A';
- else if (c >= 'a' && c <= 'f')
- digit = 10 + c - 'a';
-
- return digit;
-}
-
-std::string CharmapReader::ReadSequence()
-{
- SkipWhitespace();
-
- long startPos = m_pos;
-
- unsigned int length = 0;
-
- while (IsAsciiHexDigit(m_buffer[m_pos]) && IsAsciiHexDigit(m_buffer[m_pos + 1]))
- {
- m_pos += 2;
- length++;
-
- if (length > kMaxCharmapSequenceLength)
- RaiseError("byte sequence too long (max is %lu bytes)", kMaxCharmapSequenceLength);
-
- SkipWhitespace();
- }
-
- if (IsAsciiHexDigit(m_buffer[m_pos]))
- RaiseError("each byte must have 2 hex digits");
-
- if (length == 0)
- RaiseError("expected byte sequence");
-
- std::string sequence;
- sequence.reserve(length);
-
- m_pos = startPos;
-
- for (unsigned int i = 0; i < length; i++)
- {
- unsigned int digit1 = ConvertHexDigit(m_buffer[m_pos]);
- unsigned int digit2 = ConvertHexDigit(m_buffer[m_pos + 1]);
- unsigned char byte = digit1 * 16 + digit2;
- sequence += byte;
-
- m_pos += 2;
- SkipWhitespace();
- }
-
- return sequence;
-}
-
-void CharmapReader::ExpectEmptyRestOfLine()
-{
- SkipWhitespace();
-
- if (m_buffer[m_pos] == 0)
- {
- if (m_pos < m_size)
- RaiseError("unexpected null character");
- }
- else if (m_buffer[m_pos] == '\n')
- {
- m_pos++;
- m_lineNum++;
- }
- else if (m_buffer[m_pos] == '\r')
- {
- RaiseError("only Unix-style LF newlines are supported");
- }
- else
- {
- RaiseError("junk at end of line");
- }
-}
-
-void CharmapReader::RaiseError(const char* format, ...)
-{
- const int bufferSize = 1024;
- char buffer[bufferSize];
-
- std::va_list args;
- va_start(args, format);
- std::vsnprintf(buffer, bufferSize, format, args);
- va_end(args);
-
- std::fprintf(stderr, "%s:%ld: error: %s\n", m_filename.c_str(), m_lineNum, buffer);
-
- std::exit(1);
-}
-
-void CharmapReader::RemoveComments()
-{
- long pos = 0;
- bool inString = false;
-
- for (;;)
- {
- if (m_buffer[pos] == 0)
- return;
-
- if (inString)
- {
- if (m_buffer[pos] == '\\' && m_buffer[pos + 1] == '\'')
- {
- pos += 2;
- }
- else
- {
- if (m_buffer[pos] == '\'')
- inString = false;
- pos++;
- }
- }
- else if (m_buffer[pos] == '@')
- {
- while (m_buffer[pos] != '\n' && m_buffer[pos] != 0)
- m_buffer[pos++] = ' ';
- }
- else
- {
- if (m_buffer[pos] == '\'')
- inString = true;
- pos++;
- }
- }
-}
-
-std::string CharmapReader::ReadConstant()
-{
- long startPos = m_pos;
-
- while (IsIdentifierChar(m_buffer[m_pos]))
- m_pos++;
-
- return std::string(&m_buffer[startPos], m_pos - startPos);
-}
-
-void CharmapReader::SkipWhitespace()
-{
- while (m_buffer[m_pos] == '\t' || m_buffer[m_pos] == ' ')
- m_pos++;
-}
-
-Charmap::Charmap(std::string filename)
-{
- CharmapReader reader(filename);
-
- for (;;)
- {
- Lhs lhs = reader.ReadLhs();
-
- if (lhs.type == LhsType::None)
- return;
-
- reader.ExpectEqualsSign();
-
- std::string sequence = reader.ReadSequence();
-
- switch (lhs.type)
- {
- case LhsType::Char:
- if (m_chars.find(lhs.code) != m_chars.end())
- reader.RaiseError("redefining char");
- m_chars[lhs.code] = sequence;
- break;
- case LhsType::Escape:
- if (m_escapes[lhs.code].length() != 0)
- reader.RaiseError("redefining escape");
- m_escapes[lhs.code] = sequence;
- break;
- case LhsType::Constant:
- if (m_constants.find(lhs.name) != m_constants.end())
- reader.RaiseError("redefining constant");
- m_constants[lhs.name] = sequence;
- break;
- }
-
- reader.ExpectEmptyRestOfLine();
- }
-}
+// Copyright(c) 2016 YamaArashi
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#include <cstdio>
+#include <cstdint>
+#include <cstdarg>
+#include "preproc.h"
+#include "charmap.h"
+#include "char_util.h"
+#include "utf8.h"
+
+enum LhsType
+{
+ Char,
+ Escape,
+ Constant,
+ None
+};
+
+struct Lhs
+{
+ LhsType type;
+ std::string name;
+ std::int32_t code;
+};
+
+class CharmapReader
+{
+public:
+ CharmapReader(std::string filename);
+ CharmapReader(const CharmapReader&) = delete;
+ ~CharmapReader();
+ Lhs ReadLhs();
+ void ExpectEqualsSign();
+ std::string ReadSequence();
+ void ExpectEmptyRestOfLine();
+ void RaiseError(const char* format, ...);
+
+private:
+ char* m_buffer;
+ long m_pos;
+ long m_size;
+ long m_lineNum;
+ std::string m_filename;
+
+ void RemoveComments();
+ std::string ReadConstant();
+ void SkipWhitespace();
+};
+
+CharmapReader::CharmapReader(std::string filename) : m_filename(filename)
+{
+ FILE *fp = std::fopen(filename.c_str(), "rb");
+
+ if (fp == NULL)
+ FATAL_ERROR("Failed to open \"%s\" for reading.\n", filename.c_str());
+
+ std::fseek(fp, 0, SEEK_END);
+
+ m_size = std::ftell(fp);
+
+ if (m_size < 0)
+ FATAL_ERROR("File size of \"%s\" is less than zero.\n", filename.c_str());
+
+ m_buffer = new char[m_size + 1];
+
+ std::rewind(fp);
+
+ if (std::fread(m_buffer, m_size, 1, fp) != 1)
+ FATAL_ERROR("Failed to read \"%s\".\n", filename.c_str());
+
+ m_buffer[m_size] = 0;
+
+ std::fclose(fp);
+
+ m_pos = 0;
+ m_lineNum = 1;
+
+ RemoveComments();
+}
+
+CharmapReader::~CharmapReader()
+{
+ delete[] m_buffer;
+}
+
+Lhs CharmapReader::ReadLhs()
+{
+ Lhs lhs;
+
+ for (;;)
+ {
+ SkipWhitespace();
+
+ if (m_buffer[m_pos] == '\n')
+ {
+ m_pos++;
+ m_lineNum++;
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ if (m_buffer[m_pos] == '\'')
+ {
+ m_pos++;
+
+ bool isEscape = (m_buffer[m_pos] == '\\');
+
+ if (isEscape)
+ {
+ m_pos++;
+ }
+
+ unsigned char c = m_buffer[m_pos];
+
+ if (c == 0)
+ {
+ if (m_pos >= m_size)
+ RaiseError("unexpected EOF in UTF-8 character literal");
+ else
+ RaiseError("unexpected null character in UTF-8 character literal");
+ }
+
+ if (IsAscii(c) && !IsAsciiPrintable(c))
+ RaiseError("unexpected character U+%X in UTF-8 character literal", c);
+
+ UnicodeChar unicodeChar = DecodeUtf8(&m_buffer[m_pos]);
+ std::int32_t code = unicodeChar.code;
+
+ if (code == -1)
+ RaiseError("invalid encoding in UTF-8 character literal");
+
+ m_pos += unicodeChar.encodingLength;
+
+ if (m_buffer[m_pos] != '\'')
+ RaiseError("unterminated character literal");
+
+ m_pos++;
+
+ lhs.code = code;
+
+ if (isEscape)
+ {
+ if (code >= 128)
+ RaiseError("escapes using non-ASCII characters are invalid");
+
+ switch (code)
+ {
+ case '\'':
+ lhs.type = LhsType::Char;
+ break;
+ case '\\':
+ lhs.type = LhsType::Char;
+ case '"':
+ RaiseError("cannot escape double quote");
+ break;
+ default:
+ lhs.type = LhsType::Escape;
+ }
+ }
+ else
+ {
+ if (code == '\'')
+ RaiseError("empty character literal");
+
+ lhs.type = LhsType::Char;
+ }
+ }
+ else if (IsIdentifierStartingChar(m_buffer[m_pos]))
+ {
+ lhs.type = LhsType::Constant;
+ lhs.name = ReadConstant();
+ }
+ else if (m_buffer[m_pos] == '\r')
+ {
+ RaiseError("only Unix-style LF newlines are supported");
+ }
+ else if (m_buffer[m_pos] == 0)
+ {
+ if (m_pos < m_size)
+ RaiseError("unexpected null character");
+ lhs.type = LhsType::None;
+ }
+ else
+ {
+ RaiseError("junk at start of line");
+ }
+
+ return lhs;
+}
+
+void CharmapReader::ExpectEqualsSign()
+{
+ SkipWhitespace();
+
+ if (m_buffer[m_pos] != '=')
+ RaiseError("expected equals sign");
+
+ m_pos++;
+}
+
+static unsigned int ConvertHexDigit(char c)
+{
+ unsigned int digit = 0;
+
+ if (c >= '0' && c <= '9')
+ digit = c - '0';
+ else if (c >= 'A' && c <= 'F')
+ digit = 10 + c - 'A';
+ else if (c >= 'a' && c <= 'f')
+ digit = 10 + c - 'a';
+
+ return digit;
+}
+
+std::string CharmapReader::ReadSequence()
+{
+ SkipWhitespace();
+
+ long startPos = m_pos;
+
+ unsigned int length = 0;
+
+ while (IsAsciiHexDigit(m_buffer[m_pos]) && IsAsciiHexDigit(m_buffer[m_pos + 1]))
+ {
+ m_pos += 2;
+ length++;
+
+ if (length > kMaxCharmapSequenceLength)
+ RaiseError("byte sequence too long (max is %lu bytes)", kMaxCharmapSequenceLength);
+
+ SkipWhitespace();
+ }
+
+ if (IsAsciiHexDigit(m_buffer[m_pos]))
+ RaiseError("each byte must have 2 hex digits");
+
+ if (length == 0)
+ RaiseError("expected byte sequence");
+
+ std::string sequence;
+ sequence.reserve(length);
+
+ m_pos = startPos;
+
+ for (unsigned int i = 0; i < length; i++)
+ {
+ unsigned int digit1 = ConvertHexDigit(m_buffer[m_pos]);
+ unsigned int digit2 = ConvertHexDigit(m_buffer[m_pos + 1]);
+ unsigned char byte = digit1 * 16 + digit2;
+ sequence += byte;
+
+ m_pos += 2;
+ SkipWhitespace();
+ }
+
+ return sequence;
+}
+
+void CharmapReader::ExpectEmptyRestOfLine()
+{
+ SkipWhitespace();
+
+ if (m_buffer[m_pos] == 0)
+ {
+ if (m_pos < m_size)
+ RaiseError("unexpected null character");
+ }
+ else if (m_buffer[m_pos] == '\n')
+ {
+ m_pos++;
+ m_lineNum++;
+ }
+ else if (m_buffer[m_pos] == '\r')
+ {
+ RaiseError("only Unix-style LF newlines are supported");
+ }
+ else
+ {
+ RaiseError("junk at end of line");
+ }
+}
+
+void CharmapReader::RaiseError(const char* format, ...)
+{
+ const int bufferSize = 1024;
+ char buffer[bufferSize];
+
+ std::va_list args;
+ va_start(args, format);
+ std::vsnprintf(buffer, bufferSize, format, args);
+ va_end(args);
+
+ std::fprintf(stderr, "%s:%ld: error: %s\n", m_filename.c_str(), m_lineNum, buffer);
+
+ std::exit(1);
+}
+
+void CharmapReader::RemoveComments()
+{
+ long pos = 0;
+ bool inString = false;
+
+ for (;;)
+ {
+ if (m_buffer[pos] == 0)
+ return;
+
+ if (inString)
+ {
+ if (m_buffer[pos] == '\\' && m_buffer[pos + 1] == '\'')
+ {
+ pos += 2;
+ }
+ else
+ {
+ if (m_buffer[pos] == '\'')
+ inString = false;
+ pos++;
+ }
+ }
+ else if (m_buffer[pos] == '@')
+ {
+ while (m_buffer[pos] != '\n' && m_buffer[pos] != 0)
+ m_buffer[pos++] = ' ';
+ }
+ else
+ {
+ if (m_buffer[pos] == '\'')
+ inString = true;
+ pos++;
+ }
+ }
+}
+
+std::string CharmapReader::ReadConstant()
+{
+ long startPos = m_pos;
+
+ while (IsIdentifierChar(m_buffer[m_pos]))
+ m_pos++;
+
+ return std::string(&m_buffer[startPos], m_pos - startPos);
+}
+
+void CharmapReader::SkipWhitespace()
+{
+ while (m_buffer[m_pos] == '\t' || m_buffer[m_pos] == ' ')
+ m_pos++;
+}
+
+Charmap::Charmap(std::string filename)
+{
+ CharmapReader reader(filename);
+
+ for (;;)
+ {
+ Lhs lhs = reader.ReadLhs();
+
+ if (lhs.type == LhsType::None)
+ return;
+
+ reader.ExpectEqualsSign();
+
+ std::string sequence = reader.ReadSequence();
+
+ switch (lhs.type)
+ {
+ case LhsType::Char:
+ if (m_chars.find(lhs.code) != m_chars.end())
+ reader.RaiseError("redefining char");
+ m_chars[lhs.code] = sequence;
+ break;
+ case LhsType::Escape:
+ if (m_escapes[lhs.code].length() != 0)
+ reader.RaiseError("redefining escape");
+ m_escapes[lhs.code] = sequence;
+ break;
+ case LhsType::Constant:
+ if (m_constants.find(lhs.name) != m_constants.end())
+ reader.RaiseError("redefining constant");
+ m_constants[lhs.name] = sequence;
+ break;
+ }
+
+ reader.ExpectEmptyRestOfLine();
+ }
+}
diff --git a/tools/preproc/preproc.cpp b/tools/preproc/preproc.cpp
index 41856f7..c9c6042 100644
--- a/tools/preproc/preproc.cpp
+++ b/tools/preproc/preproc.cpp
@@ -1,156 +1,156 @@
-// Copyright(c) 2016 YamaArashi
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#include <string>
-#include <stack>
-#include "preproc.h"
-#include "asm_file.h"
-#include "c_file.h"
-#include "charmap.h"
-
-Charmap* g_charmap;
-
-void PrintAsmBytes(unsigned char *s, int length)
-{
- if (length > 0)
- {
- std::printf("\t.byte ");
- for (int i = 0; i < length; i++)
- {
- std::printf("0x%02X", s[i]);
-
- if (i < length - 1)
- std::printf(", ");
- }
- std::putchar('\n');
- }
-}
-
-void PreprocAsmFile(std::string filename)
-{
- std::stack<AsmFile> stack;
-
- stack.push(AsmFile(filename));
-
- for (;;)
- {
- while (stack.top().IsAtEnd())
- {
- stack.pop();
-
- if (stack.empty())
- return;
- else
- stack.top().OutputLocation();
- }
-
- Directive directive = stack.top().GetDirective();
-
- switch (directive)
- {
- case Directive::Include:
- stack.push(AsmFile(stack.top().ReadPath()));
- stack.top().OutputLocation();
- break;
- case Directive::String:
- {
- unsigned char s[kMaxStringLength];
- int length = stack.top().ReadString(s);
- PrintAsmBytes(s, length);
- break;
- }
- case Directive::Braille:
- {
- unsigned char s[kMaxStringLength];
- int length = stack.top().ReadBraille(s);
- PrintAsmBytes(s, length);
- break;
- }
- case Directive::Unknown:
- {
- std::string globalLabel = stack.top().GetGlobalLabel();
-
- if (globalLabel.length() != 0)
- {
- const char *s = globalLabel.c_str();
- std::printf("%s: ; .global %s\n", s, s);
- }
- else
- {
- stack.top().OutputLine();
- }
-
- break;
- }
- }
- }
-}
-
-void PreprocCFile(std::string filename)
-{
- CFile cFile(filename);
- cFile.Preproc();
-}
-
-char* GetFileExtension(char* filename)
-{
- char* extension = filename;
-
- while (*extension != 0)
- extension++;
-
- while (extension > filename && *extension != '.')
- extension--;
-
- if (extension == filename)
- return nullptr;
-
- extension++;
-
- if (*extension == 0)
- return nullptr;
-
- return extension;
-}
-
-int main(int argc, char **argv)
-{
- if (argc != 3)
- {
- std::fprintf(stderr, "Usage: %s SRC_FILE CHARMAP_FILE", argv[0]);
- return 1;
- }
-
- g_charmap = new Charmap(argv[2]);
-
- char* extension = GetFileExtension(argv[1]);
-
- if (!extension)
- FATAL_ERROR("\"%s\" has no file extension.\n", argv[1]);
-
- if ((extension[0] == 's') && extension[1] == 0)
- PreprocAsmFile(argv[1]);
- else if ((extension[0] == 'c' || extension[0] == 'i') && extension[1] == 0)
- PreprocCFile(argv[1]);
- else
- FATAL_ERROR("\"%s\" has an unknown file extension of \"%s\".\n", argv[1], extension);
-
- return 0;
-}
+// Copyright(c) 2016 YamaArashi
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#include <string>
+#include <stack>
+#include "preproc.h"
+#include "asm_file.h"
+#include "c_file.h"
+#include "charmap.h"
+
+Charmap* g_charmap;
+
+void PrintAsmBytes(unsigned char *s, int length)
+{
+ if (length > 0)
+ {
+ std::printf("\t.byte ");
+ for (int i = 0; i < length; i++)
+ {
+ std::printf("0x%02X", s[i]);
+
+ if (i < length - 1)
+ std::printf(", ");
+ }
+ std::putchar('\n');
+ }
+}
+
+void PreprocAsmFile(std::string filename)
+{
+ std::stack<AsmFile> stack;
+
+ stack.push(AsmFile(filename));
+
+ for (;;)
+ {
+ while (stack.top().IsAtEnd())
+ {
+ stack.pop();
+
+ if (stack.empty())
+ return;
+ else
+ stack.top().OutputLocation();
+ }
+
+ Directive directive = stack.top().GetDirective();
+
+ switch (directive)
+ {
+ case Directive::Include:
+ stack.push(AsmFile(stack.top().ReadPath()));
+ stack.top().OutputLocation();
+ break;
+ case Directive::String:
+ {
+ unsigned char s[kMaxStringLength];
+ int length = stack.top().ReadString(s);
+ PrintAsmBytes(s, length);
+ break;
+ }
+ case Directive::Braille:
+ {
+ unsigned char s[kMaxStringLength];
+ int length = stack.top().ReadBraille(s);
+ PrintAsmBytes(s, length);
+ break;
+ }
+ case Directive::Unknown:
+ {
+ std::string globalLabel = stack.top().GetGlobalLabel();
+
+ if (globalLabel.length() != 0)
+ {
+ const char *s = globalLabel.c_str();
+ std::printf("%s: ; .global %s\n", s, s);
+ }
+ else
+ {
+ stack.top().OutputLine();
+ }
+
+ break;
+ }
+ }
+ }
+}
+
+void PreprocCFile(std::string filename)
+{
+ CFile cFile(filename);
+ cFile.Preproc();
+}
+
+char* GetFileExtension(char* filename)
+{
+ char* extension = filename;
+
+ while (*extension != 0)
+ extension++;
+
+ while (extension > filename && *extension != '.')
+ extension--;
+
+ if (extension == filename)
+ return nullptr;
+
+ extension++;
+
+ if (*extension == 0)
+ return nullptr;
+
+ return extension;
+}
+
+int main(int argc, char **argv)
+{
+ if (argc != 3)
+ {
+ std::fprintf(stderr, "Usage: %s SRC_FILE CHARMAP_FILE", argv[0]);
+ return 1;
+ }
+
+ g_charmap = new Charmap(argv[2]);
+
+ char* extension = GetFileExtension(argv[1]);
+
+ if (!extension)
+ FATAL_ERROR("\"%s\" has no file extension.\n", argv[1]);
+
+ if ((extension[0] == 's') && extension[1] == 0)
+ PreprocAsmFile(argv[1]);
+ else if ((extension[0] == 'c' || extension[0] == 'i') && extension[1] == 0)
+ PreprocCFile(argv[1]);
+ else
+ FATAL_ERROR("\"%s\" has an unknown file extension of \"%s\".\n", argv[1], extension);
+
+ return 0;
+}
diff --git a/tools/preproc/string_parser.cpp b/tools/preproc/string_parser.cpp
index b0a4875..dd5196a 100644
--- a/tools/preproc/string_parser.cpp
+++ b/tools/preproc/string_parser.cpp
@@ -1,355 +1,355 @@
-// Copyright(c) 2016 YamaArashi
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#include <cstdio>
-#include <cstdarg>
-#include <stdexcept>
-#include "preproc.h"
-#include "string_parser.h"
-#include "char_util.h"
-#include "utf8.h"
-
-// Reads a charmap char or escape sequence.
-std::string StringParser::ReadCharOrEscape()
-{
- std::string sequence;
-
- bool isEscape = (m_buffer[m_pos] == '\\');
-
- if (isEscape)
- {
- m_pos++;
-
- if (m_buffer[m_pos] == '"')
- {
- sequence = g_charmap->Char('"');
-
- if (sequence.length() == 0)
- RaiseError("no mapping exists for double quote");
-
- return sequence;
- }
- else if (m_buffer[m_pos] == '\\')
- {
- sequence = g_charmap->Char('\\');
-
- if (sequence.length() == 0)
- RaiseError("no mapping exists for backslash");
-
- return sequence;
- }
- }
-
- unsigned char c = m_buffer[m_pos];
-
- if (c == 0)
- {
- if (m_pos >= m_size)
- RaiseError("unexpected EOF in UTF-8 string");
- else
- RaiseError("unexpected null character in UTF-8 string");
- }
-
- if (IsAscii(c) && !IsAsciiPrintable(c))
- RaiseError("unexpected character U+%X in UTF-8 string", c);
-
- UnicodeChar unicodeChar = DecodeUtf8(&m_buffer[m_pos]);
- m_pos += unicodeChar.encodingLength;
- std::int32_t code = unicodeChar.code;
-
- if (code == -1)
- RaiseError("invalid encoding in UTF-8 string");
-
- if (isEscape && code >= 128)
- RaiseError("escapes using non-ASCII characters are invalid");
-
- sequence = isEscape ? g_charmap->Escape(code) : g_charmap->Char(code);
-
- if (sequence.length() == 0)
- {
- if (isEscape)
- RaiseError("unknown escape '\\%c'", code);
- else
- RaiseError("unknown character U+%X", code);
- }
-
- return sequence;
-}
-
-// Reads a charmap constant, i.e. "{FOO}".
-std::string StringParser::ReadBracketedConstants()
-{
- std::string totalSequence;
-
- m_pos++; // Assume we're on the left curly bracket.
-
- while (m_buffer[m_pos] != '}')
- {
- SkipWhitespace();
-
- if (IsIdentifierStartingChar(m_buffer[m_pos]))
- {
- long startPos = m_pos;
-
- m_pos++;
-
- while (IsIdentifierChar(m_buffer[m_pos]))
- m_pos++;
-
- std::string sequence = g_charmap->Constant(std::string(&m_buffer[startPos], m_pos - startPos));
-
- if (sequence.length() == 0)
- {
- m_buffer[m_pos] = 0;
- RaiseError("unknown constant '%s'", &m_buffer[startPos]);
- }
-
- totalSequence += sequence;
- }
- else if (IsAsciiDigit(m_buffer[m_pos]))
- {
- Integer integer = ReadInteger();
-
- switch (integer.size)
- {
- case 1:
- totalSequence += (unsigned char)integer.value;
- break;
- case 2:
- totalSequence += (unsigned char)integer.value;
- totalSequence += (unsigned char)(integer.value >> 8);
- break;
- case 4:
- totalSequence += (unsigned char)integer.value;
- totalSequence += (unsigned char)(integer.value >> 8);
- totalSequence += (unsigned char)(integer.value >> 16);
- totalSequence += (unsigned char)(integer.value >> 24);
- break;
- }
- }
- else if (m_buffer[m_pos] == 0)
- {
- if (m_pos >= m_size)
- RaiseError("unexpected EOF after left curly bracket");
- else
- RaiseError("unexpected null character within curly brackets");
- }
- else
- {
- if (IsAsciiPrintable(m_buffer[m_pos]))
- RaiseError("unexpected character '%c' within curly brackets", m_buffer[m_pos]);
- else
- RaiseError("unexpected character '\\x%02X' within curly brackets", m_buffer[m_pos]);
- }
- }
-
- m_pos++; // Go past the right curly bracket.
-
- return totalSequence;
-}
-
-// Reads a charmap string.
-int StringParser::ParseString(long srcPos, unsigned char* dest, int& destLength)
-{
- m_pos = srcPos;
-
- if (m_buffer[m_pos] != '"')
- RaiseError("expected UTF-8 string literal");
-
- long start = m_pos;
-
- m_pos++;
-
- destLength = 0;
-
- while (m_buffer[m_pos] != '"')
- {
- std::string sequence = (m_buffer[m_pos] == '{') ? ReadBracketedConstants() : ReadCharOrEscape();
-
- for (const char& c : sequence)
- {
- if (destLength == kMaxStringLength)
- RaiseError("mapped string longer than %d bytes", kMaxStringLength);
-
- dest[destLength++] = c;
- }
- }
-
- m_pos++; // Go past the right quote.
-
- return m_pos - start;
-}
-
-void StringParser::RaiseError(const char* format, ...)
-{
- const int bufferSize = 1024;
- char buffer[bufferSize];
-
- std::va_list args;
- va_start(args, format);
- std::vsnprintf(buffer, bufferSize, format, args);
- va_end(args);
-
- throw std::runtime_error(buffer);
-}
-
-// Converts digit character to numerical value.
-static int ConvertDigit(char c, int radix)
-{
- int digit;
-
- if (c >= '0' && c <= '9')
- digit = c - '0';
- else if (c >= 'A' && c <= 'F')
- digit = 10 + c - 'A';
- else if (c >= 'a' && c <= 'f')
- digit = 10 + c - 'a';
- else
- return -1;
-
- return (digit < radix) ? digit : -1;
-}
-
-void StringParser::SkipRestOfInteger(int radix)
-{
- while (ConvertDigit(m_buffer[m_pos], radix) != -1)
- m_pos++;
-}
-
-StringParser::Integer StringParser::ReadDecimal()
-{
- const int radix = 10;
- std::uint64_t n = 0;
- int digit;
- std::uint64_t max = UINT32_MAX;
- long startPos = m_pos;
-
- while ((digit = ConvertDigit(m_buffer[m_pos], radix)) != -1)
- {
- n = n * radix + digit;
-
- if (n >= max)
- {
- SkipRestOfInteger(radix);
-
- std::string intLiteral(m_buffer + startPos, m_pos - startPos);
- RaiseError("integer literal \"%s\" is too large", intLiteral.c_str());
- }
-
- m_pos++;
- }
-
- int size;
-
- if (m_buffer[m_pos] == 'H')
- {
- if (n >= 0x10000)
- {
- RaiseError("%lu is too large to be a halfword", (unsigned long)n);
- }
-
- size = 2;
- m_pos++;
- }
- else if (m_buffer[m_pos] == 'W')
- {
- size = 4;
- m_pos++;
- }
- else
- {
- if (n >= 0x10000)
- size = 4;
- else if (n >= 0x100)
- size = 2;
- else
- size = 1;
- }
-
- return{ static_cast<std::uint32_t>(n), size };
-}
-
-StringParser::Integer StringParser::ReadHex()
-{
- const int radix = 16;
- std::uint64_t n = 0;
- int digit;
- std::uint64_t max = UINT32_MAX;
- long startPos = m_pos;
-
- while ((digit = ConvertDigit(m_buffer[m_pos], radix)) != -1)
- {
- n = n * radix + digit;
-
- if (n >= max)
- {
- SkipRestOfInteger(radix);
-
- std::string intLiteral(m_buffer + startPos, m_pos - startPos);
- RaiseError("integer literal \"%s\" is too large", intLiteral.c_str());
- }
-
- m_pos++;
- }
-
- int length = m_pos - startPos;
- int size = 0;
-
- switch (length)
- {
- case 2:
- size = 1;
- break;
- case 4:
- size = 2;
- break;
- case 8:
- size = 4;
- break;
- default:
- {
- std::string intLiteral(m_buffer + startPos, m_pos - startPos);
- RaiseError("hex integer literal \"0x%s\" doesn't have length of 2, 4, or 8 digits", intLiteral.c_str());
- }
- }
-
- return{ static_cast<std::uint32_t>(n), size };
-}
-
-StringParser::Integer StringParser::ReadInteger()
-{
- if (!IsAsciiDigit(m_buffer[m_pos]))
- RaiseError("expected integer");
-
- if (m_buffer[m_pos] == '0' && m_buffer[m_pos + 1] == 'x')
- {
- m_pos += 2;
- return ReadHex();
- }
-
- return ReadDecimal();
-}
-
-// Skips tabs and spaces.
-void StringParser::SkipWhitespace()
-{
- while (m_buffer[m_pos] == '\t' || m_buffer[m_pos] == ' ')
- m_pos++;
-}
+// Copyright(c) 2016 YamaArashi
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#include <cstdio>
+#include <cstdarg>
+#include <stdexcept>
+#include "preproc.h"
+#include "string_parser.h"
+#include "char_util.h"
+#include "utf8.h"
+
+// Reads a charmap char or escape sequence.
+std::string StringParser::ReadCharOrEscape()
+{
+ std::string sequence;
+
+ bool isEscape = (m_buffer[m_pos] == '\\');
+
+ if (isEscape)
+ {
+ m_pos++;
+
+ if (m_buffer[m_pos] == '"')
+ {
+ sequence = g_charmap->Char('"');
+
+ if (sequence.length() == 0)
+ RaiseError("no mapping exists for double quote");
+
+ return sequence;
+ }
+ else if (m_buffer[m_pos] == '\\')
+ {
+ sequence = g_charmap->Char('\\');
+
+ if (sequence.length() == 0)
+ RaiseError("no mapping exists for backslash");
+
+ return sequence;
+ }
+ }
+
+ unsigned char c = m_buffer[m_pos];
+
+ if (c == 0)
+ {
+ if (m_pos >= m_size)
+ RaiseError("unexpected EOF in UTF-8 string");
+ else
+ RaiseError("unexpected null character in UTF-8 string");
+ }
+
+ if (IsAscii(c) && !IsAsciiPrintable(c))
+ RaiseError("unexpected character U+%X in UTF-8 string", c);
+
+ UnicodeChar unicodeChar = DecodeUtf8(&m_buffer[m_pos]);
+ m_pos += unicodeChar.encodingLength;
+ std::int32_t code = unicodeChar.code;
+
+ if (code == -1)
+ RaiseError("invalid encoding in UTF-8 string");
+
+ if (isEscape && code >= 128)
+ RaiseError("escapes using non-ASCII characters are invalid");
+
+ sequence = isEscape ? g_charmap->Escape(code) : g_charmap->Char(code);
+
+ if (sequence.length() == 0)
+ {
+ if (isEscape)
+ RaiseError("unknown escape '\\%c'", code);
+ else
+ RaiseError("unknown character U+%X", code);
+ }
+
+ return sequence;
+}
+
+// Reads a charmap constant, i.e. "{FOO}".
+std::string StringParser::ReadBracketedConstants()
+{
+ std::string totalSequence;
+
+ m_pos++; // Assume we're on the left curly bracket.
+
+ while (m_buffer[m_pos] != '}')
+ {
+ SkipWhitespace();
+
+ if (IsIdentifierStartingChar(m_buffer[m_pos]))
+ {
+ long startPos = m_pos;
+
+ m_pos++;
+
+ while (IsIdentifierChar(m_buffer[m_pos]))
+ m_pos++;
+
+ std::string sequence = g_charmap->Constant(std::string(&m_buffer[startPos], m_pos - startPos));
+
+ if (sequence.length() == 0)
+ {
+ m_buffer[m_pos] = 0;
+ RaiseError("unknown constant '%s'", &m_buffer[startPos]);
+ }
+
+ totalSequence += sequence;
+ }
+ else if (IsAsciiDigit(m_buffer[m_pos]))
+ {
+ Integer integer = ReadInteger();
+
+ switch (integer.size)
+ {
+ case 1:
+ totalSequence += (unsigned char)integer.value;
+ break;
+ case 2:
+ totalSequence += (unsigned char)integer.value;
+ totalSequence += (unsigned char)(integer.value >> 8);
+ break;
+ case 4:
+ totalSequence += (unsigned char)integer.value;
+ totalSequence += (unsigned char)(integer.value >> 8);
+ totalSequence += (unsigned char)(integer.value >> 16);
+ totalSequence += (unsigned char)(integer.value >> 24);
+ break;
+ }
+ }
+ else if (m_buffer[m_pos] == 0)
+ {
+ if (m_pos >= m_size)
+ RaiseError("unexpected EOF after left curly bracket");
+ else
+ RaiseError("unexpected null character within curly brackets");
+ }
+ else
+ {
+ if (IsAsciiPrintable(m_buffer[m_pos]))
+ RaiseError("unexpected character '%c' within curly brackets", m_buffer[m_pos]);
+ else
+ RaiseError("unexpected character '\\x%02X' within curly brackets", m_buffer[m_pos]);
+ }
+ }
+
+ m_pos++; // Go past the right curly bracket.
+
+ return totalSequence;
+}
+
+// Reads a charmap string.
+int StringParser::ParseString(long srcPos, unsigned char* dest, int& destLength)
+{
+ m_pos = srcPos;
+
+ if (m_buffer[m_pos] != '"')
+ RaiseError("expected UTF-8 string literal");
+
+ long start = m_pos;
+
+ m_pos++;
+
+ destLength = 0;
+
+ while (m_buffer[m_pos] != '"')
+ {
+ std::string sequence = (m_buffer[m_pos] == '{') ? ReadBracketedConstants() : ReadCharOrEscape();
+
+ for (const char& c : sequence)
+ {
+ if (destLength == kMaxStringLength)
+ RaiseError("mapped string longer than %d bytes", kMaxStringLength);
+
+ dest[destLength++] = c;
+ }
+ }
+
+ m_pos++; // Go past the right quote.
+
+ return m_pos - start;
+}
+
+void StringParser::RaiseError(const char* format, ...)
+{
+ const int bufferSize = 1024;
+ char buffer[bufferSize];
+
+ std::va_list args;
+ va_start(args, format);
+ std::vsnprintf(buffer, bufferSize, format, args);
+ va_end(args);
+
+ throw std::runtime_error(buffer);
+}
+
+// Converts digit character to numerical value.
+static int ConvertDigit(char c, int radix)
+{
+ int digit;
+
+ if (c >= '0' && c <= '9')
+ digit = c - '0';
+ else if (c >= 'A' && c <= 'F')
+ digit = 10 + c - 'A';
+ else if (c >= 'a' && c <= 'f')
+ digit = 10 + c - 'a';
+ else
+ return -1;
+
+ return (digit < radix) ? digit : -1;
+}
+
+void StringParser::SkipRestOfInteger(int radix)
+{
+ while (ConvertDigit(m_buffer[m_pos], radix) != -1)
+ m_pos++;
+}
+
+StringParser::Integer StringParser::ReadDecimal()
+{
+ const int radix = 10;
+ std::uint64_t n = 0;
+ int digit;
+ std::uint64_t max = UINT32_MAX;
+ long startPos = m_pos;
+
+ while ((digit = ConvertDigit(m_buffer[m_pos], radix)) != -1)
+ {
+ n = n * radix + digit;
+
+ if (n >= max)
+ {
+ SkipRestOfInteger(radix);
+
+ std::string intLiteral(m_buffer + startPos, m_pos - startPos);
+ RaiseError("integer literal \"%s\" is too large", intLiteral.c_str());
+ }
+
+ m_pos++;
+ }
+
+ int size;
+
+ if (m_buffer[m_pos] == 'H')
+ {
+ if (n >= 0x10000)
+ {
+ RaiseError("%lu is too large to be a halfword", (unsigned long)n);
+ }
+
+ size = 2;
+ m_pos++;
+ }
+ else if (m_buffer[m_pos] == 'W')
+ {
+ size = 4;
+ m_pos++;
+ }
+ else
+ {
+ if (n >= 0x10000)
+ size = 4;
+ else if (n >= 0x100)
+ size = 2;
+ else
+ size = 1;
+ }
+
+ return{ static_cast<std::uint32_t>(n), size };
+}
+
+StringParser::Integer StringParser::ReadHex()
+{
+ const int radix = 16;
+ std::uint64_t n = 0;
+ int digit;
+ std::uint64_t max = UINT32_MAX;
+ long startPos = m_pos;
+
+ while ((digit = ConvertDigit(m_buffer[m_pos], radix)) != -1)
+ {
+ n = n * radix + digit;
+
+ if (n >= max)
+ {
+ SkipRestOfInteger(radix);
+
+ std::string intLiteral(m_buffer + startPos, m_pos - startPos);
+ RaiseError("integer literal \"%s\" is too large", intLiteral.c_str());
+ }
+
+ m_pos++;
+ }
+
+ int length = m_pos - startPos;
+ int size = 0;
+
+ switch (length)
+ {
+ case 2:
+ size = 1;
+ break;
+ case 4:
+ size = 2;
+ break;
+ case 8:
+ size = 4;
+ break;
+ default:
+ {
+ std::string intLiteral(m_buffer + startPos, m_pos - startPos);
+ RaiseError("hex integer literal \"0x%s\" doesn't have length of 2, 4, or 8 digits", intLiteral.c_str());
+ }
+ }
+
+ return{ static_cast<std::uint32_t>(n), size };
+}
+
+StringParser::Integer StringParser::ReadInteger()
+{
+ if (!IsAsciiDigit(m_buffer[m_pos]))
+ RaiseError("expected integer");
+
+ if (m_buffer[m_pos] == '0' && m_buffer[m_pos + 1] == 'x')
+ {
+ m_pos += 2;
+ return ReadHex();
+ }
+
+ return ReadDecimal();
+}
+
+// Skips tabs and spaces.
+void StringParser::SkipWhitespace()
+{
+ while (m_buffer[m_pos] == '\t' || m_buffer[m_pos] == ' ')
+ m_pos++;
+}
diff --git a/tools/preproc/utf8.cpp b/tools/preproc/utf8.cpp
index 8ed10a1..7facfd4 100644
--- a/tools/preproc/utf8.cpp
+++ b/tools/preproc/utf8.cpp
@@ -1,92 +1,92 @@
-// Copyright (c) 2008-2009 Bjoern Hoehrmann <bjoern@hoehrmann.de>
-// See http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ for details.
-//
-// Copyright(c) 2016 YamaArashi
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#include <cstdint>
-#include "utf8.h"
-
-static const unsigned char s_byteTypeTable[] =
-{
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 00..1f
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 20..3f
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 40..5f
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 60..7f
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, // 80..9f
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, // a0..bf
- 8,8,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, // c0..df
- 0xa,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x4,0x3,0x3, // e0..ef
- 0xb,0x6,0x6,0x6,0x5,0x8,0x8,0x8,0x8,0x8,0x8,0x8,0x8,0x8,0x8,0x8, // f0..ff
-};
-
-const unsigned char s0 = 0 * 12;
-const unsigned char s1 = 1 * 12;
-const unsigned char s2 = 2 * 12;
-const unsigned char s3 = 3 * 12;
-const unsigned char s4 = 4 * 12;
-const unsigned char s5 = 5 * 12;
-const unsigned char s6 = 6 * 12;
-const unsigned char s7 = 7 * 12;
-const unsigned char s8 = 8 * 12;
-
-static const unsigned char s_transitionTable[] =
-{
- s0,s1,s2,s3,s5,s8,s7,s1,s1,s1,s4,s6, // s0
- s1,s1,s1,s1,s1,s1,s1,s1,s1,s1,s1,s1, // s1
- s1,s0,s1,s1,s1,s1,s1,s0,s1,s0,s1,s1, // s2
- s1,s2,s1,s1,s1,s1,s1,s2,s1,s2,s1,s1, // s3
- s1,s1,s1,s1,s1,s1,s1,s2,s1,s1,s1,s1, // s4
- s1,s2,s1,s1,s1,s1,s1,s1,s1,s2,s1,s1, // s5
- s1,s1,s1,s1,s1,s1,s1,s3,s1,s3,s1,s1, // s6
- s1,s3,s1,s1,s1,s1,s1,s3,s1,s3,s1,s1, // s7
- s1,s3,s1,s1,s1,s1,s1,s1,s1,s1,s1,s1, // s8
-};
-
-// Decodes UTF-8 encoded Unicode code point at "s".
-UnicodeChar DecodeUtf8(const char* s)
-{
- UnicodeChar unicodeChar;
- int state = s0;
- auto start = s;
-
- do
- {
- unsigned char byte = *s++;
- int type = s_byteTypeTable[byte];
-
- if (state == s0)
- unicodeChar.code = (0xFF >> type) & byte;
- else
- unicodeChar.code = (unicodeChar.code << 6) | (byte & 0x3F);
-
- state = s_transitionTable[state + type];
-
- if (state == s1)
- {
- unicodeChar.code = -1;
- return unicodeChar;
- }
- } while (state != s0);
-
- unicodeChar.encodingLength = s - start;
-
- return unicodeChar;
-}
+// Copyright (c) 2008-2009 Bjoern Hoehrmann <bjoern@hoehrmann.de>
+// See http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ for details.
+//
+// Copyright(c) 2016 YamaArashi
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#include <cstdint>
+#include "utf8.h"
+
+static const unsigned char s_byteTypeTable[] =
+{
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 00..1f
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 20..3f
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 40..5f
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 60..7f
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, // 80..9f
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, // a0..bf
+ 8,8,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, // c0..df
+ 0xa,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x4,0x3,0x3, // e0..ef
+ 0xb,0x6,0x6,0x6,0x5,0x8,0x8,0x8,0x8,0x8,0x8,0x8,0x8,0x8,0x8,0x8, // f0..ff
+};
+
+const unsigned char s0 = 0 * 12;
+const unsigned char s1 = 1 * 12;
+const unsigned char s2 = 2 * 12;
+const unsigned char s3 = 3 * 12;
+const unsigned char s4 = 4 * 12;
+const unsigned char s5 = 5 * 12;
+const unsigned char s6 = 6 * 12;
+const unsigned char s7 = 7 * 12;
+const unsigned char s8 = 8 * 12;
+
+static const unsigned char s_transitionTable[] =
+{
+ s0,s1,s2,s3,s5,s8,s7,s1,s1,s1,s4,s6, // s0
+ s1,s1,s1,s1,s1,s1,s1,s1,s1,s1,s1,s1, // s1
+ s1,s0,s1,s1,s1,s1,s1,s0,s1,s0,s1,s1, // s2
+ s1,s2,s1,s1,s1,s1,s1,s2,s1,s2,s1,s1, // s3
+ s1,s1,s1,s1,s1,s1,s1,s2,s1,s1,s1,s1, // s4
+ s1,s2,s1,s1,s1,s1,s1,s1,s1,s2,s1,s1, // s5
+ s1,s1,s1,s1,s1,s1,s1,s3,s1,s3,s1,s1, // s6
+ s1,s3,s1,s1,s1,s1,s1,s3,s1,s3,s1,s1, // s7
+ s1,s3,s1,s1,s1,s1,s1,s1,s1,s1,s1,s1, // s8
+};
+
+// Decodes UTF-8 encoded Unicode code point at "s".
+UnicodeChar DecodeUtf8(const char* s)
+{
+ UnicodeChar unicodeChar;
+ int state = s0;
+ auto start = s;
+
+ do
+ {
+ unsigned char byte = *s++;
+ int type = s_byteTypeTable[byte];
+
+ if (state == s0)
+ unicodeChar.code = (0xFF >> type) & byte;
+ else
+ unicodeChar.code = (unicodeChar.code << 6) | (byte & 0x3F);
+
+ state = s_transitionTable[state + type];
+
+ if (state == s1)
+ {
+ unicodeChar.code = -1;
+ return unicodeChar;
+ }
+ } while (state != s0);
+
+ unicodeChar.encodingLength = s - start;
+
+ return unicodeChar;
+}
diff --git a/tools/ramscrgen/.gitignore b/tools/ramscrgen/.gitignore
index f17f6e7..4d0ae82 100644
--- a/tools/ramscrgen/.gitignore
+++ b/tools/ramscrgen/.gitignore
@@ -1 +1 @@
-ramscrgen
+ramscrgen
diff --git a/tools/ramscrgen/elf.cpp b/tools/ramscrgen/elf.cpp
index 7cef9f9..7e78704 100644
--- a/tools/ramscrgen/elf.cpp
+++ b/tools/ramscrgen/elf.cpp
@@ -1,272 +1,272 @@
-#include <cstdio>
-#include <cstring>
-#include <cstdint>
-#include <map>
-#include <vector>
-#include <string>
-#include "ramscrgen.h"
-#include "elf.h"
-
-#define SHN_COMMON 0xFFF2
-
-static std::string s_elfPath;
-static std::string s_archiveFilePath;
-static std::string s_archiveObjectPath;
-
-static FILE *s_file;
-
-static std::uint32_t s_sectionHeaderOffset;
-static int s_sectionHeaderEntrySize;
-static int s_sectionCount;
-static int s_shstrtabIndex;
-
-static std::uint32_t s_symtabOffset;
-static std::uint32_t s_strtabOffset;
-
-static std::uint32_t s_symbolCount;
-static std::uint32_t s_elfFileOffset;
-
-struct Symbol
-{
- std::uint32_t nameOffset;
- std::uint32_t size;
-};
-
-static void Seek(long offset)
-{
- if (std::fseek(s_file, s_elfFileOffset + offset, SEEK_SET) != 0)
- FATAL_ERROR("error: failed to seek to %ld in \"%s\"", offset, s_elfPath.c_str());
-}
-
-static void Skip(long offset)
-{
- if (std::fseek(s_file, offset, SEEK_CUR) != 0)
- FATAL_ERROR("error: failed to skip %ld bytes in \"%s\"", offset, s_elfPath.c_str());
-}
-
-static std::uint32_t ReadInt8()
-{
- int c = std::fgetc(s_file);
-
- if (c < 0)
- FATAL_ERROR("error: unexpected EOF when reading ELF file \"%s\"\n", s_elfPath.c_str());
-
- return c;
-}
-
-static std::uint32_t ReadInt16()
-{
- std::uint32_t val = 0;
- val |= ReadInt8();
- val |= ReadInt8() << 8;
- return val;
-}
-
-static std::uint32_t ReadInt32()
-{
- std::uint32_t val = 0;
- val |= ReadInt8();
- val |= ReadInt8() << 8;
- val |= ReadInt8() << 16;
- val |= ReadInt8() << 24;
- return val;
-}
-
-static std::string ReadString()
-{
- std::string s;
- char c;
-
- while ((c = ReadInt8()) != 0)
- s += c;
-
- return s;
-}
-
-static void VerifyElfIdent()
-{
- char expectedMagic[4] = { 0x7F, 'E', 'L', 'F' };
- char magic[4];
-
- if (std::fread(magic, 4, 1, s_file) != 1)
- FATAL_ERROR("error: failed to read ELF magic from \"%s\"\n", s_elfPath.c_str());
-
- if (std::memcmp(magic, expectedMagic, 4) != 0)
- FATAL_ERROR("error: ELF magic did not match in \"%s\"\n", s_elfPath.c_str());
-
- if (std::fgetc(s_file) != 1)
- FATAL_ERROR("error: \"%s\" not 32-bit ELF\n", s_elfPath.c_str());
-
- if (std::fgetc(s_file) != 1)
- FATAL_ERROR("error: \"%s\" not little-endian ELF\n", s_elfPath.c_str());
-}
-
-static void VerifyAr()
-{
- char expectedMagic[8] = {'!', '<', 'a', 'r', 'c', 'h', '>', '\n'};
- char magic[8];
-
- if (std::fread(magic, 8, 1, s_file) != 1)
- FATAL_ERROR("error: failed to read AR magic from \"%s\"\n", s_archiveFilePath.c_str());
-
- if (std::memcmp(magic, expectedMagic, 8) != 0)
- FATAL_ERROR("error: AR magic did not match in \"%s\"\n", s_archiveFilePath.c_str());
-}
-
-static void ReadElfHeader()
-{
- Seek(0x20);
- s_sectionHeaderOffset = ReadInt32();
- Seek(0x2E);
- s_sectionHeaderEntrySize = ReadInt16();
- s_sectionCount = ReadInt16();
- s_shstrtabIndex = ReadInt16();
-}
-
-static void FindArObj()
-{
- char file_ident[17] = {0};
- char filesize_s[11] = {0};
- char expectedEndMagic[2] = { 0x60, 0x0a };
- char end_magic[2];
- std::size_t filesize;
-
- Seek(8);
- while (!std::feof(s_file)) {
- if (std::fread(file_ident, 16, 1, s_file) != 1)
- FATAL_ERROR("error: failed to read file ident in \"%s\"\n", s_archiveFilePath.c_str());
- Skip(32);
- if (std::fread(filesize_s, 10, 1, s_file) != 1)
- FATAL_ERROR("error: failed to read filesize in \"%s\"\n", s_archiveFilePath.c_str());
- if (std::fread(end_magic, 2, 1, s_file) != 1)
- FATAL_ERROR("error: failed to read end sentinel in \"%s\"\n", s_archiveFilePath.c_str());
- if (std::memcmp(end_magic, expectedEndMagic, 2) != 0)
- FATAL_ERROR("error: corrupted archive header in \"%s\" at \"%s\"\n", s_archiveFilePath.c_str(), file_ident);
-
- char * ptr = std::strchr(file_ident, '/');
- if (ptr != nullptr)
- *ptr = 0;
- filesize = std::strtoul(filesize_s, nullptr, 10);
- if (std::strncmp(s_archiveObjectPath.c_str(), file_ident, 16) == 0) {
- s_elfFileOffset = std::ftell(s_file);
- return;
- }
- Skip(filesize);
- }
-
- FATAL_ERROR("error: could not find object \"%s\" in archive \"%s\"\n", s_archiveObjectPath.c_str(), s_archiveFilePath.c_str());
-}
-
-static std::string GetSectionName(std::uint32_t shstrtabOffset, int index)
-{
- Seek(s_sectionHeaderOffset + s_sectionHeaderEntrySize * index);
- std::uint32_t nameOffset = ReadInt32();
- Seek(shstrtabOffset + nameOffset);
- return ReadString();
-}
-
-static void FindTableOffsets()
-{
- s_symtabOffset = 0;
- s_strtabOffset = 0;
-
- Seek(s_sectionHeaderOffset + s_sectionHeaderEntrySize * s_shstrtabIndex + 0x10);
- std::uint32_t shstrtabOffset = ReadInt32();
-
- for (int i = 0; i < s_sectionCount; i++)
- {
- std::string name = GetSectionName(shstrtabOffset, i);
-
- if (name == ".symtab")
- {
- if (s_symtabOffset)
- FATAL_ERROR("error: mutiple .symtab sections found in \"%s\"\n", s_elfPath.c_str());
- Seek(s_sectionHeaderOffset + s_sectionHeaderEntrySize * i + 0x10);
- s_symtabOffset = ReadInt32();
- std::uint32_t size = ReadInt32();
- s_symbolCount = size / 16;
- }
- else if (name == ".strtab")
- {
- if (s_strtabOffset)
- FATAL_ERROR("error: mutiple .strtab sections found in \"%s\"\n", s_elfPath.c_str());
- Seek(s_sectionHeaderOffset + s_sectionHeaderEntrySize * i + 0x10);
- s_strtabOffset = ReadInt32();
- }
- }
-
- if (!s_symtabOffset)
- FATAL_ERROR("error: couldn't find .symtab section in \"%s\"\n", s_elfPath.c_str());
-
- if (!s_strtabOffset)
- FATAL_ERROR("error: couldn't find .strtab section in \"%s\"\n", s_elfPath.c_str());
-}
-
-static std::map<std::string, std::uint32_t> GetCommonSymbols_Shared()
-{
- VerifyElfIdent();
- ReadElfHeader();
- FindTableOffsets();
-
- std::map<std::string, std::uint32_t> commonSymbols;
-
- std::vector<Symbol> commonSymbolVec;
-
- Seek(s_symtabOffset);
-
- for (std::uint32_t i = 0; i < s_symbolCount; i++)
- {
- Symbol sym;
- sym.nameOffset = ReadInt32();
- Skip(4);
- sym.size = ReadInt32();
- Skip(2);
- std::uint16_t sectionIndex = ReadInt16();
- if (sectionIndex == SHN_COMMON)
- commonSymbolVec.push_back(sym);
- }
-
- for (const Symbol& sym : commonSymbolVec)
- {
- Seek(s_strtabOffset + sym.nameOffset);
- std::string name = ReadString();
- commonSymbols[name] = sym.size;
- }
-
- return commonSymbols;
-}
-
-std::map<std::string, std::uint32_t> GetCommonSymbolsFromLib(std::string sourcePath, std::string libpath)
-{
- std::size_t colonPos = libpath.find(':');
- if (colonPos == std::string::npos)
- FATAL_ERROR("error: missing colon separator in libfile \"%s\"\n", s_elfPath.c_str());
-
- s_archiveObjectPath = libpath.substr(colonPos + 1);
- s_archiveFilePath = sourcePath + "/" + libpath.substr(1, colonPos - 1);
- s_elfPath = sourcePath + "/" + libpath.substr(1);
-
- s_file = std::fopen(s_archiveFilePath.c_str(), "rb");
-
- if (s_file == NULL)
- FATAL_ERROR("error: failed to open \"%s\" for reading\n", s_archiveFilePath.c_str());
-
- VerifyAr();
- FindArObj();
- return GetCommonSymbols_Shared();
-}
-
-std::map<std::string, std::uint32_t> GetCommonSymbols(std::string sourcePath, std::string path)
-{
- s_elfFileOffset = 0;
- if (path[0] == '*')
- return GetCommonSymbolsFromLib(sourcePath, path);
-
- s_elfPath = sourcePath + "/" + path;
- s_file = std::fopen(s_elfPath.c_str(), "rb");
-
- if (s_file == NULL)
- FATAL_ERROR("error: failed to open \"%s\" for reading\n", path.c_str());
-
- return GetCommonSymbols_Shared();
-}
+#include <cstdio>
+#include <cstring>
+#include <cstdint>
+#include <map>
+#include <vector>
+#include <string>
+#include "ramscrgen.h"
+#include "elf.h"
+
+#define SHN_COMMON 0xFFF2
+
+static std::string s_elfPath;
+static std::string s_archiveFilePath;
+static std::string s_archiveObjectPath;
+
+static FILE *s_file;
+
+static std::uint32_t s_sectionHeaderOffset;
+static int s_sectionHeaderEntrySize;
+static int s_sectionCount;
+static int s_shstrtabIndex;
+
+static std::uint32_t s_symtabOffset;
+static std::uint32_t s_strtabOffset;
+
+static std::uint32_t s_symbolCount;
+static std::uint32_t s_elfFileOffset;
+
+struct Symbol
+{
+ std::uint32_t nameOffset;
+ std::uint32_t size;
+};
+
+static void Seek(long offset)
+{
+ if (std::fseek(s_file, s_elfFileOffset + offset, SEEK_SET) != 0)
+ FATAL_ERROR("error: failed to seek to %ld in \"%s\"", offset, s_elfPath.c_str());
+}
+
+static void Skip(long offset)
+{
+ if (std::fseek(s_file, offset, SEEK_CUR) != 0)
+ FATAL_ERROR("error: failed to skip %ld bytes in \"%s\"", offset, s_elfPath.c_str());
+}
+
+static std::uint32_t ReadInt8()
+{
+ int c = std::fgetc(s_file);
+
+ if (c < 0)
+ FATAL_ERROR("error: unexpected EOF when reading ELF file \"%s\"\n", s_elfPath.c_str());
+
+ return c;
+}
+
+static std::uint32_t ReadInt16()
+{
+ std::uint32_t val = 0;
+ val |= ReadInt8();
+ val |= ReadInt8() << 8;
+ return val;
+}
+
+static std::uint32_t ReadInt32()
+{
+ std::uint32_t val = 0;
+ val |= ReadInt8();
+ val |= ReadInt8() << 8;
+ val |= ReadInt8() << 16;
+ val |= ReadInt8() << 24;
+ return val;
+}
+
+static std::string ReadString()
+{
+ std::string s;
+ char c;
+
+ while ((c = ReadInt8()) != 0)
+ s += c;
+
+ return s;
+}
+
+static void VerifyElfIdent()
+{
+ char expectedMagic[4] = { 0x7F, 'E', 'L', 'F' };
+ char magic[4];
+
+ if (std::fread(magic, 4, 1, s_file) != 1)
+ FATAL_ERROR("error: failed to read ELF magic from \"%s\"\n", s_elfPath.c_str());
+
+ if (std::memcmp(magic, expectedMagic, 4) != 0)
+ FATAL_ERROR("error: ELF magic did not match in \"%s\"\n", s_elfPath.c_str());
+
+ if (std::fgetc(s_file) != 1)
+ FATAL_ERROR("error: \"%s\" not 32-bit ELF\n", s_elfPath.c_str());
+
+ if (std::fgetc(s_file) != 1)
+ FATAL_ERROR("error: \"%s\" not little-endian ELF\n", s_elfPath.c_str());
+}
+
+static void VerifyAr()
+{
+ char expectedMagic[8] = {'!', '<', 'a', 'r', 'c', 'h', '>', '\n'};
+ char magic[8];
+
+ if (std::fread(magic, 8, 1, s_file) != 1)
+ FATAL_ERROR("error: failed to read AR magic from \"%s\"\n", s_archiveFilePath.c_str());
+
+ if (std::memcmp(magic, expectedMagic, 8) != 0)
+ FATAL_ERROR("error: AR magic did not match in \"%s\"\n", s_archiveFilePath.c_str());
+}
+
+static void ReadElfHeader()
+{
+ Seek(0x20);
+ s_sectionHeaderOffset = ReadInt32();
+ Seek(0x2E);
+ s_sectionHeaderEntrySize = ReadInt16();
+ s_sectionCount = ReadInt16();
+ s_shstrtabIndex = ReadInt16();
+}
+
+static void FindArObj()
+{
+ char file_ident[17] = {0};
+ char filesize_s[11] = {0};
+ char expectedEndMagic[2] = { 0x60, 0x0a };
+ char end_magic[2];
+ std::size_t filesize;
+
+ Seek(8);
+ while (!std::feof(s_file)) {
+ if (std::fread(file_ident, 16, 1, s_file) != 1)
+ FATAL_ERROR("error: failed to read file ident in \"%s\"\n", s_archiveFilePath.c_str());
+ Skip(32);
+ if (std::fread(filesize_s, 10, 1, s_file) != 1)
+ FATAL_ERROR("error: failed to read filesize in \"%s\"\n", s_archiveFilePath.c_str());
+ if (std::fread(end_magic, 2, 1, s_file) != 1)
+ FATAL_ERROR("error: failed to read end sentinel in \"%s\"\n", s_archiveFilePath.c_str());
+ if (std::memcmp(end_magic, expectedEndMagic, 2) != 0)
+ FATAL_ERROR("error: corrupted archive header in \"%s\" at \"%s\"\n", s_archiveFilePath.c_str(), file_ident);
+
+ char * ptr = std::strchr(file_ident, '/');
+ if (ptr != nullptr)
+ *ptr = 0;
+ filesize = std::strtoul(filesize_s, nullptr, 10);
+ if (std::strncmp(s_archiveObjectPath.c_str(), file_ident, 16) == 0) {
+ s_elfFileOffset = std::ftell(s_file);
+ return;
+ }
+ Skip(filesize);
+ }
+
+ FATAL_ERROR("error: could not find object \"%s\" in archive \"%s\"\n", s_archiveObjectPath.c_str(), s_archiveFilePath.c_str());
+}
+
+static std::string GetSectionName(std::uint32_t shstrtabOffset, int index)
+{
+ Seek(s_sectionHeaderOffset + s_sectionHeaderEntrySize * index);
+ std::uint32_t nameOffset = ReadInt32();
+ Seek(shstrtabOffset + nameOffset);
+ return ReadString();
+}
+
+static void FindTableOffsets()
+{
+ s_symtabOffset = 0;
+ s_strtabOffset = 0;
+
+ Seek(s_sectionHeaderOffset + s_sectionHeaderEntrySize * s_shstrtabIndex + 0x10);
+ std::uint32_t shstrtabOffset = ReadInt32();
+
+ for (int i = 0; i < s_sectionCount; i++)
+ {
+ std::string name = GetSectionName(shstrtabOffset, i);
+
+ if (name == ".symtab")
+ {
+ if (s_symtabOffset)
+ FATAL_ERROR("error: mutiple .symtab sections found in \"%s\"\n", s_elfPath.c_str());
+ Seek(s_sectionHeaderOffset + s_sectionHeaderEntrySize * i + 0x10);
+ s_symtabOffset = ReadInt32();
+ std::uint32_t size = ReadInt32();
+ s_symbolCount = size / 16;
+ }
+ else if (name == ".strtab")
+ {
+ if (s_strtabOffset)
+ FATAL_ERROR("error: mutiple .strtab sections found in \"%s\"\n", s_elfPath.c_str());
+ Seek(s_sectionHeaderOffset + s_sectionHeaderEntrySize * i + 0x10);
+ s_strtabOffset = ReadInt32();
+ }
+ }
+
+ if (!s_symtabOffset)
+ FATAL_ERROR("error: couldn't find .symtab section in \"%s\"\n", s_elfPath.c_str());
+
+ if (!s_strtabOffset)
+ FATAL_ERROR("error: couldn't find .strtab section in \"%s\"\n", s_elfPath.c_str());
+}
+
+static std::map<std::string, std::uint32_t> GetCommonSymbols_Shared()
+{
+ VerifyElfIdent();
+ ReadElfHeader();
+ FindTableOffsets();
+
+ std::map<std::string, std::uint32_t> commonSymbols;
+
+ std::vector<Symbol> commonSymbolVec;
+
+ Seek(s_symtabOffset);
+
+ for (std::uint32_t i = 0; i < s_symbolCount; i++)
+ {
+ Symbol sym;
+ sym.nameOffset = ReadInt32();
+ Skip(4);
+ sym.size = ReadInt32();
+ Skip(2);
+ std::uint16_t sectionIndex = ReadInt16();
+ if (sectionIndex == SHN_COMMON)
+ commonSymbolVec.push_back(sym);
+ }
+
+ for (const Symbol& sym : commonSymbolVec)
+ {
+ Seek(s_strtabOffset + sym.nameOffset);
+ std::string name = ReadString();
+ commonSymbols[name] = sym.size;
+ }
+
+ return commonSymbols;
+}
+
+std::map<std::string, std::uint32_t> GetCommonSymbolsFromLib(std::string sourcePath, std::string libpath)
+{
+ std::size_t colonPos = libpath.find(':');
+ if (colonPos == std::string::npos)
+ FATAL_ERROR("error: missing colon separator in libfile \"%s\"\n", s_elfPath.c_str());
+
+ s_archiveObjectPath = libpath.substr(colonPos + 1);
+ s_archiveFilePath = sourcePath + "/" + libpath.substr(1, colonPos - 1);
+ s_elfPath = sourcePath + "/" + libpath.substr(1);
+
+ s_file = std::fopen(s_archiveFilePath.c_str(), "rb");
+
+ if (s_file == NULL)
+ FATAL_ERROR("error: failed to open \"%s\" for reading\n", s_archiveFilePath.c_str());
+
+ VerifyAr();
+ FindArObj();
+ return GetCommonSymbols_Shared();
+}
+
+std::map<std::string, std::uint32_t> GetCommonSymbols(std::string sourcePath, std::string path)
+{
+ s_elfFileOffset = 0;
+ if (path[0] == '*')
+ return GetCommonSymbolsFromLib(sourcePath, path);
+
+ s_elfPath = sourcePath + "/" + path;
+ s_file = std::fopen(s_elfPath.c_str(), "rb");
+
+ if (s_file == NULL)
+ FATAL_ERROR("error: failed to open \"%s\" for reading\n", path.c_str());
+
+ return GetCommonSymbols_Shared();
+}
diff --git a/tools/ramscrgen/main.cpp b/tools/ramscrgen/main.cpp
index faeba46..5e5894f 100644
--- a/tools/ramscrgen/main.cpp
+++ b/tools/ramscrgen/main.cpp
@@ -1,187 +1,187 @@
-// Copyright(c) 2016 YamaArashi
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#include <cstdio>
-#include <cstring>
-#include <string>
-#include "ramscrgen.h"
-#include "sym_file.h"
-#include "elf.h"
-
-void HandleCommonInclude(std::string filename, std::string sourcePath, std::string symOrderPath, std::string lang)
-{
- auto commonSymbols = GetCommonSymbols(sourcePath, filename);
- std::size_t dotIndex;
-
- if (filename[0] == '*') {
- dotIndex = filename.find_last_of(':');
- filename = filename.substr(dotIndex + 1);
- }
-
- dotIndex = filename.find_last_of('.');
-
- if (dotIndex == std::string::npos)
- FATAL_ERROR("error: \"%s\" doesn't have a file extension\n", filename.c_str());
-
- std::string symOrderFilename = filename.substr(0, dotIndex + 1) + "txt";
-
- SymFile symFile(symOrderPath + "/" + symOrderFilename);
-
- while (!symFile.IsAtEnd())
- {
- symFile.HandleLangConditional(lang);
-
- std::string label = symFile.GetLabel(false);
-
- if (label.length() == 0)
- {
- unsigned long length;
- if (symFile.ReadInteger(length))
- {
- if (length & 3)
- symFile.RaiseWarning("gap length %d is not multiple of 4", length);
- printf(". += 0x%lX;\n", length);
- }
- }
- else
- {
- if (commonSymbols.count(label) == 0)
- symFile.RaiseError("no common symbol named \"%s\"", label.c_str());
- unsigned long size = commonSymbols[label];
- int alignment = 4;
- if (size > 4)
- alignment = 8;
- if (size > 8)
- alignment = 16;
- printf(". = ALIGN(%d);\n", alignment);
- printf("%s = .;\n", label.c_str());
- printf(". += 0x%lX;\n", size);
- }
-
- symFile.ExpectEmptyRestOfLine();
- }
-}
-
-void ConvertSymFile(std::string filename, std::string sectionName, std::string lang, bool common, std::string sourcePath, std::string commonSymPath, std::string libSourcePath)
-{
- SymFile symFile(filename);
-
- while (!symFile.IsAtEnd())
- {
- symFile.HandleLangConditional(lang);
-
- Directive directive = symFile.GetDirective();
-
- switch (directive)
- {
- case Directive::Include:
- {
- std::string incFilename = symFile.ReadPath();
- symFile.ExpectEmptyRestOfLine();
- printf(". = ALIGN(4);\n");
- if (common)
- HandleCommonInclude(incFilename, incFilename[0] == '*' ? libSourcePath : sourcePath, commonSymPath, lang);
- else
- printf("%s(%s);\n", incFilename.c_str(), sectionName.c_str());
- break;
- }
- case Directive::Space:
- {
- unsigned long length;
- if (!symFile.ReadInteger(length))
- symFile.RaiseError("expected integer after .space directive");
- symFile.ExpectEmptyRestOfLine();
- printf(". += 0x%lX;\n", length);
- break;
- }
- case Directive::Align:
- {
- unsigned long amount;
- if (!symFile.ReadInteger(amount))
- symFile.RaiseError("expected integer after .align directive");
- if (amount > 4)
- symFile.RaiseError("max alignment amount is 4");
- amount = 1UL << amount;
- symFile.ExpectEmptyRestOfLine();
- printf(". = ALIGN(%lu);\n", amount);
- break;
- }
- case Directive::Unknown:
- {
- std::string label = symFile.GetLabel();
-
- if (label.length() != 0)
- {
- printf("%s = .;\n", label.c_str());
- }
-
- symFile.ExpectEmptyRestOfLine();
-
- break;
- }
- }
- }
-}
-
-int main(int argc, char **argv)
-{
- if (argc < 4)
- {
- fprintf(stderr, "Usage: %s SECTION_NAME SYM_FILE LANG [-c SRC_PATH,COMMON_SYM_PATH]", argv[0]);
- return 1;
- }
-
- bool common = false;
- std::string sectionName = std::string(argv[1]);
- std::string symFileName = std::string(argv[2]);
- std::string lang = std::string(argv[3]);
- std::string sourcePath;
- std::string commonSymPath;
- std::string libSourcePath;
-
- if (argc > 4)
- {
- if (std::strcmp(argv[4], "-c") != 0)
- FATAL_ERROR("error: unrecognized argument \"%s\"\n", argv[4]);
-
- if (argc < 6)
- FATAL_ERROR("error: missing SRC_PATH,COMMON_SYM_PATH after \"-c\"\n");
-
- common = true;
- std::string paths = std::string(argv[5]);
- std::size_t commaPos = paths.find(',');
-
- if (commaPos == std::string::npos)
- FATAL_ERROR("error: missing comma in argument after \"-c\"\n");
-
- sourcePath = paths.substr(0, commaPos);
- commonSymPath = paths.substr(commaPos + 1);
- commaPos = commonSymPath.find(',');
- if (commaPos == std::string::npos) {
- libSourcePath = "tools/agbcc/lib";
- } else {
- libSourcePath = commonSymPath.substr(commaPos + 1);
- commonSymPath = commonSymPath.substr(0, commaPos);
- }
- }
-
- ConvertSymFile(symFileName, sectionName, lang, common, sourcePath, commonSymPath, libSourcePath);
- return 0;
-}
+// Copyright(c) 2016 YamaArashi
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#include <cstdio>
+#include <cstring>
+#include <string>
+#include "ramscrgen.h"
+#include "sym_file.h"
+#include "elf.h"
+
+void HandleCommonInclude(std::string filename, std::string sourcePath, std::string symOrderPath, std::string lang)
+{
+ auto commonSymbols = GetCommonSymbols(sourcePath, filename);
+ std::size_t dotIndex;
+
+ if (filename[0] == '*') {
+ dotIndex = filename.find_last_of(':');
+ filename = filename.substr(dotIndex + 1);
+ }
+
+ dotIndex = filename.find_last_of('.');
+
+ if (dotIndex == std::string::npos)
+ FATAL_ERROR("error: \"%s\" doesn't have a file extension\n", filename.c_str());
+
+ std::string symOrderFilename = filename.substr(0, dotIndex + 1) + "txt";
+
+ SymFile symFile(symOrderPath + "/" + symOrderFilename);
+
+ while (!symFile.IsAtEnd())
+ {
+ symFile.HandleLangConditional(lang);
+
+ std::string label = symFile.GetLabel(false);
+
+ if (label.length() == 0)
+ {
+ unsigned long length;
+ if (symFile.ReadInteger(length))
+ {
+ if (length & 3)
+ symFile.RaiseWarning("gap length %d is not multiple of 4", length);
+ printf(". += 0x%lX;\n", length);
+ }
+ }
+ else
+ {
+ if (commonSymbols.count(label) == 0)
+ symFile.RaiseError("no common symbol named \"%s\"", label.c_str());
+ unsigned long size = commonSymbols[label];
+ int alignment = 4;
+ if (size > 4)
+ alignment = 8;
+ if (size > 8)
+ alignment = 16;
+ printf(". = ALIGN(%d);\n", alignment);
+ printf("%s = .;\n", label.c_str());
+ printf(". += 0x%lX;\n", size);
+ }
+
+ symFile.ExpectEmptyRestOfLine();
+ }
+}
+
+void ConvertSymFile(std::string filename, std::string sectionName, std::string lang, bool common, std::string sourcePath, std::string commonSymPath, std::string libSourcePath)
+{
+ SymFile symFile(filename);
+
+ while (!symFile.IsAtEnd())
+ {
+ symFile.HandleLangConditional(lang);
+
+ Directive directive = symFile.GetDirective();
+
+ switch (directive)
+ {
+ case Directive::Include:
+ {
+ std::string incFilename = symFile.ReadPath();
+ symFile.ExpectEmptyRestOfLine();
+ printf(". = ALIGN(4);\n");
+ if (common)
+ HandleCommonInclude(incFilename, incFilename[0] == '*' ? libSourcePath : sourcePath, commonSymPath, lang);
+ else
+ printf("%s(%s);\n", incFilename.c_str(), sectionName.c_str());
+ break;
+ }
+ case Directive::Space:
+ {
+ unsigned long length;
+ if (!symFile.ReadInteger(length))
+ symFile.RaiseError("expected integer after .space directive");
+ symFile.ExpectEmptyRestOfLine();
+ printf(". += 0x%lX;\n", length);
+ break;
+ }
+ case Directive::Align:
+ {
+ unsigned long amount;
+ if (!symFile.ReadInteger(amount))
+ symFile.RaiseError("expected integer after .align directive");
+ if (amount > 4)
+ symFile.RaiseError("max alignment amount is 4");
+ amount = 1UL << amount;
+ symFile.ExpectEmptyRestOfLine();
+ printf(". = ALIGN(%lu);\n", amount);
+ break;
+ }
+ case Directive::Unknown:
+ {
+ std::string label = symFile.GetLabel();
+
+ if (label.length() != 0)
+ {
+ printf("%s = .;\n", label.c_str());
+ }
+
+ symFile.ExpectEmptyRestOfLine();
+
+ break;
+ }
+ }
+ }
+}
+
+int main(int argc, char **argv)
+{
+ if (argc < 4)
+ {
+ fprintf(stderr, "Usage: %s SECTION_NAME SYM_FILE LANG [-c SRC_PATH,COMMON_SYM_PATH]", argv[0]);
+ return 1;
+ }
+
+ bool common = false;
+ std::string sectionName = std::string(argv[1]);
+ std::string symFileName = std::string(argv[2]);
+ std::string lang = std::string(argv[3]);
+ std::string sourcePath;
+ std::string commonSymPath;
+ std::string libSourcePath;
+
+ if (argc > 4)
+ {
+ if (std::strcmp(argv[4], "-c") != 0)
+ FATAL_ERROR("error: unrecognized argument \"%s\"\n", argv[4]);
+
+ if (argc < 6)
+ FATAL_ERROR("error: missing SRC_PATH,COMMON_SYM_PATH after \"-c\"\n");
+
+ common = true;
+ std::string paths = std::string(argv[5]);
+ std::size_t commaPos = paths.find(',');
+
+ if (commaPos == std::string::npos)
+ FATAL_ERROR("error: missing comma in argument after \"-c\"\n");
+
+ sourcePath = paths.substr(0, commaPos);
+ commonSymPath = paths.substr(commaPos + 1);
+ commaPos = commonSymPath.find(',');
+ if (commaPos == std::string::npos) {
+ libSourcePath = "tools/agbcc/lib";
+ } else {
+ libSourcePath = commonSymPath.substr(commaPos + 1);
+ commonSymPath = commonSymPath.substr(0, commaPos);
+ }
+ }
+
+ ConvertSymFile(symFileName, sectionName, lang, common, sourcePath, commonSymPath, libSourcePath);
+ return 0;
+}
diff --git a/tools/ramscrgen/sym_file.cpp b/tools/ramscrgen/sym_file.cpp
index 1272ef1..5379bd9 100644
--- a/tools/ramscrgen/sym_file.cpp
+++ b/tools/ramscrgen/sym_file.cpp
@@ -1,492 +1,492 @@
-// Copyright(c) 2016 YamaArashi
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#include <cstdio>
-#include <cstdarg>
-#include <climits>
-#include "ramscrgen.h"
-#include "sym_file.h"
-#include "char_util.h"
-
-SymFile::SymFile(std::string filename) : m_filename(filename)
-{
- FILE *fp = std::fopen(filename.c_str(), "rb");
-
- if (fp == NULL)
- FATAL_ERROR("Failed to open \"%s\" for reading.\n", filename.c_str());
-
- std::fseek(fp, 0, SEEK_END);
-
- m_size = std::ftell(fp);
-
- if (m_size < 0)
- FATAL_ERROR("File size of \"%s\" is less than zero.\n", filename.c_str());
-
- m_buffer = new char[m_size + 1];
-
- std::rewind(fp);
-
- if (std::fread(m_buffer, m_size, 1, fp) != 1)
- FATAL_ERROR("Failed to read \"%s\".\n", filename.c_str());
-
- m_buffer[m_size] = 0;
-
- std::fclose(fp);
-
- m_pos = 0;
- m_lineNum = 1;
- m_lineStart = 0;
- m_inLangConditional = false;
-
- RemoveComments();
-}
-
-SymFile::SymFile(SymFile&& other) : m_filename(std::move(other.m_filename))
-{
- m_buffer = other.m_buffer;
- m_pos = other.m_pos;
- m_size = other.m_size;
- m_lineNum = other.m_lineNum;
- m_lineStart = other.m_lineStart;
-
- other.m_buffer = nullptr;
-}
-
-SymFile::~SymFile()
-{
- delete[] m_buffer;
-}
-
-// Removes comments to simplify further processing.
-// It stops upon encountering a null character,
-// which may or may not be the end of file marker.
-// If it's not, the error will be caught later.
-void SymFile::RemoveComments()
-{
- long pos = 0;
- char stringChar = 0;
-
- for (;;)
- {
- if (m_buffer[pos] == 0)
- return;
-
- if (stringChar != 0)
- {
- if (m_buffer[pos] == '\\' && m_buffer[pos + 1] == stringChar)
- {
- pos += 2;
- }
- else
- {
- if (m_buffer[pos] == stringChar)
- stringChar = 0;
- pos++;
- }
- }
- else if (m_buffer[pos] == '@' && (pos == 0 || m_buffer[pos - 1] != '\\'))
- {
- while (m_buffer[pos] != '\n' && m_buffer[pos] != 0)
- m_buffer[pos++] = ' ';
- }
- else if (m_buffer[pos] == '/' && m_buffer[pos + 1] == '*')
- {
- m_buffer[pos++] = ' ';
- m_buffer[pos++] = ' ';
-
- char commentStringChar = 0;
-
- for (;;)
- {
- if (m_buffer[pos] == 0)
- return;
-
- if (commentStringChar != 0)
- {
- if (m_buffer[pos] == '\\' && m_buffer[pos + 1] == commentStringChar)
- {
- m_buffer[pos++] = ' ';
- m_buffer[pos++] = ' ';
- }
- else
- {
- if (m_buffer[pos] == commentStringChar)
- commentStringChar = 0;
- if (m_buffer[pos] != '\n')
- m_buffer[pos] = ' ';
- pos++;
- }
- }
- else
- {
- if (m_buffer[pos] == '*' && m_buffer[pos + 1] == '/')
- {
- m_buffer[pos++] = ' ';
- m_buffer[pos++] = ' ';
- break;
- }
- else
- {
- if (m_buffer[pos] == '"' || m_buffer[pos] == '\'')
- commentStringChar = m_buffer[pos];
- if (m_buffer[pos] != '\n')
- m_buffer[pos] = ' ';
- pos++;
- }
- }
- }
- }
- else
- {
- if (m_buffer[pos] == '"' || m_buffer[pos] == '\'')
- stringChar = m_buffer[pos];
- pos++;
- }
- }
-}
-
-// Checks if we're at a particular directive and if so, consumes it.
-// Returns whether the directive was found.
-bool SymFile::CheckForDirective(std::string name)
-{
- long i;
- long length = static_cast<long>(name.length());
-
- for (i = 0; i < length && m_pos + i < m_size; i++)
- if (name[i] != m_buffer[m_pos + i])
- return false;
-
- if (i < length)
- return false;
-
- m_pos += length;
-
- return true;
-}
-
-// Checks if we're at a known directive and if so, consumes it.
-// Returns which directive was found.
-Directive SymFile::GetDirective()
-{
- SkipWhitespace();
-
- if (CheckForDirective(".include"))
- return Directive::Include;
- else if (CheckForDirective(".space"))
- return Directive::Space;
- else if (CheckForDirective(".align"))
- return Directive::Align;
- else
- return Directive::Unknown;
-}
-
-// Checks if we're at label.
-// Returns the name if so and an empty string if not.
-std::string SymFile::GetLabel(bool requireColon)
-{
- long start = m_pos;
- long pos = m_pos;
-
- if (IsIdentifierStartingChar(m_buffer[pos]))
- {
- pos++;
-
- while (IsIdentifierChar(m_buffer[pos]))
- pos++;
- }
-
- if (requireColon)
- {
- if (m_buffer[pos] == ':')
- {
- if (pos != start)
- m_pos = pos + 1;
- }
- else
- {
- pos = start;
- }
- }
- else
- {
- m_pos = pos;
- }
-
- return std::string(&m_buffer[start], pos - start);
-}
-
-// Skips tabs and spaces.
-void SymFile::SkipWhitespace()
-{
- while (m_buffer[m_pos] == '\t' || m_buffer[m_pos] == ' ')
- m_pos++;
-}
-
-// Reads include path.
-std::string SymFile::ReadPath()
-{
- SkipWhitespace();
-
- if (m_buffer[m_pos] != '"')
- RaiseError("expected file path");
-
- m_pos++;
-
- int length = 0;
- long startPos = m_pos;
-
- while (m_buffer[m_pos] != '"')
- {
- unsigned char c = m_buffer[m_pos++];
-
- if (c == 0)
- {
- if (m_pos >= m_size)
- RaiseError("unexpected EOF in include string");
- else
- RaiseError("unexpected null character in include string");
- }
-
- if (!IsAsciiPrintable(c))
- RaiseError("unexpected character '\\x%02X' in include string", c);
-
- // Don't bother allowing any escape sequences.
- if (c == '\\')
- {
- c = m_buffer[m_pos];
- RaiseError("unexpected escape '\\%c' in include string", c);
- }
-
- length++;
-
- if (length > kMaxPath)
- RaiseError("path is too long");
- }
-
- m_pos++; // Go past the right quote.
-
- return std::string(&m_buffer[startPos], length);
-}
-
-// If we're at a comma, consumes it.
-// Returns whether a comma was found.
-bool SymFile::ConsumeComma()
-{
- if (m_buffer[m_pos] == ',')
- {
- m_pos++;
- return true;
- }
-
- return false;
-}
-
-// Converts digit character to numerical value.
-static int ConvertDigit(char c, int radix)
-{
- int digit;
-
- if (c >= '0' && c <= '9')
- digit = c - '0';
- else if (c >= 'A' && c <= 'F')
- digit = 10 + c - 'A';
- else if (c >= 'a' && c <= 'f')
- digit = 10 + c - 'a';
- else
- return -1;
-
- return (digit < radix) ? digit : -1;
-}
-
-// Reads an integer.
-bool SymFile::ReadInteger(unsigned long& n)
-{
- SkipWhitespace();
-
- if (!IsAsciiDigit(m_buffer[m_pos]))
- return false;
-
- int startPos = m_pos;
- int radix = 10;
-
- if (m_buffer[m_pos] == '0' && m_buffer[m_pos + 1] == 'x')
- {
- radix = 16;
- m_pos += 2;
- }
-
- unsigned long cutoff = ULONG_MAX / radix;
- unsigned long cutoffRemainder = ULONG_MAX % radix;
- int digit;
-
- n = 0;
-
- while ((digit = ConvertDigit(m_buffer[m_pos], radix)) != -1)
- {
- if (n < cutoff || (n == cutoff && (unsigned long)digit <= cutoffRemainder))
- {
- n = n * radix + digit;
- }
- else
- {
- m_pos++;
-
- while (ConvertDigit(m_buffer[m_pos], radix) != -1)
- m_pos++;
-
- RaiseError("integer is too large (%s)", std::string(&m_buffer[startPos], m_pos - startPos).c_str());
- }
-
- m_pos++;
- }
-
- return true;
-}
-
-// Asserts that the rest of the line is empty and moves to the next one.
-void SymFile::ExpectEmptyRestOfLine()
-{
- SkipWhitespace();
-
- if (m_buffer[m_pos] == 0)
- {
- if (m_pos >= m_size)
- RaiseWarning("file doesn't end with newline");
- else
- RaiseError("unexpected null character");
- }
- else if (m_buffer[m_pos] == '\n')
- {
- m_pos++;
- m_lineStart = m_pos;
- m_lineNum++;
- }
- else if (m_buffer[m_pos] == '\r')
- {
- RaiseError("only Unix-style LF newlines are supported");
- }
- else
- {
- RaiseError("junk at end of line");
- }
-}
-
-
-void SymFile::SkipLine()
-{
- while (m_buffer[m_pos] != 0 && m_buffer[m_pos] != '\n')
- m_pos++;
-
- if (m_buffer[m_pos] == '\n')
- m_pos++;
-}
-
-// Checks if we're at the end of the file.
-bool SymFile::IsAtEnd()
-{
- return (m_pos >= m_size);
-}
-
-void SymFile::HandleLangConditional(std::string lang)
-{
- if (m_buffer[m_pos] != '#')
- return;
-
- m_pos++;
-
- if (CheckForDirective("begin"))
- {
- if (m_inLangConditional)
- RaiseError("already inside language conditional");
-
- SkipWhitespace();
-
- std::string label = GetLabel(false);
-
- if (label.length() == 0)
- RaiseError("no language name after #begin");
-
- ExpectEmptyRestOfLine();
-
- if (lang == label)
- {
- m_inLangConditional = true;
- }
- else
- {
- while (!IsAtEnd() && m_buffer[m_pos] != '#')
- SkipLine();
-
- if (m_buffer[m_pos] != '#')
- RaiseError("unterminated language conditional");
-
- m_pos++;
-
- if (!CheckForDirective("end"))
- RaiseError("expected #end");
-
- ExpectEmptyRestOfLine();
- }
- }
- else if (CheckForDirective("end"))
- {
- if (!m_inLangConditional)
- RaiseError("not inside language conditional");
-
- m_inLangConditional = false;
-
- ExpectEmptyRestOfLine();
- }
- else
- {
- RaiseError("unknown # directive");
- }
-}
-
-// Reports a diagnostic message.
-void SymFile::ReportDiagnostic(const char* type, const char* format, std::va_list args)
-{
- const int bufferSize = 1024;
- char buffer[bufferSize];
- std::vsnprintf(buffer, bufferSize, format, args);
- std::fprintf(stderr, "%s:%ld: %s: %s\n", m_filename.c_str(), m_lineNum, type, buffer);
-}
-
-#define DO_REPORT(type) \
-do \
-{ \
- std::va_list args; \
- va_start(args, format); \
- ReportDiagnostic(type, format, args); \
- va_end(args); \
-} while (0)
-
-// Reports an error diagnostic and terminates the program.
-void SymFile::RaiseError(const char* format, ...)
-{
- DO_REPORT("error");
- std::exit(1);
-}
-
-// Reports a warning diagnostic.
-void SymFile::RaiseWarning(const char* format, ...)
-{
- DO_REPORT("warning");
-}
+// Copyright(c) 2016 YamaArashi
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#include <cstdio>
+#include <cstdarg>
+#include <climits>
+#include "ramscrgen.h"
+#include "sym_file.h"
+#include "char_util.h"
+
+SymFile::SymFile(std::string filename) : m_filename(filename)
+{
+ FILE *fp = std::fopen(filename.c_str(), "rb");
+
+ if (fp == NULL)
+ FATAL_ERROR("Failed to open \"%s\" for reading.\n", filename.c_str());
+
+ std::fseek(fp, 0, SEEK_END);
+
+ m_size = std::ftell(fp);
+
+ if (m_size < 0)
+ FATAL_ERROR("File size of \"%s\" is less than zero.\n", filename.c_str());
+
+ m_buffer = new char[m_size + 1];
+
+ std::rewind(fp);
+
+ if (std::fread(m_buffer, m_size, 1, fp) != 1)
+ FATAL_ERROR("Failed to read \"%s\".\n", filename.c_str());
+
+ m_buffer[m_size] = 0;
+
+ std::fclose(fp);
+
+ m_pos = 0;
+ m_lineNum = 1;
+ m_lineStart = 0;
+ m_inLangConditional = false;
+
+ RemoveComments();
+}
+
+SymFile::SymFile(SymFile&& other) : m_filename(std::move(other.m_filename))
+{
+ m_buffer = other.m_buffer;
+ m_pos = other.m_pos;
+ m_size = other.m_size;
+ m_lineNum = other.m_lineNum;
+ m_lineStart = other.m_lineStart;
+
+ other.m_buffer = nullptr;
+}
+
+SymFile::~SymFile()
+{
+ delete[] m_buffer;
+}
+
+// Removes comments to simplify further processing.
+// It stops upon encountering a null character,
+// which may or may not be the end of file marker.
+// If it's not, the error will be caught later.
+void SymFile::RemoveComments()
+{
+ long pos = 0;
+ char stringChar = 0;
+
+ for (;;)
+ {
+ if (m_buffer[pos] == 0)
+ return;
+
+ if (stringChar != 0)
+ {
+ if (m_buffer[pos] == '\\' && m_buffer[pos + 1] == stringChar)
+ {
+ pos += 2;
+ }
+ else
+ {
+ if (m_buffer[pos] == stringChar)
+ stringChar = 0;
+ pos++;
+ }
+ }
+ else if (m_buffer[pos] == '@' && (pos == 0 || m_buffer[pos - 1] != '\\'))
+ {
+ while (m_buffer[pos] != '\n' && m_buffer[pos] != 0)
+ m_buffer[pos++] = ' ';
+ }
+ else if (m_buffer[pos] == '/' && m_buffer[pos + 1] == '*')
+ {
+ m_buffer[pos++] = ' ';
+ m_buffer[pos++] = ' ';
+
+ char commentStringChar = 0;
+
+ for (;;)
+ {
+ if (m_buffer[pos] == 0)
+ return;
+
+ if (commentStringChar != 0)
+ {
+ if (m_buffer[pos] == '\\' && m_buffer[pos + 1] == commentStringChar)
+ {
+ m_buffer[pos++] = ' ';
+ m_buffer[pos++] = ' ';
+ }
+ else
+ {
+ if (m_buffer[pos] == commentStringChar)
+ commentStringChar = 0;
+ if (m_buffer[pos] != '\n')
+ m_buffer[pos] = ' ';
+ pos++;
+ }
+ }
+ else
+ {
+ if (m_buffer[pos] == '*' && m_buffer[pos + 1] == '/')
+ {
+ m_buffer[pos++] = ' ';
+ m_buffer[pos++] = ' ';
+ break;
+ }
+ else
+ {
+ if (m_buffer[pos] == '"' || m_buffer[pos] == '\'')
+ commentStringChar = m_buffer[pos];
+ if (m_buffer[pos] != '\n')
+ m_buffer[pos] = ' ';
+ pos++;
+ }
+ }
+ }
+ }
+ else
+ {
+ if (m_buffer[pos] == '"' || m_buffer[pos] == '\'')
+ stringChar = m_buffer[pos];
+ pos++;
+ }
+ }
+}
+
+// Checks if we're at a particular directive and if so, consumes it.
+// Returns whether the directive was found.
+bool SymFile::CheckForDirective(std::string name)
+{
+ long i;
+ long length = static_cast<long>(name.length());
+
+ for (i = 0; i < length && m_pos + i < m_size; i++)
+ if (name[i] != m_buffer[m_pos + i])
+ return false;
+
+ if (i < length)
+ return false;
+
+ m_pos += length;
+
+ return true;
+}
+
+// Checks if we're at a known directive and if so, consumes it.
+// Returns which directive was found.
+Directive SymFile::GetDirective()
+{
+ SkipWhitespace();
+
+ if (CheckForDirective(".include"))
+ return Directive::Include;
+ else if (CheckForDirective(".space"))
+ return Directive::Space;
+ else if (CheckForDirective(".align"))
+ return Directive::Align;
+ else
+ return Directive::Unknown;
+}
+
+// Checks if we're at label.
+// Returns the name if so and an empty string if not.
+std::string SymFile::GetLabel(bool requireColon)
+{
+ long start = m_pos;
+ long pos = m_pos;
+
+ if (IsIdentifierStartingChar(m_buffer[pos]))
+ {
+ pos++;
+
+ while (IsIdentifierChar(m_buffer[pos]))
+ pos++;
+ }
+
+ if (requireColon)
+ {
+ if (m_buffer[pos] == ':')
+ {
+ if (pos != start)
+ m_pos = pos + 1;
+ }
+ else
+ {
+ pos = start;
+ }
+ }
+ else
+ {
+ m_pos = pos;
+ }
+
+ return std::string(&m_buffer[start], pos - start);
+}
+
+// Skips tabs and spaces.
+void SymFile::SkipWhitespace()
+{
+ while (m_buffer[m_pos] == '\t' || m_buffer[m_pos] == ' ')
+ m_pos++;
+}
+
+// Reads include path.
+std::string SymFile::ReadPath()
+{
+ SkipWhitespace();
+
+ if (m_buffer[m_pos] != '"')
+ RaiseError("expected file path");
+
+ m_pos++;
+
+ int length = 0;
+ long startPos = m_pos;
+
+ while (m_buffer[m_pos] != '"')
+ {
+ unsigned char c = m_buffer[m_pos++];
+
+ if (c == 0)
+ {
+ if (m_pos >= m_size)
+ RaiseError("unexpected EOF in include string");
+ else
+ RaiseError("unexpected null character in include string");
+ }
+
+ if (!IsAsciiPrintable(c))
+ RaiseError("unexpected character '\\x%02X' in include string", c);
+
+ // Don't bother allowing any escape sequences.
+ if (c == '\\')
+ {
+ c = m_buffer[m_pos];
+ RaiseError("unexpected escape '\\%c' in include string", c);
+ }
+
+ length++;
+
+ if (length > kMaxPath)
+ RaiseError("path is too long");
+ }
+
+ m_pos++; // Go past the right quote.
+
+ return std::string(&m_buffer[startPos], length);
+}
+
+// If we're at a comma, consumes it.
+// Returns whether a comma was found.
+bool SymFile::ConsumeComma()
+{
+ if (m_buffer[m_pos] == ',')
+ {
+ m_pos++;
+ return true;
+ }
+
+ return false;
+}
+
+// Converts digit character to numerical value.
+static int ConvertDigit(char c, int radix)
+{
+ int digit;
+
+ if (c >= '0' && c <= '9')
+ digit = c - '0';
+ else if (c >= 'A' && c <= 'F')
+ digit = 10 + c - 'A';
+ else if (c >= 'a' && c <= 'f')
+ digit = 10 + c - 'a';
+ else
+ return -1;
+
+ return (digit < radix) ? digit : -1;
+}
+
+// Reads an integer.
+bool SymFile::ReadInteger(unsigned long& n)
+{
+ SkipWhitespace();
+
+ if (!IsAsciiDigit(m_buffer[m_pos]))
+ return false;
+
+ int startPos = m_pos;
+ int radix = 10;
+
+ if (m_buffer[m_pos] == '0' && m_buffer[m_pos + 1] == 'x')
+ {
+ radix = 16;
+ m_pos += 2;
+ }
+
+ unsigned long cutoff = ULONG_MAX / radix;
+ unsigned long cutoffRemainder = ULONG_MAX % radix;
+ int digit;
+
+ n = 0;
+
+ while ((digit = ConvertDigit(m_buffer[m_pos], radix)) != -1)
+ {
+ if (n < cutoff || (n == cutoff && (unsigned long)digit <= cutoffRemainder))
+ {
+ n = n * radix + digit;
+ }
+ else
+ {
+ m_pos++;
+
+ while (ConvertDigit(m_buffer[m_pos], radix) != -1)
+ m_pos++;
+
+ RaiseError("integer is too large (%s)", std::string(&m_buffer[startPos], m_pos - startPos).c_str());
+ }
+
+ m_pos++;
+ }
+
+ return true;
+}
+
+// Asserts that the rest of the line is empty and moves to the next one.
+void SymFile::ExpectEmptyRestOfLine()
+{
+ SkipWhitespace();
+
+ if (m_buffer[m_pos] == 0)
+ {
+ if (m_pos >= m_size)
+ RaiseWarning("file doesn't end with newline");
+ else
+ RaiseError("unexpected null character");
+ }
+ else if (m_buffer[m_pos] == '\n')
+ {
+ m_pos++;
+ m_lineStart = m_pos;
+ m_lineNum++;
+ }
+ else if (m_buffer[m_pos] == '\r')
+ {
+ RaiseError("only Unix-style LF newlines are supported");
+ }
+ else
+ {
+ RaiseError("junk at end of line");
+ }
+}
+
+
+void SymFile::SkipLine()
+{
+ while (m_buffer[m_pos] != 0 && m_buffer[m_pos] != '\n')
+ m_pos++;
+
+ if (m_buffer[m_pos] == '\n')
+ m_pos++;
+}
+
+// Checks if we're at the end of the file.
+bool SymFile::IsAtEnd()
+{
+ return (m_pos >= m_size);
+}
+
+void SymFile::HandleLangConditional(std::string lang)
+{
+ if (m_buffer[m_pos] != '#')
+ return;
+
+ m_pos++;
+
+ if (CheckForDirective("begin"))
+ {
+ if (m_inLangConditional)
+ RaiseError("already inside language conditional");
+
+ SkipWhitespace();
+
+ std::string label = GetLabel(false);
+
+ if (label.length() == 0)
+ RaiseError("no language name after #begin");
+
+ ExpectEmptyRestOfLine();
+
+ if (lang == label)
+ {
+ m_inLangConditional = true;
+ }
+ else
+ {
+ while (!IsAtEnd() && m_buffer[m_pos] != '#')
+ SkipLine();
+
+ if (m_buffer[m_pos] != '#')
+ RaiseError("unterminated language conditional");
+
+ m_pos++;
+
+ if (!CheckForDirective("end"))
+ RaiseError("expected #end");
+
+ ExpectEmptyRestOfLine();
+ }
+ }
+ else if (CheckForDirective("end"))
+ {
+ if (!m_inLangConditional)
+ RaiseError("not inside language conditional");
+
+ m_inLangConditional = false;
+
+ ExpectEmptyRestOfLine();
+ }
+ else
+ {
+ RaiseError("unknown # directive");
+ }
+}
+
+// Reports a diagnostic message.
+void SymFile::ReportDiagnostic(const char* type, const char* format, std::va_list args)
+{
+ const int bufferSize = 1024;
+ char buffer[bufferSize];
+ std::vsnprintf(buffer, bufferSize, format, args);
+ std::fprintf(stderr, "%s:%ld: %s: %s\n", m_filename.c_str(), m_lineNum, type, buffer);
+}
+
+#define DO_REPORT(type) \
+do \
+{ \
+ std::va_list args; \
+ va_start(args, format); \
+ ReportDiagnostic(type, format, args); \
+ va_end(args); \
+} while (0)
+
+// Reports an error diagnostic and terminates the program.
+void SymFile::RaiseError(const char* format, ...)
+{
+ DO_REPORT("error");
+ std::exit(1);
+}
+
+// Reports a warning diagnostic.
+void SymFile::RaiseWarning(const char* format, ...)
+{
+ DO_REPORT("warning");
+}
diff --git a/tools/rsfont/.gitignore b/tools/rsfont/.gitignore
index 89506e5..3140ece 100644
--- a/tools/rsfont/.gitignore
+++ b/tools/rsfont/.gitignore
@@ -1 +1 @@
-rsfont
+rsfont
diff --git a/tools/scaninc/.gitignore b/tools/scaninc/.gitignore
index a167a08..94bfbf9 100644
--- a/tools/scaninc/.gitignore
+++ b/tools/scaninc/.gitignore
@@ -1 +1 @@
-scaninc
+scaninc
diff --git a/tools/scaninc/asm_file.cpp b/tools/scaninc/asm_file.cpp
index e94d678..109e604 100644
--- a/tools/scaninc/asm_file.cpp
+++ b/tools/scaninc/asm_file.cpp
@@ -1,192 +1,192 @@
-// Copyright(c) 2015-2017 YamaArashi
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#include <cstdio>
-#include <string>
-#include "scaninc.h"
-#include "asm_file.h"
-
-AsmFile::AsmFile(std::string path)
-{
- m_path = path;
-
- FILE *fp = std::fopen(path.c_str(), "rb");
-
- if (fp == NULL)
- FATAL_ERROR("Failed to open \"%s\" for reading.\n", path.c_str());
-
- std::fseek(fp, 0, SEEK_END);
-
- m_size = std::ftell(fp);
-
- m_buffer = new char[m_size];
-
- std::rewind(fp);
-
- if (std::fread(m_buffer, m_size, 1, fp) != 1)
- FATAL_ERROR("Failed to read \"%s\".\n", path.c_str());
-
- std::fclose(fp);
-
- m_pos = 0;
- m_lineNum = 1;
-}
-
-AsmFile::~AsmFile()
-{
- delete[] m_buffer;
-}
-
-IncDirectiveType AsmFile::ReadUntilIncDirective(std::string &path)
-{
- // At the beginning of each loop iteration, the current file position
- // should be at the start of a line or at the end of the file.
- for (;;)
- {
- SkipTabsAndSpaces();
-
- IncDirectiveType incDirectiveType = IncDirectiveType::None;
-
- char c = PeekChar();
- if (c == '.' || c == '#')
- {
- m_pos++;
-
- if (MatchIncDirective("incbin", path))
- incDirectiveType = IncDirectiveType::Incbin;
- else if (MatchIncDirective("include", path))
- incDirectiveType = IncDirectiveType::Include;
- }
-
- for (;;)
- {
- int c = GetChar();
-
- if (c == -1)
- return incDirectiveType;
-
- if (c == ';')
- {
- SkipEndOfLineComment();
- break;
- }
- else if (c == '/' && PeekChar() == '*')
- {
- m_pos++;
- SkipMultiLineComment();
- }
- else if (c == '"')
- {
- SkipString();
- }
- else if (c == '\n')
- {
- break;
- }
- }
-
- if (incDirectiveType != IncDirectiveType::None)
- return incDirectiveType;
- }
-}
-
-std::string AsmFile::ReadPath()
-{
- int length = 0;
- int startPos = m_pos;
-
- for (;;)
- {
- int c = GetChar();
-
- if (c == '"')
- break;
-
- if (c == -1)
- FATAL_INPUT_ERROR("unexpected EOF in include string\n");
-
- if (c == 0)
- FATAL_INPUT_ERROR("unexpected NUL character in include string\n");
-
- if (c == '\n')
- FATAL_INPUT_ERROR("unexpected end of line character in include string\n");
-
- // Don't bother allowing any escape sequences.
- if (c == '\\')
- FATAL_INPUT_ERROR("unexpected escape in include string\n");
-
- length++;
-
- if (length > SCANINC_MAX_PATH)
- FATAL_INPUT_ERROR("path is too long");
- }
-
- return std::string(m_buffer + startPos, length);
-}
-
-void AsmFile::SkipEndOfLineComment()
-{
- int c;
-
- do
- {
- c = GetChar();
- } while (c != -1 && c != '\n');
-}
-
-void AsmFile::SkipMultiLineComment()
-{
- for (;;)
- {
- int c = GetChar();
-
- if (c == '*')
- {
- if (PeekChar() == '/')
- {
- m_pos++;
- return;
- }
- }
- else if (c == -1)
- {
- return;
- }
- }
-}
-
-void AsmFile::SkipString()
-{
- for (;;)
- {
- int c = GetChar();
-
- if (c == '"')
- break;
-
- if (c == -1)
- FATAL_INPUT_ERROR("unexpected EOF in string\n");
-
- if (c == '\\')
- {
- c = GetChar();
- }
- }
-}
+// Copyright(c) 2015-2017 YamaArashi
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#include <cstdio>
+#include <string>
+#include "scaninc.h"
+#include "asm_file.h"
+
+AsmFile::AsmFile(std::string path)
+{
+ m_path = path;
+
+ FILE *fp = std::fopen(path.c_str(), "rb");
+
+ if (fp == NULL)
+ FATAL_ERROR("Failed to open \"%s\" for reading.\n", path.c_str());
+
+ std::fseek(fp, 0, SEEK_END);
+
+ m_size = std::ftell(fp);
+
+ m_buffer = new char[m_size];
+
+ std::rewind(fp);
+
+ if (std::fread(m_buffer, m_size, 1, fp) != 1)
+ FATAL_ERROR("Failed to read \"%s\".\n", path.c_str());
+
+ std::fclose(fp);
+
+ m_pos = 0;
+ m_lineNum = 1;
+}
+
+AsmFile::~AsmFile()
+{
+ delete[] m_buffer;
+}
+
+IncDirectiveType AsmFile::ReadUntilIncDirective(std::string &path)
+{
+ // At the beginning of each loop iteration, the current file position
+ // should be at the start of a line or at the end of the file.
+ for (;;)
+ {
+ SkipTabsAndSpaces();
+
+ IncDirectiveType incDirectiveType = IncDirectiveType::None;
+
+ char c = PeekChar();
+ if (c == '.' || c == '#')
+ {
+ m_pos++;
+
+ if (MatchIncDirective("incbin", path))
+ incDirectiveType = IncDirectiveType::Incbin;
+ else if (MatchIncDirective("include", path))
+ incDirectiveType = IncDirectiveType::Include;
+ }
+
+ for (;;)
+ {
+ int c = GetChar();
+
+ if (c == -1)
+ return incDirectiveType;
+
+ if (c == ';')
+ {
+ SkipEndOfLineComment();
+ break;
+ }
+ else if (c == '/' && PeekChar() == '*')
+ {
+ m_pos++;
+ SkipMultiLineComment();
+ }
+ else if (c == '"')
+ {
+ SkipString();
+ }
+ else if (c == '\n')
+ {
+ break;
+ }
+ }
+
+ if (incDirectiveType != IncDirectiveType::None)
+ return incDirectiveType;
+ }
+}
+
+std::string AsmFile::ReadPath()
+{
+ int length = 0;
+ int startPos = m_pos;
+
+ for (;;)
+ {
+ int c = GetChar();
+
+ if (c == '"')
+ break;
+
+ if (c == -1)
+ FATAL_INPUT_ERROR("unexpected EOF in include string\n");
+
+ if (c == 0)
+ FATAL_INPUT_ERROR("unexpected NUL character in include string\n");
+
+ if (c == '\n')
+ FATAL_INPUT_ERROR("unexpected end of line character in include string\n");
+
+ // Don't bother allowing any escape sequences.
+ if (c == '\\')
+ FATAL_INPUT_ERROR("unexpected escape in include string\n");
+
+ length++;
+
+ if (length > SCANINC_MAX_PATH)
+ FATAL_INPUT_ERROR("path is too long");
+ }
+
+ return std::string(m_buffer + startPos, length);
+}
+
+void AsmFile::SkipEndOfLineComment()
+{
+ int c;
+
+ do
+ {
+ c = GetChar();
+ } while (c != -1 && c != '\n');
+}
+
+void AsmFile::SkipMultiLineComment()
+{
+ for (;;)
+ {
+ int c = GetChar();
+
+ if (c == '*')
+ {
+ if (PeekChar() == '/')
+ {
+ m_pos++;
+ return;
+ }
+ }
+ else if (c == -1)
+ {
+ return;
+ }
+ }
+}
+
+void AsmFile::SkipString()
+{
+ for (;;)
+ {
+ int c = GetChar();
+
+ if (c == '"')
+ break;
+
+ if (c == -1)
+ FATAL_INPUT_ERROR("unexpected EOF in string\n");
+
+ if (c == '\\')
+ {
+ c = GetChar();
+ }
+ }
+}
diff --git a/tools/scaninc/c_file.cpp b/tools/scaninc/c_file.cpp
index e3cd988..595f366 100644
--- a/tools/scaninc/c_file.cpp
+++ b/tools/scaninc/c_file.cpp
@@ -1,307 +1,307 @@
-// Copyright(c) 2017 YamaArashi
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#include "c_file.h"
-
-CFile::CFile(std::string path)
-{
- m_path = path;
-
- FILE *fp = std::fopen(path.c_str(), "rb");
-
- if (fp == NULL)
- FATAL_ERROR("Failed to open \"%s\" for reading.\n", path.c_str());
-
- std::fseek(fp, 0, SEEK_END);
-
- m_size = std::ftell(fp);
-
- m_buffer = new char[m_size + 1];
- m_buffer[m_size] = 0;
-
- std::rewind(fp);
-
- if (std::fread(m_buffer, m_size, 1, fp) != 1)
- FATAL_ERROR("Failed to read \"%s\".\n", path.c_str());
-
- std::fclose(fp);
-
- m_pos = 0;
- m_lineNum = 1;
-}
-
-CFile::~CFile()
-{
- delete[] m_buffer;
-}
-
-void CFile::FindIncbins()
-{
- char stringChar = 0;
-
- while (m_pos < m_size)
- {
- if (stringChar)
- {
- if (m_buffer[m_pos] == stringChar)
- {
- m_pos++;
- stringChar = 0;
- }
- else if (m_buffer[m_pos] == '\\' && m_buffer[m_pos + 1] == stringChar)
- {
- m_pos += 2;
- }
- else
- {
- if (m_buffer[m_pos] == '\n')
- m_lineNum++;
- m_pos++;
- }
- }
- else
- {
- SkipWhitespace();
- CheckInclude();
- CheckIncbin();
-
- if (m_pos >= m_size)
- break;
-
- char c = m_buffer[m_pos++];
-
- if (c == '\n')
- m_lineNum++;
- else if (c == '"')
- stringChar = '"';
- else if (c == '\'')
- stringChar = '\'';
- else if (c == 0)
- FATAL_INPUT_ERROR("unexpected null character");
- }
- }
-}
-
-bool CFile::ConsumeHorizontalWhitespace()
-{
- if (m_buffer[m_pos] == '\t' || m_buffer[m_pos] == ' ')
- {
- m_pos++;
- return true;
- }
-
- return false;
-}
-
-bool CFile::ConsumeNewline()
-{
- if (m_buffer[m_pos] == '\n')
- {
- m_pos++;
- m_lineNum++;
- return true;
- }
-
- if (m_buffer[m_pos] == '\r' && m_buffer[m_pos + 1] == '\n')
- {
- m_pos += 2;
- m_lineNum++;
- return true;
- }
-
- return false;
-}
-
-bool CFile::ConsumeComment()
-{
- if (m_buffer[m_pos] == '/' && m_buffer[m_pos + 1] == '*')
- {
- m_pos += 2;
- while (m_buffer[m_pos] != '*' || m_buffer[m_pos + 1] != '/')
- {
- if (m_buffer[m_pos] == 0)
- return false;
- if (!ConsumeNewline())
- m_pos++;
- }
- m_pos += 2;
- return true;
- }
- else if (m_buffer[m_pos] == '/' && m_buffer[m_pos + 1] == '/')
- {
- m_pos += 2;
- while (!ConsumeNewline())
- {
- if (m_buffer[m_pos] == 0)
- return false;
- m_pos++;
- }
- return true;
- }
-
- return false;
-}
-
-void CFile::SkipWhitespace()
-{
- while (ConsumeHorizontalWhitespace() || ConsumeNewline() || ConsumeComment())
- ;
-}
-
-bool CFile::CheckIdentifier(const std::string& ident)
-{
- unsigned int i;
-
- for (i = 0; i < ident.length() && m_pos + i < (unsigned)m_size; i++)
- if (ident[i] != m_buffer[m_pos + i])
- return false;
-
- return (i == ident.length());
-}
-
-void CFile::CheckInclude()
-{
- if (m_buffer[m_pos] != '#')
- return;
-
- std::string ident = "#include";
-
- if (!CheckIdentifier(ident))
- {
- return;
- }
-
- m_pos += ident.length();
-
- ConsumeHorizontalWhitespace();
-
- std::string path = ReadPath();
-
- if (!path.empty()) {
- m_includes.emplace(path);
- }
-}
-
-void CFile::CheckIncbin()
-{
- // Optimization: assume most lines are not incbins
- if (!(m_buffer[m_pos+0] == 'I'
- && m_buffer[m_pos+1] == 'N'
- && m_buffer[m_pos+2] == 'C'
- && m_buffer[m_pos+3] == 'B'
- && m_buffer[m_pos+4] == 'I'
- && m_buffer[m_pos+5] == 'N'
- && m_buffer[m_pos+6] == '_'))
- {
- return;
- }
-
- std::string idents[6] = { "INCBIN_S8", "INCBIN_U8", "INCBIN_S16", "INCBIN_U16", "INCBIN_S32", "INCBIN_U32" };
- int incbinType = -1;
-
- for (int i = 0; i < 6; i++)
- {
- if (CheckIdentifier(idents[i]))
- {
- incbinType = i;
- break;
- }
- }
-
- if (incbinType == -1)
- return;
-
- long oldPos = m_pos;
- long oldLineNum = m_lineNum;
-
- m_pos += idents[incbinType].length();
-
- SkipWhitespace();
-
- if (m_buffer[m_pos] != '(')
- {
- m_pos = oldPos;
- m_lineNum = oldLineNum;
- return;
- }
-
- m_pos++;
-
- while (true)
- {
- SkipWhitespace();
-
- std::string path = ReadPath();
-
- SkipWhitespace();
-
- m_incbins.emplace(path);
-
- if (m_buffer[m_pos] != ',')
- break;
-
- m_pos++;
- }
-
- if (m_buffer[m_pos] != ')')
- FATAL_INPUT_ERROR("expected ')'");
-
- m_pos++;
-
-}
-
-std::string CFile::ReadPath()
-{
- if (m_buffer[m_pos] != '"')
- {
- if (m_buffer[m_pos] == '<')
- {
- return std::string();
- }
- FATAL_INPUT_ERROR("expected '\"' or '<'");
- }
-
- m_pos++;
-
- int startPos = m_pos;
-
- while (m_buffer[m_pos] != '"')
- {
- if (m_buffer[m_pos] == 0)
- {
- if (m_pos >= m_size)
- FATAL_INPUT_ERROR("unexpected EOF in path string");
- else
- FATAL_INPUT_ERROR("unexpected null character in path string");
- }
-
- if (m_buffer[m_pos] == '\r' || m_buffer[m_pos] == '\n')
- FATAL_INPUT_ERROR("unexpected end of line character in path string");
-
- if (m_buffer[m_pos] == '\\')
- FATAL_INPUT_ERROR("unexpected escape in path string");
-
- m_pos++;
- }
-
- m_pos++;
-
- return std::string(m_buffer + startPos, m_pos - 1 - startPos);
-}
+// Copyright(c) 2017 YamaArashi
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#include "c_file.h"
+
+CFile::CFile(std::string path)
+{
+ m_path = path;
+
+ FILE *fp = std::fopen(path.c_str(), "rb");
+
+ if (fp == NULL)
+ FATAL_ERROR("Failed to open \"%s\" for reading.\n", path.c_str());
+
+ std::fseek(fp, 0, SEEK_END);
+
+ m_size = std::ftell(fp);
+
+ m_buffer = new char[m_size + 1];
+ m_buffer[m_size] = 0;
+
+ std::rewind(fp);
+
+ if (std::fread(m_buffer, m_size, 1, fp) != 1)
+ FATAL_ERROR("Failed to read \"%s\".\n", path.c_str());
+
+ std::fclose(fp);
+
+ m_pos = 0;
+ m_lineNum = 1;
+}
+
+CFile::~CFile()
+{
+ delete[] m_buffer;
+}
+
+void CFile::FindIncbins()
+{
+ char stringChar = 0;
+
+ while (m_pos < m_size)
+ {
+ if (stringChar)
+ {
+ if (m_buffer[m_pos] == stringChar)
+ {
+ m_pos++;
+ stringChar = 0;
+ }
+ else if (m_buffer[m_pos] == '\\' && m_buffer[m_pos + 1] == stringChar)
+ {
+ m_pos += 2;
+ }
+ else
+ {
+ if (m_buffer[m_pos] == '\n')
+ m_lineNum++;
+ m_pos++;
+ }
+ }
+ else
+ {
+ SkipWhitespace();
+ CheckInclude();
+ CheckIncbin();
+
+ if (m_pos >= m_size)
+ break;
+
+ char c = m_buffer[m_pos++];
+
+ if (c == '\n')
+ m_lineNum++;
+ else if (c == '"')
+ stringChar = '"';
+ else if (c == '\'')
+ stringChar = '\'';
+ else if (c == 0)
+ FATAL_INPUT_ERROR("unexpected null character");
+ }
+ }
+}
+
+bool CFile::ConsumeHorizontalWhitespace()
+{
+ if (m_buffer[m_pos] == '\t' || m_buffer[m_pos] == ' ')
+ {
+ m_pos++;
+ return true;
+ }
+
+ return false;
+}
+
+bool CFile::ConsumeNewline()
+{
+ if (m_buffer[m_pos] == '\n')
+ {
+ m_pos++;
+ m_lineNum++;
+ return true;
+ }
+
+ if (m_buffer[m_pos] == '\r' && m_buffer[m_pos + 1] == '\n')
+ {
+ m_pos += 2;
+ m_lineNum++;
+ return true;
+ }
+
+ return false;
+}
+
+bool CFile::ConsumeComment()
+{
+ if (m_buffer[m_pos] == '/' && m_buffer[m_pos + 1] == '*')
+ {
+ m_pos += 2;
+ while (m_buffer[m_pos] != '*' || m_buffer[m_pos + 1] != '/')
+ {
+ if (m_buffer[m_pos] == 0)
+ return false;
+ if (!ConsumeNewline())
+ m_pos++;
+ }
+ m_pos += 2;
+ return true;
+ }
+ else if (m_buffer[m_pos] == '/' && m_buffer[m_pos + 1] == '/')
+ {
+ m_pos += 2;
+ while (!ConsumeNewline())
+ {
+ if (m_buffer[m_pos] == 0)
+ return false;
+ m_pos++;
+ }
+ return true;
+ }
+
+ return false;
+}
+
+void CFile::SkipWhitespace()
+{
+ while (ConsumeHorizontalWhitespace() || ConsumeNewline() || ConsumeComment())
+ ;
+}
+
+bool CFile::CheckIdentifier(const std::string& ident)
+{
+ unsigned int i;
+
+ for (i = 0; i < ident.length() && m_pos + i < (unsigned)m_size; i++)
+ if (ident[i] != m_buffer[m_pos + i])
+ return false;
+
+ return (i == ident.length());
+}
+
+void CFile::CheckInclude()
+{
+ if (m_buffer[m_pos] != '#')
+ return;
+
+ std::string ident = "#include";
+
+ if (!CheckIdentifier(ident))
+ {
+ return;
+ }
+
+ m_pos += ident.length();
+
+ ConsumeHorizontalWhitespace();
+
+ std::string path = ReadPath();
+
+ if (!path.empty()) {
+ m_includes.emplace(path);
+ }
+}
+
+void CFile::CheckIncbin()
+{
+ // Optimization: assume most lines are not incbins
+ if (!(m_buffer[m_pos+0] == 'I'
+ && m_buffer[m_pos+1] == 'N'
+ && m_buffer[m_pos+2] == 'C'
+ && m_buffer[m_pos+3] == 'B'
+ && m_buffer[m_pos+4] == 'I'
+ && m_buffer[m_pos+5] == 'N'
+ && m_buffer[m_pos+6] == '_'))
+ {
+ return;
+ }
+
+ std::string idents[6] = { "INCBIN_S8", "INCBIN_U8", "INCBIN_S16", "INCBIN_U16", "INCBIN_S32", "INCBIN_U32" };
+ int incbinType = -1;
+
+ for (int i = 0; i < 6; i++)
+ {
+ if (CheckIdentifier(idents[i]))
+ {
+ incbinType = i;
+ break;
+ }
+ }
+
+ if (incbinType == -1)
+ return;
+
+ long oldPos = m_pos;
+ long oldLineNum = m_lineNum;
+
+ m_pos += idents[incbinType].length();
+
+ SkipWhitespace();
+
+ if (m_buffer[m_pos] != '(')
+ {
+ m_pos = oldPos;
+ m_lineNum = oldLineNum;
+ return;
+ }
+
+ m_pos++;
+
+ while (true)
+ {
+ SkipWhitespace();
+
+ std::string path = ReadPath();
+
+ SkipWhitespace();
+
+ m_incbins.emplace(path);
+
+ if (m_buffer[m_pos] != ',')
+ break;
+
+ m_pos++;
+ }
+
+ if (m_buffer[m_pos] != ')')
+ FATAL_INPUT_ERROR("expected ')'");
+
+ m_pos++;
+
+}
+
+std::string CFile::ReadPath()
+{
+ if (m_buffer[m_pos] != '"')
+ {
+ if (m_buffer[m_pos] == '<')
+ {
+ return std::string();
+ }
+ FATAL_INPUT_ERROR("expected '\"' or '<'");
+ }
+
+ m_pos++;
+
+ int startPos = m_pos;
+
+ while (m_buffer[m_pos] != '"')
+ {
+ if (m_buffer[m_pos] == 0)
+ {
+ if (m_pos >= m_size)
+ FATAL_INPUT_ERROR("unexpected EOF in path string");
+ else
+ FATAL_INPUT_ERROR("unexpected null character in path string");
+ }
+
+ if (m_buffer[m_pos] == '\r' || m_buffer[m_pos] == '\n')
+ FATAL_INPUT_ERROR("unexpected end of line character in path string");
+
+ if (m_buffer[m_pos] == '\\')
+ FATAL_INPUT_ERROR("unexpected escape in path string");
+
+ m_pos++;
+ }
+
+ m_pos++;
+
+ return std::string(m_buffer + startPos, m_pos - 1 - startPos);
+}