第一章 00 StringUtil.cpp和StringUtil.hh分析

 1 /*
 2  * StringUtil.hh
 3  *
 4  * Copyright 2002, Log4cpp Project. All rights reserved.
 5  *
 6  * See the COPYING file for the terms of usage and distribution.
 7  */
 8 頭文件的說明,以及與版權相關的說明一般都會放置在文件的開始位置


9 #ifndef _LOG4CPP_STRINGUTIL_HH //為了防止代碼被多重包含 10 #define _LOG4CPP_STRINGUTIL_HH 11 12 #include "PortabilityImpl.hh" 13 #include <string> 14 #include <vector> 15 #include <climits> 16 #include <stdarg.h> 17 18 namespace log4cpp { 19 20 class StringUtil { 21 public: 22 23 /** 24 Returns a string contructed from the a format specifier 25 and a va_list of arguments, analogously to vprintf(3). 26 @param format the format specifier. 27 @param args the va_list of arguments. 28 **/ 29 static std::string vform(const char* format, va_list args); 30 31 /** 32 Returns a string identical to the given string but without leading 33 or trailing HTABs or spaces. 34 **/ 35 static std::string trim(const std::string& s); 36 37 /** 38 splits a string into a vector of string segments based on the 39 given delimiter. 40 @param v The vector in which the segments will be stored. The vector 41 will be emptied before storing the segments 42 @param s The string to split into segments. 43 @param delimiter The delimiter character 44 @param maxSegments the maximum number of segments. Upon return 45 v.size() <= maxSegments. The string is scanned from left to right 46 so v[maxSegments - 1] may contain a string containing the delimiter 47 character. 48 @return The actual number of segments (limited by maxSegments). 49 **/ 50 static unsigned int split(std::vector<std::string>& v, 51 const std::string& s, char delimiter, 52 unsigned int maxSegments = INT_MAX); 53 /** 54 splits a string into string segments based on the given delimiter 55 and assigns the segments through an output_iterator. 56 @param output The output_iterator through which to assign the string 57 segments. Typically this will be a back_insertion_iterator. 58 @param s The string to split into segments. 59 @param delimiter The delimiter character 60 @param maxSegments The maximum number of segments. 61 @return The actual number of segments (limited by maxSegments). 62 **/ 63 template<typename T> static unsigned int split(T& output, 64 const std::string& s, char delimiter, 65 unsigned int maxSegments = INT_MAX) { 66 std::string::size_type left = 0; 67 unsigned int i; 68 for(i = 1; i < maxSegments; i++) { 69 std::string::size_type right = s.find(delimiter, left); 70 if (right == std::string::npos) { 71 break; 72 } 73 *output++ = s.substr(left, right - left); 74 left = right + 1; 75 } 76 77 *output++ = s.substr(left); 78 return i; 79 } 80 }; 81 } 82 83 #endif // _LOG4CPP_STRINGUTIL_HH


一、關于#include的話題
#include <iostream>
#include <iostream.h>
兩行代碼有什么區別呢
 1 #include <iostream.h>
 2 
 3 using namespace std;
 4 
 5 int main(int argc,char**argv)
 6 {
 7    cout<<"hi guys"<<endl;
 8         
 9   return 0;   
10 }
 
編譯器會發出報警哦:


看來是C++標準的問題,新的代碼逐漸不再支持<X.h>的包含方式,但是該警告信息可以在編譯器中用-Wno-deprecated選項關閉的。deprecated這里的意思是“過時了”

至于是否在頭文件中要用include包含頭文件,這個可以開新的話題了,留待以后補上吧。。。。。
嗯哼。。。LINE16還沒解釋,為毛????
stdarg.h是C語言中C標準函數庫的頭文件,stdarg是由standard(標準) arguments(參數)簡化而來,主要目的為讓函數能夠接收可變參數。
C++的cstdarg頭文件中也提供這樣的功能;雖然與C的頭文件是兼容的,但是也有沖突存在。

