1ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// Protocol Buffers - Google's data interchange format 2ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// Copyright 2008 Google Inc. All rights reserved. 3ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// http://code.google.com/p/protobuf/ 4ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// 5ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// Redistribution and use in source and binary forms, with or without 6ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// modification, are permitted provided that the following conditions are 7ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// met: 8ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// 9ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// * Redistributions of source code must retain the above copyright 10ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// notice, this list of conditions and the following disclaimer. 11ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// * Redistributions in binary form must reproduce the above 12ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// copyright notice, this list of conditions and the following disclaimer 13ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// in the documentation and/or other materials provided with the 14ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// distribution. 15ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// * Neither the name of Google Inc. nor the names of its 16ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// contributors may be used to endorse or promote products derived from 17ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// this software without specific prior written permission. 18ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// 19ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville 31d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville// Author: jasonh@google.com (Jason Hsueh) 32ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// 33d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville// Implements methods of coded_stream.h that need to be inlined for performance 34d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville// reasons, but should not be defined in a public header. 35ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville 36d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville#ifndef GOOGLE_PROTOBUF_IO_CODED_STREAM_INL_H__ 37d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville#define GOOGLE_PROTOBUF_IO_CODED_STREAM_INL_H__ 38ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville 39d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville#include <google/protobuf/io/coded_stream.h> 40d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville#include <string> 41d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville#include <google/protobuf/stubs/stl_util-inl.h> 42ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville 43d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Savillenamespace google { 44d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Savillenamespace protobuf { 45d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Savillenamespace io { 46d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville 47d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Savilleinline bool CodedInputStream::InternalReadStringInline(string* buffer, 48d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville int size) { 49d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville if (size < 0) return false; // security: size is often user-supplied 50ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville 51d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville if (BufferSize() >= size) { 52d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville STLStringResizeUninitialized(buffer, size); 53d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville memcpy(string_as_array(buffer), buffer_, size); 54d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville Advance(size); 55d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville return true; 56ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville } 57ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville 58d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville return ReadStringFallback(buffer, size); 59ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville} 60d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville 61d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville} // namespace io 62d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville} // namespace protobuf 63d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville} // namespace google 64d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville#endif // GOOGLE_PROTOBUF_IO_CODED_STREAM_INL_H__ 65