michael@0: /* michael@0: * Copyright (c) 2008 Mozilla Foundation michael@0: * michael@0: * Permission is hereby granted, free of charge, to any person obtaining a michael@0: * copy of this software and associated documentation files (the "Software"), michael@0: * to deal in the Software without restriction, including without limitation michael@0: * the rights to use, copy, modify, merge, publish, distribute, sublicense, michael@0: * and/or sell copies of the Software, and to permit persons to whom the michael@0: * Software is furnished to do so, subject to the following conditions: michael@0: * michael@0: * The above copyright notice and this permission notice shall be included in michael@0: * all copies or substantial portions of the Software. michael@0: * michael@0: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR michael@0: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, michael@0: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL michael@0: * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER michael@0: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING michael@0: * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER michael@0: * DEALINGS IN THE SOFTWARE. michael@0: */ michael@0: michael@0: #ifndef nsHtml5ArrayCopy_h michael@0: #define nsHtml5ArrayCopy_h michael@0: michael@0: michael@0: class nsString; michael@0: class nsHtml5StackNode; michael@0: class nsHtml5AttributeName; michael@0: michael@0: // Unfortunately, these don't work as template functions because the arguments michael@0: // would need coercion from a template class, which complicates things. michael@0: class nsHtml5ArrayCopy { michael@0: public: michael@0: michael@0: static inline void michael@0: arraycopy(char16_t* source, int32_t sourceOffset, char16_t* target, int32_t targetOffset, int32_t length) michael@0: { michael@0: memcpy(&(target[targetOffset]), &(source[sourceOffset]), length * sizeof(char16_t)); michael@0: } michael@0: michael@0: static inline void michael@0: arraycopy(char16_t* source, char16_t* target, int32_t length) michael@0: { michael@0: memcpy(target, source, length * sizeof(char16_t)); michael@0: } michael@0: michael@0: static inline void michael@0: arraycopy(int32_t* source, int32_t* target, int32_t length) michael@0: { michael@0: memcpy(target, source, length * sizeof(int32_t)); michael@0: } michael@0: michael@0: static inline void michael@0: arraycopy(nsString** source, nsString** target, int32_t length) michael@0: { michael@0: memcpy(target, source, length * sizeof(nsString*)); michael@0: } michael@0: michael@0: static inline void michael@0: arraycopy(nsHtml5AttributeName** source, nsHtml5AttributeName** target, int32_t length) michael@0: { michael@0: memcpy(target, source, length * sizeof(nsHtml5AttributeName*)); michael@0: } michael@0: michael@0: static inline void michael@0: arraycopy(nsHtml5StackNode** source, nsHtml5StackNode** target, int32_t length) michael@0: { michael@0: memcpy(target, source, length * sizeof(nsHtml5StackNode*)); michael@0: } michael@0: michael@0: static inline void michael@0: arraycopy(nsHtml5StackNode** arr, int32_t sourceOffset, int32_t targetOffset, int32_t length) michael@0: { michael@0: memmove(&(arr[targetOffset]), &(arr[sourceOffset]), length * sizeof(nsHtml5StackNode*)); michael@0: } michael@0: }; michael@0: #endif // nsHtml5ArrayCopy_h