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


C++ StringStack类代码示例

本文整理汇总了C++中StringStack的典型用法代码示例。如果您正苦于以下问题:C++ StringStack类的具体用法?C++ StringStack怎么用?C++ StringStack使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: main

int
main(void)
{
	StringStack	stack;

	//用初始化构造函数构造一个字符串常量数组
	MyString	my[] = {
		MyString("hello"), 
		MyString("programmer"), 
		MyString("It`s a nice day"), 
		MyString("keep do it"), 
		MyString("Never give up") 
	};

	//字符串常量指针入栈,注意存的是指针,所以采用取地址操作
	for (int i = 0; i < sizeof my / sizeof *my; i++) {
		stack.push(&my[i]);
	}

	//返回的是一个常量对象指正,故只有常量成员函数才能调用
	const MyString* cm;
	for (int i = 0; i < sizeof my / sizeof *my; i++) {
		//注意此处cm是指针,直接进行赋值即可不需要进行取地址操作
		cm = stack.pop();
		cm->print();
	}

	return 0;
}
开发者ID:forzenheart,项目名称:Thinking-In-C-resource,代码行数:29,代码来源:c0820.cpp

示例2: _ctp_end_brackets

inline void _ctp_end_brackets(POSTFIX &postfix, StringStack &oper_stack)
{
	while(oper_stack.getSize())
	{
		if(oper_stack.get_last()=="("){
			oper_stack.remove();
			break;
		}
		
		String s;
		
		s=oper_stack.get_last();
		oper_stack.remove();
		
		if(isalpha(s[0])) {
			//don't worry: this seems allright!!!
			String name;
			name="'";
			name+=s;
			postfix.add(name);
		}else{
			postfix.add(s);
		}
		
			
			
				
	}
}
开发者ID:tdrhq,项目名称:openmath,代码行数:29,代码来源:expression_working.cpp

示例3: reverse_stack

void reverse_stack(StringStack &from, StringStack &to){
	while(from.get_top_position()){
		
		to.add(from.get_last());
		from.remove();
		
	}
}
开发者ID:tdrhq,项目名称:openmath,代码行数:8,代码来源:expression_working.cpp

示例4: main

int main() {
  StringStack ss;
  for(int i = 0; i < iCsz; i++)
    ss.push(&iceCream[i]);
  const string* cp;
  while((cp = ss.pop()) != 0)
    cout << *cp << endl;
} ///:~
开发者ID:archfp,项目名称:floorplan,代码行数:8,代码来源:StringStack.cpp

示例5: main

int main() {
  StringStack ss;
  for (int i = 0; i < iCsz; i++)
    ss.push(&iceCream[i]);

  const MyString *cp;
  while((cp = ss.pop()) != NULL)
	  cp->print();
}
开发者ID:taras-ko,项目名称:br-eckel,代码行数:9,代码来源:StringStack.cpp

示例6: main

int main() {
	StringStack ss;
	for (int i = 0; i < iCsz; i++)
		ss.push(new MyString(&iceCream[i]));
	const MyString* cp;
	
	while ((cp = ss.pop()) != 0) {
		cp->print();
		delete cp;
	}
} ///:~
开发者ID:aadarshasubedi,项目名称:B.Eckel-Thinking-in-CPP-vol.1,代码行数:11,代码来源:Ex20.cpp

示例7: main

int main() {
    StringStack ss;
    myString* ms;
    for(int i = 0; i < iCsz; i++){
	ms = new myString(iceCream[i]);
	ss.push(ms);
    }
    const myString* cp;
    while((cp = ss.pop()) != 0)
	cout << cp->str << endl;
}
开发者ID:chenxuehu2016,项目名称:thinking-in-cpp,代码行数:11,代码来源:ex20.cpp

示例8: main

int main(int argc, char const *argv[])
{
	StringStack SS;
	for (int i = 0; i < ICsz; ++i)
	{
		SS.push(iceCream[i]);
	}
	const char* cp;
	while((cp = SS.pop()) != 0)
		cout << cp << endl;
	return 0;
}
开发者ID:songshuangkk,项目名称:Arch,代码行数:12,代码来源:enum2.cpp

示例9: main

