OLD | NEW |
| (Empty) |
1 // Copyright 2010 The Native Client Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can | |
3 // be found in the LICENSE file. | |
4 | |
5 #ifndef C_SALT_NPAPI_SCOPED_NPID_TO_STRING_CONVERTER_H_ | |
6 #define C_SALT_NPAPI_SCOPED_NPID_TO_STRING_CONVERTER_H_ | |
7 | |
8 #include <nacl/nacl_npapi.h> | |
9 #include <nacl/npruntime.h> | |
10 | |
11 #include <string> | |
12 | |
13 namespace c_salt { | |
14 namespace npapi { | |
15 | |
16 // A small helper class that converts an NPIdentifier into a std::string. | |
17 // It follows the RAII pattern: when the class goes out of scope, the memory | |
18 // used to get the string is freed with NPN_MemFree(). | |
19 class ScopedNPIdToStringConverter { | |
20 public: | |
21 explicit ScopedNPIdToStringConverter(const NPIdentifier& np_id); | |
22 ~ScopedNPIdToStringConverter(); | |
23 const std::string& string_value() const; | |
24 private: | |
25 NPUTF8* np_string_; | |
26 std::string string_value_; | |
27 }; | |
28 | |
29 } // namespace npapi | |
30 } // namespace c_salt | |
31 | |
32 #endif // C_SALT_NPAPI_SCOPED_NPID_TO_STRING_CONVERTER_H_ | |
OLD | NEW |