×

pcre c

如何在线安装pcre?如何使用Exchange Web Service获取日历

admin admin 发表于2022-05-09 06:02:29 浏览132 评论0

抢沙发发表评论

如何在线安装pcre

PCRE的安装及使用  1、主页地址:www pcre org  下载pcre-8.13 tar bz2  2、解压缩:  tar xjpf pcre-8.13 tar bz2  3、配置:  cd pcre-8.13  ./configure --prefix=/usr/local/pcre-8.13 --libdir=/usr/local/lib/pcre --includedir=/usr/local/include/pcre  configure有许多参数可配,具体参见./configure --help及手册  4、编译:  make  5、安装:  make install  6、将库文件导入cache:  方法1:在/etc/ld.so.conf中加入: /usr/local/lib/pcre,然后运行ldconfig  方法2:在/etc/ld.so.conf.d/下新生成一个文件(或在其中的文件中加入同样内容),文件内容为:  /usr/local/lib/pcre,然后运行ldconfig 7、编译自带的demo程序gcc -Wall pcredemo.c -I/usr/local/include/pcre -L/usr/local/lib/pcre -lpcre -o pcredemo 8、执行./pcredemo -g ’cat|dog’ ’the dog sat on the cat’./pcredemo ’cat|dog’ ’the cat sat on the mat’ 安装过程遇到的问题,在ubuntu 10.04下,如果直接./configure;make;make intall的话,默认安装的目录是/usr/local/,但是,即使用gcc -Wall pcredemo.c -I/usr/local/include -L/usr/local/lib -lpcre -o pcredemo编译,执行时会出现./pcredemo: error while loading shared libraries: libpcre.so.0: cannot open shared object file: No such file or directory 错误的原因是没用用ldconfig加载库文件到cache。只需按第6步将库文件加载到cache就行

如何使用Exchange Web Service获取日历

本文介绍如何使用EWS代理类调用Exchange的日历(1)首先生成代理类 ExchangeServiceBinding _ExchangeBinding = new ExchangeServiceBinding(); _ExchangeBinding.Credentials = new NetworkCredential(username, password, domain); _ExchangeBinding.Url = Helper.GetWebconfig(“exchangewebservice“);(2)定义请求的属性 请注意:在定义请求属性时,一定要定义CalendarViewType属性,默认的日历返回是不含循环日历的,如果需要返回循环会议请求,就需要等译CalendarViewFindItemType findItemRequest = new FindItemType(); ItemResponseShapeType itemProperties = new ItemResponseShapeType(); itemProperties.BaseShape = DefaultShapeNamesType.AllProperties; findItemRequest.ItemShape = itemProperties; //我们查找的是日历 DistinguishedFolderIdType folderIDs = { new DistinguishedFolderIdType { Id = DistinguishedFolderIdNameType.calendar } }; findItemRequest.ParentFolderIds = folderIDs; //增加搜索的日历范围,红色代码要饭服务器返回循环会议 CalendarViewType cldview = new CalendarViewType(); cldview.StartDate = dt.AddDays(-2); cldview.EndDate = dt.AddDays(2); findItemRequest.Item = cldview; findItemRequest.Traversal = ItemQueryTraversalType.Shallow;(3)定义服务器返回的数据属性 FindItemResponseType findItemResponse = _ExchangeBinding.FindItem(findItemRequest);ArrayOfResponseMessagesType responseMessages = findItemResponse.ResponseMessages; ResponseMessageType responseMessage = responseMessages.Items;foreach (ResponseMessageType rmt in responseMessage) { #region 结果FindItemResponseMessageType msgType = (rmt as FindItemResponseMessageType); if (msgType.RootFolder == null) continue;FindItemParentType parentType = msgType.RootFolder;object obj = parentType.Item; if (obj is ArrayOfRealItemsType) { ArrayOfRealItemsType items = (obj as ArrayOfRealItemsType); if (items != null) { if (items.Items != null) { foreach (ItemType item in items.Items) { CalendarItemType calItem = item as CalendarItemType; DataRow row = table.NewRow(); row[“roomid“] = 1; row[“guid“] = guid; row[“begintime“] = calItem.Start.AddHours(timezone); row[“endtime“] = calItem.End.AddHours(timezone); row[“location“] = calItem.Location; row[“title“] = calItem.Subject; row[“displayname“] = calItem.Organizer.Item.Name; if (row[“endtime“].ToString() != ““) { table.Rows.Add(row); } } } } } #endregion }

C++用dynamic_cast将父类指针转换为子类指针,为什么不一定成功

这个问题牵扯到c++的对象模型。一般认为子类对象大小》=父类对象大小。为什么?因为子类可以扩展父类,可以增加成员变量。如果一个子类增加了成员变量,那么它的对象的内存空间会大于父类对象。这时一个实际指向父类的指针,如果被强制转化为子类对象指针,当使用这个指针时可能会导致越界访问非法内存。相反,为何子类指针可以转换为父类指针?因为父类指针需要的,子类对象都有,不会出现非法内存访问。这就是dynamic_cast不一定成功的原因。如果一个实际指向子类对象的指针被转换成了父类指针,然后再用dynamic_cast转换回来,一定能成功,而一个实际指向父类对象的指针,被dynamic_cast转换为子类指针,一定会失败。