第一章 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.mzph.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 "…