這里引出了兩個標準函數庫:C標準函數庫和C++標準函數庫。額,這也是兩個巨大的Topics,還是度娘吧。。。。。由于這里引用了C標準函數庫的頭文件,
So,用了#include <stdargs.h>的寫法。至于。。。至于哪個頭文件屬于C++標準函數庫,哪個屬于C標準函數庫呢,Windows平臺的IDE開發環境發揮了積極的優勢。
See See吧,

自動補齊功能,提示的是.h文件哦。。。。


這個是沒有.h的。
好了,不要在這個話題上糾結了。Go on .......睡覺鳥。。。。。


























?

轉載于:https://www.cnblogs.com/lopnor/p/4133983.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/375462.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/375462.shtml
英文地址,請注明出處:http://en.pswp.cn/news/375462.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

【SQL】服務器環境下的SQL

一、大型數據庫的三層體系結構 web服務器&#xff1a;比如在淘寶頁面上&#xff0c;輸入“牛肉干”&#xff0c;就是web服務器來處理&#xff0c;提交給應用服務器。 應用服務器&#xff1a;在獲取到“牛肉干”這個請求后&#xff0c;應用服務器決定如何匯集結果&#xff0c;并…

【置頂】全局變量的好處與壞處

近日在做項目的過程中對plsql的使用非常多&#xff0c;主要是編寫存儲過程實現業務邏輯。但是在coding的過程中遇到非常奇怪的問題。 問題是&#xff1a;在package包頭中定義了一個變量&#xff0c;current_time : sysdate,然后在procedure使用這個定義的變量&#xff0c;直接i…

三個線程按順序輸出數字

當 n 3N 時&#xff0c;線程1輸出 當 n 3N 1 時&#xff0c;線程2輸出 當 n 3N 2 時&#xff0c;線程3輸出 最終的輸出為 0、1、2、3、4、5、6、7、8、10 #include <iostream> #include <thread> #include <mutex> #include <condition_variable&g…

TextView實現自動滾動滾動.

必須有要四個屬性: android:ellipsize"marquee"; android:focusable"true";android"focusableInTouchMode"true";android:singleLine"true"; <TextViewandroid:layout_width"fill_parent"android:layout_height&quo…

用最少數量的箭引爆氣球

在二維空間中有許多球形的氣球。對于每個氣球&#xff0c;提供的輸入是水平方向上&#xff0c;氣球直徑的開始和結束坐標。由于它是水平的&#xff0c;所以y坐標并不重要&#xff0c;因此只要知道開始和結束的x坐標就足夠了。開始坐標總是小于結束坐標。平面內最多存在104個氣球…

ExtJS中使用ztree 不顯示樹的解決辦法

最近部門同事碰到一個問題&#xff0c;將ztree嵌入在套了幾層Panel的面板中不會正常顯示&#xff0c;但是將上層面板換成window就能正常顯示&#xff0c;開始以為是所在的外部容器不管嵌套了幾層&#xff0c;但是必須最底層是window容器&#xff0c;但是測試后發現不是這樣的&a…

尋找小鎮的法官

在一個小鎮里&#xff0c;按從 1 到 N 標記了 N 個人。傳言稱&#xff0c;這些人中有一個是小鎮上的秘密法官。 如果小鎮的法官真的存在&#xff0c;那么&#xff1a; 小鎮的法官不相信任何人。 每個人&#xff08;除了小鎮法官外&#xff09;都信任小鎮的法官。 只有一個人同…

事務的隔離界別

事務的ACID特性&#xff1a; 1、Atomicity原子性 事務操作的不可分割性&#xff0c;要么全部執行&#xff0c;要么回滾。 2、Consistency一致性 數據庫在事務處理前后處于的一致性狀態。如銀行轉賬&#xff0c;兩個賬戶轉賬前的狀態和轉賬后的狀態必須一致。 3、Isolation隔離…

程序員福利各大平臺免費接口非常適用

電商接口 京東獲取單個商品價格接口: http://p.3.cn/prices/mgets?skuIdsJ_商品ID&type1 ps:商品ID這么獲取:http://item.jd.com/954086.html 物流接口 快遞接口: http://www.kuaidi100.com/query?type快遞公司代號&postid快遞單號 ps:快遞公司編碼:申通”shentong”…

WriteN, RTMP send error

