本文整理汇总了C++中ca函数的典型用法代码示例。如果您正苦于以下问题:C++ ca函数的具体用法?C++ ca怎么用?C++ ca使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ca函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ShortSave
/** Save a QPolygon to a stream in a shorter form. */
void ShortSave(QDataStream & s, const QPolygon& a)
{
//first, check if we _can_ do this the short way...
QRect bBox = a.boundingRect();
if (bBox.width() <= 254 && bBox.height() <= 254)
{
//qDebug("using 8 bits format");
//ok, we can do our own saving in 8 bits format to save space
s << (qint8) 1; //set flag to say we used this format :-)
QPoint topLeft = bBox.topLeft(); //get the coordinates of the top left of the box
s << topLeft;
QPolygon ca(a);
ca.translate(-topLeft.x(), -topLeft.y()); // translate the box so it's top left on (0,0)
//now, all points in the array fit into 16 bits!
s << (quint32) ca.count();
for (int i = 0; i < ca.count(); i++)
{
s << (quint8) ca.at(i).x();
s << (quint8) ca.at(i).y();
}
}
else if (bBox.width() < 65500 && bBox.height() < 65500)
{
//qDebug("using 16 bits format");
//ok, we can do our own saving in 16 bits format to save space
s << (qint8) 2; //set flag to say we used this format :-)
QPoint topLeft = bBox.topLeft(); //get the coordinates of the top left of the box
s << topLeft;
QPolygon ca(a);
ca.translate(-topLeft.x(), -topLeft.y()); // translate the box so it's top left on (0,0)
//now, all points in the array fit into 32 bits!
s << (quint32) ca.count();
for (int i = 0; i < ca.count(); i++)
{
s << (quint16) ca.at(i).x();
s << (quint16) ca.at(i).y();
}
}
else
{
//qDebug("using long 32 bits format.");
//too big. We need to use the normal 2x32 bits format :-(
s << (qint8) 4; //we need to set a flag that we use the normal format
s << a;
}
}
示例2: ca
LRESULT C_BranchProperties::OnColour(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
C_STLException::install();
try {
if (m_pBranch) {
C_ColourAreaPtr ca(m_pBranch);
if (ca) {
HWND wnd = reinterpret_cast<HWND>(lParam);
if (wnd == m_btnFill.m_hWnd) {
ca->put_FillColour(wParam);
if (m_pMap) {
m_pMap->RedrawAll();
}
}
/*else if (wnd == m_btnOutline.m_hWnd) {
ca->put_BorderColour(wParam);
}*/
}
}
}
catch (C_STLNonStackException const &exception) {
exception.Log(_T("Exception in C_BranchProperties::"));
}
return S_OK;
}
示例3: CONST_COMMITABLE_CAST
void MarkerStorage::generateMarkers(PCube fromCube, const Area* fromArea)
{
Context* context = Context::getContext();
CPDatabase db = CONST_COMMITABLE_CAST(Database, context->getParent(fromCube));
PEngineBase engine = context->getServer()->getEngine(EngineBase::CPU, false);
PCubeArea ca(new CubeArea(db, fromCube, *fromArea));
PArea area = ca->expandStar(CubeArea::BASE_ELEMENTS);
//go through string storage
PSourcePlanNode sn(new SourcePlanNode(fromCube->getStringStorageId(), area, fromCube->getObjectRevision()));
PProcessorBase cs = engine->createProcessor(sn, true);
while (cs->next()) {
addMarker(cs->getKey());
}
//go through numeric storage
sn.reset(new SourcePlanNode(fromCube->getNumericStorageId(), area, fromCube->getObjectRevision()));
cs = engine->createProcessor(sn, true);
while (cs->next()) {
addMarker(cs->getKey());
}
//go through marker storage
sn.reset(new SourcePlanNode(fromCube->getMarkerStorageId(), area, fromCube->getObjectRevision())); // TODO: -jj- right version object?
cs = engine->createProcessor(sn, true);
while (cs->next()) {
addMarker(cs->getKey());
}
//go through changedCells
PCellMapPlanNode cmpn(new CellMapPlanNode(fromCube->getMarkerStorageId(), area));
cs = engine->createProcessor(cmpn, true);
while (cs->next()) {
addMarker(cs->getKey());
}
}
示例4: TEST
/* ****************************************************************************
*
* check_json -
*/
TEST(ContextAttributeResponseVector, check_json)
{
ContextAttributeResponseVector carV;
ContextAttribute ca("caName", "caType", "caValue");
ContextAttributeResponse car;
std::string out;
const char* outfile1 = "ngsi10.contextAttributeResponse.check1.valid.json";
const char* outfile2 = "ngsi10.contextAttributeResponse.check2.valid.json";
ConnectionInfo ci(JSON);
// 1. ok
car.contextAttributeVector.push_back(&ca);
carV.push_back(&car);
out = carV.check(&ci, UpdateContextAttribute, "", "", 0);
EXPECT_STREQ("OK", out.c_str());
// 2. Predetected Error
out = carV.check(&ci, UpdateContextAttribute, "", "PRE ERROR", 0);
EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outfile1)) << "Error getting test data from '" << outfile1 << "'";
EXPECT_STREQ(expectedBuf, out.c_str());
// 3. Bad ContextAttribute
ContextAttribute ca2("", "caType", "caValue");
car.contextAttributeVector.push_back(&ca2);
out = carV.check(&ci, UpdateContextAttribute, "", "", 0);
EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outfile2)) << "Error getting test data from '" << outfile2 << "'";
EXPECT_STREQ(expectedBuf, out.c_str());
}
示例5: check
static void check(const UString& dati_cert, const UString& dati_ca)
{
U_TRACE(5,"check(%p,%p)", &dati_cert, &dati_ca)
UCertificate c(dati_cert);
UCertificate ca(dati_ca);
UVector<UString> vec1, vec2;
(void) c.getCAIssuers(vec1);
(void) c.getRevocationURL(vec2);
cout << c << '\n'
<< c.isSelfSigned() << '\n'
<< c.isIssued(ca) << '\n'
<< c.getIssuer() << '\n'
// << c.getIssuerForLDAP() << '\n'
<< c.getSubject() << '\n'
<< c.getVersionNumber() << '\n'
<< c.getSerialNumber() << '\n'
<< c.hashCode() << '\n'
<< c.getNotBefore() << '\n'
<< c.getNotAfter() << '\n'
<< c.checkValidity() << '\n'
<< vec1 << '\n'
<< vec2 << '\n';
UString encoded = c.getEncoded("PEM");
/*
UFile::writeTo("certificate.encode", encoded);
U_ASSERT( dati_cert == encoded )
*/
}
示例6: glog
// fuse::read
int AutoHttpFs::read(const char* path, char* buf, size_t size, off_t offset, struct fuse_file_info* ffi)
{
AutoHttpFsContext* ctx = AUTOHTTPFSCONTEXTS.find(ffi->fh);
glog(Log::DEBUG, ">> %s(%s) ffi=%p, fh=%"FINT64"d, ctx=%p, size=%"FINT64"d, offset=%"FINT64"d\n", \
__FUNCTION__, path, ffi, ffi->fh, ctx, (off_t)size, offset);
if(ffi->fh==0) return -EINVAL;
// for proc/.
if(ctx->proc) return ctx->proc->read(glog, buf, size, offset);
// for normal files.
UrlStat us;
int r = ctx->get_attr(glog, path, us);
if(r!=0) return r;
if(!us.is_reg()) return -EINVAL;
if((uint64_t)offset>=us.length) return 0;
if((uint64_t)offset+(uint64_t)size>=us.length) {
size = us.length - offset;
}
if(size<0) return 0;
CurlAccessor ca(path);
r = ca.get(glog, buf, offset, size);
if((r==200)||(r==206)) return size;
return -ENOENT;
}
示例7: c
void tst_Q3CString::constructor()
{
Q3CString a;
Q3CString b; //b(10);
Q3CString c("String C");
char tmp[10];
tmp[0] = 'S';
tmp[1] = 't';
tmp[2] = 'r';
tmp[3] = 'i';
tmp[4] = 'n';
tmp[5] = 'g';
tmp[6] = ' ';
tmp[7] = 'D';
tmp[8] = 'X';
tmp[9] = '\0';
Q3CString d(tmp,9);
Q3CString ca(a);
Q3CString cb(b);
Q3CString cc(c);
QCOMPARE(a,ca);
QVERIFY(a.isNull());
QVERIFY(a == Q3CString(""));
QCOMPARE(b,cb);
QCOMPARE(c,cc);
QCOMPARE(d,(Q3CString)"String D");
Q3CString null(0);
QVERIFY( null.isNull() );
QVERIFY( null.isEmpty() );
Q3CString empty("");
QVERIFY( !empty.isNull() );
QVERIFY( empty.isEmpty() );
}
示例8: TEST
/* ****************************************************************************
*
* check_json -
*/
TEST(AppendContextElementResponse, check_json)
{
AppendContextElementResponse acer;
ContextAttributeResponse car;
ContextAttribute ca("", "TYPE", "VALUE"); // empty name, thus provoking error
std::string out;
const char* outfile1 = "ngsi10.appendContextElementRequest.check1.postponed.json";
const char* outfile2 = "ngsi10.appendContextElementRequest.check2.postponed.json";
ConnectionInfo ci;
utInit();
// 1. predetected error
ci.outMimeType = JSON;
out = acer.check(&ci, IndividualContextEntity, "", "PRE ERR", 0);
EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outfile1)) << "Error getting test data from '" << outfile1 << "'";
EXPECT_STREQ(expectedBuf, out.c_str());
// 2. bad contextAttributeResponseVector
car.contextAttributeVector.push_back(&ca);
acer.contextAttributeResponseVector.push_back(&car);
out = acer.check(&ci, IndividualContextEntity, "", "", 0);
EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outfile2)) << "Error getting test data from '" << outfile2 << "'";
EXPECT_STREQ(expectedBuf, out.c_str());
// 3. OK
ca.name = "NAME";
out = acer.check(&ci, IndividualContextEntity, "", "", 0);
EXPECT_EQ("OK", out);
utExit();
}
示例9: main
int main() {
ContoCorrente cc(1000);
cc.preleva(300);
cc.deposita(700);
ContoArancio ca(cc, 500);
ca.preleva(100);
}
示例10: main
int main(int argc, char *argv[])
{
if (argc == 2)
{
QCoreApplication ca(argc, argv);
if (ca.arguments().at(1) == "-s")
{
LsPaConnection(NULL).printDeviceList();
}
return 0;
}
QApplication a(argc, argv);
PaUtilRingBuffer rb;
char buffer[8 * 1024 * 16];
ring_buffer_size_t size = PaUtil_InitializeRingBuffer(&rb, 8, 1024 * 16, &buffer[0]);
Q_UNUSED(size);
PaUtil_FlushRingBuffer(&rb);
int ret = -1;
LsPaConnection connection(&rb);
Control control;
control.setPortAudioRec(&connection);
if (a.arguments().count() > 2)
{
bool ok = false;
int nr = a.arguments().at(1).toInt(&ok);
QString deviceName;
if ( ! ok )
{
deviceName = "Line 3/4 (M-Audio Delta 1010LT)[Windows WASAPI]";
}
else
{
deviceName = connection.getDeviceName(nr);
}
if (deviceName != "")
{
control.startRecording(deviceName, a.arguments().at(2));
}
ret = a.exec();
}
else
{
ThreatedServerSocket server(&control);
server.start();
ret = a.exec();
}
return ret;
}
示例11: check
static void check(const UString& dati_crl, const UString& dati_ca)
{
U_TRACE(5,"check(%p,%p)", &dati_crl, &dati_ca)
// long revoked[10];
UCrl c(dati_crl);
UCertificate ca(dati_ca);
cout << c << "\n"
<< c.isUpToDate() << "\n"
<< c.getIssuer() << "\n"
<< c.isIssued(ca) << "\n"
<< c.getVersionNumber() << "\n"
<< c.getLastUpdate() << "\n"
// << c.getRevokedSerials(revoked, 10) << "\n"
<< c.getNextUpdate();
UString encoded = c.getEncoded("PEM");
/*
UFile::writeTo("crl.encode", encoded);
U_ASSERT( dati_crl == encoded )
*/
}
示例12: pSaveBtn
C4Network2ResDlg::ListItem::ListItem(C4Network2ResDlg *pForResDlg, const C4Network2Res *pByRes)
: pSaveBtn(NULL)
{
// init by res core (2do)
iResID = pByRes->getResID();
const char *szFilename = GetFilename(pByRes->getCore().getFileName());
// get size
int iIconSize = ::GraphicsResource.TextFont.GetLineHeight();
int iWidth = pForResDlg->GetItemWidth();
int iVerticalIndent = 2;
SetBounds(C4Rect(0, 0, iWidth, iIconSize+2*iVerticalIndent));
C4GUI::ComponentAligner ca(GetContainedClientRect(), 0,iVerticalIndent);
// create subcomponents
pFileIcon = new C4GUI::Icon(ca.GetFromLeft(iIconSize), C4GUI::Ico_Resource);
pLabel = new C4GUI::Label(szFilename, iIconSize + IconLabelSpacing,iVerticalIndent, ALeft);
pProgress = NULL;
// add components
AddElement(pFileIcon); AddElement(pLabel);
// tooltip
SetToolTip(LoadResStr("IDS_DESC_RESOURCE"));
// add to listbox (will eventually get moved)
pForResDlg->AddElement(this);
// first-time update
Update(pByRes);
}
示例13: Option
C4GameOptionsList::OptionDropdown::OptionDropdown(class C4GameOptionsList *pForDlg, const char *szCaption, bool fReadOnly)
: Option(pForDlg)
{
CStdFont &rUseFont = ::GraphicsResource.TextFont;
// get size of caption label
bool fTabular = pForDlg->IsTabular();
int32_t iCaptWidth, iCaptHeight;
if (fTabular)
{
// tabular layout: Caption label width by largest caption
rUseFont.GetTextExtent(LoadResStr("IDS_NET_RUNTIMEJOIN"), iCaptWidth, iCaptHeight, true);
iCaptWidth = iCaptWidth * 5 / 4;
}
else
{
rUseFont.GetTextExtent(szCaption, iCaptWidth, iCaptHeight, true);
}
// calc total height for component
int iHorizontalMargin = 1;
int iVerticalMargin = 1;
int iComboMargin = 5;
int iSelComboHgt = C4GUI::ComboBox::GetDefaultHeight();
SetBounds(C4Rect(0, 0, pForDlg->GetItemWidth(), (!fTabular) * (iCaptHeight + iVerticalMargin*2) + iVerticalMargin*2 + iSelComboHgt));
C4GUI::ComponentAligner ca(GetContainedClientRect(), iHorizontalMargin, iVerticalMargin);
// create subcomponents
AddElement(pCaption = new C4GUI::Label(FormatString("%s:", szCaption).getData(), fTabular ? ca.GetFromLeft(iCaptWidth, iCaptHeight) : ca.GetFromTop(iCaptHeight), ALeft));
ca.ExpandLeft(-iComboMargin);
AddElement(pPrimarySubcomponent = pDropdownList = new C4GUI::ComboBox(ca.GetAll()));
pDropdownList->SetReadOnly(fReadOnly);
pDropdownList->SetComboCB(new C4GUI::ComboBox_FillCallback<C4GameOptionsList::OptionDropdown>(this, &C4GameOptionsList::OptionDropdown::OnDropdownFill, &C4GameOptionsList::OptionDropdown::OnDropdownSelChange));
// final init
InitOption(pForDlg);
}
示例14: ab
//頂点abcで作られたポリゴンから法線を計算
Vector3<float> ShadowScene::createPolygonNormal(Vector3<float> a, Vector3<float> b, Vector3<float> c) {
Vector3<float> ab( b - a );
Vector3<float> ca( c - a );
Vector3<float> normal = ab.cross(ca); //ab bcの外積
normal.normalize();//単位ベクトルにする
return normal;
}
示例15: ListItem
C4Network2ClientListBox::ClientListItem::ClientListItem(class C4Network2ClientListBox *pForDlg, int iClientID) // ctor
: ListItem(pForDlg, iClientID), pStatusIcon(nullptr), pName(nullptr), pPing(nullptr), pActivateBtn(nullptr), pKickBtn(nullptr), last_sound_time(0)
{
// get associated client
const C4Client *pClient = GetClient();
// get size
int iIconSize = ::GraphicsResource.TextFont.GetLineHeight();
if (pForDlg->IsStartup()) iIconSize *= 2;
int iWidth = pForDlg->GetItemWidth();
int iVerticalIndent = 2;
SetBounds(C4Rect(0, 0, iWidth, iIconSize+2*iVerticalIndent));
C4GUI::ComponentAligner ca(GetContainedClientRect(), 0,iVerticalIndent);
// create subcomponents
bool fIsHost = pClient && pClient->isHost();
pStatusIcon = new C4GUI::Icon(ca.GetFromLeft(iIconSize), fIsHost ? C4GUI::Ico_Host : C4GUI::Ico_Client);
StdStrBuf sNameLabel;
if (pClient)
{
if (pForDlg->IsStartup())
sNameLabel.Ref(pClient->getName());
else
sNameLabel.Format("%s:%s", pClient->getName(), pClient->getNick());
}
else
{
sNameLabel.Ref("???");
}
pName = new C4GUI::Label(sNameLabel.getData(), iIconSize + IconLabelSpacing,iVerticalIndent, ALeft);
int iPingRightPos = GetBounds().Wdt - IconLabelSpacing;
if (::Network.isHost()) iPingRightPos -= 48;
if (::Network.isHost() && pClient && !pClient->isHost())
{
// activate/deactivate and kick btns for clients at host
if (!pForDlg->IsStartup())
{
pActivateBtn = new C4GUI::CallbackButtonEx<C4Network2ClientListBox::ClientListItem, C4GUI::IconButton>(C4GUI::Ico_Active, GetToprightCornerRect(std::max(iIconSize, 16),std::max(iIconSize, 16),2,1,1), 0, this, &ClientListItem::OnButtonActivate);
fShownActive = true;
}
pKickBtn = new C4GUI::CallbackButtonEx<C4Network2ClientListBox::ClientListItem, C4GUI::IconButton>(C4GUI::Ico_Kick, GetToprightCornerRect(std::max(iIconSize, 16),std::max(iIconSize, 16),2,1,0), 0, this, &ClientListItem::OnButtonKick);
pKickBtn->SetToolTip(LoadResStrNoAmp("IDS_NET_KICKCLIENT"));
}
if (!pForDlg->IsStartup()) if (pClient && !pClient->isLocal())
{
// wait time
pPing = new C4GUI::Label("???", iPingRightPos, iVerticalIndent, ARight);
pPing->SetToolTip(LoadResStr("IDS_DESC_CONTROLWAITTIME"));
}
// add components
AddElement(pStatusIcon); AddElement(pName);
if (pPing) AddElement(pPing);
if (pActivateBtn) AddElement(pActivateBtn);
if (pKickBtn) AddElement(pKickBtn);
// add to listbox (will eventually get moved)
pForDlg->AddElement(this);
// first-time update
Update();
}