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


C++ spaces函数代码示例

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


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

示例1: process

// calls either process_dir or process_file, above
static void process(const char *what, int level, int recursive,
                    char *overlapping_dems[], int *next_dem_number,
                    meta_parameters *meta, int *n_dems_total)
{
  struct stat stbuf;

  if (stat(what, &stbuf) == -1) {
    asfPrintStatus("  Cannot access: %s\n", what);
    return;
  }

  char *base = get_filename(what);

  if ((stbuf.st_mode & S_IFMT) == S_IFDIR) {
      if (level==0 || recursive) {
          asfPrintStatus("  %s%s/\n", spaces(level), base);
          process_dir(what, level+1, recursive, overlapping_dems,
              next_dem_number, meta, n_dems_total);
      }
      else {
          asfPrintStatus("  %s%s (skipped)\n", spaces(level), base);
      }
  }
  else {
      process_file(what, level, overlapping_dems, next_dem_number,
          meta, n_dems_total);
  }

  FREE(base);
}
开发者ID:glshort,项目名称:MapReady,代码行数:31,代码来源:build_dem.c

示例2: DumpType

static void DumpType(IDiaSymbol *symbol, int deep)
{
    IDiaEnumSymbols *   enumChilds = NULL;
    HRESULT             hr;
    const char *        nameStr = NULL;
    const char *        type;
    LONG                offset;
    ULONGLONG           length;
    ULONG               celt = 0;
    ULONG               symtag;
    DWORD               locType;
    bool                typeSeen;

#if 0
    if (deep > 2)
        return;
#endif

    if (symbol->get_symTag(&symtag) != S_OK)
        return;

    nameStr = GetTypeName(symbol);

    g_typesSeen.Intern(nameStr, &typeSeen);
    if (typeSeen)
        return;

    symbol->get_length(&length);
    symbol->get_offset(&offset);

    if (SymTagData == symtag) {
        if (symbol->get_locationType(&locType) != S_OK)
            return; // must be a symbol in optimized code

        // TODO: use get_offsetInUdt (http://msdn.microsoft.com/en-us/library/dd997149.aspx) ?
        // TODO: use get_type (http://msdn.microsoft.com/en-US/library/cwx3656b(v=vs.80).aspx) ?
        // TODO: see what else we can get http://msdn.microsoft.com/en-US/library/w8ae4k32(v=vs.80).aspx
        if (LocIsThisRel == locType) {
            g_report.AppendFmt("%s%s|%d\n", spaces(deep), nameStr, (int)offset);
        }
    } else if (SymTagUDT == symtag) {
        // TODO: why is it always "struct" even for classes?
        type = GetUdtType(symbol);
        g_report.AppendFmt("%s%s|%s|%d\n", spaces(deep), type, nameStr, (int)length);
        hr = symbol->findChildren(SymTagNull, NULL, nsNone, &enumChilds);
        if (!SUCCEEDED(hr))
            return;
        IDiaSymbol* child;
        while (SUCCEEDED(enumChilds->Next(1, &child, &celt)) && (celt == 1))
        {
            DumpType(child, deep+1);
            child->Release();
        }
        enumChilds->Release();
    } else {
        if (symbol->get_locationType(&locType) != S_OK)
            return; // must be a symbol in optimized code
        // TODO: assert?
    }
}
开发者ID:DavidWiberg,项目名称:sumatrapdf,代码行数:60,代码来源:main.cpp

示例3: spaces

void XmlWriter::write(const NodePtr nodeArg)
{
    NodePtr node = nodeArg;

    indent+=2;

    NamedNodeMap attributes = node->getAttributes();
    int nrAttrs = attributes.getLength();

    //### Start open tag
    spaces();
    po("<");
    pos(node->getNodeName());
    if (nrAttrs>0)
        po("\n");

    //### Attributes
    for (int i=0 ; i<nrAttrs ; i++)
        {
        NodePtr attr = attributes.item(i);
        spaces();
        pos(attr->getNodeName());
        po("=\"");
        pos(attr->getNodeValue());
        po("\"\n");
        }

    //### Finish open tag
    if (nrAttrs>0)
        spaces();
    po(">\n");

    //### Contents
    spaces();
    pos(node->getNodeValue());

    //### Children
    for (NodePtr child = node->getFirstChild() ;
         child.get() ;
         child=child->getNextSibling())
        {
        write(child);
        }

    //### Close tag
    spaces();
    po("</");
    pos(node->getNodeName());
    po(">\n");

    indent-=2;
}
开发者ID:Spin0za,项目名称:inkscape,代码行数:52,代码来源:xmlwriter.cpp

