StringAppender.h

Go to the documentation of this file.
00001 /*
00002  *    Copyright 2004-2006 Intel Corporation
00003  * 
00004  *    Licensed under the Apache License, Version 2.0 (the "License");
00005  *    you may not use this file except in compliance with the License.
00006  *    You may obtain a copy of the License at
00007  * 
00008  *        http://www.apache.org/licenses/LICENSE-2.0
00009  * 
00010  *    Unless required by applicable law or agreed to in writing, software
00011  *    distributed under the License is distributed on an "AS IS" BASIS,
00012  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  *    See the License for the specific language governing permissions and
00014  *    limitations under the License.
00015  */
00016 
00017 
00018 
00019 #ifndef _OASYS_STRING_APPENDER_H_
00020 #define _OASYS_STRING_APPENDER_H_
00021 
00022 #include "../debug/Log.h" // for PRINTFLIKE macro
00023 
00024 namespace oasys {
00025 
00032 class StringAppender {
00033 public:
00038     StringAppender(char* buf, size_t size);
00039 
00047     size_t append(const char* str, size_t len = 0);
00048 
00055     size_t append(const std::string& str)
00056     {
00057         return append(str.data(), str.length());
00058     }
00059 
00066     size_t append(char c);
00067 
00074     size_t appendf(const char* fmt, ...) PRINTFLIKE(2, 3);
00075 
00083     size_t vappendf(const char* fmt, va_list ap);
00084 
00088     size_t length() { return len_; }
00089 
00094     size_t desired_length() { return desired_; }
00095     
00096 private:
00097     char*  cur_;
00098     size_t remaining_;
00099     size_t len_;
00100     size_t desired_;
00101 };
00102 
00103 } // namespace oasys
00104 
00105 #endif // OASYS_STRING_APPENDER

Generated on Sat Sep 8 08:36:18 2007 for DTN Reference Implementation by  doxygen 1.5.3