本文整理汇总了C++中IString::size方法的典型用法代码示例。如果您正苦于以下问题:C++ IString::size方法的具体用法?C++ IString::size怎么用?C++ IString::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IString
的用法示例。
在下文中一共展示了IString::size方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: attIn
/**
* This method opens a cube. If the cube is already opened, this method will
* return the cube from memory. The CubeManager class retains ownership of this
* cube pointer, so do not close the cube, destroy the pointer, or otherwise
* modify the cube object or pointer such that another object using them would
* fail. This method does not guarantee you are the only one with this pointer,
* nor is it recommended to keep this pointer out of a local (method) scope.
*
* @param cubeFileName The filename of the cube you wish to open
*
* @return Cube* A pointer to the cube object that CubeManager retains ownership
* to and may delete at any time
*/
Cube *CubeManager::OpenCube(const QString &cubeFileName) {
CubeAttributeInput attIn(cubeFileName);
IString attri = attIn.toString();
IString expName = FileName(cubeFileName).expanded();
// If there are attributes, we need a plus sign on the name
if(attri.size() > 0) {
expName += "+";
}
IString fullName = expName + attri;
QString fileName(fullName.ToQt());
QMap<QString, Cube *>::iterator searchResult = p_cubes.find(fileName);
if(searchResult == p_cubes.end()) {
p_cubes.insert(fileName, new Cube());
searchResult = p_cubes.find(fileName);
// Bands are the only thing input attributes can affect
(*searchResult)->setVirtualBands(attIn.bands());
try {
(*searchResult)->open(fileName);
}
catch(IException &e) {
CleanCubes(fileName);
throw;
}
}
// Keep track of the newly opened cube in our queue
p_opened.removeAll(fileName);
p_opened.enqueue(fileName);
// cleanup if necessary
if(p_minimumCubes != 0) {
while(p_opened.size() > (int)(p_minimumCubes)) {
QString needsCleaned = p_opened.dequeue();
CleanCubes(needsCleaned);
}
}
return (*searchResult);
}
示例2: run
//! Starts the socket thread
void SocketThread::run() {
std::string p_socketFile = ("/tmp/isis_qview_" + Application::UserName()).toAscii().data();
struct sockaddr_un p_socketName;
p_socketName.sun_family = AF_UNIX;
strcpy(p_socketName.sun_path, p_socketFile.c_str());
int p_socket;
// Create a socket
if((p_socket = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) {
std::string msg = "Unable to create socket";
std::cerr << msg << std::endl;
remove(p_socketFile.c_str());
return;
}
// Setting a timeout didn't work for Mac, so we're using a non-blocking mode
// instead.
fcntl(p_socket, F_SETFL, O_NONBLOCK);
// Bind the file to the socket
int status = bind(p_socket, (struct sockaddr *)&p_socketName, sizeof(p_socketName));
if(status < 0) {
std::string msg = "Unable to bind to socket [" + p_socketFile + "]";
std::cerr << msg << std::endl;
remove(p_socketFile.c_str());
return;
}
// Set up to listen to the socket
if(listen(p_socket, 5) < 0) {
std::string msg = "Unable to listen to socket [" + p_socketFile + "]";
std::cerr << msg << std::endl;
remove(p_socketFile.c_str());
return;
}
p_done = false;
while(!p_done) {
// Accept Socket
socklen_t len = sizeof(&p_socketName);
int childSocket = accept(p_socket, (struct sockaddr *)&p_socketName, &len);
if (childSocket < 0)
if (errno == EWOULDBLOCK) {
msleep(100);
continue; // probably timed out, we cant do anything about this anyways
}
// Receive Data
int bytes;
// This used to be char buf[1024*1024]; but when that line existed the
// mac OS's would crash unpredictably, even when the code on that
// line wasn't executed.
QScopedPointer< char, QScopedPointerArrayDeleter<char> > buf(
new char[1024*1024]);
if((bytes = recv(childSocket, buf.data(), 1024 * 1024, 0)) < 0) {
std::string msg = "Unable to read from socket [" + p_socketFile + "]";
std::cerr << msg << std::endl;
remove(p_socketFile.c_str());
return;
}
// Push everything onto our string buffer
IString buffer;
for(int i = 0; i < bytes; i++) buffer += buf.data()[i];
while(buffer.size() > 0) {
IString token = buffer.Token(" ");
if(token == "raise") {
emit focusApp();
}
else emit newImage(token.c_str());
}
};
}