示例4: spaces

 void InfoVisitor::apply(osg::Geode& geode)
 {
     std::cout << spaces() << geode.libraryName() << "::" << geode.className() << std::endl;
     ++_level;
     osg::Drawable* drawable = nullptr;
     for (size_t i = 0; i < geode.getNumDrawables(); ++i)
     {
         drawable = geode.getDrawable(i);
         std::cout << spaces() << drawable->libraryName() << "::" << drawable->className() << std::endl;
     }
     traverse(geode);
     --_level;
 }
开发者ID:vwaurich,项目名称:OMVis,代码行数:13,代码来源:InfoVisiter.cpp

示例5: floorArea

 double Building_Impl::peoplePerFloorArea() const {
   double area = floorArea();
   double np = numberOfPeople();
   if (equal(area,0.0)) {
     if (equal(np,0.0)) {
       return 0.0;
     }
     if (spaces().size() == 1u) {
       return spaces()[0].peoplePerFloorArea();
     }
     LOG_AND_THROW("Calculation would require division by 0.");
   }
   return np / area;
 }
开发者ID:Anto-F,项目名称:OpenStudio,代码行数:14,代码来源:Building.cpp

示例6: airVolume

 double Building_Impl::infiltrationDesignAirChangesPerHour() const {
   double volume = airVolume();
   double idfr = infiltrationDesignFlowRate();
   if (equal(volume,0.0)) {
     if (equal(idfr,0.0)) {
       return 0.0;
     }
     if (spaces().size() == 1u) {
       return spaces()[0].infiltrationDesignAirChangesPerHour();
     }
     LOG_AND_THROW("Calculation would require division by 0.");
   }
   return convert(idfr/volume,"1/s","1/h").get();
 }
开发者ID:Anto-F,项目名称:OpenStudio,代码行数:14,代码来源:Building.cpp

示例7: world_free

void world_free(World *w){
	int i;	
	assert(w!=NULL);
	for(i=0; i<numobj(w);i++)
		object_free(obj(w)[i]);
	free(obj(w));
	for(i=0; i<numspaces(w);i++)
		space_free(spaces(w)[i]);
	player_free(player(w));
	free(spaces(w));
	free(w);

	return;
}
开发者ID:RodrigoDePool,项目名称:ProyProg,代码行数:14,代码来源:world.c

示例8: exteriorWallArea

 double Building_Impl::infiltrationDesignFlowPerExteriorWallArea() const {
   double area = exteriorWallArea();
   double idfr = infiltrationDesignFlowRate();
   if (equal(area,0.0)) {
     if (equal(idfr,0.0)) {
       return 0.0;
     }
     if (spaces().size() == 1u) {
       return spaces()[0].infiltrationDesignFlowPerExteriorWallArea();
     }
     LOG_AND_THROW("Calculation would require division by 0.");
   }
   return idfr/area;
 }
开发者ID:Anto-F,项目名称:OpenStudio,代码行数:14,代码来源:Building.cpp

示例9: numberOfPeople

 double Building_Impl::gasEquipmentPowerPerPerson() const {
   double np = numberOfPeople();
   double ep = gasEquipmentPower();
   if (equal(np,0.0)) {
     if (equal(ep,0.0)) {
       return 0.0;
     }
     if (spaces().size() == 1u) {
       return spaces()[0].gasEquipmentPowerPerPerson();
     }
     LOG_AND_THROW("Calculation would require division by 0.");
   }
   return ep / np;
 }
开发者ID:Anto-F,项目名称:OpenStudio,代码行数:14,代码来源:Building.cpp

示例10: gen_headings

void gen_headings( int width, int depth, int subh, char *alpha)
{
    char alphabet[100];
    int k, i;
    int count = 0;
    
    for (k = width - 1 ; k >= 0 ; k--)
    {
        count++;

        if (subh)
            sprintf(alphabet, "%s%i", alpha, ((width)- k));
        
        else
            sprintf(alphabet, "%s%c", alpha, ('a'-1) + ((width) - k ));
     
	printf("Section %s\n",alphabet);
	spaces(count);        
        if (depth == 0)
            return;
        else if ( depth != 0)
        {
            i = strlen(alphabet);
            alphabet[i] = '.';
            alphabet[i + 1] = '\0';
        }
    
    
    gen_headings(width, depth - 1, !subh,  alphabet);

    }
}
开发者ID:Dhrumil95,项目名称:AcademicProjects,代码行数:32,代码来源:outline.c

示例11: __error_gen_internal

