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


C++ Column::Alignment方法代码示例

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


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

示例1: SetColumns

  /**
   * Sets the vector of Columns and writes out the first row of the file.
   * 
   * @param cols A vector of Columns, setting the format of the table
   */
  void WriteTabular::SetColumns(std::vector <Column> cols ){
    for (unsigned int index=0; index < cols.size(); index++) {
      Column thisCol = cols[index];
      std::string thisTitle = thisCol.Name();

      if (thisTitle.length() > thisCol.Width()) {
        std::string message = "Column header [" + thisTitle + "] is wider " +
          "than the set width for column [" + iString((int)index) + "]";
          throw Isis::iException::Message(Isis::iException::User,message,_FILEINFO_);
      }

      int iteration = 0;
      while (thisTitle.length() < thisCol.Width()) {
        if (thisCol.Alignment() == Column::Left) {
          thisTitle += " ";
        }
        else if (thisCol.Alignment() == Column::Right ||
                 thisCol.Alignment() == Column::Decimal) {
          thisTitle = " " + thisTitle;
        }
        else {
          std::string message = "Alignment is improperly set";
          throw Isis::iException::Message(Isis::iException::User,message,_FILEINFO_);
        }
        iteration++;
      }//end while

      p_cols.push_back(thisCol);
      p_outfile << thisTitle;
      if (index < (cols.size()-1)) {
        p_outfile << p_delimiter;
      }
    }//end for
    p_outfile << "\n";
  }//end function
开发者ID:assutech,项目名称:isis3,代码行数:40,代码来源:WriteTabular.cpp

示例2: Write

  /**
   * Add an integer value to the next column in this row
   * 
   * @param item The integer value to put in this column.
   */
  void WriteTabular::Write(int item){
    Column thisCol = p_cols[p_curCol];
    if (thisCol.DataType() != Column::Integer &&
        thisCol.DataType() != Column::Pixel) {
      if (thisCol.DataType() == Column::Real ||
          thisCol.DataType() == Column::Pixel) {
        Write((double)item);
        return;
      }
      std::string message = "Wrong data type for this Column";
      throw Isis::iException::Message(Isis::iException::User,message,_FILEINFO_);
    }
    iString thisItem(item);
    if (thisItem.length() > thisCol.Width()) {
      thisItem = "*";
      while (thisItem.length() < thisCol.Width()) {
        thisItem += "*";
      }
    }
    std::stringstream tempStream;
    tempStream.width(thisCol.Width());
    tempStream.fill(' ');

    if (thisCol.Alignment() == Column::Left) {
      tempStream.setf(std::ios::left);
    }
    else tempStream.setf(std::ios::right);

    tempStream << thisItem;
    thisItem = tempStream.str();

    if (p_curCol == 0) {
      p_rows++;
    }

    if (p_curCol < (p_cols.size()-1)) {
      thisItem += p_delimiter;
      p_curCol++;
    }
    else {
      thisItem += "\n";
      p_curCol = 0;
    }
    p_outfile << thisItem.c_str();
  }
开发者ID:assutech,项目名称:isis3,代码行数:50,代码来源:WriteTabular.cpp

示例3: Write

  /**
   * Writes a string to the next column in the current row
   *
   * @param item The string to write out
   */
  void WriteTabular::Write(const char *itemCStr) {
    Column thisCol = p_cols[p_curCol];
    if(thisCol.DataType() != Column::String &&
        thisCol.DataType() != Column::Pixel) {
      QString message = "Wrong data type for this Column";
      throw IException(IException::User, message, _FILEINFO_);
    }

    QString item(itemCStr);
    if(item.length() > (int)thisCol.Width()) {
      item = "*";
      while(item.length() < (int)thisCol.Width()) {
        item += "*";
      }
    }
    stringstream tempStream;
    tempStream.width(thisCol.Width());
    tempStream.fill(' ');

    if(thisCol.Alignment() == Column::Left) {
      tempStream.setf(std::ios::left);
    }
    else tempStream.setf(std::ios::right);

    tempStream << item;
    item = tempStream.str().c_str();

    if(p_curCol == 0) {
      p_rows++;
    }

    if(p_curCol < (p_cols.size() - 1)) {
      item += p_delimiter;
      p_curCol++;
    }
    else {
      item += "\n";
      p_curCol = 0;
    }
    p_outfile << item;
  }
开发者ID:corburn,项目名称:ISIS,代码行数:46,代码来源:WriteTabular.cpp


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