C++的I/O(vc版)(四)

c++builder调用VC的dll以及VC调用c++builder的dll 解析__cdecl,__fastcall, __stdcall 的不同:在函数调用过程中,会使用堆栈,这三个表示不同的堆栈调用方式和释放方式。 比如说__cdecl,它是标准的c方法的堆栈调用方式,就是在函数调用时的参数压入堆栈是与函数的声明顺序相反的,其它两个可以看MSDN,不过这个对我们编程没有太大的作用 ------------------------------------------ 阅读详情

下面进行我们的第二大类,流缓冲类。stream并不负责写或者读,毕竟如它原本的目的一样:负责格式化,存储格式化信息;当然我们还用它存储状态信息等等。stream把它的读写工作转交给stream buffer,即缓冲区类。


缓冲区类主要是围绕着位置展开操作,下面先介绍一个与位置有关的类:

/*fpos:它可以存储还原任何流中的任意文件的位置指示器所需的所有信息
 * 对象的类 fpos <St> 有效地存储至少两个成员对象:
 *字节偏移量,类型的 streamoff。
 *转换状态,供使用的类 basic_filebuf,对象类型的 St,通常是mbstate_t。
 * 它还可以存储任意文件的位置,以供类的对象 basic_filebuf,类型的fpos_t。 
 *对于具有有限的文件大小,但是,环境streamoff和fpos_t有时可以互换使用。 
 *对于不具有依赖于状态的编码的流的环境mbstate_t实际上可能是未使用。
 */

#define _Longlong   __int64
typedef _Longlong  streamoff;
typedef _Longlong  streamsize;
typedef __int64  fpos_t;
#define _FPZ   0
#define _FPOSOFF(fp) ((long)(fp))
//定义fpos
template<class _Statetype>
class fpos//store arbitrary file position
{
	typedef fpos<_Statetype> _Myt;
private:
	static const _Statetype _stz;//initail conversion state
	streamoff _myoff;//stream offset
	fpos_t  _fpos; //c file position
	_Statetype _mystate; //current conversion state
public:
	fpos(streamoff _off=0)
		:_myoff(_off),_fpos(_FPZ),_mystate(_stz)
	{//construct with stream offset
		//可以进行隐式转换
	}
	fpos(_Statetype _state,fpos_t _fileposition)
		:_myoff(0),_fpos(_fileposition),_mystate(_state)
	{
		//construct with conversion state and c file position
	}
	//此处采用了I/O接口中经常使用的策略,无参数时返回,有参数时设置
	_Statetype state() const
	{//return conversion state
		return (_mystate);
	}
	void state(_Statetype _state)
	{//set conversion state
		_mystate=_state;
	}

	fpos_t seekpos() const
	{
		return (_fpos);
	}

	operator streamoff() const
	{//return offset
		return (static_cast<streamoff>(_myoff+_FPOSOFF(_fpos)));
	}
	//至此streamoff和fpos的相互转化以全部完成
	streamoff operator-(const _Myt& _right) const
	{
		return(static_cast<streamoff>(*this)-static_cast<streamoff>(_right));
	}
	//遵循了+,-,+=,-=的定义法则,具体见《more effective c++》
	_Myt& operator+=(streamoff _off)
	{//add offset
		_myoff+=_off;
		return (*this);
	}
	_Myt& operator-=(strteamoff _off)
	{//subtract offset
		_myoff-=_off;
		return(*this);
	}
	_Myt  operator+(streamoff _off) const
	{
		_Myt _tmp=*this;
		return (_tmp+=_off);
	}
	_Myt operator-(streamoff _off) const
	{
		_Myt _tmp=*this;
		return (_tmp-=_off);
	}
	
