本文整理汇总了C++中AString::Left方法的典型用法代码示例。如果您正苦于以下问题:C++ AString::Left方法的具体用法?C++ AString::Left怎么用?C++ AString::Left使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AString
的用法示例。
在下文中一共展示了AString::Left方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PropToString
static AString PropToString2(const NCOM::CPropVariant &prop, PROPID propID)
{
AString s = PropToString(prop, propID);
if (s.Length() > (kInfoPanelLineSize - 1))
s = s.Left(kInfoPanelLineSize - 1);
return s;
}
示例2: 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;
}
示例3: GetNameOfProp
static AString GetNameOfProp2(PROPID propID, const wchar_t *name)
{
AString s = GetNameOfProp(propID, name);
if (s.Length() > (kInfoPanelLineSize - 1))
s = s.Left(kInfoPanelLineSize - 1);
return s;
}
示例4: ReplaceTerms
AString ADVBConfig::ReplaceTerms(const AString& user, const AString& subitem, const AString& _str) const
{
AString str = _str;
int p1, p2;
while (((p1 = str.Pos("{conf:")) >= 0) && ((p2 = str.Pos("}", p1)) >= 0)) {
AString item = GetUserSubItemConfigItem(user, subitem, str.Mid(p1 + 6, p2 - p1 - 6));
str = str.Left(p1) + item + str.Mid(p2 + 1);
}
return str;
}
示例5: GetErrorMessage
/*--------------------------------------------------------------------------------*/
AString PostgresDatabase::GetErrorMessage(PGconn *conn, bool full)
{
AString msg;
if (conn) {
msg = AString(PQerrorMessage(conn)).SearchAndReplace("\r", "").SearchAndReplace("\n\n", ", ");
if (msg.EndsWith(", ")) msg = msg.Left(msg.len() - 2);
if (!full) msg = msg.Line(0);
}
else msg = "No connection!";
return msg;
}
示例6: my_windows_split_path
void my_windows_split_path(const AString &p_path, AString &dir , AString &base) {
int pos = p_path.ReverseFind('/');
if (pos == -1) {
// no separator
dir = ".";
if (p_path.IsEmpty())
base = ".";
else
base = p_path;
} else if ((pos+1) < p_path.Len()) {
// true separator
base = p_path.Ptr(pos+1);
while ((pos >= 1) && (p_path[pos-1] == '/'))
pos--;
if (pos == 0)
dir = "/";
else
dir = p_path.Left(pos);
} else {
// separator at the end of the path
// pos = p_path.find_last_not_of("/");
pos = -1;
int ind = 0;
while (p_path[ind]) {
if (p_path[ind] != '/')
pos = ind;
ind++;
}
if (pos == -1) {
base = "/";
dir = "/";
} else {
my_windows_split_path(p_path.Left(pos+1),dir,base);
}
}
}
示例7: ConvertSimpleType
/*--------------------------------------------------------------------------------*/
AString PostgresDatabase::ConvertSimpleType(const AString& ctype) const
{
AString type;
if (ctype == "id") type = "integer not null primary key"; // primary key id
else if (ctype == "id64") type = "bigint not null primary key"; // primary key id (64-bit)
else if (ctype.Left(6) == "string") type.printf("varchar%s", ctype.Mid(6).SearchAndReplace("[", "(").SearchAndReplace("]", ")").str()); // string type / varchar
else if (ctype == "datetime") type = "timestamp";
else if (ctype == "float") type = "real";
else if (ctype == "double") type = "real";
else if (ctype == "short") type = "smallint";
else if (ctype == "int64") type = "bigint";
else if (ctype == "") type = "integer";
return type;
}
示例8: AddItem
static bool AddItem(const CXmlItem &item, CObjectVector<CFile> &files, int parent)
{
if (!item.IsTag)
return true;
if (item.Name == "file")
{
CFile file;
file.Parent = parent;
parent = files.Size();
file.Name = item.GetSubStringForTag("name");
AString type = item.GetSubStringForTag("type");
if (type == "directory")
file.IsDir = true;
else if (type == "file")
file.IsDir = false;
else
return false;
int dataIndex = item.FindSubTag("data");
if (dataIndex >= 0 && !file.IsDir)
{
file.HasData = true;
const CXmlItem &dataItem = item.SubItems[dataIndex];
if (!ParseUInt64(dataItem, "size", file.Size))
return false;
if (!ParseUInt64(dataItem, "length", file.PackSize))
return false;
if (!ParseUInt64(dataItem, "offset", file.Offset))
return false;
file.Sha1IsDefined = ParseSha1(dataItem, "extracted-checksum", file.Sha1);
// file.packSha1IsDefined = ParseSha1(dataItem, "archived-checksum", file.packSha1);
int encodingIndex = dataItem.FindSubTag("encoding");
if (encodingIndex >= 0)
{
const CXmlItem &encodingItem = dataItem.SubItems[encodingIndex];
if (encodingItem.IsTag)
{
AString s = encodingItem.GetPropertyValue("style");
if (s.Length() >= 0)
{
AString appl = "application/";
if (s.Left(appl.Length()) == appl)
{
s = s.Mid(appl.Length());
AString xx = "x-";
if (s.Left(xx.Length()) == xx)
{
s = s.Mid(xx.Length());
if (s == "gzip")
s = METHOD_NAME_ZLIB;
}
}
file.Method = s;
}
}
}
}
file.CTime = ParseTime(item, "ctime");
file.MTime = ParseTime(item, "mtime");
file.ATime = ParseTime(item, "atime");
files.Add(file);
}
for (int i = 0; i < item.SubItems.Size(); i++)
if (!AddItem(item.SubItems[i], files, parent))
return false;
return true;
}
示例9: Configure
void MotionDetector::Configure()
{
AString nstr = AString("%").Arg(index);
log.printf("%s[%u]: Reading new settings...\n", ADateTime().DateFormat("%Y-%M-%D %h:%m:%s.%S").str(), index);
stream.Close();
stream.SetUsernameAndPassword(GetSetting("username", "admin"),
GetSetting("password", "arsebark"));
AString camera = GetSetting("camera", "");
log.printf("%s[%u]: Connecting to %s...\n", ADateTime().DateFormat("%Y-%M-%D %h:%m:%s.%S").str(), index, camera.str());
if (!stream.OpenHost(camera)) {
log.printf("%s[%u]: Failed to connect to %s...\n", ADateTime().DateFormat("%Y-%M-%D %h:%m:%s.%S").str(), index, camera.str());
}
imagedir = GetSetting("imagedir", "/media/cctv");
imagefmt = GetSetting("filename", "%Y-%M-%D/%h/Image-{camera}-%Y-%M-%D-%h-%m-%s-%S");
detimgdir = GetSetting("detimagedir");
detimgfmt = GetSetting("detfilename", "%Y-%M-%D/%h/detection/Image-{camera}-%Y-%M-%D-%h-%m-%s-%S");
detcmd = GetSetting("detcommand", "");
nodetcmd = GetSetting("nodetcommand", "");
coeff = (double)GetSetting("coeff", "1.0e-3");
avgfactor = (double)GetSetting("avgfactor", "1.0");
sdfactor = (double)GetSetting("sdfactor", "2.0");
redscale = (double)GetSetting("rscale", "1.0");
grnscale = (double)GetSetting("gscale", "1.0");
bluscale = (double)GetSetting("bscale", "1.0");
threshold = (double)GetSetting("threshold", "3000.0");
verbose = (uint_t)GetSetting("verbose", "0");
matmul = 1.f;
matwid = mathgt = 0;
AString _matrix = GetSetting("matrix", "");
if (_matrix.Valid()) {
uint_t row, nrows = _matrix.CountLines(";");
uint_t col, ncols = 1;
int p;
if ((p = _matrix.Pos("*")) >= 0) {
AString mul = _matrix.Mid(p + 1);
_matrix = _matrix.Left(p);
if ((p = mul.Pos("/")) >= 0) {
matmul = (float)mul.Left(p) / (float)mul.Mid(p + 1);
}
else matmul = (float)mul;
}
else if ((p = _matrix.Pos("/")) >= 0) {
AString mul = _matrix.Mid(p + 1);
_matrix = _matrix.Left(p);
matmul = 1.f / (float)mul;
}
for (row = 0; row < nrows; row++) {
uint_t n = _matrix.Line(row, ";").CountLines(",");
ncols = MAX(ncols, n);
}
nrows |= 1;
ncols |= 1;
matrix.resize(nrows * ncols);
for (row = 0; row < nrows; row++) {
AString line = _matrix.Line(row,";");
for (col = 0; col < ncols; col++) matrix[col + row * ncols] = (float)line.Line(col, ",");
}
matwid = ncols;
mathgt = nrows;
#if 0
printf("Matrix is %u x %u:\n", matwid, mathgt);
for (row = 0; row < nrows; row++) {
for (col = 0; col < ncols; col++) printf("%8.3f", matrix[col + row * ncols]);
printf("\n");
}
printf("Multiplier %0.6f\n", matmul);
#endif
}
else matrix.resize(0);
}