"Fossies" - the Fresh Open Source Software Archive 
Member "netxms-3.8.166/src/libnxsl/storage.cpp" (23 Feb 2021, 1946 Bytes) of package /linux/misc/netxms-3.8.166.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "storage.cpp" see the
Fossies "Dox" file reference documentation.
1 /*
2 ** NetXMS - Network Management System
3 ** NetXMS Scripting Language Interpreter
4 ** Copyright (C) 2003-2020 Victor Kirhenshtein
5 **
6 ** This program is free software; you can redistribute it and/or modify
7 ** it under the terms of the GNU Lesser General Public License as published by
8 ** the Free Software Foundation; either version 3 of the License, or
9 ** (at your option) any later version.
10 **
11 ** This program is distributed in the hope that it will be useful,
12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ** GNU General Public License for more details.
15 **
16 ** You should have received a copy of the GNU Lesser General Public License
17 ** along with this program; if not, write to the Free Software
18 ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 **
20 ** File: storage.cpp
21 **
22 **/
23
24 #include "libnxsl.h"
25
26 /**
27 * Constructor
28 */
29 NXSL_Storage::NXSL_Storage()
30 {
31 }
32
33 /**
34 * Destructor
35 */
36 NXSL_Storage::~NXSL_Storage()
37 {
38 }
39
40 /**
41 * Local storage constructor
42 */
43 NXSL_LocalStorage::NXSL_LocalStorage(NXSL_VM *vm) : NXSL_Storage()
44 {
45 m_vm = vm;
46 m_values = new NXSL_StringValueMap(vm, Ownership::True);
47 }
48
49 /**
50 * Local storage destructor
51 */
52 NXSL_LocalStorage::~NXSL_LocalStorage()
53 {
54 delete m_values;
55 }
56
57 /**
58 * Write to storage. Storage becomes owner of provided value.
59 * Passing NULL value will effectively remove value from storage.
60 */
61 void NXSL_LocalStorage::write(const TCHAR *name, NXSL_Value *value)
62 {
63 if ((value == NULL) || value->isNull())
64 m_values->remove(name);
65 else
66 m_values->set(name, m_vm->createValue(value));
67 }
68
69 /**
70 * Read from storage. Returns new value owned by caller. Returns NXSL NULL if there are no value with given name.
71 */
72 NXSL_Value *NXSL_LocalStorage::read(const TCHAR *name, NXSL_ValueManager *vm)
73 {
74 NXSL_Value *v = m_values->get(name);
75 return (v != NULL) ? vm->createValue(v) : vm->createValue();
76 }