예제 #1
0
bool LDAPAttribute::isNotPrintable() const {
    StringList::const_iterator i;
    for(i=m_values.begin(); i!=m_values.end(); i++) {
        size_t len = i->size();
        for(size_t j=0; j<len; j++) {
            if (! isprint( (i->data())[j] ) ) {
                return true;
            }
        }
    }
    return false;
}
예제 #2
0
파일: Postgres.cpp 프로젝트: AmesianX/staff
    virtual void Execute(const std::string& sExecute, const StringList& rlsParams)
    {
      STAFF_ASSERT(m_pProvider != NULL && m_pProvider->m_pImpl->m_pConn != NULL, "Not Initialized");

      Reset();

      std::string sExecuteParams = sExecute;
      int nIndex = 1;
      std::string sIndex;
      unsigned nCount = 0;
      std::string::size_type nPos = 0;
      while ((nPos = sExecuteParams.find("?", nPos)) != std::string::npos)
      {
        ToString(nIndex, sIndex);
        sExecuteParams.replace(nPos, 1, "$" + sIndex);
        nPos += sIndex.size() + 1;
        ++nCount;
        ++nIndex;
      }

      STAFF_ASSERT(nCount == rlsParams.size(), "Params count mismatch");

      int* panParamLengths = new int[nCount];
      int* panParamFormats = new int[nCount];
      char** paszParamValues = new char*[nCount];

      try
      {
        unsigned nPos = 0;
        for (StringList::const_iterator itParam = rlsParams.begin();
             itParam != rlsParams.end(); ++itParam, ++nPos)
        {
          panParamFormats[nPos] = 0;
          if (*itParam == STAFF_DAS_NULL_VALUE)
          {
            panParamLengths[nPos] = 0;
            paszParamValues[nPos] = NULL;
          }
          else
          {
            panParamLengths[nPos] = itParam->size();
            paszParamValues[nPos] = const_cast<char*>(itParam->c_str());
          }
        }

        m_pResult = PQexecParams(m_pProvider->m_pImpl->m_pConn,
          sExecuteParams.c_str(), nCount, NULL, paszParamValues, panParamLengths, panParamFormats, 0);

        delete[] paszParamValues;
        delete[] panParamFormats;
        delete[] panParamLengths;
      }
      catch(...)
      {
        delete[] paszParamValues;
        delete[] panParamFormats;
        delete[] panParamLengths;
        throw;
      }

      ExecStatusType tQueryStatus = PQresultStatus(m_pResult);
      if (tQueryStatus != PGRES_COMMAND_OK)
      {
        STAFF_ASSERT(tQueryStatus == PGRES_TUPLES_OK, "error executing query #"
                     + ToString(tQueryStatus) + ": \n"
                     + std::string(PQerrorMessage(m_pProvider->m_pImpl->m_pConn))
                     + "\nQuery was:\n----------\n" + sExecute + "\n----------\n");

        m_nRowsCount = static_cast<unsigned>(PQntuples(m_pResult));
        m_nFieldsCount = static_cast<unsigned>(PQnfields(m_pResult));
      }
    }