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


C++ s4函数代码示例

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


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

示例1: f

//!----------------------------------------------------------------------------------------------------
//!
//! \brief GuidewareTrackingWindow::startNaigation
//!
void GuidewareTrackingWindow::startNaigation(){
    //! -----------------------------------------------------------------------
    collaborativeState = "on"; //on/off
    collaborativeName = this->patientHandling->getName();
    collaborativeType = "navi"; //standby/normal/reconstruct/reconstructed
    collaborativePath = this->patientHandling->getCTImagePath() + "navi";

    QFile f(this->configuratonFilePath);
    if(!f.open(QIODevice::WriteOnly | QIODevice::Text))
    {
        cout << "Open failed." << endl;
    }

    QTextStream txtOutput(&f);
    QString s1(collaborativeState);
    QString s2(collaborativeName);
    QString s3(collaborativeType);
    QString s4(collaborativePath);

    txtOutput << "state:" << s1 << endl;
    txtOutput << "name:" << s2 << endl;
    txtOutput << "type:" << s3 << endl;
    txtOutput << "path:" << s4 << endl;

    f.close();
    //! -----------------------------------------------------------------------
}
开发者ID:wangtseng,项目名称:piss,代码行数:31,代码来源:GuidewareTrackingWindow.cpp

示例2: capacity_test

bool capacity_test( )
{
  bool rc = true;

  std::string s1;
  std::string s2("Hello, World!");

  if( s1.capacity( ) == 0) FAIL
  if( s2.size( ) > s2.capacity( ) ) FAIL
  if( s1.empty( )    == false ) FAIL
  if( s2.empty( )    == true  ) FAIL

  s2.clear( );
  if( s2.empty( ) == false ) FAIL

  std::string s3("Hello");
  s3.resize( 2 );
  if( s3.size( ) != 2 || s3 != "He" ) FAIL

  s3.resize( 5, 'x' );
  if( s3.size( ) != 5 || s3 != "Hexxx" ) FAIL

  s3.resize( 40, 'y' );
  if( s3.size( ) != 40 ||
      s3 != "Hexxxyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy" ) FAIL

  std::string s4("Hello");
  std::string::size_type new_s4capacity = ( 7 * s4.capacity( ) ) / 2;
  s4.reserve( new_s4capacity );
  if( s4.capacity( ) < new_s4capacity || s4.size( ) != 5 || s4 != "Hello" ) {
    FAIL
  }
  return( rc );
}
开发者ID:ABratovic,项目名称:open-watcom-v2,代码行数:34,代码来源:string01.cpp

示例3: erase_test

bool erase_test( )
{
  bool rc = true;

  std::string s1( "Hello, World!" );
  s1.erase( );
  if( s1 != "" || s1.size( ) != 0 || INSANE( s1 ) ) FAIL

  std::string s2( "Hello, World!" );
  s2.erase( 2, 3 );
  if( s2 != "He, World!" || s2.size( ) != 10 || INSANE( s2 ) ) FAIL

  std::string s3( "Hello, World!" );
  s3.erase( 7, 6 );
  if( s3 != "Hello, " || s3.size( ) != 7 || INSANE( s3 ) ) FAIL

  std::string s4( "Hello, World!" );
  s4.erase( s4.begin( ) );
  if( s4 != "ello, World!" || s4.size( ) != 12 || INSANE( s4 ) ) FAIL

  std::string s5( "Hello, World!" );
  s5.erase( s5.begin( ) + 2, s5.begin( ) + 5 );
  if( s5 != "He, World!" || s5.size( ) != 10 || INSANE( s5 ) ) FAIL

  return( rc );
}
开发者ID:ABratovic,项目名称:open-watcom-v2,代码行数:26,代码来源:string01.cpp

示例4: main

//===========================================================================
int main ()
{
    // Define, output default constructed value
    string s1("blah");
    std::cout << "string 1: ";
    std::cout << s1;
    std::cout << "\n";

    // Define, output 1 digit number
    string s2("pooltable");
    std::cout << "string 2: ";
    std::cout << s2;
    std::cout << "\n";

    // Define, output 3 digit number
    string s3("crazy man");
    std::cout << "string 2: ";
    std::cout << s3;
    std::cout << "\n";

    // Define, output 90 digit number
    string s4("this project is really hard to understand, as a cs major i have no life.");
    std::cout << "string 3: ";
    std::cout << s4;
    std::cout << "\n";

}
开发者ID:stakere,项目名称:CS33001,代码行数:28,代码来源:test_output.cpp

