本文整理汇总了C++中wxInputStream::CanRead方法的典型用法代码示例。如果您正苦于以下问题:C++ wxInputStream::CanRead方法的具体用法?C++ wxInputStream::CanRead怎么用?C++ wxInputStream::CanRead使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxInputStream
的用法示例。
在下文中一共展示了wxInputStream::CanRead方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadLongLong
/** @brief Read a long long from an input stream
*
* @param in wxInputStream&
* @param out_LongLong long long&
* @return bool
*
*/
static bool ReadLongLong( wxInputStream& in, long long& out_LongLong )
{
long long val = 0;
if (!in.CanRead())
return false;
in.Read(&val, sizeof(val));
out_LongLong = val;
return true;
}
示例2: DoGetFromStream
void MyPipeFrame::DoGetFromStream(wxTextCtrl *text, wxInputStream& in)
{
while ( in.CanRead() )
{
char buffer[4096];
buffer[in.Read(buffer, WXSIZEOF(buffer) - 1).LastRead()] = '\0';
text->AppendText(buffer);
}
}
示例3: ReadInt
/** @brief Read an int from an input stream
*
* @param in wxInputStream&
* @param out_Int int&
* @return bool
*
*/
static bool ReadInt( wxInputStream& in, int& out_Int )
{
int val = 0;
if (!in.CanRead())
return false;
in.Read(&val, sizeof(val));
out_Int = val;
return true;
}
示例4: ParseHeader
// parse header section: just skip everything
bool DXFRenderer::ParseHeader(wxInputStream& stream)
{
wxTextInputStream text(stream);
wxString line1, line2;
while (stream.CanRead())
{
GetLines(text, line1, line2);
if (line1 == "0" && line2 == "ENDSEC")
return true;
}
return false;
}
示例5: ReadIn
/** @brief Read a tokendatabase from disk
*
* @param tokenDatabase The tokendatabase to read into
* @param in The wxInputStream to read from
* @return true if the operation succeeded, false otherwise
*
*/
bool ClTokenDatabase::ReadIn( ClTokenDatabase& tokenDatabase, wxInputStream& in )
{
in.SeekI(4); // Magic number
int version = 0;
if (!ReadInt(in, version))
return false;
int i = 0;
if (version != 0x01)
{
return false;
}
tokenDatabase.Clear();
int read_count = 0;
wxMutexLocker(tokenDatabase.m_Mutex);
while (in.CanRead())
{
int packetType = 0;
if (!ReadInt(in, packetType))
return false;
switch (packetType)
{
case ClTokenPacketType_filenames:
if (!ClFilenameDatabase::ReadIn(tokenDatabase.m_FileDB, in))
return false;
break;
case ClTokenPacketType_tokens:
int packetCount = 0;
if (!ReadInt(in, packetCount))
return false;
for (i = 0; i < packetCount; ++i)
{
ClAbstractToken token;
if (!ClAbstractToken::ReadIn(token, in))
return false;
if (token.fileId != -1)
{
//ClTokenId tokId =
tokenDatabase.InsertToken(token);
//fprintf( stdout, " '%s' / '%s' / fId=%d location=%d:%d hash=%d dbEntryId=%d\n", (const char*)token.identifier.mb_str(), (const char*)token.displayName.mbc_str(), token.fileId, token.location.line, token.location.column, token.tokenHash, tokId );
read_count++;
}
}
break;
}
}
return true;
}
示例6: ReadString
/** @brief Read a string from an input stream
*
* @param in wxInputStream&
* @param out_String wxString&
* @return bool
*
*/
static bool ReadString( wxInputStream& in, wxString& out_String )
{
int len;
if (!ReadInt(in, len))
return false;
if (len == 0)
{
out_String = out_String.Truncate(0);
return true;
}
if (!in.CanRead())
return false;
char buffer[len + 1];
in.Read( buffer, len );
buffer[len] = '\0';
out_String = wxString::FromUTF8(buffer);
return true;
}
示例7: ParseTables
// parse tables section: save layers name and colour
bool DXFRenderer::ParseTables(wxInputStream& stream)
{
wxTextInputStream text(stream);
wxString line1, line2;
bool inlayer=false;
DXFLayer layer;
while (stream.CanRead())
{
GetLines(text, line1, line2);
if (line1 == "0" && inlayer)
{
// flush layer
if (!layer.name.IsEmpty() && layer.colour != -1)
{
DXFLayer *p = new DXFLayer;
p->name = layer.name;
p->colour = layer.colour;
m_layers.Append(p);
}
layer = DXFLayer();
inlayer = false;
}
if (line1 == "0" && line2 == "ENDSEC")
return true;
else if (line1 == "0" && line2 == "LAYER")
inlayer = true;
else if (inlayer)
{
if (line1 == "2") // layer name
layer.name = line2;
else if (line1 == "62") // ACI colour
{
long l;
line2.ToLong(&l);
layer.colour = l;
}
}
}
return false;
}
示例8: Load
// parse and load a DXF file
// currently pretty limited, but knows enough to handle 3DFACEs and LINEs
bool DXFRenderer::Load(wxInputStream& stream)
{
Clear();
wxTextInputStream text(stream);
wxString line1, line2;
while (stream.CanRead())
{
GetLines(text, line1, line2);
if (line1 == "999") // comment
continue;
else if (line1 == "0" && line2 == "SECTION")
{
GetLines(text, line1, line2);
if (line1 == "2")
{
if (line2 == "HEADER")
{
if (!ParseHeader(stream))
return false;
}
else if (line2 == "TABLES")
{
if (!ParseTables(stream))
return false;
}
else if (line2 == "ENTITIES")
{
if (!ParseEntities(stream))
return false;
}
}
}
}
NormalizeEntities();
m_loaded = true;
return true;
}
示例9: ParseEntities
// parse entities section: save 3DFACE and LINE entities
bool DXFRenderer::ParseEntities(wxInputStream& stream)
{
wxTextInputStream text(stream);
wxString line1, line2;
int state = 0; // 0: none, 1: 3DFACE, 2: LINE
DXFVector v[4];
int colour = -1;
wxString layer;
while (stream.CanRead())
{
GetLines(text, line1, line2);
if (line1 == "0" && state > 0)
{
// flush entity
if (state == 1) // 3DFACE
{
DXFFace *p = new DXFFace;
p->v0 = v[0];
p->v1 = v[1];
p->v2 = v[2];
p->v3 = v[3];
p->CalculateNormal();
if (colour != -1)
p->colour = colour;
else
p->colour = GetLayerColour(layer);
m_entities.Append(p);
colour = -1; layer.clear();
v[0] = v[1] = v[2] = v[3] = DXFVector();
state = 0;
}
else if (state == 2) // LINE
{
DXFLine *p = new DXFLine;
p->v0 = v[0];
p->v1 = v[1];
if (colour != -1)
p->colour = colour;
else
p->colour = GetLayerColour(layer);
m_entities.Append(p);
colour = -1; layer.clear();
v[0] = v[1] = v[2] = v[3] = DXFVector();
state = 0;
}
}
if (line1 == "0" && line2 == "ENDSEC")
return true;
else if (line1 == "0" && line2 == "3DFACE")
state = 1;
else if (line1 == "0" && line2 == "LINE")
state = 2;
else if (state > 0)
{
const double d=ToDouble(line2);
if (line1 == "10")
v[0].x = d;
else if (line1 == "20")
v[0].y = d;
else if (line1 == "30")
v[0].z = d;
else if (line1 == "11")
v[1].x = d;
else if (line1 == "21")
v[1].y = d;
else if (line1 == "31")
v[1].z = d;
else if (line1 == "12")
v[2].x = d;
else if (line1 == "22")
v[2].y = d;
else if (line1 == "32")
v[2].z = d;
else if (line1 == "13")
v[3].x = d;
else if (line1 == "23")
v[3].y = d;
else if (line1 == "33")
v[3].z = d;
else if (line1 == "8") // layer
layer = line2;
else if (line1 == "62") // colour
{
long l;
line2.ToLong(&l);
colour = l;
}
}
}
return false;
}
示例10: LoadStream
bool wxDatabaseConfig::LoadStream(wxInputStream& inStream, wxString* err)
{
SetRootPath(m_entry);
if (m_viewName.IsEmpty())
{
m_viewName = m_self->GetAppName();
if (m_viewName.IsEmpty())
{
m_viewName = viewname_default;
}
}
m_viewName.Replace(wxCONFIG_PATH_SEPARATOR, wxEmptyString);
if (!inStream.CanRead())
{
if (err) err->Append("can't read");
return false;
}
wxFileConfig config(inStream);
/*
SQLite doesn't support stored procedures nor recursion.
The best compromise between all the flavours of databases is to store the group paths as a closure set
and to access the groups and entries via a view with triggers instead of accessing the underlying tables directly.
table "tablename_entry" contains the rows for both group names and entry name/values
table "tablename_path" contains a closure set for the group paths
view "viewname" (and its associated triggers) provide the interface used by this code
*/
wxString sqlCreateTablePath;
wxString sqlCreateTableEntry;
wxString sqlCreateViewPath;
wxString sqlCreateTriggerInsteadOfInsertViewPath;
wxString sqlCreateTriggerInsteadOfUpdateViewPath;
wxString sqlCreateTriggerInsteadOfDeleteViewPath;
wxString sqlAddEntry;
wxString sqlDelEntry;
wxString sqlEditEntry;
wxString sqlFindEntries;
wxString sqlDropAll;
// should work on all DBs?
sqlCreateTablePath <<
"IF NOT EXISTS (SELECT * FROM sys.views WHERE name = '" << viewname <<"') "
"AND NOT EXISTS (SELECT * FROM sys.objects WHERE type IN ('U') AND name = '" << tablename_path << "') EXECUTE('"
"CREATE TABLE " << tablename_path <<
"("
"pid INT NOT NULL,"
"id INT NOT NULL,"
"PRIMARY KEY (pid, id),"
"FOREIGN KEY (pid) REFERENCES " << tablename_entry << "(id),"
"FOREIGN KEY (id) REFERENCES " << tablename_entry << "(id)"
")"
"')"
;
sqlCreateTableEntry <<
"IF NOT EXISTS (SELECT * FROM sys.views WHERE name = '" << viewname <<"') "
"AND NOT EXISTS (SELECT * FROM sys.objects WHERE type IN ('U') AND name = '" << tablename_entry <<"') EXECUTE('"
"CREATE TABLE " << tablename_entry <<
"("
"id INT IDENTITY PRIMARY KEY,"
"name VARCHAR(255) NOT NULL,"
"value VARCHAR(255) NULL"
")"
"')"
;
sqlAddEntry <<
"INSERT INTO " << viewname <<" (id, name, value) VALUES (?, ?, ?)"
;
sqlDelEntry <<
"DELETE FROM " << viewname <<" WHERE id = ?"
;
sqlEditEntry <<
"UPDATE " << viewname <<" SET name = ?, value = ? WHERE id = ?"
;
sqlFindEntries <<
"SELECT id, name, value, path, isgroup FROM " << viewname <<" WHERE path LIKE ?"
;
sqlDropAll <<
"DROP VIEW " << viewname <<"\n"
"DROP TABLE " << tablename_path <<"\n"
"DROP TABLE " << tablename_entry <<"\n"
;
sqlCreateTriggerInsteadOfInsertViewPath <<
"IF NOT EXISTS (SELECT * FROM sys.triggers WHERE name = '" << triggername_insertviewpath <<"') EXECUTE('\n"
"CREATE TRIGGER [" << triggername_insertviewpath <<"] ON " << viewname <<" INSTEAD OF INSERT\n"
"AS\n"
"BEGIN\n"
"\tINSERT INTO " << tablename_entry <<" (name, value) SELECT i.name, i.value FROM inserted i\n"
"\tINSERT INTO " << tablename_path <<" (pid, id)\n"
"\tSELECT p.pid, (SELECT MAX(id) FROM " << tablename_entry <<")\n"
"\tFROM\n"
"\t\t" << tablename_path <<" p\n"
//.........这里部分代码省略.........