#include <memory.h>
#include <string>
+
+#include "include/base/cef_string16.h"
#include "include/internal/cef_string_types.h"
-#ifdef BUILDING_CEF_SHARED
-#include "base/strings/string16.h"
+#if defined(USING_CHROMIUM_INCLUDES)
+#include "base/files/file_path.h"
#endif
-
///
// Traits implementation for wide character strings.
///
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 base::string16 to_string16(const struct_type *s) {
cef_string_utf16_t cstr;
true : false;
}
#endif // WCHAR_T_IS_UTF32
-#endif // BUILDING_CEF_SHARED
};
///
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 base::string16 to_string16(const struct_type* s) {
cef_string_utf16_t cstr;
memset(&cstr, 0, sizeof(cstr));
return cef_string_utf16_to_utf8(str.c_str(), str.length(), s) ?
true : false;
}
-#endif // BUILDING_CEF_SHARED
};
///
true : false;
}
#endif // WCHAR_T_IS_UTF32
-#if defined(BUILDING_CEF_SHARED)
static inline base::string16 to_string16(const struct_type* s) {
return base::string16(s->str, s->length);
}
return cef_string_utf16_set(str.c_str(), str.length(), s, true) ?
true : false;
}
-#endif // BUILDING_CEF_SHARED
};
///
FromWString(std::wstring(src));
}
-#if (defined(BUILDING_CEF_SHARED) && defined(WCHAR_T_IS_UTF32))
+#if 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
if (src)
FromString16(base::string16(src));
}
-#endif // BUILDING_CEF_SHARED && WCHAR_T_IS_UTF32
+#endif // WCHAR_T_IS_UTF32
///
// Create a new string from an existing character array. If |copy| is 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.
AllocIfNeeded();
return traits::from_string16(str, string_);
}
-#endif // BUILDING_CEF_SHARED
///
// Comparison operator overloads.
FromWString(std::wstring(str));
return *this;
}
-#if (defined(BUILDING_CEF_SHARED) && defined(WCHAR_T_IS_UTF32))
+#if defined(WCHAR_T_IS_UTF32)
operator base::string16() const {
return ToString16();
}
FromString16(base::string16(str));
return *this;
}
-#endif // BUILDING_CEF_SHARED && WCHAR_T_IS_UTF32
+#endif // WCHAR_T_IS_UTF32
+#if defined(USING_CHROMIUM_INCLUDES)
+ // The base::FilePath constructor is marked as explicit so provide the
+ // conversion here for convenience.
+ operator base::FilePath() const {
+#if defined(OS_WIN)
+ return base::FilePath(ToWString());
+#else
+ return base::FilePath(ToString());
+#endif
+ }
+#endif // USING_CHROMIUM_INCLUDES
private:
// Allocate the string structure if it doesn't already exist.