示例5: TEST

TEST(functor_call_traits, non_const_this_ref_functor) {
  member_op f;
  member_op const &cf = f;

  functor_call_traits functor;

  EXPECT_THROW(functor(f, 0l, 0.0, 0, ""), std::exception);

  EXPECT_EQ(3.1415926, functor_call_traits::call(cf));
  functor_call_traits::call(f);
  EXPECT_EQ(5.6, functor_call_traits::call(cf));

  std::string s1("hello");
  char const *s2 = ", ";
  std::string const s3("world");
  std::string s4("!");
  std::string out("some test string");

  EXPECT_EQ(17, functor(f, 17));

  EXPECT_EQ(
    s1.size() + std::strlen(s2) + s3.size() + s4.size(),
    (functor(f, s1, s2, s3, s4, out))
  );
  EXPECT_EQ("hello, world!", out);

  typedef std::integral_constant<int, functor(f, 2, 3, 5)> c;

  EXPECT_EQ(2 + 3 + 5, c::value);

  EXPECT_EQ(57, functor(f, 57, true));
  EXPECT_EQ(-57, functor(f, 57, false));
}
开发者ID:amidvidy,项目名称:fatal,代码行数:33,代码来源:call_traits_test.cpp

示例6: s1

void StdStringTestCase::StdConstructors()
{
    wxString s1(wxT("abcdefgh")),
             s2(wxT("abcdefghijklm"), 8),
             s3(wxT("abcdefghijklm")),
             s4(8, wxT('a'));
    wxString s5(s1),
             s6(s3, 0, 8),
             s7(s3.begin(), s3.begin() + 8);
    wxString s8(s1, 4, 8);

    CPPUNIT_ASSERT_EQUAL( wxT("abcdefgh"), s1 );
    CPPUNIT_ASSERT_EQUAL( s1, s2 );
    CPPUNIT_ASSERT_EQUAL( wxT("aaaaaaaa"), s4 );
    CPPUNIT_ASSERT_EQUAL( wxT("abcdefgh"), s5 );
    CPPUNIT_ASSERT_EQUAL( s1, s6 );
    CPPUNIT_ASSERT_EQUAL( s1, s7 );
    CPPUNIT_ASSERT_EQUAL( wxT("efgh"), s8 );

    const char *pc = s1.c_str();
    CPPUNIT_ASSERT_EQUAL( "bcd", wxString(pc + 1, pc + 4) );

    const wchar_t *pw = s2.c_str();
    CPPUNIT_ASSERT_EQUAL( "a", wxString(pw, pw + 1) );
}
开发者ID:Metallicow,项目名称:wxWidgets,代码行数:25,代码来源:stdstrings.cpp

示例7: strStd

void StdStringTestCase::StdConversion()
{
    std::string strStd("std::string value");
    wxStdWideString strStdWide(L"std::wstring value");

    wxString s1(strStd);
    CPPUNIT_ASSERT_EQUAL( "std::string value", s1 );

    wxString s2(strStdWide);
    CPPUNIT_ASSERT_EQUAL( "std::wstring value", s2 );

    wxString s3;
    s3 = strStd;
    CPPUNIT_ASSERT_EQUAL( "std::string value", s3 );
    s3 = strStdWide;
    CPPUNIT_ASSERT_EQUAL( "std::wstring value", s3 );

    wxString s4("hello");

    // wxString -> std::string conversion is only available in wxUSE_STL case,
    // because it conflicts with conversion to const char*/wchar_t*:
#if wxUSE_STL
    std::string s5 = s4;
    CPPUNIT_ASSERT_EQUAL( "hello", s5 );

    wxStdWideString s6 = s4;
    CPPUNIT_ASSERT_EQUAL( "hello", s6 );
#endif

    std::string s7(s4);
    CPPUNIT_ASSERT( s7 == "hello" );

    wxStdWideString s8(s4);
    CPPUNIT_ASSERT( s8 == "hello" );
}
开发者ID:czxxjtu,项目名称:wxPython-1,代码行数:35,代码来源:stdstrings.cpp

