OsmAnd
jni/protobuf/google/protobuf/io/coded_stream_inl.h
Go to the documentation of this file.
00001 // Protocol Buffers - Google's data interchange format
00002 // Copyright 2008 Google Inc.  All rights reserved.
00003 // http://code.google.com/p/protobuf/
00004 //
00005 // Redistribution and use in source and binary forms, with or without
00006 // modification, are permitted provided that the following conditions are
00007 // met:
00008 //
00009 //     * Redistributions of source code must retain the above copyright
00010 // notice, this list of conditions and the following disclaimer.
00011 //     * Redistributions in binary form must reproduce the above
00012 // copyright notice, this list of conditions and the following disclaimer
00013 // in the documentation and/or other materials provided with the
00014 // distribution.
00015 //     * Neither the name of Google Inc. nor the names of its
00016 // contributors may be used to endorse or promote products derived from
00017 // this software without specific prior written permission.
00018 //
00019 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00020 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00021 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00022 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00023 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00024 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00025 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00026 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00027 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00028 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00029 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00030 
00031 // Author: jasonh@google.com (Jason Hsueh)
00032 //
00033 // Implements methods of coded_stream.h that need to be inlined for performance
00034 // reasons, but should not be defined in a public header.
00035 
00036 #ifndef GOOGLE_PROTOBUF_IO_CODED_STREAM_INL_H__
00037 #define GOOGLE_PROTOBUF_IO_CODED_STREAM_INL_H__
00038 
00039 #include <google/protobuf/io/coded_stream.h>
00040 #include <string>
00041 #include <google/protobuf/stubs/stl_util-inl.h>
00042 
00043 namespace google {
00044 namespace protobuf {
00045 namespace io {
00046 
00047 inline bool CodedInputStream::InternalReadStringInline(string* buffer,
00048                                                        int size) {
00049   if (size < 0) return false;  // security: size is often user-supplied
00050 
00051   if (BufferSize() >= size) {
00052     STLStringResizeUninitialized(buffer, size);
00053     memcpy(string_as_array(buffer), buffer_, size);
00054     Advance(size);
00055     return true;
00056   }
00057 
00058   return ReadStringFallback(buffer, size);
00059 }
00060 
00061 }  // namespace io
00062 }  // namespace protobuf
00063 }  // namespace google
00064 #endif  // GOOGLE_PROTOBUF_IO_CODED_STREAM_INL_H__
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines