2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2009 - DIGITEO - Allan CORNET
5 * This file must be used under the terms of the CeCILL.
6 * This source file is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at
9 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
12 /*--------------------------------------------------------------------------*/
13 #include "diary_manager.hxx"
14 #include "DiaryList.hxx"
17 /*--------------------------------------------------------------------------*/
18 static DiaryList *SCIDIARY = NULL;
19 /*--------------------------------------------------------------------------*/
20 static int createDiaryManager(void)
24 SCIDIARY = new DiaryList();
29 /*--------------------------------------------------------------------------*/
30 static int destroyDiaryManager(void)
40 /*--------------------------------------------------------------------------*/
41 wchar_t *getDiaryFilename(int _Id)
43 wchar_t *wcFilename = NULL;
46 if (SCIDIARY->getFilename(_Id).compare(L""))
48 wcFilename = (wchar_t*) MALLOC(sizeof(wchar_t) * (SCIDIARY->getFilename(_Id).length() + 1));
49 if (wcFilename) wcscpy(wcFilename, SCIDIARY->getFilename(_Id).c_str());
54 /*--------------------------------------------------------------------------*/
55 wchar_t **getDiaryFilenames(int *array_size)
60 std::wstring * wstringFilenames = SCIDIARY->getFilenames(array_size);
63 wchar_t **wcFilenames = (wchar_t **) MALLOC (sizeof(wchar_t*) *(*array_size));
64 for(int i = 0; i < *array_size; i++)
66 wcFilenames[i] = (wchar_t*) MALLOC(sizeof(wchar_t) * (wstringFilenames[i].length() + 1));
67 wcscpy(wcFilenames[i], wstringFilenames[i].c_str());
74 /*--------------------------------------------------------------------------*/
75 int *getDiaryIDs(int *array_size)
80 int *iIDs = SCIDIARY->getIDs(array_size);
85 /*--------------------------------------------------------------------------*/
86 double *getDiaryIDsAsDouble(int *array_size)
88 int *iIDs = getDiaryIDs(array_size);
93 double *dIDs = new double[*array_size];
94 for(int i = 0;i < *array_size; i++)
96 dIDs[i] = (double)iIDs[i];
108 /*--------------------------------------------------------------------------*/
109 int diaryCloseAll(void)
111 destroyDiaryManager();
114 /*--------------------------------------------------------------------------*/
115 int diaryClose(int _iId)
121 if (SCIDIARY->closeDiary(_iId)) return 0;
126 /*--------------------------------------------------------------------------*/
127 int diaryClose(wchar_t *filename)
131 int iID = SCIDIARY->getID(filename);
134 if (SCIDIARY->closeDiary(iID)) return 0;
139 /*--------------------------------------------------------------------------*/
140 int diaryPauseAll(void)
144 SCIDIARY->setSuspendWrite(true);
149 /*--------------------------------------------------------------------------*/
150 int diaryPause(int _iId)
154 SCIDIARY->setSuspendWrite(_iId, true);
159 /*--------------------------------------------------------------------------*/
160 int diaryPause(wchar_t *filename)
164 int iID = SCIDIARY->getID(std::wstring(filename));
167 SCIDIARY->setSuspendWrite(iID, true);
173 /*--------------------------------------------------------------------------*/
174 int diaryResumeAll(void)
178 SCIDIARY->setSuspendWrite(false);
183 /*--------------------------------------------------------------------------*/
184 int diaryResume(int _iId)
188 SCIDIARY->setSuspendWrite(_iId, false);
193 /*--------------------------------------------------------------------------*/
194 int diaryResume(wchar_t *filename)
198 int iID = SCIDIARY->getID(std::wstring(filename));
201 SCIDIARY->setSuspendWrite(iID, false);
207 /*--------------------------------------------------------------------------*/
208 int diaryExists(int _iId)
212 if (SCIDIARY->exists(_iId)) return 0;
216 /*--------------------------------------------------------------------------*/
217 int diaryExists(wchar_t *filename)
221 if (SCIDIARY->exists(std::wstring(filename))) return 0;
225 /*--------------------------------------------------------------------------*/
226 int diaryNew(wchar_t *filename, bool autorename)
228 createDiaryManager();
232 return SCIDIARY->openDiary(std::wstring(filename),autorename);
237 /*--------------------------------------------------------------------------*/
238 int diaryAppend(wchar_t *filename)
240 createDiaryManager();
243 return SCIDIARY->openDiary(std::wstring(filename),1,false);
247 /*--------------------------------------------------------------------------*/
248 int diaryWrite(const wchar_t *wstr, BOOL bInput)
252 if (bInput) SCIDIARY->write(std::wstring(wstr), true);
253 else SCIDIARY->write(std::wstring(wstr), false);
258 /*--------------------------------------------------------------------------*/
259 int diaryWriteln(const wchar_t *wstr, BOOL bInput)
263 if (bInput) SCIDIARY->writeln(std::wstring(wstr), true);
264 else SCIDIARY->writeln(std::wstring(wstr), false);
269 /*--------------------------------------------------------------------------*/
270 int diarySetFilterMode(int _iId, diary_filter mode)
274 SCIDIARY->setFilterMode(_iId, mode);
279 /*--------------------------------------------------------------------------*/
280 int diarySetPrefixMode(int ID_diary,diary_prefix_time_format iPrefixMode)
284 SCIDIARY->setPrefixMode(ID_diary, iPrefixMode);
289 /*--------------------------------------------------------------------------*/
290 int diaryGetPrefixMode(int ID_diary)
294 return SCIDIARY->getPrefixMode(ID_diary);
298 /*--------------------------------------------------------------------------*/
299 int diarySetPrefixIoModeFilter(int ID_diary,diary_prefix_time_filter mode)
303 SCIDIARY->setPrefixIoModeFilter(ID_diary, mode);
308 /*--------------------------------------------------------------------------*/
309 diary_prefix_time_filter diaryGetPrefixIoModeFilter(int ID_diary)
313 return SCIDIARY->getPrefixIoModeFilter(ID_diary);
315 return PREFIX_FILTER_ERROR;
317 /*--------------------------------------------------------------------------*/