示例8: createStudents

std::vector<Student> createStudents()
{
	Student s1("Dimitar",
		"Radenkov",
		28,
		"08889793457",
		"[email protected]",
		std::vector < int > {1, 2, 3, 5});

	Student s2("Ralica",
		"Vaskova",
		32,
		"088998899889",
		"[email protected]",
		std::vector < int > {4, 2, 3, 4});

	Student s3("Nikol",
		"Georgieva",
		18,
		"08989898989",
		"[email protected]",
		std::vector < int > {2, 2, 2, 2});

	Student s4("Alexander",
		"Radenkov",
		19,
		"08989898989",
		"[email protected]",
		std::vector < int > {6, 6, 6, 6});

	std::vector<Student> students{ s1, s2, s3, s4 };

	return students;
}
开发者ID:mitko100,项目名称:CPlusPlus,代码行数:34,代码来源:main.cpp

示例9: insert

void insert()
{
/*       MemStat memStat("insert");    */
    String s1("1234", 5), s2("1234");
    String s3("1235", 4), s4("1232");
    String s5;

    insert2();
    cout << "insert" << endl;
    s1.insert(1, s1.cStr());
    assert(s1.length() ==  9);
    s2.insert(1, s2);
    assert(s2.length() ==  8 && s2 == "11234234");
    s5.insert(0, s3);
    assert(s3 == s5);
    s5.insert(2, "abcdef", 4);
    assert(s5 == "12abcd35");
    s3.insert(s3.length(), "abcd");
    assert(s3 == ((String)("1235") + "abcd"));
    s3 = "1234";
    s3.insert(0, 'x', 5);
    assert(s3 == "xxxxx1234");
    s3 = "1234";
    s3.insert(2, 'x', 5);
    assert(s3 == "12xxxxx34");
    s3 = "1234";
    s3.insert(s3.length(), 'x', 5);
    assert(s3 == "1234xxxxx");
}
开发者ID:ABratovic,项目名称:open-watcom-v2,代码行数:29,代码来源:strtest.c

示例10: main

int main(void)
{
	static const struct st3 a = {1, 2, 3, 4, 5, 6};

	l1(100);
	l2(100, 200);
	l3(100, 200, 300);
	l4(100, 200, 300, 400);
	l5(100, 200, 300, 400, 500);
	l6(100, 200, 300, 400, 500, 600);
	l7(100, 200, 300, 400, 500, 600, 700);
	l8(100, 200, 300, 400, 500, 600, 700, 800);

	d1();
	d2(43);
	d3(100, 200);
	d4(a);
	d5('a', 43, a);
	d6('a', 1);

	c1(44);
	c2(100, 'a', 3.4);
	c3(200, 2.777, 'q');
	c4(200, 1);
	c5(1.1, 2.2);
	c6(1.23, 45.6);
	c7('z', 0x200);

	a1('a');
	a2(10);
	a3(20);
	a4(102030405060LL);

	b1('a', 20);
	b2(30, 'b');
	b3(10, 20, 30, 40, 50, 60);

	s1(sx);
	s1p(&sx);
	s2(sy);
	s3(sz);
	s4(sq);
	s5(sa);
	s6(sb);

	r1();
	r3();
	r4();

	q1(200, sx);
	q2(300, 't', sx);
	q3(400, 410, sy);
	q4(500, 510, sq);
	q5(600, 610, 'z', 'q', sq);

	real1("fresh air");
	real2();

	return 0;
}
开发者ID:jkkm,项目名称:latrace,代码行数:60,代码来源:test1.c

示例11: compare

