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


C++ std::atol方法代码示例

本文整理汇总了C++中std::atol方法的典型用法代码示例。如果您正苦于以下问题:C++ std::atol方法的具体用法?C++ std::atol怎么用?C++ std::atol使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在std的用法示例。


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

示例1: select

Content& Content::updateAggregate(const std::string &category, const std::string &stat, long value) {
    char *errMsg;
    stringstream select(stringstream::out), upsert(stringstream::out);
    int id= Utils::hashCode(stat + "-" + category);
    auto aggregateTable= [&value](void *tableName, int argc, char **argv, char **colName) -> int {
        value+= atol(argv[2]);
        return 0;
    };

    select << "select * from aggregate where id=" << id;
    sqlite3_exec(db, select.str().c_str(), aggregateTable, NULL, &errMsg);

    upsert << "replace into aggregate (id, stat, value, category) values (" << 
        id << ", coalesce(( select stat from aggregate where id=" << id << "),\'" << stat << "\'), \'" << value << 
        "\', coalesce(( select category from aggregate where id=" << id << "),\'" << category << "\'));";
    sqlite3_exec(db, upsert.str().c_str(), NULL, NULL, &errMsg);

    return *this;
}
开发者ID:scaryghost,项目名称:KFSXTrackingServerLite,代码行数:19,代码来源:Content.cpp

示例2: main

int main(int argc, char *argv[]) {
	if (3 <= argc && argc <= 4) {
		int nbytes= atoi(argv[2]);
		if (nbytes <= 0) {
			cerr << "bitcount: nbytes must be greater than zero\n";
			return EXIT_FAILURE;
		}
		int nthreads= (argc > 3) ? atoi(argv[3]) : 0;
		if (nthreads < 0) {
			cerr << "bitcount: nthreads must not be less than zero\n";
			return EXIT_FAILURE;
		}
		
		vector<unsigned char> space(atol(argv[2]));
		fillMemory(space);

		if (strcmp(argv[1], "shift") == 0) {
			if (nthreads == 0)
				cout << bitCount(&space[0], space.size(), bits_shift);
			else
				cout << bitCount_mt(&space[0], space.size(), nthreads, bits_shift);
			cout << endl;
			return EXIT_SUCCESS;
		}
		if (strcmp(argv[1], "lookup") == 0) {
			if (nthreads == 0)
				cout << bitCount(&space[0], space.size(), bits_lookup);
			else
				cout << bitCount_mt(&space[0], space.size(), nthreads, bits_lookup);
			cout << endl;
			return EXIT_SUCCESS;
		}
	}
	cerr << "Usage: bitcount [shift|lookup] nbytes [nthreads]\n";
	return EXIT_FAILURE;
}
开发者ID:tbfe-de,项目名称:mc-cpp11-BLWS,代码行数:36,代码来源:bitcount.cpp

示例3: main

int main(int argc, char *argv[])
{
	srand(time(NULL));
	FILE *fd;
	static size_t rand_num;
	static long rand_min = 0L;
	static long rand_max = 1000000L;

	fd = fopen("unsorted.txt", "w");
	
	switch(argc) {
	case 2:
		rand_num = atol(argv[1]);
		break;
	case 3:
		rand_num = atol(argv[1]);
		rand_max = atol(argv[2]);
		break;
	case 4:
		rand_num = atol(argv[1]);
		rand_min = atol(argv[2]);
		rand_max = atol(argv[3]);
		break;
	default:
		printf("Usage: %s rand_num\n", argv[0]);
		printf("Usage: %s rand_num rand_max\n", argv[0]);
		printf("Usage: %s rand_num rand_min rand_max\n", argv[0]);
		break;
	}//switch

	for(int i = 1; i <= rand_num; ++i) {
		if(i % 10 == 0)
			fputc('\n', fd);
		fprintf(fd,
				"%ld ",
				(long)(rand() * (rand_max - rand_min)/RAND_MAX
					+rand_min)); 
	}//for
	
	fclose(fd);
	
	return 0;
}//main
开发者ID:adamcavendish,项目名称:HomeworkGitShare,代码行数:43,代码来源:test_file_creator.cpp

示例4: cpp_main

