DayZ 1.26
DayZ Explorer by KGB
Загрузка...
Поиск...
Не найдено
Класс JsonFileLoader< Class T >

Защищенные статические члены

static bool LoadFile (string filename, out T data, out string errorMessage)
 
static bool SaveFile (string filename, T data, out string errorMessage)
 
static bool LoadData (string string_data, out T data, out string errorMessage)
 
static bool MakeData (T inputData, out string outputData, out string errorMessage, bool prettyPrint=true)
 
static void JsonLoadFile (string filename, out T data)
 #ifndef DIAG_DEVELOPER
 
static void JsonSaveFile (string filename, T data)
 use JsonFileLoader::SaveFile instead
 
static void JsonLoadData (string string_data, out T data)
 use JsonFileLoader::LoadData instead
 
static string JsonMakeData (T data)
 use JsonFileLoader::MakeData instead
 

Статические защищенные данные

static ref JsonSerializer m_Serializer = new JsonSerializer()
 

Подробное описание

Методы

◆ JsonLoadData()

static void JsonLoadData ( string string_data,
out T data )
inlinestaticprotected

use JsonFileLoader::LoadData instead

154 {
155 string error;
156 if (!m_Serializer)
158
159 if (!m_Serializer.ReadFromString(data, string_data, error))
160 ErrorEx(string.Format("Cannot load data %1", error));
161 }
static ref JsonSerializer m_Serializer
Definition JsonFileLoader.c:3
Class for sending RPC over network.
Definition gameplay.c:50
Definition EntityAI.c:95
enum ShapeType ErrorEx

Перекрестные ссылки ErrorEx.

◆ JsonLoadFile()

static void JsonLoadFile ( string filename,
out T data )
inlinestaticprotected

#ifndef DIAG_DEVELOPER

DEPRECATED

use JsonFileLoader::LoadFile instead

108 {
109
110 if (FileExist(filename))
111 {
112 string file_content;
113 string line_content;
114 string error;
115
116 FileHandle handle = OpenFile(filename, FileMode.READ);
117 if (handle == 0)
118 return;
119
120 while (FGets(handle, line_content) >= 0)
121 {
123 }
124
125 CloseFile(handle);
126
127 if (!m_Serializer)
129
130 if (!m_Serializer.ReadFromString(data, file_content, error))
131 ErrorEx(string.Format("Cannot load data from \"%1\":\n%2", filename, error));
132 }
133 }
FileMode
Definition EnSystem.c:383
proto void CloseFile(FileHandle file)
Close the File.
proto int FGets(FileHandle file, string var)
Get line from file, every next call of this function returns next line.
proto FileHandle OpenFile(string name, FileMode mode)
Opens File.
proto bool FileExist(string name)
Check existence of file.

Перекрестные ссылки CloseFile(), ErrorEx, FGets(), FileExist() и OpenFile().

◆ JsonMakeData()

static string JsonMakeData ( T data)
inlinestaticprotected

use JsonFileLoader::MakeData instead

165 {
166 string string_data;
167 if (!m_Serializer)
169
170 m_Serializer.WriteToString(data, true, string_data);
171 return string_data;
172 }

◆ JsonSaveFile()

static void JsonSaveFile ( string filename,
T data )
inlinestaticprotected

use JsonFileLoader::SaveFile instead

137 {
138 string file_content;
139 if (!m_Serializer)
141
142 m_Serializer.WriteToString(data, true, file_content);
143
144 FileHandle handle = OpenFile(filename, FileMode.WRITE);
145 if (handle == 0)
146 return;
147
148 FPrint(handle, file_content);
149 CloseFile(handle);
150 }
proto void FPrint(FileHandle file, void var)
Write to file.

Перекрестные ссылки CloseFile(), FPrint() и OpenFile().

◆ LoadData()

static bool LoadData ( string string_data,
out T data,
out string errorMessage )
inlinestaticprotected
72 {
73 string error;
74
75 if (!m_Serializer)
77
78 if (!m_Serializer.ReadFromString(data, string_data, error))
79 {
80 errorMessage = string.Format("Cannot load provided JSON data (deserialization error) - check syntax: %1", error);
81 return false;
82 }
83
84 return true;
85 }

◆ LoadFile()

static bool LoadFile ( string filename,
out T data,
out string errorMessage )
inlinestaticprotected
6 {
8 {
9 FileHandle handle = OpenFile(filename, FileMode.READ);
10 if (handle == 0)
11 {
12 errorMessage = string.Format("Cannot open file \"%1\" for reading", filename);
13 return false;
14 }
15
16 string fileContent;
17 string lineContent;
18 while (FGets(handle, lineContent) >= 0)
19 {
21 }
22
23 CloseFile(handle);
24
25 if (!m_Serializer)
27
28 string error;
29 if (!m_Serializer.ReadFromString(data, fileContent, error))
30 {
31 errorMessage = string.Format("Cannot load data from \"%1\":\n%2", filename, error);
32 return false;
33 }
34
35 return true;
36 }
37 else
38 {
39 errorMessage = string.Format("File \"%1\" does not exist, check the provided path", filename, error);
40 return false;
41 }
42 }

Перекрестные ссылки CloseFile(), FGets(), FileExist() и OpenFile().

◆ MakeData()

static bool MakeData ( T inputData,
out string outputData,
out string errorMessage,
bool prettyPrint = true )
inlinestaticprotected
88 {
89 if (!m_Serializer)
91
92 if (!m_Serializer.WriteToString(inputData, prettyPrint, outputData))
93 {
94 errorMessage = "Cannot create JSON from provided data (serialization error)";
95 return false;
96 }
97
98 return true;
99 }

◆ SaveFile()

static bool SaveFile ( string filename,
T data,
out string errorMessage )
inlinestaticprotected
45 {
46 string fileContent;
47
48 if (!m_Serializer)
50
51 string makeDataError;
53 {
54 errorMessage = string.Format("Cannot save data to file \"%1\", %2", filename, makeDataError);
55 return false;
56 }
57
58 FileHandle handle = OpenFile(filename, FileMode.WRITE);
59 if (handle == 0)
60 {
61 errorMessage = string.Format("Cannot open file \"%1\" for writing", filename);
62 return false;
63 }
64
65 FPrint(handle, fileContent);
66 CloseFile(handle);
67
68 return true;
69 }
static bool MakeData(T inputData, out string outputData, out string errorMessage, bool prettyPrint=true)
Definition JsonFileLoader.c:87

Перекрестные ссылки CloseFile(), FPrint() и OpenFile().

Поля

◆ m_Serializer

ref JsonSerializer m_Serializer = new JsonSerializer()
staticprotected

Объявления и описания членов класса находятся в файле: