/* * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. *
*/
// // The Encoding policy prescribes a template // method taking a first parameter of type T. // This is the value to be encoded. The second // parameter is a memory address - where to write // the encoded value. // The encoder method(s) should return the // number of bytes encoded into that memory address. // // template <typename T> // size_t encoder(T value, u1* dest); // // The caller ensures the destination // address is not null and that T can be fitted // in encoded form. //
if (LESS_THAN_128(v)) {
*dest = static_cast<u1>(v); // set bit 0-6, no extension return 1;
}
*dest = static_cast<u1>(v | ext_bit); // set bit 0-6, with extension if (LESS_THAN_128(v >> 7)) {
*(dest + 1) = static_cast<u1>(v >> 7); // set bit 7-13, no extension return 2;
}
*(dest + 1) = static_cast<u1>((v >> 7) | ext_bit); // set bit 7-13, with extension if (LESS_THAN_128(v >> 14)) {
*(dest + 2) = static_cast<u1>(v >> 14); // set bit 14-20, no extension return 3;
}
*(dest + 2) = static_cast<u1>((v >> 14) | ext_bit); // set bit 14-20, with extension if (LESS_THAN_128(v >> 21)) {
*(dest + 3) = static_cast<u1>(v >> 21); // set bit 21-27, no extension return 4;
}
*(dest + 3) = static_cast<u1>((v >> 21) | ext_bit); // set bit 21-27, with extension if (LESS_THAN_128(v >> 28)) {
*(dest + 4) = static_cast<u1>(v >> 28); // set bit 28-34, no extension return 5;
}
*(dest + 4) = static_cast<u1>((v >> 28) | ext_bit); // set bit 28-34, with extension if (LESS_THAN_128(v >> 35)) {
*(dest + 5) = static_cast<u1>(v >> 35); // set bit 35-41, no extension return 6;
}
*(dest + 5) = static_cast<u1>((v >> 35) | ext_bit); // set bit 35-41, with extension if (LESS_THAN_128(v >> 42)) {
*(dest + 6) = static_cast<u1>(v >> 42); // set bit 42-48, no extension return 7;
}
*(dest + 6) = static_cast<u1>((v >> 42) | ext_bit); // set bit 42-48, with extension if (LESS_THAN_128(v >> 49)) {
*(dest + 7) = static_cast<u1>(v >> 49); // set bit 49-55, no extension return 8;
}
*(dest + 7) = static_cast<u1>((v >> 49) | ext_bit); // set bit 49-55, with extension // no need to extend since only 64 bits allowed.
*(dest + 8) = static_cast<u1>(v >> 56); // set bit 56-63 return 9;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.