std::string __error_gen_internal(const Location& loc, const std::string& msg, const char* type, bool context)
{
	std::string ret;

	auto colour = COLOUR_RED_BOLD;
	if(strcmp(type, "warning") == 0)
		colour = COLOUR_MAGENTA_BOLD;

	else if(strcmp(type, "note") == 0)
		colour = COLOUR_GREY_BOLD;

	// bool empty = strcmp(type, "") == 0;
	// bool dobold = strcmp(type, "note") != 0;

	//? do we want to truncate the file path?
	//? we're doing it now, might want to change (or use a flag)

	std::string filename = frontend::getFilenameFromPath(loc.fileID == 0 ? "(unknown)"
		: frontend::getFilenameFromID(loc.fileID));

	ret += strprintf("%s%s%s:%s %s\n", COLOUR_RESET, colour, type, COLOUR_RESET, msg);

	if(loc.fileID > 0)
	{
		auto location = strprintf("%s:%d:%d", filename, loc.line + 1, loc.col + 1);
		ret += strprintf("%s%sat:%s %s%s", COLOUR_RESET, COLOUR_GREY_BOLD, spaces(strlen(type) - 2), COLOUR_RESET, location);
	}

	ret += "\n";

	if(context && loc.fileID > 0)
		ret += getSingleContext(loc) + "\n";

	return ret;
}
开发者ID:flax-lang,项目名称:flax,代码行数:35,代码来源:errors.cpp

示例12: getch

void ConsoleInput::parse()
{
    if ( kbhit() )
    {
        char ch = getch();

        if( (int)ch == 13 && !mInputBuffer.empty() )
        {
            // Enter
            std::cout << "Lua: " << mInputBuffer << std::endl;
            mCommandCallback( mInputBuffer );
            String spaces( mInputBuffer.size(), ' ' );
            std::cout << spaces << "\r" << std::flush;
            mInputBuffer.clear();
        }
        else if( (int)ch == 8 && !mInputBuffer.empty() )
        {
            // Backspace
            mInputBuffer[ mInputBuffer.size() - 1 ] = ' ';
            std::cout << mInputBuffer << "\r" << std::flush;
            mInputBuffer.erase( mInputBuffer.size() - 1 );
        }
        else if( (int)ch >= 32 && (int)ch <= 126 )
        {
            // Normal input
            mInputBuffer.append( 1, ch );
        }

        std::cout << mInputBuffer << "\r" << std::flush;
    }
}
开发者ID:Gohla,项目名称:Diversia,代码行数:31,代码来源:ConsoleInput.cpp

示例13: result

 double Building_Impl::airVolume() const {
   double result(0.0);
   for (const Space& space : spaces()) {
     result += space.volume() * space.multiplier();
   }
   return result;
 }
开发者ID:Anto-F,项目名称:OpenStudio,代码行数:7,代码来源:Building.cpp

示例14: print_struct_def

int print_struct_def(struct struct_def *sdef, long long offset, char *data)
{
	struct struct_member *member; 
	struct type_info *tinfo;
	int end;

	if (sdef->type == TYPE_ENUM) {
		my_printf("0x%lx",*((int*)data));		
		return 4;
	}
	if (sdef->type != TYPE_STRUCTURE) return 0;	
	if (!sdef) {
		my_printf("Structure not found\n");
		return 0;
	}
	
	my_printf("\n");
	indent_struct(offset);
	my_printf("struct %s size=%d {\n", sdef->name, sdef->size);
	indent++;
	member = sdef->members;
	while(member != NULL) {
		indent_struct(member->offset + offset);
		col += my_printf("%s",member->name); spaces();
		tinfo = member->type;
		print_id(tinfo->id, offset + member->offset, data + (member->offset / 8));
		end = member->offset + offset + member->size;
		member = member->next;
		my_printf("\n");
	}
	indent--;
	indent_struct(end); my_printf("}");
	return sdef->size;
}
开发者ID:tushargosavi,项目名称:utils,代码行数:34,代码来源:struct_print.c

示例15: fetchContextLine

static std::string fetchContextLine(Location loc, size_t* adjust)
{
	if(loc.fileID == 0) return "";

	auto lines = frontend::getFileLines(loc.fileID);
	if(lines.size() > loc.line)
	{
		std::string orig = util::to_string(lines[loc.line]);
		std::stringstream ln;

		// skip all leading whitespace.
		bool ws = true;
		for(auto c : orig)
		{
			if(ws && c == '\t')                 { *adjust += TAB_WIDTH; continue;   }
			else if(ws && c == ' ')             { *adjust += 1; continue;           }
			else if(c == '\n')                  { break;                            }
			else                                { ws = false; ln << c;              }
		}

		return strprintf("%s%s", spaces(LEFT_PADDING), ln.str().c_str());
	}

	return "";
}
开发者ID:flax-lang,项目名称:flax,代码行数:25,代码来源:errors.cpp


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