| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef PPAPI_SHARED_IMPL_VAR_H_ | 5 #ifndef PPAPI_SHARED_IMPL_VAR_H_ |
| 6 #define PPAPI_SHARED_IMPL_VAR_H_ | 6 #define PPAPI_SHARED_IMPL_VAR_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 // Returning a given string as a PP_Var: | 83 // Returning a given string as a PP_Var: |
| 84 // return StringVar::StringToPPVar(module, my_string); | 84 // return StringVar::StringToPPVar(module, my_string); |
| 85 // | 85 // |
| 86 // Converting a PP_Var to a string: | 86 // Converting a PP_Var to a string: |
| 87 // StringVar* string = StringVar::FromPPVar(var); | 87 // StringVar* string = StringVar::FromPPVar(var); |
| 88 // if (!string) | 88 // if (!string) |
| 89 // return false; // Not a string or an invalid var. | 89 // return false; // Not a string or an invalid var. |
| 90 // DoSomethingWithTheString(string->value()); | 90 // DoSomethingWithTheString(string->value()); |
| 91 class StringVar : public Var { | 91 class StringVar : public Var { |
| 92 public: | 92 public: |
| 93 StringVar(PP_Module module, const std::string& str); |
| 93 StringVar(PP_Module module, const char* str, uint32 len); | 94 StringVar(PP_Module module, const char* str, uint32 len); |
| 94 virtual ~StringVar(); | 95 virtual ~StringVar(); |
| 95 | 96 |
| 96 const std::string& value() const { return value_; } | 97 const std::string& value() const { return value_; } |
| 97 | 98 |
| 98 // Var override. | 99 // Var override. |
| 99 virtual StringVar* AsStringVar() OVERRIDE; | 100 virtual StringVar* AsStringVar() OVERRIDE; |
| 100 virtual PP_Var GetPPVar() OVERRIDE; | 101 virtual PP_Var GetPPVar() OVERRIDE; |
| 101 virtual PP_VarType GetType() const OVERRIDE; | 102 virtual PP_VarType GetType() const OVERRIDE; |
| 102 | 103 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 116 | 117 |
| 117 private: | 118 private: |
| 118 std::string value_; | 119 std::string value_; |
| 119 | 120 |
| 120 DISALLOW_COPY_AND_ASSIGN(StringVar); | 121 DISALLOW_COPY_AND_ASSIGN(StringVar); |
| 121 }; | 122 }; |
| 122 | 123 |
| 123 } // namespace ppapi | 124 } // namespace ppapi |
| 124 | 125 |
| 125 #endif // PPAPI_SHARED_IMPL_VAR_H_ | 126 #endif // PPAPI_SHARED_IMPL_VAR_H_ |
| OLD | NEW |