WriteN, RTMP send error 32 (133 bytes) WriteN, RTMP send error 32 (49 bytes) WriteN, RTMP send error 9 (42 bytes)現象&#xff1a; 推流失敗&#xff0c;srs服務出錯。 原因 視頻流較慢&#xff0c;音頻流較快。 復現 視頻解碼得到幀數據&#xff0c;用異步接口處…

樣式公用代碼

/************** bug ************/.clearfix:after {content:""; display:block; height:0px; clear:both; overflow:hidden;}.clearfix {display:inline-block;}.clearfix {display:block;} /************** 公共用 ************/html {overflow:-moz-scrollbars-v…

即時聊天IM之二 openfire 整合現有系統用戶

合肥程序員群&#xff1a;49313181。 合肥實名程序員群&#xff1a;128131462 (不愿透露姓名和信息者勿加入) Q Q:408365330 E-Mail:egojitqq.com 綜述&#xff1a; 每天利用中午時間更新下這個知識點的的博客如果感興趣的覺得更新慢了也別介意&#xff08;其它時間還是…

cannot convert ‘_IO_FILE*’ to ‘const char*

錯誤代碼 #ifdef NDEBUG#define DBUG_PRINT(fmt, ...) #else#define DBUG_PRINT(fmt, ...) printf(fmt, ##__VA_ARGS__) #endifBUG_PRINT(stderr, "decode %s does not support device type cuda.\n", dec->name);修改 BUG_PRINT("decode %s does not supp…

找出數組中前K大的值

將數組劃分為兩部分&#xff0c;前K項為前K大值的集合&#xff0c;無需有序。 while(true) {int flag nums[k];while(i < k && nums[i] > flag) {i;}while(j>k && nums[j] < flag) {j--;}if (i j || nums[i] nums[j]) {break;}int tmp nums[i]…

C#在ASP.NET4.5框架下的首次網頁應用

運行效果預覽: 先看實踐應用要求: 1&#xff0e;編寫一個函數&#xff0c;用于計算1&#xff01;2&#xff01;3&#xff01;4&#xff01;5&#xff01;&#xff0c;在控制臺或頁面輸出運行結果。 2&#xff0e;在控制臺或頁面輸出九九乘法表。 3&#xff0e;輸入10個以內的整…

javascript的變態位運算

javascript的變態位運算 var a "10" | 0; alert(a); alert (typeof a);結果為10,number。 這就是說這條語句可以將字符串轉化為number。 如果&#xff1a;var a "sss" | 0;alert(a);結果為0.parseInt("sss")的話&#xff0c;會返回NaN。這個太…

CUDA: OpenCV requires enabled ‘cudev‘ module from ‘opencv_contrib

wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/4.X.X.zip unzip opencv_contrib.zip cmake -D OPENCV_EXTRA_MODULES_PATH~/opencv_contrib-4.X.X/modules參考

Android-Universal-Image-Loader三大組件DisplayImageOptions、ImageLoader、ImageLoaderConfiguration詳解...

轉 一、介紹 Android-Universal-Image-Loader是 一個開源的UI組件程序&#xff0c;該項目的目的是提供一個可重復使用的儀器為異步圖像加載&#xff0c;緩存和顯示。所以&#xff0c;如果你的程序里需要這個功能的話&#xff0c;那么不妨試試它。 因為已經封裝好了一些類和方法…

營銷類文章 SEO

如何有效的推廣網站 適合沒錢的中小站長 唐世軍 a5總經理 博客 門戶網站廣告報價—以新浪為例 貴的一天30多萬 碧藍天營銷學院 網絡營銷&#xff0c;你真的了解嗎&#xff1f; SEO工具mozBar介紹、友情鏈接新參考mozRank 談談網絡推廣團隊每天工作流程、工作標準、考核 請問安卓…

顯示 grep 結果的指定行

用grep查找特定關鍵字&#xff0c;結果很多&#xff0c;但是有用的在中間的某幾行&#xff0c;即grep得到結果之后再次過濾出指定幾行。 首先查找指定行 grep -a "X" filename | grep -an "X"記下指定行&#xff0c;然后用awk打印指定行 grep -a "…