blob: b5239b29e090d3e651b75ba1747c3c72e4ecf49f [file] [log] [blame]
// Copyright 2016 The Cobalt Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Module Overview: Starboard StorageRecord module
//
// Implements a convenience class that builds on top of the core Starboard
// storage functionality.
#ifndef STARBOARD_COMMON_STORAGE_H_
#define STARBOARD_COMMON_STORAGE_H_
#include <string>
#include "starboard/configuration.h"
#include "starboard/storage.h"
#include "starboard/types.h"
#if SB_API_VERSION < 16
#include "starboard/user.h"
#endif
namespace starboard {
class StorageRecord {
public:
StorageRecord();
explicit StorageRecord(const char* name);
#if SB_API_VERSION < 16
explicit StorageRecord(SbUser user);
StorageRecord(SbUser user, const char* name);
#endif
~StorageRecord();
bool IsValid();
int64_t GetSize();
int64_t Read(char* out_data, int64_t data_size);
bool Write(const char* data, int64_t data_size);
bool Close();
bool Delete();
private:
void Initialize();
#if SB_API_VERSION < 16
SbUser user_;
#endif
std::string name_;
SbStorageRecord record_;
};
} // namespace starboard
#endif // STARBOARD_COMMON_STORAGE_H_