2015-03-23 22:17:59 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2012 Zynga Inc.
|
2017-02-14 14:36:57 +08:00
|
|
|
Copyright (c) 2013-2017 Chukong Technologies Inc.
|
2013-01-06 11:57:10 +08:00
|
|
|
|
2015-03-23 22:17:59 +08:00
|
|
|
http://www.cocos2d-x.org
|
2013-01-06 11:57:10 +08:00
|
|
|
|
|
|
|
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.
|
2015-03-23 22:17:59 +08:00
|
|
|
****************************************************************************/
|
2013-01-06 11:57:10 +08:00
|
|
|
|
|
|
|
#ifndef __JSB_LOCALSTORAGE_H
|
|
|
|
#define __JSB_LOCALSTORAGE_H
|
|
|
|
|
2014-01-20 22:31:56 +08:00
|
|
|
#include <string>
|
2016-03-20 21:53:44 +08:00
|
|
|
#include "platform/CCPlatformMacros.h"
|
2013-01-06 11:57:10 +08:00
|
|
|
|
2015-03-24 14:12:58 +08:00
|
|
|
/**
|
2015-05-28 15:48:08 +08:00
|
|
|
* @addtogroup storage
|
2015-03-24 14:12:58 +08:00
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2015-03-23 22:17:59 +08:00
|
|
|
/** Local Storage support for the JS Bindings.*/
|
|
|
|
|
|
|
|
/** Initializes the database. If path is null, it will create an in-memory DB. */
|
2014-10-17 11:52:59 +08:00
|
|
|
void CC_DLL localStorageInit( const std::string& fullpath = "");
|
2013-01-06 11:57:10 +08:00
|
|
|
|
2015-03-23 22:17:59 +08:00
|
|
|
/** Frees the allocated resources. */
|
2014-10-17 11:52:59 +08:00
|
|
|
void CC_DLL localStorageFree();
|
2013-01-06 11:57:10 +08:00
|
|
|
|
2015-03-23 22:17:59 +08:00
|
|
|
/** Sets an item in the JS. */
|
2014-10-17 11:52:59 +08:00
|
|
|
void CC_DLL localStorageSetItem( const std::string& key, const std::string& value);
|
2013-01-06 11:57:10 +08:00
|
|
|
|
2015-03-23 22:17:59 +08:00
|
|
|
/** Gets an item from the JS. */
|
2015-04-23 19:06:06 +08:00
|
|
|
bool CC_DLL localStorageGetItem( const std::string& key, std::string *outItem );
|
2013-01-06 11:57:10 +08:00
|
|
|
|
2015-03-23 22:17:59 +08:00
|
|
|
/** Removes an item from the JS. */
|
2014-10-17 11:52:59 +08:00
|
|
|
void CC_DLL localStorageRemoveItem( const std::string& key );
|
2013-01-06 11:57:10 +08:00
|
|
|
|
2015-05-12 18:02:14 +08:00
|
|
|
/** Removes all items from the JS. */
|
|
|
|
void CC_DLL localStorageClear();
|
|
|
|
|
2015-03-24 14:12:58 +08:00
|
|
|
// end group
|
|
|
|
/// @}
|
|
|
|
|
2013-01-06 11:57:10 +08:00
|
|
|
#endif // __JSB_LOCALSTORAGE_H
|