草庐IT

TIME_FORMAT

全部标签

c++ - 使用 boost/format 的安全隐患是什么?

我开始使用boost/format。使用boost/format编码时,在安全方面需要注意什么?我可以在不担心安全的情况下执行以下操作吗?std::cout在什么情况下使用boost/format会出现安全问题? 最佳答案 你的例子是安全的。事实上,使用printf是安全的。和printf一样,Boost.Format只解析它的格式字符串一次,所以没有机会插入额外的格式说明符。将不完整的format对象传递给boost::format会引发异常。我猜你害怕的是formatstringexploits.我认为,使用Boost.Form

c++ - 如何将 __DATE__ 和 __TIME__ 宏拆分为变量声明的单独组件?

我有以下结构(在嵌入式系统上):structCalib_Time_struct{uint16_tyear;uint16_tmonth;uint16_tday;uint16_thour;uint16_tminute;uint16_tseconds;};我有一个“默认”值数组,我需要在其中插入时间值:structCalib_Table_struct{unsignedinttable_id;//!我想从__DATE__宏中填写“modification_date”成员的年、月和日。有没有办法做到这一点?(有什么技巧吗?)是否可以将类似的方法或hack应用于__TIME__宏?动机是允许编译器

c++ - 在 universal_time 上使用时间方面

在boost上,要创建一个时间方面来格式化指定的时间,我们使用以下方法:boost::local_time::local_time_facet*facet=newboost::local_time::local_time_facet("%Y%m%d%H:%M:%S.%f");std::stringstreamdate_stream;date_stream.imbue(std::locale(date_stream.getloc(),facet));date_stream我如何做同样的事情,但使用通用时钟:boost::posix_time::microsec_clock::univer

c++ - 从 64 位整数秒数创建一个 boost::posix_time::ptime 对象

我有一个32位Linux系统,我必须在其中记录时间戳为1901-01-0100:00:00的UINT32秒偏移量的数据。计算时间戳对我来说没问题,因为我可以使用64位ticks()计数器和ticks_per_second()函数生成自纪元以来的秒数如下(我只需要二级分辨率)constptimeptime_origin(time_from_string("1901-01-0100:00:00"));time_durationmy_utc=microsec_clock::universal_time()-ptime_origin;boost::int64_ttick_per_sec=my_

c++ - std::chrono::time_point 无效值

boost/std::chrono::time_pointmy_time_point(/*invalidvalue*/);我需要存储一个无效/无意义/标记值。我怎么可能那样做? 最佳答案 您可以使用boost::optional(或std::optional,如果您支持C++17)表示chrono::time_point的无效状态:#include#includeintmain(){usingmy_clock=std::chrono::system_clock;usingmy_time_point=std::chrono::time

c++ - 在 boost::lambda 中使用 boost::format

出于某种原因,我未能在boost::lambda中使用boost::format。这是我的代码的(希望)可编译的简化:#include#include#include#include#include#includenamespacebl=boost::lambda;intmain(){conststd::vectorv=boost::assign::list_of(1)(2)(3);std::for_each(v.begin(),v.end(),bl::var(std::cout)第一个std::for_each产生预期的输出第二个std::for_each只输出没有任何数字的空格这是

c++ - ar 无法创建存档 : "File format not recognized"

我有这个makefilelibjackpot.a:jackport.ojackpot.oar-rcsjackport.ojackpot.ojackpot.o:jackpot.cppjackpot.hg++jackpot.cpp-std=c++11-O2-cjackport.o:jackport.cppjackpot.hjackport.hg++jackport.cpp-std=c++11-O2-c不知何故(在我的Linux机器上),我得到了ar:jackport.o:Fileformatnotrecognizedar--help给出ar:supportedtargets:elf64-x

ios - 如何在 hh :mm:ss format? 中输入时间值

我需要输入时间值hh:mm:ss(09:45:56)格式,但在Xcode文本字段中我总是得到(094556)作为格式-如何解决? 最佳答案 您可以使用NSDateFormatter来解析任何自定义格式NSDateFormatter*dateformatter=[[NSDateFormatteralloc]init];dateformatter.dateFormat=@"HH':'mm':'ss";NSString*mydate=@"09:45:56"NSDate*parseddate=[dateformatterdateFromSt

android - 如何使用 Phonegap 在 Android 中实现 "one time login"?

我正在使用PhoneGap为android和ios开发一个移动应用程序,我想实现一个像gmail和facebook应用程序一样的登录方案,即用户只需在第一次输入用户名和密码,之后应用程序应该自动启动后立即登录。我通过验证登录凭据的ajax和jquery调用Web服务。我看过很多关于ios的帖子,描述如何修改delegate.m文件,但是android呢? 最佳答案 您可以将用户session数据存储在持久存储形式中。检查用户是否已使用此数据登录。http://docs.phonegap.com/en/2.1.0/cordova_st

ios - calendarsForEntityType :EKEntityTypeReminder is empty first time, 随后工作

谁能帮我弄清楚我在这里做错了什么。我的应用程序应该访问iPhone的各种日历以检查即将发生的事件。所以我需要访问日历中的“事件”以及“提醒”。当我有事件时,我将它们临时存储在UserDefaults中在我的.h文件中有这样的东西@property(nonatomic,strong)EKEventStore*eventStore;@property(nonatomic,strong)NSMutableArray*calendars;@property(nonatomic,strong)NSMutableArray*reminders;@property(nonatomic)BOOLacc