Home | History | Annotate | Download | only in base
      1 // Copyright 2014 The Android Open Source Project
      2 //
      3 // This software is licensed under the terms of the GNU General Public
      4 // License version 2, as published by the Free Software Foundation, and
      5 // may be copied, distributed, and modified under those terms.
      6 //
      7 // This program is distributed in the hope that it will be useful,
      8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
      9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     10 // GNU General Public License for more details.
     11 
     12 #ifndef ANDROID_BASE_STRING_FORMAT_H
     13 #define ANDROID_BASE_STRING_FORMAT_H
     14 
     15 #include "android/base/String.h"
     16 
     17 #include <stdarg.h>
     18 
     19 namespace android {
     20 namespace base {
     21 
     22 // Create a new String instance that contains the printf-style formatted
     23 // output from |format| and potentially any following arguments.
     24 String StringFormat(const char* format, ...);
     25 
     26 // A variant of StringFormat() which uses a va_list to list formatting
     27 // parameters instead.
     28 String StringFormatWithArgs(const char* format, va_list args);
     29 
     30 // Appends a formatted string at the end of an existing string.
     31 // |string| is the target String instance, |format| the format string,
     32 // followed by any formatting parameters. This is more efficient than
     33 // appending the result of StringFormat(format,...) to |*string| directly.
     34 void StringAppendFormat(String* string, const char* format, ...);
     35 
     36 // A variant of StringAppendFormat() that takes a va_list to list
     37 // formatting parameters.
     38 void StringAppendFormatWithArgs(String* string,
     39                                 const char* format,
     40                                 va_list args);
     41 
     42 }  // namespace base
     43 }  // namespace android
     44 
     45 #endif  // ANDROID_BASE_STRING_FORMAT_H
     46