void compare()
{
/*       MemStat memStat("compare");    */
    String s1("1234", 5), s2("1234");
    String s3("1235", 5), s4("1232");
    String s5;

    cout << "compare" << endl;
    assert(s1.compare(s2) != 0);
    assert(compare(s1,s2) != 0);
    assert(s2.compare(s2) == 0);
    assert(s2.compare("12345", 4) == 0);
    assert(s1.compare(s3) < 0);
    assert(compare(s2, s3) < 0);
    assert(compare(s2, "1235") < 0);
    assert(compare("1235", s2) > 0);
    assert(s1.compare(s4) > 0);
    assert(s2.compare(s5) > 0);
    assert(s5.length() == 0);
    assert(s5.compare("") == 0);
    assert(compare(s5,"") == 0);
    assert(compare("",s5) == 0);
    assert(s1 != "1234");
    assert(s2 == "1234");
    assert("1234" == s2);
    assert("1234" != s1);
}
开发者ID:ABratovic,项目名称:open-watcom-v2,代码行数:27,代码来源:strtest.c

示例12: main

int main()
{
    char text[] = "world";

    String s0;
    String s1("hello");
    String s2(s0);
    String s3 = s1;
    String s4(text);
    s2 = s1;

    foo(s1);
    bar(s1);
    foo("temporary");
    bar("temporary");
    String s5 = baz();

    std::vector<String> svec;
    svec.reserve(8);
    svec.push_back(s0);
    svec.push_back(s1);
    svec.push_back(s2);
    svec.push_back(s3);
    svec.push_back(s4);
    svec.push_back(s5);
    svec.push_back(baz());
    svec.push_back("good job");

    for (const auto &s : svec) {
        std::cout << s.c_str() << std::endl;
    }
}
开发者ID:ceye1992,项目名称:learn,代码行数:32,代码来源:13.48.cpp

示例13: ReadFilterData

void ReadFilterData(bool reload)
{
	static bool loaded = false;
	if (!loaded || reload)
	{
		loaded = true;

		QFile f1("berichten/forbidden_sentences.txt");
		QFile f2("berichten/forbidden_start.txt");
		QFile f3("berichten/forbidden_sentences_ai.txt");
		QFile f4("berichten/forbidden_start_ai.txt");

		f1.open(QIODevice::ReadOnly | QIODevice::Text);
		f2.open(QIODevice::ReadOnly | QIODevice::Text);
		f3.open(QIODevice::ReadOnly | QIODevice::Text);
		f4.open(QIODevice::ReadOnly | QIODevice::Text);

		QTextStream s1(&f1);
		QTextStream s2(&f2);
		QTextStream s3(&f3);
		QTextStream s4(&f4);

		disallowed_contents = s1.readAll().split('\n');
		disallowed_begins = s2.readAll().split('\n');
		disallowed_contents_ai = s3.readAll().split('\n');
		disallowed_begins_ai = s4.readAll().split('\n');
	}
}
开发者ID:het-gekke-robotje,项目名称:pa-chatbot-qt-v4.2,代码行数:28,代码来源:PAChatClientFilter.cpp

示例14: test

void test() {

    Pboom boom;

    StringMetBits s1("alfa");
    StringMetBits s2("beta");
    StringMetBits s3("delt");
    StringMetBits s4("jaja");
    StringMetBits s5("baby");

    boom.insert(s1);
    boom.insert(s1);

    boom.insert(s2);
    boom.insert(s2);
    boom.insert(s2);

    boom.insert(s3);

    boom.insert(s4);

    boom.insert(s5);
    boom.insert(s5);

    std::cout << s1 << ": " << boom.get(s1) << std::endl;
    std::cout << s2 << ": " << boom.get(s2) << std::endl;
    std::cout << s3 << ": " << boom.get(s3) << std::endl;
    std::cout << s4 << ": " << boom.get(s4) << std::endl;
    std::cout << s5 << ": " << boom.get(s5) << std::endl;
}
开发者ID:ahluntang,项目名称:tiwi-algoritmen,代码行数:30,代码来源:main.cpp

示例15: TEST

TEST(ArrayTest, getNumRows) {
	TwoDArray<int> i4(10, 5, 42);
	TwoDArray<double> d4(2, 9, 9.9);
	TwoDArray<std::string> s4(6, 8, "e");
  EXPECT_EQ(10, i4.access(8,2));
  EXPECT_EQ(2, d4.access(0,0));
  EXPECT_EQ(6, s4.access(5,7));	
}
开发者ID:mkindt,项目名称:2dArrays,代码行数:8,代码来源:array_gtest.cpp


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