⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 myio.cpp

📁 比较简陋的数据库应用,唯一能看的就是对ODBC的封装...
💻 CPP
字号:
#include "myIO.h"

#define MAX 80

char buffer[MAX];

myIO::myIO()
{
	passcode = '*';
	prein = "  Lelouch >> ";
	preout = "  Lelouch << ";
}

myIO::~myIO()
{
}

String myIO::getIn(int type)
{
	String str;
	char ch;
	int i;
//	std::cout << std::endl;
	while (true)
	{
		std::cout << prein;
		if (type == 1)
		{
			i = 0;
			while ((ch = getch()) != '\r')
			{
				if (ch == '\b')
				{
					if (i > 0)
					{
						buffer[i--] = '\0';
						std::cout << '\b' << ' ' << '\b';
					}
				}
				else
				{
					buffer[i++] = ch;
					std::cout << passcode;
				}
			}
			buffer[i] = '\0';
			str = buffer;
			std::cout << std::endl;
		}
		else
			std::cin >> str;
		if (str.getlenth() != 0)
		{
			if (str.getlenth() == 1)
				return str;
			String temp = str.getSub(str.getlenth() - 2, str.getlenth());
			if (temp == "\\c")
				str = '\0';
			else if (temp == "\\h")
			{	
				Help();
				str = '\0';
			}
			else
				return str;
		}
	}
}

void myIO::putOut(String str)
{
	str.reGetlenth();
	std::cout << preout;
	std::cout << str;
	std::cout << std::endl;
}

void myIO::SetPreIn(String aPre)
{
	prein = aPre;
}

void myIO::SetPreOut(String aPre)
{
	preout = aPre;
}

void myIO::SetCode(char ch)
{
	passcode = ch;
}

myIO& operator>>(myIO& io, String& str)
{
	str = io.getIn(0);
	return io;
}

myIO& operator<<(myIO& io, const String& str)
{
	io.putOut(str);
	return io;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -