OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef PPAPI_CPP_DEV_STRING_WRAPPER_DEV_H_ |
| 6 #define PPAPI_CPP_DEV_STRING_WRAPPER_DEV_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "ppapi/c/pp_var.h" |
| 11 #include "ppapi/cpp/dev/may_own_ptr_dev.h" |
| 12 |
| 13 namespace pp { |
| 14 namespace internal { |
| 15 |
| 16 class StringWrapper { |
| 17 public: |
| 18 StringWrapper(PP_Var* storage, NotOwned); |
| 19 explicit StringWrapper(const std::string& value); |
| 20 StringWrapper(const StringWrapper& other); |
| 21 |
| 22 ~StringWrapper(); |
| 23 |
| 24 StringWrapper& operator=(const StringWrapper& other); |
| 25 StringWrapper& operator=(const PP_Var& other); |
| 26 |
| 27 bool is_set() const; |
| 28 void unset(); |
| 29 // TODO(yzshen): it should be easy to add a cache. |
| 30 std::string get() const; |
| 31 void set(const std::string& value); |
| 32 |
| 33 const PP_Var& ToVar() const { |
| 34 return *storage_; |
| 35 } |
| 36 |
| 37 PP_Var* StartRawUpdate() { return storage_.get(); } |
| 38 void EndRawUpdate() {} |
| 39 |
| 40 private: |
| 41 MayOwnPtr<PP_Var> storage_; |
| 42 }; |
| 43 |
| 44 } // namespace internal |
| 45 } // namespace pp |
| 46 |
| 47 #endif // PPAPI_CPP_DEV_STRING_WRAPPER_DEV_H_ |
OLD | NEW |