From e826c9b1a0a1ee0289125546b7c57318074e802a Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Tue, 23 Nov 2010 14:46:01 +0000 Subject: [PATCH] - Fix Mac compile errors due to string type changes (issue #146). - Fix Windows crash due to string type changes (issue #147). - Add missing svn:eol-style properties. git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@149 5089003a-bbd8-11dd-ad1f-f1f9622dbc98 --- include/cef_string_types.h | 367 +++--- include/cef_string_wrappers.h | 1250 ++++++++++---------- libcef/browser_impl.cc | 6 +- libcef/browser_impl_win.cc | 1 + libcef/browser_settings.h | 26 +- libcef/browser_webview_delegate_mac.mm | 27 +- libcef/browser_webview_delegate_win.cc | 2 + libcef/cef_context.cc | 4 - libcef/cef_string_types.cc | 3 +- libcef/request_impl.cc | 4 - libcef/webwidget_host_mac.mm | 2 +- libcef_dll/cpptoc/handler_cpptoc.cc | 32 +- libcef_dll/cpptoc/scheme_handler_cpptoc.cc | 3 +- libcef_dll/cpptoc/v8handler_cpptoc.cc | 3 +- libcef_dll/cpptoc/v8value_cpptoc.cc | 3 +- libcef_dll/cpptoc/xml_reader_cpptoc.cc | 768 ++++++------ libcef_dll/cpptoc/xml_reader_cpptoc.h | 68 +- libcef_dll/ctocpp/xml_reader_ctocpp.cc | 628 +++++----- libcef_dll/ctocpp/xml_reader_ctocpp.h | 138 +-- tests/cefclient/cefclient_mac.mm | 17 +- tests/cefclient/res/localstorage.html | 48 +- tests/unittests/string_unittest.cc | 6 +- 22 files changed, 1699 insertions(+), 1707 deletions(-) diff --git a/include/cef_string_types.h b/include/cef_string_types.h index 3bb0467b7..b66923545 100644 --- a/include/cef_string_types.h +++ b/include/cef_string_types.h @@ -1,183 +1,184 @@ -// Copyright (c) 2010 Marshall A. Greenblatt. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the name Chromium Embedded -// Framework nor the names of its contributors may be used to endorse -// or promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#ifndef _CEF_STRING_TYPES_T -#define _CEF_STRING_TYPES_T - -// CEF provides functions for converting between UTF-8, -16 and -32 strings. -// CEF string types are safe for reading from multiple threads but not for -// modification. It is the user's responsibility to provide synchronization if -// modifying CEF strings from multiple threads. - -#ifdef __cplusplus -extern "C" { -#endif - -#include "cef_export.h" - -// CEF character type definitions. wchat_t is 2 bytes on Windows and 4 bytes on -// most other platforms. - -#ifdef _WIN32 -typedef wchar_t char16_t; -#else // _WIN32 -typedef uint16 char16_t; -#ifndef WCHAR_T_IS_UTF32 -#define WCHAR_T_IS_UTF32 -#endif // WCHAR_T_IS_UTF32 -#endif // _WIN32 - - -// CEF string type definitions. Whomever allocates |str| is responsible for -// providing an appropriate |dtor| implementation that will free the string in -// the same memory space. When reusing an existing string structure make sure -// to call |dtor| for the old value before assigning new |str| and |dtor| -// values. Static strings will have a NULL |dtor| value. Using the below -// functions if you want this managed for you. - -typedef struct _cef_string_wide_t { - wchar_t* str; - size_t length; - void (*dtor)(wchar_t* str); -} cef_string_wide_t; - -typedef struct _cef_string_utf8_t { - char* str; - size_t length; - void (*dtor)(char* str); -} cef_string_utf8_t; - -typedef struct _cef_string_utf16_t { - char16_t* str; - size_t length; - void (*dtor)(char16_t* str); -} cef_string_utf16_t; - - -// These functions set string values. If |copy| is true (1) the value will be -// copied instead of referenced. It is up to the user to properly manage -// the lifespan of references. - -CEF_EXPORT int cef_string_wide_set(const wchar_t* src, size_t src_len, - cef_string_wide_t* output, int copy); -CEF_EXPORT int cef_string_utf8_set(const char* src, size_t src_len, - cef_string_utf8_t* output, int copy); -CEF_EXPORT int cef_string_utf16_set(const char16_t* src, size_t src_len, - cef_string_utf16_t* output, int copy); - - -// Convenience macros for copying values. - -#define cef_string_wide_copy(src, src_len, output) \ - cef_string_wide_set(src, src_len, output, true) -#define cef_string_utf8_copy(src, src_len, output) \ - cef_string_utf8_set(src, src_len, output, true) -#define cef_string_utf16_copy(src, src_len, output) \ - cef_string_utf16_set(src, src_len, output, true) - - -// These functions clear string values. The structure itself is not freed. - -CEF_EXPORT void cef_string_wide_clear(cef_string_wide_t* str); -CEF_EXPORT void cef_string_utf8_clear(cef_string_utf8_t* str); -CEF_EXPORT void cef_string_utf16_clear(cef_string_utf16_t* str); - - -// These functions compare two string values with the same results as strcmp(). - -CEF_EXPORT int cef_string_wide_cmp(const cef_string_wide_t* str1, - const cef_string_wide_t* str2); -CEF_EXPORT int cef_string_utf8_cmp(const cef_string_utf8_t* str1, - const cef_string_utf8_t* str2); -CEF_EXPORT int cef_string_utf16_cmp(const cef_string_utf16_t* str1, - const cef_string_utf16_t* str2); - - -// These functions convert between UTF-8, -16, and -32 strings. They are -// potentially slow so unnecessary conversions should be avoided. The best -// possible result will always be written to |output| with the boolean return -// value indicating whether the conversion is 100% valid. - -CEF_EXPORT int cef_string_wide_to_utf8(const wchar_t* src, size_t src_len, - cef_string_utf8_t* output); -CEF_EXPORT int cef_string_utf8_to_wide(const char* src, size_t src_len, - cef_string_wide_t* output); - -CEF_EXPORT int cef_string_wide_to_utf16(const wchar_t* src, size_t src_len, - cef_string_utf16_t* output); -CEF_EXPORT int cef_string_utf16_to_wide(const char16_t* src, size_t src_len, - cef_string_wide_t* output); - -CEF_EXPORT int cef_string_utf8_to_utf16(const char* src, size_t src_len, - cef_string_utf16_t* output); -CEF_EXPORT int cef_string_utf16_to_utf8(const char16_t* src, size_t src_len, - cef_string_utf8_t* output); - - -// These functions convert an ASCII string, typically a hardcoded constant, to a -// Wide/UTF16 string. Use instead of the UTF8 conversion routines if you know -// the string is ASCII. - -CEF_EXPORT int cef_string_ascii_to_wide(const char* src, size_t src_len, - cef_string_wide_t* output); -CEF_EXPORT int cef_string_ascii_to_utf16(const char* src, size_t src_len, - cef_string_utf16_t* output); - - - -// It is sometimes necessary for the system to allocate string structures with -// the expectation that the user will free them. The userfree types act as a -// hint that the user is responsible for freeing the structure. - -typedef cef_string_wide_t* cef_string_userfree_wide_t; -typedef cef_string_utf8_t* cef_string_userfree_utf8_t; -typedef cef_string_utf16_t* cef_string_userfree_utf16_t; - - -// These functions allocate a new string structure. They must be freed by -// calling the associated free function. - -CEF_EXPORT cef_string_userfree_wide_t cef_string_userfree_wide_alloc(); -CEF_EXPORT cef_string_userfree_utf8_t cef_string_userfree_utf8_alloc(); -CEF_EXPORT cef_string_userfree_utf16_t cef_string_userfree_utf16_alloc(); - - -// These functions free the string structure allocated by the associated -// alloc function. Any string contents will first be cleared. - -CEF_EXPORT void cef_string_userfree_wide_free(cef_string_userfree_wide_t str); -CEF_EXPORT void cef_string_userfree_utf8_free(cef_string_userfree_utf8_t str); -CEF_EXPORT void cef_string_userfree_utf16_free(cef_string_userfree_utf16_t str); - - -#ifdef __cplusplus -} -#endif - -#endif // _CEF_STRING_TYPES_T +// Copyright (c) 2010 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef _CEF_STRING_TYPES_T +#define _CEF_STRING_TYPES_T + +// CEF provides functions for converting between UTF-8, -16 and -32 strings. +// CEF string types are safe for reading from multiple threads but not for +// modification. It is the user's responsibility to provide synchronization if +// modifying CEF strings from multiple threads. + +#ifdef __cplusplus +extern "C" { +#endif + +#include "cef_export.h" +#include + +// CEF character type definitions. wchat_t is 2 bytes on Windows and 4 bytes on +// most other platforms. + +#ifdef _WIN32 +typedef wchar_t char16_t; +#else // _WIN32 +typedef unsigned short char16_t; +#ifndef WCHAR_T_IS_UTF32 +#define WCHAR_T_IS_UTF32 +#endif // WCHAR_T_IS_UTF32 +#endif // _WIN32 + + +// CEF string type definitions. Whomever allocates |str| is responsible for +// providing an appropriate |dtor| implementation that will free the string in +// the same memory space. When reusing an existing string structure make sure +// to call |dtor| for the old value before assigning new |str| and |dtor| +// values. Static strings will have a NULL |dtor| value. Using the below +// functions if you want this managed for you. + +typedef struct _cef_string_wide_t { + wchar_t* str; + size_t length; + void (*dtor)(wchar_t* str); +} cef_string_wide_t; + +typedef struct _cef_string_utf8_t { + char* str; + size_t length; + void (*dtor)(char* str); +} cef_string_utf8_t; + +typedef struct _cef_string_utf16_t { + char16_t* str; + size_t length; + void (*dtor)(char16_t* str); +} cef_string_utf16_t; + + +// These functions set string values. If |copy| is true (1) the value will be +// copied instead of referenced. It is up to the user to properly manage +// the lifespan of references. + +CEF_EXPORT int cef_string_wide_set(const wchar_t* src, size_t src_len, + cef_string_wide_t* output, int copy); +CEF_EXPORT int cef_string_utf8_set(const char* src, size_t src_len, + cef_string_utf8_t* output, int copy); +CEF_EXPORT int cef_string_utf16_set(const char16_t* src, size_t src_len, + cef_string_utf16_t* output, int copy); + + +// Convenience macros for copying values. + +#define cef_string_wide_copy(src, src_len, output) \ + cef_string_wide_set(src, src_len, output, true) +#define cef_string_utf8_copy(src, src_len, output) \ + cef_string_utf8_set(src, src_len, output, true) +#define cef_string_utf16_copy(src, src_len, output) \ + cef_string_utf16_set(src, src_len, output, true) + + +// These functions clear string values. The structure itself is not freed. + +CEF_EXPORT void cef_string_wide_clear(cef_string_wide_t* str); +CEF_EXPORT void cef_string_utf8_clear(cef_string_utf8_t* str); +CEF_EXPORT void cef_string_utf16_clear(cef_string_utf16_t* str); + + +// These functions compare two string values with the same results as strcmp(). + +CEF_EXPORT int cef_string_wide_cmp(const cef_string_wide_t* str1, + const cef_string_wide_t* str2); +CEF_EXPORT int cef_string_utf8_cmp(const cef_string_utf8_t* str1, + const cef_string_utf8_t* str2); +CEF_EXPORT int cef_string_utf16_cmp(const cef_string_utf16_t* str1, + const cef_string_utf16_t* str2); + + +// These functions convert between UTF-8, -16, and -32 strings. They are +// potentially slow so unnecessary conversions should be avoided. The best +// possible result will always be written to |output| with the boolean return +// value indicating whether the conversion is 100% valid. + +CEF_EXPORT int cef_string_wide_to_utf8(const wchar_t* src, size_t src_len, + cef_string_utf8_t* output); +CEF_EXPORT int cef_string_utf8_to_wide(const char* src, size_t src_len, + cef_string_wide_t* output); + +CEF_EXPORT int cef_string_wide_to_utf16(const wchar_t* src, size_t src_len, + cef_string_utf16_t* output); +CEF_EXPORT int cef_string_utf16_to_wide(const char16_t* src, size_t src_len, + cef_string_wide_t* output); + +CEF_EXPORT int cef_string_utf8_to_utf16(const char* src, size_t src_len, + cef_string_utf16_t* output); +CEF_EXPORT int cef_string_utf16_to_utf8(const char16_t* src, size_t src_len, + cef_string_utf8_t* output); + + +// These functions convert an ASCII string, typically a hardcoded constant, to a +// Wide/UTF16 string. Use instead of the UTF8 conversion routines if you know +// the string is ASCII. + +CEF_EXPORT int cef_string_ascii_to_wide(const char* src, size_t src_len, + cef_string_wide_t* output); +CEF_EXPORT int cef_string_ascii_to_utf16(const char* src, size_t src_len, + cef_string_utf16_t* output); + + + +// It is sometimes necessary for the system to allocate string structures with +// the expectation that the user will free them. The userfree types act as a +// hint that the user is responsible for freeing the structure. + +typedef cef_string_wide_t* cef_string_userfree_wide_t; +typedef cef_string_utf8_t* cef_string_userfree_utf8_t; +typedef cef_string_utf16_t* cef_string_userfree_utf16_t; + + +// These functions allocate a new string structure. They must be freed by +// calling the associated free function. + +CEF_EXPORT cef_string_userfree_wide_t cef_string_userfree_wide_alloc(); +CEF_EXPORT cef_string_userfree_utf8_t cef_string_userfree_utf8_alloc(); +CEF_EXPORT cef_string_userfree_utf16_t cef_string_userfree_utf16_alloc(); + + +// These functions free the string structure allocated by the associated +// alloc function. Any string contents will first be cleared. + +CEF_EXPORT void cef_string_userfree_wide_free(cef_string_userfree_wide_t str); +CEF_EXPORT void cef_string_userfree_utf8_free(cef_string_userfree_utf8_t str); +CEF_EXPORT void cef_string_userfree_utf16_free(cef_string_userfree_utf16_t str); + + +#ifdef __cplusplus +} +#endif + +#endif // _CEF_STRING_TYPES_T diff --git a/include/cef_string_wrappers.h b/include/cef_string_wrappers.h index c7631b628..ce1eb4dcc 100644 --- a/include/cef_string_wrappers.h +++ b/include/cef_string_wrappers.h @@ -1,625 +1,625 @@ -// Copyright (c) 2010 Marshall A. Greenblatt. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the name Chromium Embedded -// Framework nor the names of its contributors may be used to endorse -// or promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#ifndef _CEF_STRING_WRAPPERS_H -#define _CEF_STRING_WRAPPERS_H - -#include "cef_string_types.h" -#ifdef BUILDING_CEF_SHARED -#include "base/string16.h" -#endif -#include - -// Traits implementation for wide character strings. -struct CefStringTraitsWide { - typedef wchar_t char_type; - typedef cef_string_wide_t struct_type; - typedef cef_string_userfree_wide_t userfree_struct_type; - - static inline void clear(struct_type *s) { cef_string_wide_clear(s); } - static inline int set(const char_type* src, size_t src_size, - struct_type *output, int copy) - { return cef_string_wide_set(src, src_size, output, copy); } - static inline int compare(const struct_type* s1, const struct_type* s2) - { return cef_string_wide_cmp(s1, s2); } - static inline userfree_struct_type userfree_alloc() - { return cef_string_userfree_wide_alloc(); } - static inline void userfree_free(userfree_struct_type ufs) - { return cef_string_userfree_wide_free(ufs); } - - // Conversion methods. - static inline bool from_ascii(const char* str, size_t len, struct_type *s) - { - return cef_string_ascii_to_wide(str, len, s) ? true : false; - } - static inline std::string to_string(const struct_type *s) - { - cef_string_utf8_t cstr; - memset(&cstr, 0, sizeof(cstr)); - cef_string_wide_to_utf8(s->str, s->length, &cstr); - std::string str; - if (cstr.length > 0) - str = std::string(cstr.str, cstr.length); - cef_string_utf8_clear(&cstr); - return str; - } - static inline bool from_string(const std::string& str, struct_type *s) - { - return cef_string_utf8_to_wide(str.c_str(), str.length(), s) ? true : false; - } - static inline std::wstring to_wstring(const struct_type *s) - { - return std::wstring(s->str, s->length); - } - static inline bool from_wstring(const std::wstring& str, struct_type *s) - { - return cef_string_wide_set(str.c_str(), str.length(), s, true) ? - true : false; - } -#if defined(BUILDING_CEF_SHARED) -#if defined(WCHAR_T_IS_UTF32) - static inline string16 to_string16(const struct_type *s) - { - cef_string_utf16_t cstr; - memset(&cstr, 0, sizeof(cstr)); - cef_string_wide_to_utf16(s->str, s->length, &cstr); - string16 str; - if (cstr.length > 0) - str = string16(cstr.str, cstr.length); - cef_string_utf16_clear(&cstr); - return str; - } - static inline bool from_string16(const string16& str, struct_type *s) - { - return cef_string_utf16_to_wide(str.c_str(), str.length(), s) ? - true : false; - } -#else // WCHAR_T_IS_UTF32 - static inline string16 to_string16(const struct_type *s) - { - return string16(s->str, s->length); - } - static inline bool from_string16(const string16& str, struct_type *s) - { - return cef_string_wide_set(str.c_str(), str.length(), s, true) ? - true : false; - } -#endif // WCHAR_T_IS_UTF32 -#endif // BUILDING_CEF_SHARED -}; - -// Traits implementation for utf8 character strings. -struct CefStringTraitsUTF8 { - typedef char char_type; - typedef cef_string_utf8_t struct_type; - typedef cef_string_userfree_utf8_t userfree_struct_type; - - static inline void clear(struct_type *s) { cef_string_utf8_clear(s); } - static inline int set(const char_type* src, size_t src_size, - struct_type *output, int copy) - { return cef_string_utf8_set(src, src_size, output, copy); } - static inline int compare(const struct_type* s1, const struct_type* s2) - { return cef_string_utf8_cmp(s1, s2); } - static inline userfree_struct_type userfree_alloc() - { return cef_string_userfree_utf8_alloc(); } - static inline void userfree_free(userfree_struct_type ufs) - { return cef_string_userfree_utf8_free(ufs); } - - // Conversion methods. - static inline bool from_ascii(const char* str, size_t len, struct_type* s) - { - return cef_string_utf8_copy(str, len, s) ? true : false; - } - static inline std::string to_string(const struct_type* s) - { - return std::string(s->str, s->length); - } - static inline bool from_string(const std::string& str, struct_type* s) - { - return cef_string_utf8_copy(str.c_str(), str.length(), s) ? true : false; - } - static inline std::wstring to_wstring(const struct_type* s) - { - cef_string_wide_t cstr; - memset(&cstr, 0, sizeof(cstr)); - cef_string_utf8_to_wide(s->str, s->length, &cstr); - std::wstring str; - if (cstr.length > 0) - str = std::wstring(cstr.str, cstr.length); - cef_string_wide_clear(&cstr); - return str; - } - static inline bool from_wstring(const std::wstring& str, struct_type* s) - { - return cef_string_wide_to_utf8(str.c_str(), str.length(), s) ? true : false; - } -#if defined(BUILDING_CEF_SHARED) - static inline string16 to_string16(const struct_type* s) - { - cef_string_utf16_t cstr; - memset(&cstr, 0, sizeof(cstr)); - cef_string_utf8_to_utf16(s->str, s->length, &cstr); - string16 str; - if (cstr.length > 0) - str = string16(cstr.str, cstr.length); - cef_string_utf16_clear(&cstr); - return str; - } - static inline bool from_string16(const string16& str, struct_type* s) - { - return cef_string_utf16_to_utf8(str.c_str(), str.length(), s) ? - true : false; - } -#endif // BUILDING_CEF_SHARED -}; - -// Traits implementation for utf16 character strings. -struct CefStringTraitsUTF16 { - typedef char16_t char_type; - typedef cef_string_utf16_t struct_type; - typedef cef_string_userfree_utf16_t userfree_struct_type; - - static inline void clear(struct_type *s) { cef_string_utf16_clear(s); } - static inline int set(const char_type* src, size_t src_size, - struct_type *output, int copy) - { return cef_string_utf16_set(src, src_size, output, copy); } - static inline int compare(const struct_type* s1, const struct_type* s2) - { return cef_string_utf16_cmp(s1, s2); } - static inline userfree_struct_type userfree_alloc() - { return cef_string_userfree_utf16_alloc(); } - static inline void userfree_free(userfree_struct_type ufs) - { return cef_string_userfree_utf16_free(ufs); } - - // Conversion methods. - static inline bool from_ascii(const char* str, size_t len, struct_type* s) - { - return cef_string_ascii_to_utf16(str, len, s) ? true : false; - } - static inline std::string to_string(const struct_type* s) - { - cef_string_utf8_t cstr; - memset(&cstr, 0, sizeof(cstr)); - cef_string_utf16_to_utf8(s->str, s->length, &cstr); - std::string str; - if (cstr.length > 0) - str = std::string(cstr.str, cstr.length); - cef_string_utf8_clear(&cstr); - return str; - } - static inline bool from_string(const std::string& str, struct_type* s) - { - return cef_string_utf8_to_utf16(str.c_str(), str.length(), s) ? - true : false; - } -#if defined(WCHAR_T_IS_UTF32) - static inline std::wstring to_wstring(const struct_type* s) - { - cef_string_wide_t cstr; - memset(&cstr, 0, sizeof(cstr)); - cef_string_utf16_to_wide(s->str, s->length, &cstr); - std::wstring str; - if (cstr.length > 0) - str = std::wstring(cstr.str, cstr.length); - cef_string_wide_clear(&cstr); - return str; - } - static inline bool from_wstring(const std::wstring& str, struct_type* s) - { - return cef_string_wide_to_utf16(str.c_str(), str.length(), s) ? - true : false; - } -#else // WCHAR_T_IS_UTF32 - static inline std::wstring to_wstring(const struct_type* s) - { - return std::wstring(s->str, s->length); - } - static inline bool from_wstring(const std::wstring& str, struct_type* s) - { - return cef_string_utf16_set(str.c_str(), str.length(), s, true) ? - true : false; - } -#endif // WCHAR_T_IS_UTF32 -#if defined(BUILDING_CEF_SHARED) - static inline string16 to_string16(const struct_type* s) - { - return string16(s->str, s->length); - } - static inline bool FromString16(const string16& str, struct_type* s) - { - return cef_string_utf16_set(str.c_str(), str.length(), s, true) ? - true : false; - } -#endif // BUILDING_CEF_SHARED -}; - -// String template. -template -class CefStringBase { -public: - typedef typename traits::char_type char_type; - typedef typename traits::struct_type struct_type; - typedef typename traits::userfree_struct_type userfree_struct_type; - - // Default constructor. - CefStringBase() : string_(NULL), owner_(false) {} - - // Create a new string from an existing string. Data will always be copied. - CefStringBase(const CefStringBase& str) : string_(NULL), owner_(false) - { FromString(str.c_str(), str.length(), true); } - - // Create a new string from an existing std::string. Data will be always - // copied. Translation will occur if necessary based on the underlying string - // type. - CefStringBase(const std::string& src) : string_(NULL), owner_(false) - { FromString(src); } - CefStringBase(const char* src) : string_(NULL), owner_(false) - { FromString(std::string(src)); } - - // Create a new string from an existing std::wstring. Data will be always - // copied. Translation will occur if necessary based on the underlying string - // type. - CefStringBase(const std::wstring& src) : string_(NULL), owner_(false) - { FromWString(src); } - CefStringBase(const wchar_t* src) : string_(NULL), owner_(false) - { FromWString(std::wstring(src)); } - -#if (defined(BUILDING_CEF_SHARED) && defined(WCHAR_T_IS_UTF32)) - // Create a new string from an existing string16. Data will be always - // copied. Translation will occur if necessary based on the underlying string - // type. - CefStringBase(const string16& src) : string_(NULL), owner_(false) - { FromString16(src); } - CefStringBase(const char16_t* src) : string_(NULL), owner_(false) - { FromString16(string16(src)); } -#endif // BUILDING_CEF_SHARED && WCHAR_T_IS_UTF32 - - // Create a new string from an existing character array. If |copy| is true - // this class will copy the data. Otherwise, this class will reference the - // existing data. Referenced data must exist for the lifetime of this class - // and will not be freed by this class. - CefStringBase(const char_type* src, size_t src_len, bool copy) - : string_(NULL), owner_(false) - { FromString(src, src_len, copy); } - - // Create a new string referencing an existing string structure without taking - // ownership. Referenced structures must exist for the lifetime of this class - // and will not be freed by this class. - CefStringBase(const struct_type* src) : string_(NULL), owner_(false) - { - if (!src) - return; - // Reference the existing structure without taking ownership. - Attach(const_cast(src), false); - } - - virtual ~CefStringBase() { ClearAndFree(); } - - - // The following methods are named for compatibility with the standard library - // string template types. - - // Return a read-only pointer to the string data. - const char_type* c_str() const { return (string_ ? string_->str : NULL); } - - // Return the length of the string data. - size_t length() const { return (string_ ? string_->length : 0); } - - // Return the length of the string data. - inline size_t size() const { return length(); } - - // Returns true if the string is empty. - bool empty() const { return (string_ == NULL || string_->length == 0); } - - // Compare this string to the specified string. - int compare(const CefStringBase& str) const - { - if (empty() && str.empty()) - return 0; - if (empty()) - return -1; - if (str.empty()) - return 1; - return traits::compare(string_, str.GetStruct()); - } - - // Clear the string data. - void clear() - { - if (!empty()) - traits::clear(string_); - } - - - // The following methods are unique to CEF string template types. - - // Returns true if this class owns the underlying string structure. - bool IsOwner() const { return owner_; } - - // Returns a read-only pointer to the underlying string structure. May return - // NULL if no structure is currently allocated. - const struct_type* GetStruct() const { return string_; } - - // Returns a writable pointer to the underlying string structure. Will never - // return NULL. - struct_type* GetWritableStruct() - { - AllocIfNeeded(); - return string_; - } - - // Clear the state of this class. The underlying string structure and data - // will be freed if this class owns the structure. - void ClearAndFree() - { - if (!string_) - return; - if (owner_) { - clear(); - delete string_; - } - string_ = NULL; - owner_ = false; - } - - // Attach to the specified string structure. If |owner| is true this class - // will take ownership of the structure. - void Attach(struct_type* str, bool owner) - { - // Free the previous structure and data, if any. - ClearAndFree(); - - string_ = str; - owner_ = owner; - } - - // Take ownership of the specified userfree structure's string data. The - // userfree structure itself will be freed. Only use this method with userfree - // structures. - void AttachToUserFree(userfree_struct_type str) - { - // Free the previous structure and data, if any. - ClearAndFree(); - - if (!str) - return; - - AllocIfNeeded(); - owner_ = true; - memcpy(string_, str, sizeof(struct_type)); - - // Free the |str| structure but not the data. - memset(str, 0, sizeof(struct_type)); - traits::userfree_free(str); - } - - // Detach from the underlying string structure. To avoid memory leaks only use - // this method if you already hold a pointer to the underlying string - // structure. - void Detach() - { - string_ = NULL; - owner_ = false; - } - - // Create a userfree structure and give it ownership of this class' string - // data. This class will be disassociated from the data. May return NULL if - // this string class currently contains no data. - userfree_struct_type DetachToUserFree() - { - if (empty()) - return NULL; - - userfree_struct_type str = traits::userfree_alloc(); - memcpy(str, string_, sizeof(struct_type)); - - // Free this class' structure but not the data. - memset(string_, 0, sizeof(struct_type)); - ClearAndFree(); - - return str; - } - - // Set this string's data to the specified character array. If |copy| is true - // this class will copy the data. Otherwise, this class will reference the - // existing data. Referenced data must exist for the lifetime of this class - // and will not be freed by this class. - bool FromString(const char_type* src, size_t src_len, bool copy) - { - if (src == NULL || src_len == 0) { - clear(); - return true; - } - AllocIfNeeded(); - return traits::set(src, src_len, string_, copy) ? true : false; - } - - // Set this string's data from an existing ASCII string. Data will be always - // copied. Translation will occur if necessary based on the underlying string - // type. - bool FromASCII(const char* str) - { - size_t len = str ? strlen(str) : 0; - if (len == 0) { - clear(); - return true; - } - AllocIfNeeded(); - return traits::from_ascii(str, len, string_); - } - - // Return this string's data as a std::string. Translation will occur if - // necessary based on the underlying string type. - std::string ToString() const - { - if (empty()) - return std::string(); - return traits::to_string(string_); - } - - // Set this string's data from an existing std::string. Data will be always - // copied. Translation will occur if necessary based on the underlying string - // type. - bool FromString(const std::string& str) - { - if (str.empty()) { - clear(); - return true; - } - AllocIfNeeded(); - return traits::from_string(str, string_); - } - - // Return this string's data as a std::wstring. Translation will occur if - // necessary based on the underlying string type. - std::wstring ToWString() const - { - if (empty()) - return std::wstring(); - return traits::to_wstring(string_); - } - - // Set this string's data from an existing std::wstring. Data will be always - // copied. Translation will occur if necessary based on the underlying string - // type. - bool FromWString(const std::wstring& str) - { - if (str.empty()) { - clear(); - return true; - } - AllocIfNeeded(); - return traits::from_wstring(str, string_); - } -#if defined(BUILDING_CEF_SHARED) - // Return this string's data as a string16. Translation will occur if - // necessary based on the underlying string type. - string16 ToString16() const - { - if (empty()) - return string16(); - return traits::to_string16(string_); - } - - // Set this string's data from an existing string16. Data will be always - // copied. Translation will occur if necessary based on the underlying string - // type. - bool FromString16(const string16& str) - { - if (str.empty()) { - clear(); - return true; - } - AllocIfNeeded(); - return traits::from_string16(str, string_); - } -#endif // BUILDING_CEF_SHARED - - // Comparison operator overloads. - bool operator<(const CefStringBase& str) const - { return (compare(str) < 0); } - bool operator<=(const CefStringBase& str) const - { return (compare(str) <= 0); } - bool operator>(const CefStringBase& str) const - { return (compare(str) > 0); } - bool operator>=(const CefStringBase& str) const - { return (compare(str) >= 0); } - bool operator==(const CefStringBase& str) const - { return (compare(str) == 0); } - bool operator!=(const CefStringBase& str) const - { return (compare(str) != 0); } - - // Assignment operator overloads. - CefStringBase& operator=(const CefStringBase& str) - { FromString(str.c_str(), str.length(), true); return *this; } - operator std::string() const { return ToString(); } - CefStringBase& operator=(const std::string& str) - { FromString(str); return *this; } - CefStringBase& operator=(const char* str) - { FromString(std::string(str)); return *this; } - operator std::wstring() const { return ToWString(); } - CefStringBase& operator=(const std::wstring& str) - { FromWString(str); return *this; } - CefStringBase& operator=(const wchar_t* str) - { FromWString(std::wstring(str)); return *this; } -#if (defined(BUILDING_CEF_SHARED) && defined(WCHAR_T_IS_UTF32)) - operator string16() const { return ToString16(); } - CefStringBase& operator=(const string16& str) - { FromString16(str); return *this; } - CefStringBase& operator=(const char16_t* str) - { FromString16(string16(str)); return *this; } -#endif // BUILDING_CEF_SHARED && WCHAR_T_IS_UTF32 - -private: - // Allocate the string structure if it doesn't already exist. - void AllocIfNeeded() - { - if (string_ == NULL) { - string_ = new struct_type; - memset(string_, 0, sizeof(struct_type)); - owner_ = true; - } - } - - struct_type* string_; - bool owner_; -}; - - -// CEF string classes can convert between all supported string types. For -// example, the CefStringWide class uses wchar_t as the underlying character -// type and provides two approaches for converting data to/from a UTF8 string -// (std::string). -// -// 1. Implicit conversion using the assignment operator overload. -// -// CefStringWide aCefString; -// std::string aUTF8String; -// aCefString = aUTF8String; // Assign std::string to CefStringWide -// aUTF8String = aCefString; // Assign CefStringWide to std::string -// -// 2. Explicit conversion using the FromString/ToString methods. -// -// CefStringWide aCefString; -// std::string aUTF8String; -// aCefString.FromString(aUTF8String); // Assign std::string to CefStringWide -// aUTF8String = aCefString.ToString(); // Assign CefStringWide to std::string -// -// Conversion will only occur if the assigned value is a different string type. -// Assigning a std::string to a CefStringUTF8, for example, will copy the data -// without performing a conversion. -// -// CEF string classes are safe for reading from multiple threads but not for -// modification. It is the user's responsibility to provide synchronization if -// modifying CEF strings from multiple threads. - -typedef CefStringBase CefStringWide; -typedef CefStringBase CefStringUTF8; -typedef CefStringBase CefStringUTF16; - -#endif // _CEF_STRING_WRAPPERS_H +// Copyright (c) 2010 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef _CEF_STRING_WRAPPERS_H +#define _CEF_STRING_WRAPPERS_H + +#include "cef_string_types.h" +#ifdef BUILDING_CEF_SHARED +#include "base/string16.h" +#endif +#include + +// Traits implementation for wide character strings. +struct CefStringTraitsWide { + typedef wchar_t char_type; + typedef cef_string_wide_t struct_type; + typedef cef_string_userfree_wide_t userfree_struct_type; + + static inline void clear(struct_type *s) { cef_string_wide_clear(s); } + static inline int set(const char_type* src, size_t src_size, + struct_type *output, int copy) + { return cef_string_wide_set(src, src_size, output, copy); } + static inline int compare(const struct_type* s1, const struct_type* s2) + { return cef_string_wide_cmp(s1, s2); } + static inline userfree_struct_type userfree_alloc() + { return cef_string_userfree_wide_alloc(); } + static inline void userfree_free(userfree_struct_type ufs) + { return cef_string_userfree_wide_free(ufs); } + + // Conversion methods. + static inline bool from_ascii(const char* str, size_t len, struct_type *s) + { + return cef_string_ascii_to_wide(str, len, s) ? true : false; + } + static inline std::string to_string(const struct_type *s) + { + cef_string_utf8_t cstr; + memset(&cstr, 0, sizeof(cstr)); + cef_string_wide_to_utf8(s->str, s->length, &cstr); + std::string str; + if (cstr.length > 0) + str = std::string(cstr.str, cstr.length); + cef_string_utf8_clear(&cstr); + return str; + } + static inline bool from_string(const std::string& str, struct_type *s) + { + return cef_string_utf8_to_wide(str.c_str(), str.length(), s) ? true : false; + } + static inline std::wstring to_wstring(const struct_type *s) + { + return std::wstring(s->str, s->length); + } + static inline bool from_wstring(const std::wstring& str, struct_type *s) + { + return cef_string_wide_set(str.c_str(), str.length(), s, true) ? + true : false; + } +#if defined(BUILDING_CEF_SHARED) +#if defined(WCHAR_T_IS_UTF32) + static inline string16 to_string16(const struct_type *s) + { + cef_string_utf16_t cstr; + memset(&cstr, 0, sizeof(cstr)); + cef_string_wide_to_utf16(s->str, s->length, &cstr); + string16 str; + if (cstr.length > 0) + str = string16(cstr.str, cstr.length); + cef_string_utf16_clear(&cstr); + return str; + } + static inline bool from_string16(const string16& str, struct_type *s) + { + return cef_string_utf16_to_wide(str.c_str(), str.length(), s) ? + true : false; + } +#else // WCHAR_T_IS_UTF32 + static inline string16 to_string16(const struct_type *s) + { + return string16(s->str, s->length); + } + static inline bool from_string16(const string16& str, struct_type *s) + { + return cef_string_wide_set(str.c_str(), str.length(), s, true) ? + true : false; + } +#endif // WCHAR_T_IS_UTF32 +#endif // BUILDING_CEF_SHARED +}; + +// Traits implementation for utf8 character strings. +struct CefStringTraitsUTF8 { + typedef char char_type; + typedef cef_string_utf8_t struct_type; + typedef cef_string_userfree_utf8_t userfree_struct_type; + + static inline void clear(struct_type *s) { cef_string_utf8_clear(s); } + static inline int set(const char_type* src, size_t src_size, + struct_type *output, int copy) + { return cef_string_utf8_set(src, src_size, output, copy); } + static inline int compare(const struct_type* s1, const struct_type* s2) + { return cef_string_utf8_cmp(s1, s2); } + static inline userfree_struct_type userfree_alloc() + { return cef_string_userfree_utf8_alloc(); } + static inline void userfree_free(userfree_struct_type ufs) + { return cef_string_userfree_utf8_free(ufs); } + + // Conversion methods. + static inline bool from_ascii(const char* str, size_t len, struct_type* s) + { + return cef_string_utf8_copy(str, len, s) ? true : false; + } + static inline std::string to_string(const struct_type* s) + { + return std::string(s->str, s->length); + } + static inline bool from_string(const std::string& str, struct_type* s) + { + return cef_string_utf8_copy(str.c_str(), str.length(), s) ? true : false; + } + static inline std::wstring to_wstring(const struct_type* s) + { + cef_string_wide_t cstr; + memset(&cstr, 0, sizeof(cstr)); + cef_string_utf8_to_wide(s->str, s->length, &cstr); + std::wstring str; + if (cstr.length > 0) + str = std::wstring(cstr.str, cstr.length); + cef_string_wide_clear(&cstr); + return str; + } + static inline bool from_wstring(const std::wstring& str, struct_type* s) + { + return cef_string_wide_to_utf8(str.c_str(), str.length(), s) ? true : false; + } +#if defined(BUILDING_CEF_SHARED) + static inline string16 to_string16(const struct_type* s) + { + cef_string_utf16_t cstr; + memset(&cstr, 0, sizeof(cstr)); + cef_string_utf8_to_utf16(s->str, s->length, &cstr); + string16 str; + if (cstr.length > 0) + str = string16(cstr.str, cstr.length); + cef_string_utf16_clear(&cstr); + return str; + } + static inline bool from_string16(const string16& str, struct_type* s) + { + return cef_string_utf16_to_utf8(str.c_str(), str.length(), s) ? + true : false; + } +#endif // BUILDING_CEF_SHARED +}; + +// Traits implementation for utf16 character strings. +struct CefStringTraitsUTF16 { + typedef char16_t char_type; + typedef cef_string_utf16_t struct_type; + typedef cef_string_userfree_utf16_t userfree_struct_type; + + static inline void clear(struct_type *s) { cef_string_utf16_clear(s); } + static inline int set(const char_type* src, size_t src_size, + struct_type *output, int copy) + { return cef_string_utf16_set(src, src_size, output, copy); } + static inline int compare(const struct_type* s1, const struct_type* s2) + { return cef_string_utf16_cmp(s1, s2); } + static inline userfree_struct_type userfree_alloc() + { return cef_string_userfree_utf16_alloc(); } + static inline void userfree_free(userfree_struct_type ufs) + { return cef_string_userfree_utf16_free(ufs); } + + // Conversion methods. + static inline bool from_ascii(const char* str, size_t len, struct_type* s) + { + return cef_string_ascii_to_utf16(str, len, s) ? true : false; + } + static inline std::string to_string(const struct_type* s) + { + cef_string_utf8_t cstr; + memset(&cstr, 0, sizeof(cstr)); + cef_string_utf16_to_utf8(s->str, s->length, &cstr); + std::string str; + if (cstr.length > 0) + str = std::string(cstr.str, cstr.length); + cef_string_utf8_clear(&cstr); + return str; + } + static inline bool from_string(const std::string& str, struct_type* s) + { + return cef_string_utf8_to_utf16(str.c_str(), str.length(), s) ? + true : false; + } +#if defined(WCHAR_T_IS_UTF32) + static inline std::wstring to_wstring(const struct_type* s) + { + cef_string_wide_t cstr; + memset(&cstr, 0, sizeof(cstr)); + cef_string_utf16_to_wide(s->str, s->length, &cstr); + std::wstring str; + if (cstr.length > 0) + str = std::wstring(cstr.str, cstr.length); + cef_string_wide_clear(&cstr); + return str; + } + static inline bool from_wstring(const std::wstring& str, struct_type* s) + { + return cef_string_wide_to_utf16(str.c_str(), str.length(), s) ? + true : false; + } +#else // WCHAR_T_IS_UTF32 + static inline std::wstring to_wstring(const struct_type* s) + { + return std::wstring(s->str, s->length); + } + static inline bool from_wstring(const std::wstring& str, struct_type* s) + { + return cef_string_utf16_set(str.c_str(), str.length(), s, true) ? + true : false; + } +#endif // WCHAR_T_IS_UTF32 +#if defined(BUILDING_CEF_SHARED) + static inline string16 to_string16(const struct_type* s) + { + return string16(s->str, s->length); + } + static inline bool from_string16(const string16& str, struct_type* s) + { + return cef_string_utf16_set(str.c_str(), str.length(), s, true) ? + true : false; + } +#endif // BUILDING_CEF_SHARED +}; + +// String template. +template +class CefStringBase { +public: + typedef typename traits::char_type char_type; + typedef typename traits::struct_type struct_type; + typedef typename traits::userfree_struct_type userfree_struct_type; + + // Default constructor. + CefStringBase() : string_(NULL), owner_(false) {} + + // Create a new string from an existing string. Data will always be copied. + CefStringBase(const CefStringBase& str) : string_(NULL), owner_(false) + { FromString(str.c_str(), str.length(), true); } + + // Create a new string from an existing std::string. Data will be always + // copied. Translation will occur if necessary based on the underlying string + // type. + CefStringBase(const std::string& src) : string_(NULL), owner_(false) + { FromString(src); } + CefStringBase(const char* src) : string_(NULL), owner_(false) + { FromString(std::string(src)); } + + // Create a new string from an existing std::wstring. Data will be always + // copied. Translation will occur if necessary based on the underlying string + // type. + CefStringBase(const std::wstring& src) : string_(NULL), owner_(false) + { FromWString(src); } + CefStringBase(const wchar_t* src) : string_(NULL), owner_(false) + { FromWString(std::wstring(src)); } + +#if (defined(BUILDING_CEF_SHARED) && defined(WCHAR_T_IS_UTF32)) + // Create a new string from an existing string16. Data will be always + // copied. Translation will occur if necessary based on the underlying string + // type. + CefStringBase(const string16& src) : string_(NULL), owner_(false) + { FromString16(src); } + CefStringBase(const char16_t* src) : string_(NULL), owner_(false) + { FromString16(string16(src)); } +#endif // BUILDING_CEF_SHARED && WCHAR_T_IS_UTF32 + + // Create a new string from an existing character array. If |copy| is true + // this class will copy the data. Otherwise, this class will reference the + // existing data. Referenced data must exist for the lifetime of this class + // and will not be freed by this class. + CefStringBase(const char_type* src, size_t src_len, bool copy) + : string_(NULL), owner_(false) + { FromString(src, src_len, copy); } + + // Create a new string referencing an existing string structure without taking + // ownership. Referenced structures must exist for the lifetime of this class + // and will not be freed by this class. + CefStringBase(const struct_type* src) : string_(NULL), owner_(false) + { + if (!src) + return; + // Reference the existing structure without taking ownership. + Attach(const_cast(src), false); + } + + virtual ~CefStringBase() { ClearAndFree(); } + + + // The following methods are named for compatibility with the standard library + // string template types. + + // Return a read-only pointer to the string data. + const char_type* c_str() const { return (string_ ? string_->str : NULL); } + + // Return the length of the string data. + size_t length() const { return (string_ ? string_->length : 0); } + + // Return the length of the string data. + inline size_t size() const { return length(); } + + // Returns true if the string is empty. + bool empty() const { return (string_ == NULL || string_->length == 0); } + + // Compare this string to the specified string. + int compare(const CefStringBase& str) const + { + if (empty() && str.empty()) + return 0; + if (empty()) + return -1; + if (str.empty()) + return 1; + return traits::compare(string_, str.GetStruct()); + } + + // Clear the string data. + void clear() + { + if (!empty()) + traits::clear(string_); + } + + + // The following methods are unique to CEF string template types. + + // Returns true if this class owns the underlying string structure. + bool IsOwner() const { return owner_; } + + // Returns a read-only pointer to the underlying string structure. May return + // NULL if no structure is currently allocated. + const struct_type* GetStruct() const { return string_; } + + // Returns a writable pointer to the underlying string structure. Will never + // return NULL. + struct_type* GetWritableStruct() + { + AllocIfNeeded(); + return string_; + } + + // Clear the state of this class. The underlying string structure and data + // will be freed if this class owns the structure. + void ClearAndFree() + { + if (!string_) + return; + if (owner_) { + clear(); + delete string_; + } + string_ = NULL; + owner_ = false; + } + + // Attach to the specified string structure. If |owner| is true this class + // will take ownership of the structure. + void Attach(struct_type* str, bool owner) + { + // Free the previous structure and data, if any. + ClearAndFree(); + + string_ = str; + owner_ = owner; + } + + // Take ownership of the specified userfree structure's string data. The + // userfree structure itself will be freed. Only use this method with userfree + // structures. + void AttachToUserFree(userfree_struct_type str) + { + // Free the previous structure and data, if any. + ClearAndFree(); + + if (!str) + return; + + AllocIfNeeded(); + owner_ = true; + memcpy(string_, str, sizeof(struct_type)); + + // Free the |str| structure but not the data. + memset(str, 0, sizeof(struct_type)); + traits::userfree_free(str); + } + + // Detach from the underlying string structure. To avoid memory leaks only use + // this method if you already hold a pointer to the underlying string + // structure. + void Detach() + { + string_ = NULL; + owner_ = false; + } + + // Create a userfree structure and give it ownership of this class' string + // data. This class will be disassociated from the data. May return NULL if + // this string class currently contains no data. + userfree_struct_type DetachToUserFree() + { + if (empty()) + return NULL; + + userfree_struct_type str = traits::userfree_alloc(); + memcpy(str, string_, sizeof(struct_type)); + + // Free this class' structure but not the data. + memset(string_, 0, sizeof(struct_type)); + ClearAndFree(); + + return str; + } + + // Set this string's data to the specified character array. If |copy| is true + // this class will copy the data. Otherwise, this class will reference the + // existing data. Referenced data must exist for the lifetime of this class + // and will not be freed by this class. + bool FromString(const char_type* src, size_t src_len, bool copy) + { + if (src == NULL || src_len == 0) { + clear(); + return true; + } + AllocIfNeeded(); + return traits::set(src, src_len, string_, copy) ? true : false; + } + + // Set this string's data from an existing ASCII string. Data will be always + // copied. Translation will occur if necessary based on the underlying string + // type. + bool FromASCII(const char* str) + { + size_t len = str ? strlen(str) : 0; + if (len == 0) { + clear(); + return true; + } + AllocIfNeeded(); + return traits::from_ascii(str, len, string_); + } + + // Return this string's data as a std::string. Translation will occur if + // necessary based on the underlying string type. + std::string ToString() const + { + if (empty()) + return std::string(); + return traits::to_string(string_); + } + + // Set this string's data from an existing std::string. Data will be always + // copied. Translation will occur if necessary based on the underlying string + // type. + bool FromString(const std::string& str) + { + if (str.empty()) { + clear(); + return true; + } + AllocIfNeeded(); + return traits::from_string(str, string_); + } + + // Return this string's data as a std::wstring. Translation will occur if + // necessary based on the underlying string type. + std::wstring ToWString() const + { + if (empty()) + return std::wstring(); + return traits::to_wstring(string_); + } + + // Set this string's data from an existing std::wstring. Data will be always + // copied. Translation will occur if necessary based on the underlying string + // type. + bool FromWString(const std::wstring& str) + { + if (str.empty()) { + clear(); + return true; + } + AllocIfNeeded(); + return traits::from_wstring(str, string_); + } +#if defined(BUILDING_CEF_SHARED) + // Return this string's data as a string16. Translation will occur if + // necessary based on the underlying string type. + string16 ToString16() const + { + if (empty()) + return string16(); + return traits::to_string16(string_); + } + + // Set this string's data from an existing string16. Data will be always + // copied. Translation will occur if necessary based on the underlying string + // type. + bool FromString16(const string16& str) + { + if (str.empty()) { + clear(); + return true; + } + AllocIfNeeded(); + return traits::from_string16(str, string_); + } +#endif // BUILDING_CEF_SHARED + + // Comparison operator overloads. + bool operator<(const CefStringBase& str) const + { return (compare(str) < 0); } + bool operator<=(const CefStringBase& str) const + { return (compare(str) <= 0); } + bool operator>(const CefStringBase& str) const + { return (compare(str) > 0); } + bool operator>=(const CefStringBase& str) const + { return (compare(str) >= 0); } + bool operator==(const CefStringBase& str) const + { return (compare(str) == 0); } + bool operator!=(const CefStringBase& str) const + { return (compare(str) != 0); } + + // Assignment operator overloads. + CefStringBase& operator=(const CefStringBase& str) + { FromString(str.c_str(), str.length(), true); return *this; } + operator std::string() const { return ToString(); } + CefStringBase& operator=(const std::string& str) + { FromString(str); return *this; } + CefStringBase& operator=(const char* str) + { FromString(std::string(str)); return *this; } + operator std::wstring() const { return ToWString(); } + CefStringBase& operator=(const std::wstring& str) + { FromWString(str); return *this; } + CefStringBase& operator=(const wchar_t* str) + { FromWString(std::wstring(str)); return *this; } +#if (defined(BUILDING_CEF_SHARED) && defined(WCHAR_T_IS_UTF32)) + operator string16() const { return ToString16(); } + CefStringBase& operator=(const string16& str) + { FromString16(str); return *this; } + CefStringBase& operator=(const char16_t* str) + { FromString16(string16(str)); return *this; } +#endif // BUILDING_CEF_SHARED && WCHAR_T_IS_UTF32 + +private: + // Allocate the string structure if it doesn't already exist. + void AllocIfNeeded() + { + if (string_ == NULL) { + string_ = new struct_type; + memset(string_, 0, sizeof(struct_type)); + owner_ = true; + } + } + + struct_type* string_; + bool owner_; +}; + + +// CEF string classes can convert between all supported string types. For +// example, the CefStringWide class uses wchar_t as the underlying character +// type and provides two approaches for converting data to/from a UTF8 string +// (std::string). +// +// 1. Implicit conversion using the assignment operator overload. +// +// CefStringWide aCefString; +// std::string aUTF8String; +// aCefString = aUTF8String; // Assign std::string to CefStringWide +// aUTF8String = aCefString; // Assign CefStringWide to std::string +// +// 2. Explicit conversion using the FromString/ToString methods. +// +// CefStringWide aCefString; +// std::string aUTF8String; +// aCefString.FromString(aUTF8String); // Assign std::string to CefStringWide +// aUTF8String = aCefString.ToString(); // Assign CefStringWide to std::string +// +// Conversion will only occur if the assigned value is a different string type. +// Assigning a std::string to a CefStringUTF8, for example, will copy the data +// without performing a conversion. +// +// CEF string classes are safe for reading from multiple threads but not for +// modification. It is the user's responsibility to provide synchronization if +// modifying CEF strings from multiple threads. + +typedef CefStringBase CefStringWide; +typedef CefStringBase CefStringUTF8; +typedef CefStringBase CefStringUTF16; + +#endif // _CEF_STRING_WRAPPERS_H diff --git a/libcef/browser_impl.cc b/libcef/browser_impl.cc index 48a8f59cd..477f01bfa 100644 --- a/libcef/browser_impl.cc +++ b/libcef/browser_impl.cc @@ -245,7 +245,7 @@ CefRefPtr CefBrowserImpl::GetCefFrame(WebFrame* frame) cef_frame = frame_main_; } else { // Locate or create the appropriate named reference. - CefString name = frame->name(); + CefString name = string16(frame->name()); DCHECK(!name.empty()); FrameMap::const_iterator it = frames_.find(name); if(it != frames_.end()) @@ -381,7 +381,7 @@ CefString CefBrowserImpl::GetSource(CefRefPtr frame) // Retrieve the document string directly WebKit::WebFrame* web_frame = GetWebFrame(frame); if(web_frame) - return web_frame->contentAsMarkup(); + return string16(web_frame->contentAsMarkup()); return CefString(); } } @@ -474,7 +474,7 @@ CefString CefBrowserImpl::GetURL(CefRefPtr frame) { WebFrame* web_frame = GetWebFrame(frame); if(web_frame) - return web_frame->url().spec(); + return std::string(web_frame->url().spec()); return CefString(); } diff --git a/libcef/browser_impl_win.cc b/libcef/browser_impl_win.cc index 38b7ece5c..58bf94c81 100644 --- a/libcef/browser_impl_win.cc +++ b/libcef/browser_impl_win.cc @@ -391,6 +391,7 @@ void CefBrowserImpl::UIT_PrintPages(WebKit::WebFrame* frame) { // Make a copy of settings. printing::PrintSettings settings = print_context_.settings(); cef_print_options_t print_options; + memset(&print_options, 0, sizeof(print_options)); settings.UpdatePrintOptions(print_options); // Ask the handler if they want to update the print options. diff --git a/libcef/browser_settings.h b/libcef/browser_settings.h index b0b2572a3..fce1304e3 100644 --- a/libcef/browser_settings.h +++ b/libcef/browser_settings.h @@ -1,13 +1,13 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights -// reserved. Use of this source code is governed by a BSD-style license that can -// be found in the LICENSE file. - -#ifndef _CEF_BROWSER_SETTINGS_H -#define _CEF_BROWSER_SETTINGS_H - -class CefBrowserSettings; -struct WebPreferences; - -void BrowserToWebSettings(const CefBrowserSettings& cef, WebPreferences& web); - -#endif // _CEF_BROWSER_SETTINGS_H +// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that can +// be found in the LICENSE file. + +#ifndef _CEF_BROWSER_SETTINGS_H +#define _CEF_BROWSER_SETTINGS_H + +class CefBrowserSettings; +struct WebPreferences; + +void BrowserToWebSettings(const CefBrowserSettings& cef, WebPreferences& web); + +#endif // _CEF_BROWSER_SETTINGS_H diff --git a/libcef/browser_webview_delegate_mac.mm b/libcef/browser_webview_delegate_mac.mm index 38ad4a0d3..46d660bd4 100644 --- a/libcef/browser_webview_delegate_mac.mm +++ b/libcef/browser_webview_delegate_mac.mm @@ -195,27 +195,26 @@ void BrowserWebViewDelegate::DidMovePlugin( // Protected methods ---------------------------------------------------------- void BrowserWebViewDelegate::ShowJavaScriptAlert( - WebKit::WebFrame* webframe, const std::wstring& message) { - NSString *text = - [NSString stringWithUTF8String:(std::string(message).c_str())]; + WebKit::WebFrame* webframe, const CefString& message) { + std::string messageStr(message); + NSString *text = [NSString stringWithUTF8String:messageStr.c_str()]; NSAlert *alert = [NSAlert alertWithMessageText:@"JavaScript Alert" defaultButton:@"OK" alternateButton:nil otherButton:nil informativeTextWithFormat:text]; [alert runModal]; - [text release]; } bool BrowserWebViewDelegate::ShowJavaScriptConfirm( - WebKit::WebFrame* webframe, const std::wstring& message) { + WebKit::WebFrame* webframe, const CefString& message) { NOTIMPLEMENTED(); return false; } bool BrowserWebViewDelegate::ShowJavaScriptPrompt( - WebKit::WebFrame* webframe, const std::wstring& message, - const std::wstring& default_value, std::wstring* result) { + WebKit::WebFrame* webframe, const CefString& message, + const CefString& default_value, CefString* result) { NOTIMPLEMENTED(); return false; } @@ -228,17 +227,3 @@ bool BrowserWebViewDelegate::ShowFileChooser(std::vector& file_names, NOTIMPLEMENTED(); return false; } - -// Private methods ------------------------------------------------------------ -/* -void BrowserWebViewDelegate::SetPageTitle(const std::wstring& title) { - [[browser_->GetWebViewHost()->view_handle() window] - setTitle:[NSString stringWithUTF8String:(std::string(title).c_str())]]; -} - -void BrowserWebViewDelegate::SetAddressBarURL(const GURL& url) { - const char* frameURL = url.spec().c_str(); - NSString *address = [NSString stringWithUTF8String:frameURL]; - [browser_->GetEditWnd() setStringValue:address]; -} -*/ diff --git a/libcef/browser_webview_delegate_win.cc b/libcef/browser_webview_delegate_win.cc index 385678948..7247aa1ce 100644 --- a/libcef/browser_webview_delegate_win.cc +++ b/libcef/browser_webview_delegate_win.cc @@ -283,6 +283,8 @@ void BrowserWebViewDelegate::showContextMenu( if(handler.get()) { // Gather menu information CefHandler::MenuInfo menuInfo; + memset(&menuInfo, 0, sizeof(menuInfo)); + CefString linkStr(std::string(data.linkURL.spec())); CefString imageStr(std::string(data.srcURL.spec())); CefString pageStr(std::string(data.pageURL.spec())); diff --git a/libcef/cef_context.cc b/libcef/cef_context.cc index ac2f01efc..789f533e9 100644 --- a/libcef/cef_context.cc +++ b/libcef/cef_context.cc @@ -67,11 +67,7 @@ static void UIT_RegisterPlugin(struct CefPluginInfo* plugin_info) NPAPI::PluginVersionInfo info; -#if defined(OS_WIN) info.path = FilePath(plugin_info->unique_name); -#else - info.path = FilePath(WideToUTF8(plugin_info->unique_name)); -#endif info.product_name = plugin_info->display_name; info.file_description = plugin_info->description; info.file_version =plugin_info->version; diff --git a/libcef/cef_string_types.cc b/libcef/cef_string_types.cc index 6473333e4..41f98762e 100644 --- a/libcef/cef_string_types.cc +++ b/libcef/cef_string_types.cc @@ -167,7 +167,8 @@ CEF_EXPORT int cef_string_utf16_cmp(const cef_string_utf16_t* str1, if (str1->length == 0 && str2->length == 0) return 0; #if defined(WCHAR_T_IS_UTF32) - int r = c16memcmp(str1->str, str2->str, std::min(str1->length, str2->length)); + int r = base::c16memcmp(str1->str, str2->str, std::min(str1->length, + str2->length)); #else int r = wcsncmp(str1->str, str2->str, std::min(str1->length, str2->length)); #endif diff --git a/libcef/request_impl.cc b/libcef/request_impl.cc index 450f57252..a2bd4738c 100644 --- a/libcef/request_impl.cc +++ b/libcef/request_impl.cc @@ -448,11 +448,7 @@ void CefPostDataElementImpl::Set(const net::UploadData::Element& element) std::string(element.bytes().begin(), element.bytes().end()).c_str())); } else if (element.type() == net::UploadData::TYPE_FILE) { -#if defined(OS_WIN) SetToFile(element.file_path().value()); -#else - SetToFile(UTF8ToWide(element.file_path().value())); -#endif } else { NOTREACHED(); } diff --git a/libcef/webwidget_host_mac.mm b/libcef/webwidget_host_mac.mm index 366a40364..25fc019a6 100644 --- a/libcef/webwidget_host_mac.mm +++ b/libcef/webwidget_host_mac.mm @@ -214,7 +214,7 @@ void WebWidgetHost::Paint() { } } -void WebWidgetHost::SetTooltipText(const std::string& tooltip_text) { +void WebWidgetHost::SetTooltipText(const CefString& tooltip_text) { // TODO(port): Implement this method. } diff --git a/libcef_dll/cpptoc/handler_cpptoc.cc b/libcef_dll/cpptoc/handler_cpptoc.cc index 3921ce940..fd319fc07 100644 --- a/libcef_dll/cpptoc/handler_cpptoc.cc +++ b/libcef_dll/cpptoc/handler_cpptoc.cc @@ -53,9 +53,10 @@ enum cef_retval_t CEF_CALLBACK handler_handle_before_created( if(parentBrowser) browserPtr = CefBrowserCToCpp::Wrap(parentBrowser); + CefString urlStr(url); enum cef_retval_t rv = CefHandlerCppToC::Get(self)->HandleBeforeCreated( browserPtr, wndInfo, popup?true:false, features, handlerPtr, - CefString(url), browserSettings); + urlStr, browserSettings); if(handlerPtr.get() != origHandler) { // The handler has been changed. @@ -177,9 +178,10 @@ enum cef_retval_t CEF_CALLBACK handler_handle_load_error( if(!self || !browser || !errorText || !frame) return RV_CONTINUE; + CefString errorTextStr(errorText); return CefHandlerCppToC::Get(self)->HandleLoadError( CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), errorCode, - CefString(failedUrl), CefString(errorText)); + CefString(failedUrl), errorTextStr); } enum cef_retval_t CEF_CALLBACK handler_handle_before_resource_load( @@ -198,10 +200,12 @@ enum cef_retval_t CEF_CALLBACK handler_handle_before_resource_load( CefRefPtr streamPtr; + CefString redirectUrlStr(redirectUrl); + CefString mimeTypeStr(mimeType); enum cef_retval_t rv = CefHandlerCppToC::Get(self)-> HandleBeforeResourceLoad(CefBrowserCToCpp::Wrap(browser), - CefRequestCToCpp::Wrap(request), CefString(redirectUrl), streamPtr, - CefString(mimeType), loadFlags); + CefRequestCToCpp::Wrap(request), redirectUrlStr, streamPtr, mimeTypeStr, + loadFlags); if(streamPtr.get()) *resourceStream = CefStreamReaderCToCpp::Unwrap(streamPtr); @@ -257,8 +261,9 @@ enum cef_retval_t CEF_CALLBACK handler_handle_get_menu_label( if(!self || !browser || !label) return RV_CONTINUE; + CefString labelStr(label); return CefHandlerCppToC::Get(self)->HandleGetMenuLabel( - CefBrowserCToCpp::Wrap(browser), menuId, CefString(label)); + CefBrowserCToCpp::Wrap(browser), menuId, labelStr); } enum cef_retval_t CEF_CALLBACK handler_handle_menu_action( @@ -307,12 +312,17 @@ enum cef_retval_t CEF_CALLBACK handler_handle_print_header_footer( CefPrintInfo info = *printInfo; + CefString topLeftStr(topLeft); + CefString topCenterStr(topCenter); + CefString topRightStr(topRight); + CefString bottomLeftStr(bottomLeft); + CefString bottomCenterStr(bottomCenter); + CefString bottomRightStr(bottomRight); return CefHandlerCppToC::Get(self)-> HandlePrintHeaderFooter(CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), info, CefString(url), CefString(title), - currentPage, maxPages, CefString(topLeft), CefString(topCenter), - CefString(topRight), CefString(bottomLeft), CefString(bottomCenter), - CefString(bottomRight)); + currentPage, maxPages, topLeftStr, topCenterStr, topRightStr, + bottomLeftStr, bottomCenterStr, bottomRightStr); } enum cef_retval_t CEF_CALLBACK handler_handle_jsalert( @@ -364,9 +374,10 @@ enum cef_retval_t CEF_CALLBACK handler_handle_jsprompt( return RV_CONTINUE; bool ret = false; + CefString resultStr(result); enum cef_retval_t rv = CefHandlerCppToC::Get(self)->HandleJSPrompt( CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), - CefString(message), CefString(defaultValue), ret, CefString(result)); + CefString(message), CefString(defaultValue), ret, resultStr); *retval = (ret ? 1 : 0); return rv; @@ -448,8 +459,9 @@ enum cef_retval_t CEF_CALLBACK handler_handle_tooltip( if(!self || !browser || !text) return RV_CONTINUE; + CefString textStr(text); return CefHandlerCppToC::Get(self)->HandleTooltip( - CefBrowserCToCpp::Wrap(browser), CefString(text)); + CefBrowserCToCpp::Wrap(browser), textStr); } enum cef_retval_t CEF_CALLBACK handler_handle_console_message( diff --git a/libcef_dll/cpptoc/scheme_handler_cpptoc.cc b/libcef_dll/cpptoc/scheme_handler_cpptoc.cc index 27f14fa79..bf658245e 100644 --- a/libcef_dll/cpptoc/scheme_handler_cpptoc.cc +++ b/libcef_dll/cpptoc/scheme_handler_cpptoc.cc @@ -27,8 +27,9 @@ int CEF_CALLBACK scheme_handler_process_request( if(!self || !request || !mime_type || !response_length) return 0; + CefString mimeTypeStr(mime_type); return CefSchemeHandlerCppToC::Get(self)->ProcessRequest( - CefRequestCToCpp::Wrap(request), CefString(mime_type), response_length); + CefRequestCToCpp::Wrap(request), mimeTypeStr, response_length); } void CEF_CALLBACK scheme_handler_cancel(struct _cef_scheme_handler_t* self) diff --git a/libcef_dll/cpptoc/v8handler_cpptoc.cc b/libcef_dll/cpptoc/v8handler_cpptoc.cc index bb833b9bb..a81252c1a 100644 --- a/libcef_dll/cpptoc/v8handler_cpptoc.cc +++ b/libcef_dll/cpptoc/v8handler_cpptoc.cc @@ -35,8 +35,9 @@ int CEF_CALLBACK v8handler_execute(struct _cef_v8handler_t* self, } CefRefPtr retValPtr; + CefString exceptionStr(exception); bool rv = CefV8HandlerCppToC::Get(self)->Execute(CefString(name), objectPtr, - list, retValPtr, CefString(exception)); + list, retValPtr, exceptionStr); if(rv) { if(retValPtr.get() && retval) *retval = CefV8ValueCToCpp::Unwrap(retValPtr); diff --git a/libcef_dll/cpptoc/v8value_cpptoc.cc b/libcef_dll/cpptoc/v8value_cpptoc.cc index 31dd91c7f..b57900096 100644 --- a/libcef_dll/cpptoc/v8value_cpptoc.cc +++ b/libcef_dll/cpptoc/v8value_cpptoc.cc @@ -385,8 +385,9 @@ int CEF_CALLBACK v8value_execute_function(struct _cef_v8value_t* self, } CefRefPtr retvalPtr; + CefString exceptionStr(exception); bool rv = CefV8ValueCppToC::Get(self)->ExecuteFunction(objectPtr, - argsList, retvalPtr, CefString(exception)); + argsList, retvalPtr, exceptionStr); if(retvalPtr.get() && retval) *retval = CefV8ValueCppToC::Wrap(retvalPtr); diff --git a/libcef_dll/cpptoc/xml_reader_cpptoc.cc b/libcef_dll/cpptoc/xml_reader_cpptoc.cc index f3b0df033..2035f36ae 100644 --- a/libcef_dll/cpptoc/xml_reader_cpptoc.cc +++ b/libcef_dll/cpptoc/xml_reader_cpptoc.cc @@ -1,384 +1,384 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights -// reserved. Use of this source code is governed by a BSD-style license that -// can be found in the LICENSE file. -// -// --------------------------------------------------------------------------- -// -// A portion of this file was generated by the CEF translator tool. When -// making changes by hand only do so within the body of existing function -// implementations. See the translator.README.txt file in the tools directory -// for more information. -// - -#include "libcef_dll/cpptoc/stream_reader_cpptoc.h" -#include "libcef_dll/cpptoc/xml_reader_cpptoc.h" - - -// GLOBAL FUNCTIONS - Body may be edited by hand. - -CEF_EXPORT cef_xml_reader_t* cef_xml_reader_create(cef_stream_reader_t* stream, - enum cef_xml_encoding_type_t encodingType, const cef_string_t* URI) -{ - CefRefPtr impl = CefXmlReader::Create( - CefStreamReaderCppToC::Unwrap(stream), encodingType, CefString(URI)); - if(impl.get()) - return CefXmlReaderCppToC::Wrap(impl); - return NULL; -} - - -// MEMBER FUNCTIONS - Body may be edited by hand. - -int CEF_CALLBACK xml_reader_move_to_next_node(struct _cef_xml_reader_t* self) -{ - DCHECK(self); - if(!self) - return 0; - - return CefXmlReaderCppToC::Get(self)->MoveToNextNode(); -} - -int CEF_CALLBACK xml_reader_close(struct _cef_xml_reader_t* self) -{ - DCHECK(self); - if(!self) - return 0; - - return CefXmlReaderCppToC::Get(self)->Close(); -} - -int CEF_CALLBACK xml_reader_has_error(struct _cef_xml_reader_t* self) -{ - DCHECK(self); - if(!self) - return 0; - - return CefXmlReaderCppToC::Get(self)->HasError(); -} - -cef_string_userfree_t CEF_CALLBACK xml_reader_get_error( - struct _cef_xml_reader_t* self) -{ - DCHECK(self); - if(!self) - return NULL; - - CefString retStr = CefXmlReaderCppToC::Get(self)->GetError(); - return retStr.DetachToUserFree(); -} - -enum cef_xml_node_type_t CEF_CALLBACK xml_reader_get_type( - struct _cef_xml_reader_t* self) -{ - DCHECK(self); - if(!self) - return XML_NODE_UNSUPPORTED; - - return CefXmlReaderCppToC::Get(self)->GetType(); -} - -int CEF_CALLBACK xml_reader_get_depth(struct _cef_xml_reader_t* self) -{ - DCHECK(self); - if(!self) - return -1; - - return CefXmlReaderCppToC::Get(self)->GetDepth(); -} - -cef_string_userfree_t CEF_CALLBACK xml_reader_get_local_name( - struct _cef_xml_reader_t* self) -{ - DCHECK(self); - if(!self) - return NULL; - - CefString retStr = CefXmlReaderCppToC::Get(self)->GetLocalName(); - return retStr.DetachToUserFree(); -} - -cef_string_userfree_t CEF_CALLBACK xml_reader_get_prefix( - struct _cef_xml_reader_t* self) -{ - DCHECK(self); - if(!self) - return NULL; - - CefString retStr = CefXmlReaderCppToC::Get(self)->GetPrefix(); - return retStr.DetachToUserFree(); -} - -cef_string_userfree_t CEF_CALLBACK xml_reader_get_qualified_name( - struct _cef_xml_reader_t* self) -{ - DCHECK(self); - if(!self) - return NULL; - - CefString retStr = CefXmlReaderCppToC::Get(self)->GetQualifiedName(); - return retStr.DetachToUserFree(); -} - -cef_string_userfree_t CEF_CALLBACK xml_reader_get_namespace_uri( - struct _cef_xml_reader_t* self) -{ - DCHECK(self); - if(!self) - return NULL; - - CefString retStr = CefXmlReaderCppToC::Get(self)->GetNamespaceURI(); - return retStr.DetachToUserFree(); -} - -cef_string_userfree_t CEF_CALLBACK xml_reader_get_base_uri( - struct _cef_xml_reader_t* self) -{ - DCHECK(self); - if(!self) - return NULL; - - CefString retStr = CefXmlReaderCppToC::Get(self)->GetBaseURI(); - return retStr.DetachToUserFree(); -} - -cef_string_userfree_t CEF_CALLBACK xml_reader_get_xml_lang( - struct _cef_xml_reader_t* self) -{ - DCHECK(self); - if(!self) - return NULL; - - CefString retStr = CefXmlReaderCppToC::Get(self)->GetXmlLang(); - return retStr.DetachToUserFree(); -} - -int CEF_CALLBACK xml_reader_is_empty_element(struct _cef_xml_reader_t* self) -{ - DCHECK(self); - if(!self) - return 0; - - return CefXmlReaderCppToC::Get(self)->IsEmptyElement(); -} - -int CEF_CALLBACK xml_reader_has_value(struct _cef_xml_reader_t* self) -{ - DCHECK(self); - if(!self) - return 0; - - return CefXmlReaderCppToC::Get(self)->HasValue(); -} - -cef_string_userfree_t CEF_CALLBACK xml_reader_get_value( - struct _cef_xml_reader_t* self) -{ - DCHECK(self); - if(!self) - return NULL; - - CefString retStr = CefXmlReaderCppToC::Get(self)->GetValue(); - return retStr.DetachToUserFree(); -} - -int CEF_CALLBACK xml_reader_has_attributes(struct _cef_xml_reader_t* self) -{ - DCHECK(self); - if(!self) - return 0; - - return CefXmlReaderCppToC::Get(self)->HasAttributes(); -} - -size_t CEF_CALLBACK xml_reader_get_attribute_count( - struct _cef_xml_reader_t* self) -{ - DCHECK(self); - if(!self) - return 0; - - return CefXmlReaderCppToC::Get(self)->GetAttributeCount(); -} - -cef_string_userfree_t CEF_CALLBACK xml_reader_get_attribute_byindex( - struct _cef_xml_reader_t* self, int index) -{ - DCHECK(self); - if(!self) - return NULL; - - CefString retStr = CefXmlReaderCppToC::Get(self)->GetAttribute(index); - return retStr.DetachToUserFree(); -} - -cef_string_userfree_t CEF_CALLBACK xml_reader_get_attribute_byqname( - struct _cef_xml_reader_t* self, const cef_string_t* qualifiedName) -{ - DCHECK(self); - DCHECK(qualifiedName); - if(!self || !qualifiedName) - return NULL; - - CefString retStr = CefXmlReaderCppToC::Get(self)->GetAttribute( - CefString(qualifiedName)); - return retStr.DetachToUserFree(); -} - -cef_string_userfree_t CEF_CALLBACK xml_reader_get_attribute_bylname( - struct _cef_xml_reader_t* self, const cef_string_t* localName, - const cef_string_t* namespaceURI) -{ - DCHECK(self); - DCHECK(localName); - DCHECK(namespaceURI); - if(!self || !localName || !namespaceURI) - return NULL; - - CefString retStr = CefXmlReaderCppToC::Get(self)->GetAttribute( - CefString(localName), CefString(namespaceURI)); - return retStr.DetachToUserFree(); -} - -cef_string_userfree_t CEF_CALLBACK xml_reader_get_inner_xml( - struct _cef_xml_reader_t* self) -{ - DCHECK(self); - if(!self) - return NULL; - - CefString retStr = CefXmlReaderCppToC::Get(self)->GetInnerXml(); - return retStr.DetachToUserFree(); -} - -cef_string_userfree_t CEF_CALLBACK xml_reader_get_outer_xml( - struct _cef_xml_reader_t* self) -{ - DCHECK(self); - if(!self) - return NULL; - - CefString retStr = CefXmlReaderCppToC::Get(self)->GetOuterXml(); - return retStr.DetachToUserFree(); -} - -int CEF_CALLBACK xml_reader_get_line_number(struct _cef_xml_reader_t* self) -{ - DCHECK(self); - if(!self) - return 0; - - return CefXmlReaderCppToC::Get(self)->GetLineNumber(); -} - -int CEF_CALLBACK xml_reader_move_to_attribute_byindex( - struct _cef_xml_reader_t* self, int index) -{ - DCHECK(self); - if(!self) - return 0; - - return CefXmlReaderCppToC::Get(self)->MoveToAttribute(index); -} - -int CEF_CALLBACK xml_reader_move_to_attribute_byqname( - struct _cef_xml_reader_t* self, const cef_string_t* qualifiedName) -{ - DCHECK(self); - DCHECK(qualifiedName); - if(!self || !qualifiedName) - return 0; - - return CefXmlReaderCppToC::Get(self)->MoveToAttribute( - CefString(qualifiedName)); -} - -int CEF_CALLBACK xml_reader_move_to_attribute_bylname( - struct _cef_xml_reader_t* self, const cef_string_t* localName, - const cef_string_t* namespaceURI) -{ - DCHECK(self); - DCHECK(localName); - DCHECK(namespaceURI); - if(!self || !localName || !namespaceURI) - return 0; - - return CefXmlReaderCppToC::Get(self)->MoveToAttribute(CefString(localName), - CefString(namespaceURI)); -} - -int CEF_CALLBACK xml_reader_move_to_first_attribute( - struct _cef_xml_reader_t* self) -{ - DCHECK(self); - if(!self) - return 0; - - return CefXmlReaderCppToC::Get(self)->MoveToFirstAttribute(); -} - -int CEF_CALLBACK xml_reader_move_to_next_attribute( - struct _cef_xml_reader_t* self) -{ - DCHECK(self); - if(!self) - return 0; - - return CefXmlReaderCppToC::Get(self)->MoveToNextAttribute(); -} - -int CEF_CALLBACK xml_reader_move_to_carrying_element( - struct _cef_xml_reader_t* self) -{ - DCHECK(self); - if(!self) - return 0; - - return CefXmlReaderCppToC::Get(self)->MoveToCarryingElement(); -} - - -// CONSTRUCTOR - Do not edit by hand. - -CefXmlReaderCppToC::CefXmlReaderCppToC(CefXmlReader* cls) - : CefCppToC(cls) -{ - struct_.struct_.move_to_next_node = xml_reader_move_to_next_node; - struct_.struct_.close = xml_reader_close; - struct_.struct_.has_error = xml_reader_has_error; - struct_.struct_.get_error = xml_reader_get_error; - struct_.struct_.get_type = xml_reader_get_type; - struct_.struct_.get_depth = xml_reader_get_depth; - struct_.struct_.get_local_name = xml_reader_get_local_name; - struct_.struct_.get_prefix = xml_reader_get_prefix; - struct_.struct_.get_qualified_name = xml_reader_get_qualified_name; - struct_.struct_.get_namespace_uri = xml_reader_get_namespace_uri; - struct_.struct_.get_base_uri = xml_reader_get_base_uri; - struct_.struct_.get_xml_lang = xml_reader_get_xml_lang; - struct_.struct_.is_empty_element = xml_reader_is_empty_element; - struct_.struct_.has_value = xml_reader_has_value; - struct_.struct_.get_value = xml_reader_get_value; - struct_.struct_.has_attributes = xml_reader_has_attributes; - struct_.struct_.get_attribute_count = xml_reader_get_attribute_count; - struct_.struct_.get_attribute_byindex = xml_reader_get_attribute_byindex; - struct_.struct_.get_attribute_byqname = xml_reader_get_attribute_byqname; - struct_.struct_.get_attribute_bylname = xml_reader_get_attribute_bylname; - struct_.struct_.get_inner_xml = xml_reader_get_inner_xml; - struct_.struct_.get_outer_xml = xml_reader_get_outer_xml; - struct_.struct_.get_line_number = xml_reader_get_line_number; - struct_.struct_.move_to_attribute_byindex = - xml_reader_move_to_attribute_byindex; - struct_.struct_.move_to_attribute_byqname = - xml_reader_move_to_attribute_byqname; - struct_.struct_.move_to_attribute_bylname = - xml_reader_move_to_attribute_bylname; - struct_.struct_.move_to_first_attribute = xml_reader_move_to_first_attribute; - struct_.struct_.move_to_next_attribute = xml_reader_move_to_next_attribute; - struct_.struct_.move_to_carrying_element = - xml_reader_move_to_carrying_element; -} - -#ifdef _DEBUG -long CefCppToC::DebugObjCt = - 0; -#endif - +// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. +// +// --------------------------------------------------------------------------- +// +// A portion of this file was generated by the CEF translator tool. When +// making changes by hand only do so within the body of existing function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/stream_reader_cpptoc.h" +#include "libcef_dll/cpptoc/xml_reader_cpptoc.h" + + +// GLOBAL FUNCTIONS - Body may be edited by hand. + +CEF_EXPORT cef_xml_reader_t* cef_xml_reader_create(cef_stream_reader_t* stream, + enum cef_xml_encoding_type_t encodingType, const cef_string_t* URI) +{ + CefRefPtr impl = CefXmlReader::Create( + CefStreamReaderCppToC::Unwrap(stream), encodingType, CefString(URI)); + if(impl.get()) + return CefXmlReaderCppToC::Wrap(impl); + return NULL; +} + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +int CEF_CALLBACK xml_reader_move_to_next_node(struct _cef_xml_reader_t* self) +{ + DCHECK(self); + if(!self) + return 0; + + return CefXmlReaderCppToC::Get(self)->MoveToNextNode(); +} + +int CEF_CALLBACK xml_reader_close(struct _cef_xml_reader_t* self) +{ + DCHECK(self); + if(!self) + return 0; + + return CefXmlReaderCppToC::Get(self)->Close(); +} + +int CEF_CALLBACK xml_reader_has_error(struct _cef_xml_reader_t* self) +{ + DCHECK(self); + if(!self) + return 0; + + return CefXmlReaderCppToC::Get(self)->HasError(); +} + +cef_string_userfree_t CEF_CALLBACK xml_reader_get_error( + struct _cef_xml_reader_t* self) +{ + DCHECK(self); + if(!self) + return NULL; + + CefString retStr = CefXmlReaderCppToC::Get(self)->GetError(); + return retStr.DetachToUserFree(); +} + +enum cef_xml_node_type_t CEF_CALLBACK xml_reader_get_type( + struct _cef_xml_reader_t* self) +{ + DCHECK(self); + if(!self) + return XML_NODE_UNSUPPORTED; + + return CefXmlReaderCppToC::Get(self)->GetType(); +} + +int CEF_CALLBACK xml_reader_get_depth(struct _cef_xml_reader_t* self) +{ + DCHECK(self); + if(!self) + return -1; + + return CefXmlReaderCppToC::Get(self)->GetDepth(); +} + +cef_string_userfree_t CEF_CALLBACK xml_reader_get_local_name( + struct _cef_xml_reader_t* self) +{ + DCHECK(self); + if(!self) + return NULL; + + CefString retStr = CefXmlReaderCppToC::Get(self)->GetLocalName(); + return retStr.DetachToUserFree(); +} + +cef_string_userfree_t CEF_CALLBACK xml_reader_get_prefix( + struct _cef_xml_reader_t* self) +{ + DCHECK(self); + if(!self) + return NULL; + + CefString retStr = CefXmlReaderCppToC::Get(self)->GetPrefix(); + return retStr.DetachToUserFree(); +} + +cef_string_userfree_t CEF_CALLBACK xml_reader_get_qualified_name( + struct _cef_xml_reader_t* self) +{ + DCHECK(self); + if(!self) + return NULL; + + CefString retStr = CefXmlReaderCppToC::Get(self)->GetQualifiedName(); + return retStr.DetachToUserFree(); +} + +cef_string_userfree_t CEF_CALLBACK xml_reader_get_namespace_uri( + struct _cef_xml_reader_t* self) +{ + DCHECK(self); + if(!self) + return NULL; + + CefString retStr = CefXmlReaderCppToC::Get(self)->GetNamespaceURI(); + return retStr.DetachToUserFree(); +} + +cef_string_userfree_t CEF_CALLBACK xml_reader_get_base_uri( + struct _cef_xml_reader_t* self) +{ + DCHECK(self); + if(!self) + return NULL; + + CefString retStr = CefXmlReaderCppToC::Get(self)->GetBaseURI(); + return retStr.DetachToUserFree(); +} + +cef_string_userfree_t CEF_CALLBACK xml_reader_get_xml_lang( + struct _cef_xml_reader_t* self) +{ + DCHECK(self); + if(!self) + return NULL; + + CefString retStr = CefXmlReaderCppToC::Get(self)->GetXmlLang(); + return retStr.DetachToUserFree(); +} + +int CEF_CALLBACK xml_reader_is_empty_element(struct _cef_xml_reader_t* self) +{ + DCHECK(self); + if(!self) + return 0; + + return CefXmlReaderCppToC::Get(self)->IsEmptyElement(); +} + +int CEF_CALLBACK xml_reader_has_value(struct _cef_xml_reader_t* self) +{ + DCHECK(self); + if(!self) + return 0; + + return CefXmlReaderCppToC::Get(self)->HasValue(); +} + +cef_string_userfree_t CEF_CALLBACK xml_reader_get_value( + struct _cef_xml_reader_t* self) +{ + DCHECK(self); + if(!self) + return NULL; + + CefString retStr = CefXmlReaderCppToC::Get(self)->GetValue(); + return retStr.DetachToUserFree(); +} + +int CEF_CALLBACK xml_reader_has_attributes(struct _cef_xml_reader_t* self) +{ + DCHECK(self); + if(!self) + return 0; + + return CefXmlReaderCppToC::Get(self)->HasAttributes(); +} + +size_t CEF_CALLBACK xml_reader_get_attribute_count( + struct _cef_xml_reader_t* self) +{ + DCHECK(self); + if(!self) + return 0; + + return CefXmlReaderCppToC::Get(self)->GetAttributeCount(); +} + +cef_string_userfree_t CEF_CALLBACK xml_reader_get_attribute_byindex( + struct _cef_xml_reader_t* self, int index) +{ + DCHECK(self); + if(!self) + return NULL; + + CefString retStr = CefXmlReaderCppToC::Get(self)->GetAttribute(index); + return retStr.DetachToUserFree(); +} + +cef_string_userfree_t CEF_CALLBACK xml_reader_get_attribute_byqname( + struct _cef_xml_reader_t* self, const cef_string_t* qualifiedName) +{ + DCHECK(self); + DCHECK(qualifiedName); + if(!self || !qualifiedName) + return NULL; + + CefString retStr = CefXmlReaderCppToC::Get(self)->GetAttribute( + CefString(qualifiedName)); + return retStr.DetachToUserFree(); +} + +cef_string_userfree_t CEF_CALLBACK xml_reader_get_attribute_bylname( + struct _cef_xml_reader_t* self, const cef_string_t* localName, + const cef_string_t* namespaceURI) +{ + DCHECK(self); + DCHECK(localName); + DCHECK(namespaceURI); + if(!self || !localName || !namespaceURI) + return NULL; + + CefString retStr = CefXmlReaderCppToC::Get(self)->GetAttribute( + CefString(localName), CefString(namespaceURI)); + return retStr.DetachToUserFree(); +} + +cef_string_userfree_t CEF_CALLBACK xml_reader_get_inner_xml( + struct _cef_xml_reader_t* self) +{ + DCHECK(self); + if(!self) + return NULL; + + CefString retStr = CefXmlReaderCppToC::Get(self)->GetInnerXml(); + return retStr.DetachToUserFree(); +} + +cef_string_userfree_t CEF_CALLBACK xml_reader_get_outer_xml( + struct _cef_xml_reader_t* self) +{ + DCHECK(self); + if(!self) + return NULL; + + CefString retStr = CefXmlReaderCppToC::Get(self)->GetOuterXml(); + return retStr.DetachToUserFree(); +} + +int CEF_CALLBACK xml_reader_get_line_number(struct _cef_xml_reader_t* self) +{ + DCHECK(self); + if(!self) + return 0; + + return CefXmlReaderCppToC::Get(self)->GetLineNumber(); +} + +int CEF_CALLBACK xml_reader_move_to_attribute_byindex( + struct _cef_xml_reader_t* self, int index) +{ + DCHECK(self); + if(!self) + return 0; + + return CefXmlReaderCppToC::Get(self)->MoveToAttribute(index); +} + +int CEF_CALLBACK xml_reader_move_to_attribute_byqname( + struct _cef_xml_reader_t* self, const cef_string_t* qualifiedName) +{ + DCHECK(self); + DCHECK(qualifiedName); + if(!self || !qualifiedName) + return 0; + + return CefXmlReaderCppToC::Get(self)->MoveToAttribute( + CefString(qualifiedName)); +} + +int CEF_CALLBACK xml_reader_move_to_attribute_bylname( + struct _cef_xml_reader_t* self, const cef_string_t* localName, + const cef_string_t* namespaceURI) +{ + DCHECK(self); + DCHECK(localName); + DCHECK(namespaceURI); + if(!self || !localName || !namespaceURI) + return 0; + + return CefXmlReaderCppToC::Get(self)->MoveToAttribute(CefString(localName), + CefString(namespaceURI)); +} + +int CEF_CALLBACK xml_reader_move_to_first_attribute( + struct _cef_xml_reader_t* self) +{ + DCHECK(self); + if(!self) + return 0; + + return CefXmlReaderCppToC::Get(self)->MoveToFirstAttribute(); +} + +int CEF_CALLBACK xml_reader_move_to_next_attribute( + struct _cef_xml_reader_t* self) +{ + DCHECK(self); + if(!self) + return 0; + + return CefXmlReaderCppToC::Get(self)->MoveToNextAttribute(); +} + +int CEF_CALLBACK xml_reader_move_to_carrying_element( + struct _cef_xml_reader_t* self) +{ + DCHECK(self); + if(!self) + return 0; + + return CefXmlReaderCppToC::Get(self)->MoveToCarryingElement(); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefXmlReaderCppToC::CefXmlReaderCppToC(CefXmlReader* cls) + : CefCppToC(cls) +{ + struct_.struct_.move_to_next_node = xml_reader_move_to_next_node; + struct_.struct_.close = xml_reader_close; + struct_.struct_.has_error = xml_reader_has_error; + struct_.struct_.get_error = xml_reader_get_error; + struct_.struct_.get_type = xml_reader_get_type; + struct_.struct_.get_depth = xml_reader_get_depth; + struct_.struct_.get_local_name = xml_reader_get_local_name; + struct_.struct_.get_prefix = xml_reader_get_prefix; + struct_.struct_.get_qualified_name = xml_reader_get_qualified_name; + struct_.struct_.get_namespace_uri = xml_reader_get_namespace_uri; + struct_.struct_.get_base_uri = xml_reader_get_base_uri; + struct_.struct_.get_xml_lang = xml_reader_get_xml_lang; + struct_.struct_.is_empty_element = xml_reader_is_empty_element; + struct_.struct_.has_value = xml_reader_has_value; + struct_.struct_.get_value = xml_reader_get_value; + struct_.struct_.has_attributes = xml_reader_has_attributes; + struct_.struct_.get_attribute_count = xml_reader_get_attribute_count; + struct_.struct_.get_attribute_byindex = xml_reader_get_attribute_byindex; + struct_.struct_.get_attribute_byqname = xml_reader_get_attribute_byqname; + struct_.struct_.get_attribute_bylname = xml_reader_get_attribute_bylname; + struct_.struct_.get_inner_xml = xml_reader_get_inner_xml; + struct_.struct_.get_outer_xml = xml_reader_get_outer_xml; + struct_.struct_.get_line_number = xml_reader_get_line_number; + struct_.struct_.move_to_attribute_byindex = + xml_reader_move_to_attribute_byindex; + struct_.struct_.move_to_attribute_byqname = + xml_reader_move_to_attribute_byqname; + struct_.struct_.move_to_attribute_bylname = + xml_reader_move_to_attribute_bylname; + struct_.struct_.move_to_first_attribute = xml_reader_move_to_first_attribute; + struct_.struct_.move_to_next_attribute = xml_reader_move_to_next_attribute; + struct_.struct_.move_to_carrying_element = + xml_reader_move_to_carrying_element; +} + +#ifdef _DEBUG +long CefCppToC::DebugObjCt = + 0; +#endif + diff --git a/libcef_dll/cpptoc/xml_reader_cpptoc.h b/libcef_dll/cpptoc/xml_reader_cpptoc.h index 3f34d911d..a20cbfbb7 100644 --- a/libcef_dll/cpptoc/xml_reader_cpptoc.h +++ b/libcef_dll/cpptoc/xml_reader_cpptoc.h @@ -1,34 +1,34 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights -// reserved. Use of this source code is governed by a BSD-style license that -// can be found in the LICENSE file. -// -// --------------------------------------------------------------------------- -// -// This file was generated by the CEF translator tool and should not edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// -#ifndef _XMLREADER_CPPTOC_H -#define _XMLREADER_CPPTOC_H - -#ifndef BUILDING_CEF_SHARED -#pragma message("Warning: "__FILE__" may be accessed DLL-side only") -#else // BUILDING_CEF_SHARED - -#include "include/cef.h" -#include "include/cef_capi.h" -#include "libcef_dll/cpptoc/cpptoc.h" - -// Wrap a C++ class with a C structure. -// This class may be instantiated and accessed DLL-side only. -class CefXmlReaderCppToC - : public CefCppToC -{ -public: - CefXmlReaderCppToC(CefXmlReader* cls); - virtual ~CefXmlReaderCppToC() {} -}; - -#endif // BUILDING_CEF_SHARED -#endif // _XMLREADER_CPPTOC_H - +// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// +#ifndef _XMLREADER_CPPTOC_H +#define _XMLREADER_CPPTOC_H + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef.h" +#include "include/cef_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefXmlReaderCppToC + : public CefCppToC +{ +public: + CefXmlReaderCppToC(CefXmlReader* cls); + virtual ~CefXmlReaderCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // _XMLREADER_CPPTOC_H + diff --git a/libcef_dll/ctocpp/xml_reader_ctocpp.cc b/libcef_dll/ctocpp/xml_reader_ctocpp.cc index 54310913a..4b1c87796 100644 --- a/libcef_dll/ctocpp/xml_reader_ctocpp.cc +++ b/libcef_dll/ctocpp/xml_reader_ctocpp.cc @@ -1,314 +1,314 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights -// reserved. Use of this source code is governed by a BSD-style license that -// can be found in the LICENSE file. -// -// --------------------------------------------------------------------------- -// -// A portion of this file was generated by the CEF translator tool. When -// making changes by hand only do so within the body of existing static and -// virtual method implementations. See the translator.README.txt file in the -// tools directory for more information. -// - -#include "libcef_dll/ctocpp/stream_reader_ctocpp.h" -#include "libcef_dll/ctocpp/xml_reader_ctocpp.h" - - -// STATIC METHODS - Body may be edited by hand. - -CefRefPtr CefXmlReader::Create(CefRefPtr stream, - EncodingType encodingType, const CefString& URI) -{ - cef_xml_reader_t* impl = cef_xml_reader_create( - CefStreamReaderCToCpp::Unwrap(stream), encodingType, URI.GetStruct()); - if(impl) - return CefXmlReaderCToCpp::Wrap(impl); - return NULL; -} - - -// VIRTUAL METHODS - Body may be edited by hand. - -bool CefXmlReaderCToCpp::MoveToNextNode() -{ - if(CEF_MEMBER_MISSING(struct_, move_to_next_node)) - return false; - - return struct_->move_to_next_node(struct_) ? true : false; -} - -bool CefXmlReaderCToCpp::Close() -{ - if(CEF_MEMBER_MISSING(struct_, close)) - return false; - - return struct_->close(struct_) ? true : false; -} - -bool CefXmlReaderCToCpp::HasError() -{ - if(CEF_MEMBER_MISSING(struct_, has_error)) - return false; - - return struct_->has_error(struct_) ? true : false; -} - -CefString CefXmlReaderCToCpp::GetError() -{ - CefString str; - if(CEF_MEMBER_MISSING(struct_, get_error)) - return str; - - cef_string_userfree_t strPtr = struct_->get_error(struct_); - str.AttachToUserFree(strPtr); - return str; -} - -CefXmlReader::NodeType CefXmlReaderCToCpp::GetType() -{ - if(CEF_MEMBER_MISSING(struct_, get_type)) - return XML_NODE_UNSUPPORTED; - - return struct_->get_type(struct_); -} - -int CefXmlReaderCToCpp::GetDepth() -{ - if(CEF_MEMBER_MISSING(struct_, get_depth)) - return -1; - - return struct_->get_depth(struct_); -} - -CefString CefXmlReaderCToCpp::GetLocalName() -{ - CefString str; - if(CEF_MEMBER_MISSING(struct_, get_local_name)) - return str; - - cef_string_userfree_t strPtr = struct_->get_local_name(struct_); - str.AttachToUserFree(strPtr); - return str; -} - -CefString CefXmlReaderCToCpp::GetPrefix() -{ - CefString str; - if(CEF_MEMBER_MISSING(struct_, get_prefix)) - return str; - - cef_string_userfree_t strPtr = struct_->get_prefix(struct_); - str.AttachToUserFree(strPtr); - return str; -} - -CefString CefXmlReaderCToCpp::GetQualifiedName() -{ - CefString str; - if(CEF_MEMBER_MISSING(struct_, get_qualified_name)) - return str; - - cef_string_userfree_t strPtr = struct_->get_qualified_name(struct_); - str.AttachToUserFree(strPtr); - return str; -} - -CefString CefXmlReaderCToCpp::GetNamespaceURI() -{ - CefString str; - if(CEF_MEMBER_MISSING(struct_, get_namespace_uri)) - return str; - - cef_string_userfree_t strPtr = struct_->get_namespace_uri(struct_); - str.AttachToUserFree(strPtr); - return str; -} - -CefString CefXmlReaderCToCpp::GetBaseURI() -{ - CefString str; - if(CEF_MEMBER_MISSING(struct_, get_base_uri)) - return str; - - cef_string_userfree_t strPtr = struct_->get_base_uri(struct_); - str.AttachToUserFree(strPtr); - return str; -} - -CefString CefXmlReaderCToCpp::GetXmlLang() -{ - CefString str; - if(CEF_MEMBER_MISSING(struct_, get_xml_lang)) - return str; - - cef_string_userfree_t strPtr = struct_->get_xml_lang(struct_); - str.AttachToUserFree(strPtr); - return str; -} - -bool CefXmlReaderCToCpp::IsEmptyElement() -{ - if(CEF_MEMBER_MISSING(struct_, is_empty_element)) - return false; - - return struct_->is_empty_element(struct_) ? true : false; -} - -bool CefXmlReaderCToCpp::HasValue() -{ - if(CEF_MEMBER_MISSING(struct_, has_value)) - return false; - - return struct_->has_value(struct_) ? true : false; -} - -CefString CefXmlReaderCToCpp::GetValue() -{ - CefString str; - if(CEF_MEMBER_MISSING(struct_, get_value)) - return str; - - cef_string_userfree_t strPtr = struct_->get_value(struct_); - str.AttachToUserFree(strPtr); - return str; -} - -bool CefXmlReaderCToCpp::HasAttributes() -{ - if(CEF_MEMBER_MISSING(struct_, has_attributes)) - return false; - - return struct_->has_attributes(struct_) ? true : false; -} - -size_t CefXmlReaderCToCpp::GetAttributeCount() -{ - if(CEF_MEMBER_MISSING(struct_, get_attribute_count)) - return 0; - - return struct_->get_attribute_count(struct_); -} - -CefString CefXmlReaderCToCpp::GetAttribute(int index) -{ - CefString str; - if(CEF_MEMBER_MISSING(struct_, get_attribute_byindex)) - return str; - - cef_string_userfree_t strPtr = struct_->get_attribute_byindex(struct_, index); - str.AttachToUserFree(strPtr); - return str; -} - -CefString CefXmlReaderCToCpp::GetAttribute(const CefString& qualifiedName) -{ - CefString str; - if(CEF_MEMBER_MISSING(struct_, get_attribute_byqname)) - return str; - - cef_string_userfree_t strPtr = struct_->get_attribute_byqname(struct_, - qualifiedName.GetStruct()); - str.AttachToUserFree(strPtr); - return str; -} - -CefString CefXmlReaderCToCpp::GetAttribute(const CefString& localName, - const CefString& namespaceURI) -{ - CefString str; - if(CEF_MEMBER_MISSING(struct_, get_attribute_bylname)) - return str; - - cef_string_userfree_t strPtr = struct_->get_attribute_bylname(struct_, - localName.GetStruct(), namespaceURI.GetStruct()); - str.AttachToUserFree(strPtr); - return str; -} - -CefString CefXmlReaderCToCpp::GetInnerXml() -{ - CefString str; - if(CEF_MEMBER_MISSING(struct_, get_inner_xml)) - return str; - - cef_string_userfree_t strPtr = struct_->get_inner_xml(struct_); - str.AttachToUserFree(strPtr); - return str; -} - -CefString CefXmlReaderCToCpp::GetOuterXml() -{ - CefString str; - if(CEF_MEMBER_MISSING(struct_, get_outer_xml)) - return str; - - cef_string_userfree_t strPtr = struct_->get_outer_xml(struct_); - str.AttachToUserFree(strPtr); - return str; -} - -int CefXmlReaderCToCpp::GetLineNumber() -{ - if(CEF_MEMBER_MISSING(struct_, get_line_number)) - return false; - - return struct_->get_line_number(struct_); -} - -bool CefXmlReaderCToCpp::MoveToAttribute(int index) -{ - if(CEF_MEMBER_MISSING(struct_, move_to_attribute_byindex)) - return false; - - return struct_->move_to_attribute_byindex(struct_, index) ? true : false; -} - -bool CefXmlReaderCToCpp::MoveToAttribute(const CefString& qualifiedName) -{ - if(CEF_MEMBER_MISSING(struct_, move_to_attribute_byqname)) - return false; - - return struct_->move_to_attribute_byqname(struct_, qualifiedName.GetStruct())? - true : false; -} - -bool CefXmlReaderCToCpp::MoveToAttribute(const CefString& localName, - const CefString& namespaceURI) -{ - if(CEF_MEMBER_MISSING(struct_, move_to_attribute_bylname)) - return false; - - return struct_->move_to_attribute_bylname(struct_, localName.GetStruct(), - namespaceURI.GetStruct()) ? true : false; -} - -bool CefXmlReaderCToCpp::MoveToFirstAttribute() -{ - if(CEF_MEMBER_MISSING(struct_, move_to_first_attribute)) - return false; - - return struct_->move_to_first_attribute(struct_) ? true : false; -} - -bool CefXmlReaderCToCpp::MoveToNextAttribute() -{ - if(CEF_MEMBER_MISSING(struct_, move_to_next_attribute)) - return false; - - return struct_->move_to_next_attribute(struct_) ? true : false; -} - -bool CefXmlReaderCToCpp::MoveToCarryingElement() -{ - if(CEF_MEMBER_MISSING(struct_, move_to_carrying_element)) - return false; - - return struct_->move_to_carrying_element(struct_) ? true : false; -} - - -#ifdef _DEBUG -long CefCToCpp::DebugObjCt = - 0; -#endif - +// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. +// +// --------------------------------------------------------------------------- +// +// A portion of this file was generated by the CEF translator tool. When +// making changes by hand only do so within the body of existing static and +// virtual method implementations. See the translator.README.txt file in the +// tools directory for more information. +// + +#include "libcef_dll/ctocpp/stream_reader_ctocpp.h" +#include "libcef_dll/ctocpp/xml_reader_ctocpp.h" + + +// STATIC METHODS - Body may be edited by hand. + +CefRefPtr CefXmlReader::Create(CefRefPtr stream, + EncodingType encodingType, const CefString& URI) +{ + cef_xml_reader_t* impl = cef_xml_reader_create( + CefStreamReaderCToCpp::Unwrap(stream), encodingType, URI.GetStruct()); + if(impl) + return CefXmlReaderCToCpp::Wrap(impl); + return NULL; +} + + +// VIRTUAL METHODS - Body may be edited by hand. + +bool CefXmlReaderCToCpp::MoveToNextNode() +{ + if(CEF_MEMBER_MISSING(struct_, move_to_next_node)) + return false; + + return struct_->move_to_next_node(struct_) ? true : false; +} + +bool CefXmlReaderCToCpp::Close() +{ + if(CEF_MEMBER_MISSING(struct_, close)) + return false; + + return struct_->close(struct_) ? true : false; +} + +bool CefXmlReaderCToCpp::HasError() +{ + if(CEF_MEMBER_MISSING(struct_, has_error)) + return false; + + return struct_->has_error(struct_) ? true : false; +} + +CefString CefXmlReaderCToCpp::GetError() +{ + CefString str; + if(CEF_MEMBER_MISSING(struct_, get_error)) + return str; + + cef_string_userfree_t strPtr = struct_->get_error(struct_); + str.AttachToUserFree(strPtr); + return str; +} + +CefXmlReader::NodeType CefXmlReaderCToCpp::GetType() +{ + if(CEF_MEMBER_MISSING(struct_, get_type)) + return XML_NODE_UNSUPPORTED; + + return struct_->get_type(struct_); +} + +int CefXmlReaderCToCpp::GetDepth() +{ + if(CEF_MEMBER_MISSING(struct_, get_depth)) + return -1; + + return struct_->get_depth(struct_); +} + +CefString CefXmlReaderCToCpp::GetLocalName() +{ + CefString str; + if(CEF_MEMBER_MISSING(struct_, get_local_name)) + return str; + + cef_string_userfree_t strPtr = struct_->get_local_name(struct_); + str.AttachToUserFree(strPtr); + return str; +} + +CefString CefXmlReaderCToCpp::GetPrefix() +{ + CefString str; + if(CEF_MEMBER_MISSING(struct_, get_prefix)) + return str; + + cef_string_userfree_t strPtr = struct_->get_prefix(struct_); + str.AttachToUserFree(strPtr); + return str; +} + +CefString CefXmlReaderCToCpp::GetQualifiedName() +{ + CefString str; + if(CEF_MEMBER_MISSING(struct_, get_qualified_name)) + return str; + + cef_string_userfree_t strPtr = struct_->get_qualified_name(struct_); + str.AttachToUserFree(strPtr); + return str; +} + +CefString CefXmlReaderCToCpp::GetNamespaceURI() +{ + CefString str; + if(CEF_MEMBER_MISSING(struct_, get_namespace_uri)) + return str; + + cef_string_userfree_t strPtr = struct_->get_namespace_uri(struct_); + str.AttachToUserFree(strPtr); + return str; +} + +CefString CefXmlReaderCToCpp::GetBaseURI() +{ + CefString str; + if(CEF_MEMBER_MISSING(struct_, get_base_uri)) + return str; + + cef_string_userfree_t strPtr = struct_->get_base_uri(struct_); + str.AttachToUserFree(strPtr); + return str; +} + +CefString CefXmlReaderCToCpp::GetXmlLang() +{ + CefString str; + if(CEF_MEMBER_MISSING(struct_, get_xml_lang)) + return str; + + cef_string_userfree_t strPtr = struct_->get_xml_lang(struct_); + str.AttachToUserFree(strPtr); + return str; +} + +bool CefXmlReaderCToCpp::IsEmptyElement() +{ + if(CEF_MEMBER_MISSING(struct_, is_empty_element)) + return false; + + return struct_->is_empty_element(struct_) ? true : false; +} + +bool CefXmlReaderCToCpp::HasValue() +{ + if(CEF_MEMBER_MISSING(struct_, has_value)) + return false; + + return struct_->has_value(struct_) ? true : false; +} + +CefString CefXmlReaderCToCpp::GetValue() +{ + CefString str; + if(CEF_MEMBER_MISSING(struct_, get_value)) + return str; + + cef_string_userfree_t strPtr = struct_->get_value(struct_); + str.AttachToUserFree(strPtr); + return str; +} + +bool CefXmlReaderCToCpp::HasAttributes() +{ + if(CEF_MEMBER_MISSING(struct_, has_attributes)) + return false; + + return struct_->has_attributes(struct_) ? true : false; +} + +size_t CefXmlReaderCToCpp::GetAttributeCount() +{ + if(CEF_MEMBER_MISSING(struct_, get_attribute_count)) + return 0; + + return struct_->get_attribute_count(struct_); +} + +CefString CefXmlReaderCToCpp::GetAttribute(int index) +{ + CefString str; + if(CEF_MEMBER_MISSING(struct_, get_attribute_byindex)) + return str; + + cef_string_userfree_t strPtr = struct_->get_attribute_byindex(struct_, index); + str.AttachToUserFree(strPtr); + return str; +} + +CefString CefXmlReaderCToCpp::GetAttribute(const CefString& qualifiedName) +{ + CefString str; + if(CEF_MEMBER_MISSING(struct_, get_attribute_byqname)) + return str; + + cef_string_userfree_t strPtr = struct_->get_attribute_byqname(struct_, + qualifiedName.GetStruct()); + str.AttachToUserFree(strPtr); + return str; +} + +CefString CefXmlReaderCToCpp::GetAttribute(const CefString& localName, + const CefString& namespaceURI) +{ + CefString str; + if(CEF_MEMBER_MISSING(struct_, get_attribute_bylname)) + return str; + + cef_string_userfree_t strPtr = struct_->get_attribute_bylname(struct_, + localName.GetStruct(), namespaceURI.GetStruct()); + str.AttachToUserFree(strPtr); + return str; +} + +CefString CefXmlReaderCToCpp::GetInnerXml() +{ + CefString str; + if(CEF_MEMBER_MISSING(struct_, get_inner_xml)) + return str; + + cef_string_userfree_t strPtr = struct_->get_inner_xml(struct_); + str.AttachToUserFree(strPtr); + return str; +} + +CefString CefXmlReaderCToCpp::GetOuterXml() +{ + CefString str; + if(CEF_MEMBER_MISSING(struct_, get_outer_xml)) + return str; + + cef_string_userfree_t strPtr = struct_->get_outer_xml(struct_); + str.AttachToUserFree(strPtr); + return str; +} + +int CefXmlReaderCToCpp::GetLineNumber() +{ + if(CEF_MEMBER_MISSING(struct_, get_line_number)) + return false; + + return struct_->get_line_number(struct_); +} + +bool CefXmlReaderCToCpp::MoveToAttribute(int index) +{ + if(CEF_MEMBER_MISSING(struct_, move_to_attribute_byindex)) + return false; + + return struct_->move_to_attribute_byindex(struct_, index) ? true : false; +} + +bool CefXmlReaderCToCpp::MoveToAttribute(const CefString& qualifiedName) +{ + if(CEF_MEMBER_MISSING(struct_, move_to_attribute_byqname)) + return false; + + return struct_->move_to_attribute_byqname(struct_, qualifiedName.GetStruct())? + true : false; +} + +bool CefXmlReaderCToCpp::MoveToAttribute(const CefString& localName, + const CefString& namespaceURI) +{ + if(CEF_MEMBER_MISSING(struct_, move_to_attribute_bylname)) + return false; + + return struct_->move_to_attribute_bylname(struct_, localName.GetStruct(), + namespaceURI.GetStruct()) ? true : false; +} + +bool CefXmlReaderCToCpp::MoveToFirstAttribute() +{ + if(CEF_MEMBER_MISSING(struct_, move_to_first_attribute)) + return false; + + return struct_->move_to_first_attribute(struct_) ? true : false; +} + +bool CefXmlReaderCToCpp::MoveToNextAttribute() +{ + if(CEF_MEMBER_MISSING(struct_, move_to_next_attribute)) + return false; + + return struct_->move_to_next_attribute(struct_) ? true : false; +} + +bool CefXmlReaderCToCpp::MoveToCarryingElement() +{ + if(CEF_MEMBER_MISSING(struct_, move_to_carrying_element)) + return false; + + return struct_->move_to_carrying_element(struct_) ? true : false; +} + + +#ifdef _DEBUG +long CefCToCpp::DebugObjCt = + 0; +#endif + diff --git a/libcef_dll/ctocpp/xml_reader_ctocpp.h b/libcef_dll/ctocpp/xml_reader_ctocpp.h index 4d4050c57..b9db7eef6 100644 --- a/libcef_dll/ctocpp/xml_reader_ctocpp.h +++ b/libcef_dll/ctocpp/xml_reader_ctocpp.h @@ -1,69 +1,69 @@ -// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights -// reserved. Use of this source code is governed by a BSD-style license that -// can be found in the LICENSE file. -// -// ------------------------------------------------------------------------- -// -// This file was generated by the CEF translator tool and should not edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#ifndef _XMLREADER_CTOCPP_H -#define _XMLREADER_CTOCPP_H - -#ifndef USING_CEF_SHARED -#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") -#else // USING_CEF_SHARED - -#include "include/cef.h" -#include "include/cef_capi.h" -#include "libcef_dll/ctocpp/ctocpp.h" - -// Wrap a C structure with a C++ class. -// This class may be instantiated and accessed wrapper-side only. -class CefXmlReaderCToCpp - : public CefCToCpp -{ -public: - CefXmlReaderCToCpp(cef_xml_reader_t* str) - : CefCToCpp(str) {} - virtual ~CefXmlReaderCToCpp() {} - - // CefXmlReader methods - virtual bool MoveToNextNode(); - virtual bool Close(); - virtual bool HasError(); - virtual CefString GetError(); - virtual NodeType GetType(); - virtual int GetDepth(); - virtual CefString GetLocalName(); - virtual CefString GetPrefix(); - virtual CefString GetQualifiedName(); - virtual CefString GetNamespaceURI(); - virtual CefString GetBaseURI(); - virtual CefString GetXmlLang(); - virtual bool IsEmptyElement(); - virtual bool HasValue(); - virtual CefString GetValue(); - virtual bool HasAttributes(); - virtual size_t GetAttributeCount(); - virtual CefString GetAttribute(int index); - virtual CefString GetAttribute(const CefString& qualifiedName); - virtual CefString GetAttribute(const CefString& localName, - const CefString& namespaceURI); - virtual CefString GetInnerXml(); - virtual CefString GetOuterXml(); - virtual int GetLineNumber(); - virtual bool MoveToAttribute(int index); - virtual bool MoveToAttribute(const CefString& qualifiedName); - virtual bool MoveToAttribute(const CefString& localName, - const CefString& namespaceURI); - virtual bool MoveToFirstAttribute(); - virtual bool MoveToNextAttribute(); - virtual bool MoveToCarryingElement(); -}; - -#endif // USING_CEF_SHARED -#endif // _XMLREADER_CTOCPP_H - +// Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. +// +// ------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef _XMLREADER_CTOCPP_H +#define _XMLREADER_CTOCPP_H + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef.h" +#include "include/cef_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefXmlReaderCToCpp + : public CefCToCpp +{ +public: + CefXmlReaderCToCpp(cef_xml_reader_t* str) + : CefCToCpp(str) {} + virtual ~CefXmlReaderCToCpp() {} + + // CefXmlReader methods + virtual bool MoveToNextNode(); + virtual bool Close(); + virtual bool HasError(); + virtual CefString GetError(); + virtual NodeType GetType(); + virtual int GetDepth(); + virtual CefString GetLocalName(); + virtual CefString GetPrefix(); + virtual CefString GetQualifiedName(); + virtual CefString GetNamespaceURI(); + virtual CefString GetBaseURI(); + virtual CefString GetXmlLang(); + virtual bool IsEmptyElement(); + virtual bool HasValue(); + virtual CefString GetValue(); + virtual bool HasAttributes(); + virtual size_t GetAttributeCount(); + virtual CefString GetAttribute(int index); + virtual CefString GetAttribute(const CefString& qualifiedName); + virtual CefString GetAttribute(const CefString& localName, + const CefString& namespaceURI); + virtual CefString GetInnerXml(); + virtual CefString GetOuterXml(); + virtual int GetLineNumber(); + virtual bool MoveToAttribute(int index); + virtual bool MoveToAttribute(const CefString& qualifiedName); + virtual bool MoveToAttribute(const CefString& localName, + const CefString& namespaceURI); + virtual bool MoveToFirstAttribute(); + virtual bool MoveToNextAttribute(); + virtual bool MoveToCarryingElement(); +}; + +#endif // USING_CEF_SHARED +#endif // _XMLREADER_CTOCPP_H + diff --git a/tests/cefclient/cefclient_mac.mm b/tests/cefclient/cefclient_mac.mm index bf3ab8eee..da370d964 100644 --- a/tests/cefclient/cefclient_mac.mm +++ b/tests/cefclient/cefclient_mac.mm @@ -95,7 +95,6 @@ const int kWindowHeight = 600; ss << "Console messages will be written to " << g_handler->GetLogFile(); NSString* str = [NSString stringWithUTF8String:(ss.str().c_str())]; [self alert:@"Console Messages" withMessage:str]; - [str release]; } - (void)notifyDownloadComplete:(id)object { @@ -104,7 +103,6 @@ const int kWindowHeight = 600; "\" downloaded successfully."; NSString* str = [NSString stringWithUTF8String:(ss.str().c_str())]; [self alert:@"File Download" withMessage:str]; - [str release]; } - (void)notifyDownloadError:(id)object { @@ -113,7 +111,6 @@ const int kWindowHeight = 600; "\" failed to download."; NSString* str = [NSString stringWithUTF8String:(ss.str().c_str())]; [self alert:@"File Download" withMessage:str]; - [str release]; } - (void)windowDidBecomeKey:(NSNotification*)notification { @@ -236,7 +233,7 @@ NSButton* MakeButton(NSRect* rect, NSString* title, NSView* parent) { // Create the buttons. NSRect button_rect = [[mainWnd contentView] bounds]; button_rect.origin.y = window_rect.size.height - URLBAR_HEIGHT + - (URLBAR_HEIGHT - BUTTON_HEIGHT) / 2; + (URLBAR_HEIGHT - BUTTON_HEIGHT) / 2; button_rect.size.height = BUTTON_HEIGHT; button_rect.origin.x += BUTTON_MARGIN; button_rect.size.width = BUTTON_WIDTH; @@ -281,7 +278,7 @@ NSButton* MakeButton(NSRect* rect, NSString* title, NSView* parent) { window_info.SetAsChild((void*)[mainWnd contentView], 0, 0, kWindowWidth, kWindowHeight); CefBrowser::CreateBrowser(window_info, false, g_handler.get(), - L"http://www.google.com"); + "http://www.google.com"); // Show the window. [mainWnd makeKeyAndOrderFront: nil]; @@ -378,10 +375,9 @@ CefHandler::RetVal ClientHandler::HandleAddressChange( { // Set the edit window text NSTextField* textField = (NSTextField*)m_EditHwnd; - NSString* str = - [NSString stringWithUTF8String:(std::string(url).c_str())]; + std::string urlStr(url); + NSString* str = [NSString stringWithUTF8String:urlStr.c_str()]; [textField setStringValue:str]; - [str release]; } return RV_CONTINUE; } @@ -391,10 +387,9 @@ CefHandler::RetVal ClientHandler::HandleTitleChange( { // Set the frame window title bar NSWindow* window = (NSWindow*)m_MainHwnd; - NSString* str = - [NSString stringWithUTF8String:(std::string(title).c_str())]; + std::string titleStr(title); + NSString* str = [NSString stringWithUTF8String:titleStr.c_str()]; [window setTitle:str]; - [str release]; return RV_CONTINUE; } diff --git a/tests/cefclient/res/localstorage.html b/tests/cefclient/res/localstorage.html index 913d3ed9d..a794305b7 100644 --- a/tests/cefclient/res/localstorage.html +++ b/tests/cefclient/res/localstorage.html @@ -1,24 +1,24 @@ - - - -Click the "Add Line" button to add a line or the "Clear" button to clear.
-This data will persist across sessions if a cache path was specified.
- - -
- - - + + + +Click the "Add Line" button to add a line or the "Clear" button to clear.
+This data will persist across sessions if a cache path was specified.
+ + +
+ + + diff --git a/tests/unittests/string_unittest.cc b/tests/unittests/string_unittest.cc index 9e67b1fe9..f5bb11101 100644 --- a/tests/unittests/string_unittest.cc +++ b/tests/unittests/string_unittest.cc @@ -13,7 +13,7 @@ TEST(StringTest, UTF8) { CefStringUTF8 str1("Test String"); - ASSERT_EQ(str1.length(), 11); + ASSERT_EQ(str1.length(), (size_t)11); ASSERT_FALSE(str1.empty()); ASSERT_TRUE(str1.IsOwner()); @@ -52,7 +52,7 @@ TEST(StringTest, UTF8) TEST(StringTest, UTF16) { CefStringUTF16 str1("Test String"); - ASSERT_EQ(str1.length(), 11); + ASSERT_EQ(str1.length(), (size_t)11); ASSERT_FALSE(str1.empty()); ASSERT_TRUE(str1.IsOwner()); @@ -91,7 +91,7 @@ TEST(StringTest, UTF16) TEST(StringTest, Wide) { CefStringWide str1("Test String"); - ASSERT_EQ(str1.length(), 11); + ASSERT_EQ(str1.length(), (size_t)11); ASSERT_FALSE(str1.empty()); ASSERT_TRUE(str1.IsOwner());