int main() {
  ifstream in("InheritStack.cpp");
  assure(in, "InheritStack.cpp");
  string line;
  StringStack textlines;
  while(getline(in, line))
    textlines.push(new string(line));
  string* s;
  while((s = textlines.pop()) != 0) { // No cast!
    cout << *s << endl;
    delete s;
  }
} ///:~
开发者ID:archfp,项目名称:floorplan,代码行数:13,代码来源:InheritStack.cpp

示例10: DoDirs

bool CommandLineInterface::DoDirs()
{

    StringStack tempStack;
    
    std::string cwd;
    if (!GetCurrentWorkingDirectory(cwd))
    {
        return false;
    }
    
    // cwd is top of stack
    if (m_RawOutput)
    {
        m_Result << cwd;
    }
    else
    {
        AppendArgTagFast(sml_Names::kParamDirectory, sml_Names::kTypeString, cwd);
    }
    
    // print rest of stack making a new one
    while (m_DirectoryStack.size())
    {
        if (m_RawOutput)
        {
            m_Result << ' ' << m_DirectoryStack.top();
        }
        else
        {
            AppendArgTagFast(sml_Names::kParamDirectory, sml_Names::kTypeString, m_DirectoryStack.top());
        }
        
        tempStack.push(m_DirectoryStack.top());
        m_DirectoryStack.pop();
    }
    
    // put the old stack back together
    while (tempStack.size())
    {
        m_DirectoryStack.push(tempStack.top());
        tempStack.pop();
    }
    return true;
}
开发者ID:SoarGroup,项目名称:Soar,代码行数:45,代码来源:cli_file_system_cmds.cpp

示例11: main

/** Test-driving code for StringStacks.
 */
int main() {
   StringStack* testStack = new StringStack();
   cout << "Pushing \"AAA\" ... ";        //no "endl", keep next on same line
   testStack->push("AAA"); 
   cout << "Pushing \"BBB\" ... " << endl;
   testStack->push("BBB"); 
   cout << "Size is now " << testStack->size() << endl;
   testStack->pop();
   cout << "Pop---size is now " << testStack->size() << endl;
   string c = testStack->pop();
   cout << "I popped the string \""
        << c << "\", size now " << testStack->size() << endl;
   cout << "Can I pop again?" << endl;
   string d = testStack->pop();
   cout << "Oops!  I got: \"" << d << "\"" << endl;
   //delete(testStack);
   StringStack test2 = (*testStack);
   return (0);
}
开发者ID:Oswamano,项目名称:SchoolProjects,代码行数:21,代码来源:StringClient.cpp

示例12: doType

void MessageGenerator::doType(StringStack& parent, int indent, const char* tag, IXmlType* type, StringBuffer& buf)
{
    const char* typeName = type->queryName();

    if (type->isComplexType())
    {
        if (typeName && std::find(parent.begin(),parent.end(),typeName) != parent.end())
        {
            //DBGLOG("Recursive type: %s, ignored", type->queryName());
        }
        else 
        {
            int flds = type->getFieldCount();
            for (int i=0; i<flds; i++)
            {
                const char* fldName = type->queryFieldName(i);
                buf.appendf("<%s>", fldName);
                if (typeName)
                    parent.push_back(typeName);
                doType(parent,indent+1,fldName,type->queryFieldType(i),buf);
                buf.appendf("</%s>", fldName);
                if (typeName)
                    parent.pop_back();
            }
        }
    }
    else if (type->isArray())
    {
        if (typeName && std::find(parent.begin(),parent.end(),typeName) != parent.end())
        {
            //DBGLOG("Recursive type: %s, ignored", type->queryName());
        }
        else
        {
            const char* itemName = type->queryFieldName(0);
            IXmlType* itemType = type->queryFieldType(0);
            if (typeName)
                parent.push_back(typeName);
            for (int i=0; i<m_items; i++)
            {
                buf.appendf("<%s>", itemName);
                doType(parent,indent+2,itemName, itemType, buf);
                buf.appendf("</%s>", itemName);
            }
            if (m_ecl2esp)
                buf.appendf("<%s/>", itemName);
            if (typeName)
                parent.pop_back();
        }
    }
    else
    {
        //TODO: handle restriction etc
        if (strcmp(typeName,"string")==0) // string type: [tag-typeName]
        {
            if (m_gx)
                buf.append("*** MISSING ***");
            else
                if (m_ecl2esp)
                    buf.append("[?]");
                else
                    buf.appendf("[%s]", tag);
        }
        else
            setDefaultValue(buf,type,tag);
    }
}
开发者ID:AlexLuya,项目名称:HPCC-Platform,代码行数:67,代码来源:msggenerator.cpp

