当前位置: 首页>>代码示例>>C++>>正文


C++ AString::ReadLn方法代码示例

本文整理汇总了C++中AString::ReadLn方法的典型用法代码示例。如果您正苦于以下问题:C++ AString::ReadLn方法的具体用法?C++ AString::ReadLn怎么用?C++ AString::ReadLn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AString的用法示例。


在下文中一共展示了AString::ReadLn方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ReadReplacementsFile

bool ADVBConfig::ReadReplacementsFile(std::vector<REPLACEMENT>& replacements, const AString& filename) const
{
	AStdFile fp;
	bool success = false;

	if (fp.open(filename)) {
		AString line;

		//printf("Reading replacements file '%s':", filename.str());

		while (line.ReadLn(fp) >= 0) {
			int p = 0;

			if ((line.Word(0)[0] != ';') && ((p = line.Pos("=")) >= 0)) {
				REPLACEMENT repl = {
					line.Left(p).Word(0).DeQuotify(),
					line.Mid(p + 1).Word(0).DeQuotify(),
				};

				//printf("Replacement: '%s' -> '%s'", repl.search.str(), repl.replace.str());

				replacements.push_back(repl);
			}
		}

		fp.close();

		success = true;
	}
	else logit("Failed to open replacements file '%s'", filename.str());

	return success;
}
开发者ID:,项目名称:,代码行数:33,代码来源:

示例2: main

int main(int argc, char *argv[])
{
	ASocketServer server;
	AStdSocket    socket(server);

	if (argc < 2) {
		fprintf(stderr, "cmdsender " VER_STRING "\n");
		fprintf(stderr, "Usage: cmdsender <host> [<port>]\n");
		exit(1);
	}
	
	if (socket.open("0.0.0.0",
					0,
					ASocketServer::Type_Datagram)) {
		uint_t port = 1722;

		if (argc >= 3) port = (uint_t)AString(argv[2]);
		
		if (socket.setdatagramdestination(argv[1], port)) {
			AString line;
			while (line.ReadLn(Stdin) >= 0) {
				if (socket.printf("%s\n", line.str()) <= 0) break;
			}
		}
		
		socket.close();
	}
	
	return 0;
}
开发者ID:richardxday,项目名称:rdutils,代码行数:30,代码来源:cmdsender.cpp

示例3: AddPatternToFile

bool ADVBPatterns::AddPatternToFile(const AString& filename, const AString& pattern)
{
	const ADVBConfig& config = ADVBConfig::Get();
	AStdFile fp;
	bool done = false;
	bool added = false;

	if (fp.open(filename)) {
		AString line;

		while (line.ReadLn(fp) >= 0) {
			if (line == pattern) {
				done = true;
				break;
			}
		}

		fp.close();
	}

	if (!done) {
		if (fp.open(filename, "a")) {
			fp.printf("%s\n", pattern.str());
			fp.close();

			config.logit("Add pattern '%s' to file '%s'", pattern.str(), filename.str());

			added = true;
		}
	}

	return added;
}
开发者ID:,项目名称:,代码行数:33,代码来源:

示例4: UpdatePatternInFile

bool ADVBPatterns::UpdatePatternInFile(const AString& filename, const AString& pattern, const AString& newpattern)
{
	const ADVBConfig& config = ADVBConfig::Get();
	AString filename1 = filename + ".new";
	AStdFile ifp, ofp;
	bool changed = false, found = false;

	if (ifp.open(filename)) {
		if (ofp.open(filename1, "w")) {
			AString line;

			while (line.ReadLn(ifp) >= 0) {
				if (line == pattern) {
					if (newpattern.Valid()) ofp.printf("%s\n", newpattern.str());
					changed = found = true;

					if (newpattern.Valid()) {
						config.logit("Changed pattern '%s' to '%s' in file '%s'", pattern.str(), newpattern.str(), filename.str());
					}
					else {
						config.logit("Deleted pattern '%s' from file '%s'", pattern.str(), filename.str());
					}
				}
				else if (line.Words(0).Valid()) ofp.printf("%s\n", line.str());
				else changed = true;
			}
			ofp.close();
		}

		ifp.close();

		if (changed) {
			remove(filename);
			rename(filename1, filename);
		}
		else remove(filename1);
	}

	return found;
}
开发者ID:,项目名称:,代码行数:40,代码来源:

示例5: ExtractLogData

bool ADVBConfig::ExtractLogData(const ADateTime& start, const ADateTime& end, const AString& filename) const
{
	AStdFile dst;
	bool success = false;

	if (dst.open(filename, "w")) {
		ADateTime dt;
		uint32_t day1 = start.GetDays();
		uint32_t day2 = end.GetDays();
		uint32_t day;
		bool     valid = false;

		for (day = day1; day <= day2; day++) {
			AStdFile src;

			if (src.open(GetLogFile(day))) {
				AString line;

				while (line.ReadLn(src) >= 0) {
					valid |= dt.FromTimeStamp(line.Words(0, 2));

					if (valid) {
						if ((dt >= start) && (dt <= end)) dst.printf("%s\n", line.str());
						if (dt >= end) break;
					}
				}

				src.close();
			}
		}

		dst.close();
	}

	return success;
}
开发者ID:,项目名称:,代码行数:36,代码来源:

示例6: ListUsers

void ADVBConfig::ListUsers(AList& list) const
{
	AHash 	 users(10);
	AList 	 userpatterns;
	AString  filepattern 	   = GetUserPatternsPattern();
	AString  filepattern_parsed = ParseRegex(filepattern);
	AString  _users             = GetConfigItem("users");
	AStdFile fp;
	uint_t   i, n = _users.CountColumns();

	//debug("Reading users from config %s\n", config.GetFilename().str());

	for (i = 0; i < n; i++) {
		AString user = _users.Column(i).Words(0);

		if (!users.Exists(user)) {
			users.Insert(user, 0);
			list.Add(new AString(user));
		}
	}

	if (fp.open(GetPatternsFile())) {
		AString line;

		while (line.ReadLn(fp) >= 0) {
			AString user;
			int p;

			if		((p = line.PosNoCase(" user:=")) >= 0) user = line.Mid(p + 7).Word(0).DeQuotify();
			else if (line.PosNoCase("user:=") == 0)        user = line.Mid(6).Word(0).DeQuotify();

			if (user.Valid() && !users.Exists(user)) {
				users.Insert(user, 0);
				list.Add(new AString(user));
			}
		}

		fp.close();
	}

	::CollectFiles(filepattern.PathPart(), filepattern.FilePart(), 0, userpatterns);

	const AString *file = AString::Cast(userpatterns.First());
	while (file) {
		AString   user;
		ADataList regions;

		if (MatchRegex(*file, filepattern_parsed, regions)) {
			const REGEXREGION *region = (const REGEXREGION *)regions[0];

			if (region) {
				user = file->Mid(region->pos, region->len);
				if (!users.Exists(user)) {
					users.Insert(user, 0);
					list.Add(new AString(user));
				}
			}
		}

		file = file->Next();
	}

	list.Sort(&AString::AlphaCompareCase);
}
开发者ID:,项目名称:,代码行数:64,代码来源:


注:本文中的AString::ReadLn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。