	//判断操作符
	bool operator==(const _Myt& _right) const
	{//test for file position equality
		return (static_cast<streamoff>(*this)==static_cast<streamoff>(_right);
	}
使你的C/C++代码支持Unicode 阅读详情

相关推荐

VC/C++实现TXT到DAT文件转换的源代码

本文还有配套的精品资源,点击获取 简介:在IT行业中,文件格式转换是一个常见任务,特别是在文本数据处理方面。本文详细介绍了如何通过VC/C++编程语言实现从TXT文本文件到DAT数据文件的转换。此转换流程包括读取TXT文件内容、数据预处理、创建并写入DAT文件等步骤。在VC/MFC环境中,还可以利用MFC库简化文件操作,并创建图形用户界面。 1. 文件格式转换基础...

weixin_35649491的博客 1314

高效处理大文件的重叠I/O VC++源代码解析

OVERLAPPED结构体是Windows平台上用于处理异步I/O请求的一种数据结构。它允许应用程序在文件操作(如读取和写入)进行的同时,继续执行其他任务。在本章节中,我们详细讨论了OVERLAPPED结构体的介绍、在重叠I/O中的应用,以及处理超大文件和错误管理的高级技巧。在Windows平台开发中,合理利用OVERLAPPED结构体能够有效提升应用程序的性能和效率。在接下来的章节中,我们将继续探讨如何在VC++中实现重叠I/O,以及WinAPI中CreateFileReadFile。

weixin_33193177的博客 769

PCB Layout总结

PCB Layout作为硬件设计中的一个环节,也是很重要的一个环节;在硬件电路设计合理的情况下,他其实是影响性能的一个绝对重要的指标。现在很多的PCB Layout工程师都是按照硬件工程师或者PI SI工程师给出的约束规则来完成布局布线的,这些也就是俗称的 “拉线工”。他们重复而机械的完成一块块PCB设计,一段时间设计后,他们中的一些或许已经有了这样的一些经验:哪些要做等长,哪些要走粗、哪些要平...

xydlxd118的博客 2583

机器视觉学习(七)—— 卷积、边缘和滤波器

卷积运算、垂直边缘与水平边缘、滤波器

歆歆~黯了 2740

【机器人】线性方程最小二乘解法对机械臂DH参数进行标定

1.前言 看了一篇文章,觉得里面的DH参数标定法讲的很清晰,便使用Matlab复现了一下,效果还可以,特写此文记录。 2.原理 2.1.误差最佳值的最小二乘计算 有研究结果表明:几乎95%的机器人位置误差都是由机器人内部运动学的不准确描述引起的,所以对DH模型参数进行标定是很有必要的。 DH参数物理含义:选自《机器人学、机器视觉与控制-Matlab基础》 当DH参数确定后,我们...

要恰饭得嘛 1万+

论文深度解析:基于大语言模型的城市公园多维度感知解码与公平性提升

本文针对城市公园感知测量的精细化不足与公平性评估缺口,提出了一套融合社交媒体数据与大语言模型(LLM)的创新分析框架。通过领域适配微调开发的Park-Perception-LLM模型,实现了对感知可达性、可用性、吸引力三大核心维度83%-91%的高精度分类。将该感知指标创新性地融入增强两步浮动集水区法(E2SFCA),以香港高密度城市为案例,系统揭示了公园质量与数量的空间不平等及错配模式。借助多元回归模型,深入挖掘了公园内部特征、宏观建成环境、微观街道景观及时间因素对感知的影响机制。

May the Force be with you 1014

2022年全国职业院校技能大赛网络系统管理赛项模块A:网络构建(样题5)-网络部分解析-附详细代码

2022年全国职业院校技能大赛网络系统管理赛项模块A:网络构建(样题5)-网络部分解析-附详细代码

bfq05234214的博客 416

基于滤波反投影的图像重建算法matlab仿真

基于滤波反投影的图像重建算法是一种用于医学影像重建的计算机辅助技术。该算法可以从投影数据中重建出高质量的三维图像,被广泛应用于医学影像学、CT、PET等领域。本文将详细介绍基于滤波反投影的图像重建算法的原理、步骤和应用。一、原理介绍基于滤波反投影的图像重建算法基于X射线CT成像原理,它的主要思想是通过对投影数据进行处理,反推出被成像物体的三维形状。其核心原理是投影数据与目标物体之间的线性关系,即通过估计目标物体的吸收率来计算投影数据的变化,从而反推出目标物体的三维形状。

平时工作较为繁忙,私信消息一般晚上回复,谢谢大家~~ 386

EtherCAT主站IGH-- 49 -- 搭建xenomai系统及自己的IGH主站

以上就是搭建xenomai系统及自己的IGH主站的内容。有不明白的地方欢迎留言;有建议欢迎留言,我后面编写文档好改进。创作不容,如果文档对您有帮助,记得给个赞。

常驻客栈的博客--嵌入式EtherCAT 3158

华为OD技术面真题 - JAVA开发 - 1

汇总华为OD技术面八股JAVA八股,高频技术真题并提供详细解答。

qq_45776114的博客 1201

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

上一篇: C++的I/O(vc版)(三)
下一篇: C++的I/O(vc版)(五)
wangyanphp
博客等级 码龄14年 90粉丝 51原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值