示例13: ScreenUpdates_Enable

void ScreenUpdates_Enable (void)
{
	ASSERT_MESSAGE(!ScreenUpdates_Enabled(), "screen updates already enabled");
	g_wait_stack.pop_back();
	if (g_wait_stack.empty()) {
		map::AutoSaver().startTimer();
		gtk_grab_remove(GTK_WIDGET(g_wait.m_window));
		destroy_floating_window(g_wait.m_window);
		g_wait.m_window = 0;
	} else if (GTK_WIDGET_VISIBLE(g_wait.m_window)) {
		gtk_label_set_text(g_wait.m_label, g_wait_stack.back().c_str());
		ScreenUpdates_process();
	}
}
开发者ID:AresAndy,项目名称:ufoai,代码行数:14,代码来源:mainframe.cpp

示例14: warnf

const char *execute(S32 argc, const char *argv[])
{
#ifdef TORQUE_MULTITHREAD
   if(isMainThread())
   {
#endif
      Namespace::Entry *ent;
      StringTableEntry funcName = StringTable->insert(argv[0]);
      ent = Namespace::global()->lookup(funcName);

      if(!ent)
      {
         warnf(ConsoleLogEntry::Script, "%s: Unknown command.", argv[0]);

         // Clean up arg buffers, if any.
         STR.clearFunctionOffset();
         return "";
      }
      return ent->execute(argc, argv, &gEvalState);
#ifdef TORQUE_MULTITHREAD
   }
   else
   {
      SimConsoleThreadExecCallback cb;
      SimConsoleThreadExecEvent *evt = new SimConsoleThreadExecEvent(argc, argv, false, &cb);
      Sim::postEvent(Sim::getRootGroup(), evt, Sim::getCurrentTime());
      
      return cb.waitForResult();
   }
#endif
}
开发者ID:Adhdcrazzy,项目名称:Torque3D,代码行数:31,代码来源:console.cpp

示例15: dSprintf

//------------------------------------------------------------------------------
const char *execute(SimObject *object, S32 argc, const char *argv[], bool thisCallOnly)
{
   static char idBuf[16];
   if(argc < 2)
      return "";

   // [neo, 10/05/2007 - #3010]
   // Make sure we don't get recursive calls, respect the flag!   
   // Should we be calling handlesMethod() first?
   if( !thisCallOnly )
   {
      ICallMethod *com = dynamic_cast<ICallMethod *>(object);
      if(com)
         com->callMethodArgList(argc, argv, false);
   }

   if(object->getNamespace())
   {
      dSprintf(idBuf, sizeof(idBuf), "%d", object->getId());
      argv[1] = idBuf;

      StringTableEntry funcName = StringTable->insert(argv[0]);
      Namespace::Entry *ent = object->getNamespace()->lookup(funcName);

      if(ent == NULL)
      {
         //warnf(ConsoleLogEntry::Script, "%s: undefined for object '%s' - id %d", funcName, object->getName(), object->getId());

         // Clean up arg buffers, if any.
         STR.clearFunctionOffset();
         return "";
      }

      // Twiddle %this argument
      const char *oldArg1 = argv[1];
      dSprintf(idBuf, sizeof(idBuf), "%d", object->getId());
      argv[1] = idBuf;

      SimObject *save = gEvalState.thisObject;
      gEvalState.thisObject = object;
      const char *ret = ent->execute(argc, argv, &gEvalState);
      gEvalState.thisObject = save;

      // Twiddle it back
      argv[1] = oldArg1;

      return ret;
   }
   warnf(ConsoleLogEntry::Script, "Con::execute - %d has no namespace: %s", object->getId(), argv[0]);
   return "";
}
开发者ID:Adhdcrazzy,项目名称:Torque3D,代码行数:52,代码来源:console.cpp


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