int cpp_main(int argc, char *argv[])
{
  for (int a = 0; a < argc; ++a)
  {
    command_args += argv[a];
    if (a != argc-1)
      command_args += ' ';
  }

  cout << "command line arguments: " << command_args << '\n';

  cout << "*******************************************************************\n"
          "*  WARNING: DUMPING AND RELOADING STATE FOR RESTART NOT WORKING;  *\n"
          "*  COMMENTED OUT CODE NEEDS TO BE FIXED TO RESTART RNG AND        *\n"
          "*  DUMP AND RESTORE mapped_type DATA IF PRESENT.                  *\n"
          "*******************************************************************\n\n";

  for (; argc > 1; ++argv, --argc) 
  {
    if (*argv[1] != '-')
      path_prefix = argv[1];
    else
    {
      if (strncmp(argv[1]+1, "max=", 4) == 0)
        max = atol(argv[1]+5);
      else if (strncmp(argv[1]+1, "min=", 4) == 0)
        min = atol(argv[1]+5);
      else if (strncmp(argv[1]+1, "low=", 4) == 0)
        low = atol(argv[1]+5);
      else if (strncmp(argv[1]+1, "high=", 5) == 0)
        high = atol(argv[1]+6);
      else if (strncmp(argv[1]+1, "cycles=", 7) == 0)
        cycles = atol(argv[1]+8);
      else if (strncmp(argv[1]+1, "seed=", 5) == 0)
        rng_seed = atol(argv[1]+6);
      else if (strncmp(argv[1]+1, "node=", 5) == 0)
        node_sz = atol(argv[1]+6);
      else if (strncmp(argv[1]+1, "cache=", 6) == 0)
        cache_sz = atol(argv[1]+7);
      else if (strncmp(argv[1]+1, "dump=", 5) == 0)
        dump = atol(argv[1]+6);
      else if (strncmp(argv[1]+1, "restart", 7) == 0)
        restart = true;
      else if (strcmp(argv[1]+1, "v") == 0)
        verbose = true;
      else if ( memcmp( argv[2]+1, "sep=", 4 )==0
          && (std::ispunct(*(argv[2]+5)) || *(argv[2]+5)== '\0') )
        thou_separator = *(argv[2]+5) ? *(argv[2]+5) : ' ';
      else
      {
        cout << "Error - unknown option: " << argv[1] << "\n\n";
        argc = -1;
        break;
      }
    }
  }

  if (argc < 2) 
  {
    cout << "Usage: stl_test [Options]\n"
      "The argument n specifies the number of test cases to run\n"
      "Options:\n"
      "   path-prefix  Test files path-prefix; default '" << path_prefix << "'\n"
      "                Two files will be created; path-prefix.btr and path-prefix.stl\n"
      "   -max=#       Maximum number of test elements; default " << max << "\n"
      "   -min=#       Minimum number of test elements; default " << min << "\n"
      "   -low=#       Random key distribution low value; default 0\n"
      "   -high=#      Random key distribution high value; default max*2.\n"
      "                (high-low) must be >max, so that max is reached\n"
      "   -cycles=#    Cycle tests specified number of times; default " << cycles << "\n"
      "                -cycles=0 causes tests to cycle forever\n"
      "   -seed=#      Seed for random number generator; default "  << rng_seed << "\n"
      "   -node=#      Node size (>=128); default " << node_sz << "\n"
      "                Small node sizes increase stress\n"
      "   -cache=#     Cache size; default " << cache_sz << " nodes\n"
      "   -dump=#      Dump restart files when cycles run mod dump # == 0, except \n"
      "                dump # -1 means dump at end only, 0 means never dump;\n"
      "                default " << dump << "\n"
      "   -restart     Restart using restart files from previous run\n"
      "   -v           Verbose output statistics\n"
      "   -sep=[punct] cout thousands separator; space if punct omitted, default -sep,\n"
      "\n    Each test cycle inserts the same random values into both a btree_map\n"
      "and a std::map until the maximum number of elements is reached.\n"
      "The same sequence of random elements will then be erased, until the minimum\n"
      "number of elements is reached. The btree, std::map, and program state are\n"
      "copied to files, and the cycle ends.\n"
      "    At the maximum and minimum points of each cycle, forward iteration,\n"
      "backward iteration, find, lower_bound, and upper_bound tests are run\n"
      "against both containers. If results are not identical, the program\n"
      "issues an error message and returns 1.\n"
      "    The -restart argument causes the btree, std::map, and program to be\n"
      "initialized to the state saved in the restart files from the prior run.\n"
      ;
  }

  if (argc == -1)
    return 1;

  if (high == 0)
    high = max * 2;
//.........这里部分代码省略.........
开发者ID:Beman,项目名称:btree,代码行数:101,代码来源:stl_test.cpp


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