问题列表 - 第38416页

根据模板参数创建字符串

我有很多这样的类/方法:

template<typename CharT, typename TraitsT = std::char_traits<CharT> >
struct Foo
{
   std::basic_string<CharT, TraitsT> getFoo(void) const
   {
     return "Foo"; // + this->member_var1 + this->member_var2...
   }
};
Run Code Online (Sandbox Code Playgroud)

但是根据CharT,我必须使用"","",""或"U"(对于char,wchar_t,u16char_t,u32char_t).

必须使用什么语法来创建与此类模板参数无关的字符串?

c++ string templates

14
推荐指数
1
解决办法
743
查看次数

轻松触发问题

我想这对于那些使用T-SQL,尤其是触发器工作很多的人来说,这将是一个简单的问题:

我想对所有更新和对此表的插入强制执行以下约束:

  1. 如果DiscountTypeId = 1,则FlatFee不能为NULL.
  2. 如果DiscountTypeId = 2,则DiscountRate不能为null.

如果这两个条件中的任何一个在插入或更新表上失败,我想返回一个适当的错误.

触发器似乎还没有做任何事情..您可以提供必要的更改,使其按照描述执行吗?

USE [PandaVisa2008]
GO

/****** Object:  Table [dbo].[CustomerSpeed]    Script Date: 11/04/2010 15:51:10 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[CustomerSpeed](
 [CustomerSpeedId] [int] NOT NULL,
 [CustomerId] [int] NULL,
 [SpeedId] [int] NOT NULL,
 [DiscountTypeId] [int] NOT NULL,
 [FlatFee] [money] NULL,
 [DiscountRate] [decimal](3, 3) NULL,
 CONSTRAINT [PK_AgentFee] PRIMARY KEY CLUSTERED 
(USE [PandaVisa2008]

GO

/****** Object:  Trigger [dbo].[TRG_CustomerSpeed_OnInsertUpdate]    Script Date: 11/04/2010 15:38:06 ******/
SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO …
Run Code Online (Sandbox Code Playgroud)

t-sql sql-server triggers

2
推荐指数
1
解决办法
121
查看次数

Kohana 3分页

我真的迷失在考纳如何在kohana 3中工作.在Kohana 3的任何地方都有一个很好的分页例子吗?

php pagination kohana kohana-3

6
推荐指数
1
解决办法
7016
查看次数

抑制"ISO C99要求使用休息参数"

考虑以下两个宏:

#define PNORM( v, s, ... )  { \
  if( VERBOSITY_CHECK( v ) ) { \
    if( ( errno = pthread_mutex_lock(&server.output_mutex) ) ) { \
      PERROR_LOCKFREE( normal, "\tpthread_mutex_lock failed on output_mutex.\r\n" ) ; \
    } \
    fprintf( stdout, s, ## __VA_ARGS__ ) ; \
    fflush( stdout ) ; \
    if( ( errno = pthread_mutex_unlock(&server.output_mutex) ) ) { \
      PERROR_LOCKFREE( normal, "\tpthread_mutex_unlock failed on output_mutex.\r\n" ) ; \
    } \
  } \
}

#define PERROR_LOCKFREE( v, s, ... ) { \ …
Run Code Online (Sandbox Code Playgroud)

c gcc posix variadic-functions gcc-warning

10
推荐指数
1
解决办法
1万
查看次数

有INNER JOIN限制吗?

使用INNER JOIN是有限制的吗?

原始查询(工作得很好)我受到了77行的影响

    SELECT atendimento.id, atendimento.responsavel, atendimento.ocorrencia, 
           atendimento.idcontrato, cliente.nome as clinome, cliente.id as cliid, 
           atendimento.d_ini, usuario.apelido, tipos.descricao, tipos.id as tip 
      FROM atendimento 
INNER JOIN cliente ON atendimento.cliente=cliente.id 
INNER JOIN usuario ON atendimento.usuario=usuario.id 
INNER JOIN tipos ON atendimento.status=tipos.id 
     WHERE 1=1 AND (atendimento.status=10 OR atendimento.status=11) 
  ORDER BY tipos.id, atendimento.d_ini ASC
Run Code Online (Sandbox Code Playgroud)

新尝试:(不能很好地工作)它仅限于受影响的17行.除了我的查询中返回的只有17行之外,此处的结果是相同的.

    SELECT atendimento.id, atendimento.responsavel, atendimento.ocorrencia, 
           atendimento.idcontrato, atend_os.protocolo, atend_os.tecnico, 
           cliente.nome as clinome, cliente.id as cliid, atendimento.d_ini, 
           usuario.apelido, tipos.descricao, tipos.id as tip 
      FROM atendimento 
INNER JOIN atend_os ON atendimento.id=atend_os.protocolo 
INNER JOIN cliente …
Run Code Online (Sandbox Code Playgroud)

mysql sql join

0
推荐指数
1
解决办法
144
查看次数

无法摆脱Visual Studio 2010 xaml编辑器中的十字准线(放置新项目)光标

我在设计屏幕中的XAML页面内.不知怎的,我把VS2010变成了一个模式,它将光标改变为十字准线,当你点击时你将UIElement放在你点击的位置. 我无法弄清楚a)我是如何进入这种模式的,以及b)如何离开. 我希望能够单击"设计"视图中的元素并自动导航到与其关联的XAML,并且我无法返回到该模式.

有任何想法吗?

PS-我在Visual Studio Express 2010 for C#中,如果这有任何区别.

c# visual-studio-2010

17
推荐指数
1
解决办法
2726
查看次数

存储信用卡信息的替代方法

可能重复:
存储信用卡详细信息

我正在为用户可以登录和购买产品的网站创建架构.我的老板希望结账页面记住用户的信用卡信息,这样他们就不必每次都输入它,比如亚马逊.

出于各种原因,我不想将信用卡信息存储在数据库中; 我拒绝这样做.但我的老板坚持在网站上记住用户的信用卡信息.

那么,如何实现呢?它显然正在完成,除非像亚马逊这样的网站存储用户的信用卡信息并使其非常安全.

payment-processing

6
推荐指数
2
解决办法
724
查看次数

checkstyle规则,涵盖有效的Java建议

有没有人知道是否有一个检查样式规则的汇编,涵盖了Joshua Bloch在他的Effective Java书中提出的大部分建议?我知道我可以在checkstyle插件中添加自定义规则,但我想知道是否有人已经这样做并且是否愿意分享它们.:)

java checkstyle sonarqube

4
推荐指数
1
解决办法
1153
查看次数

如何在HTML表单中创建一组项目的数组

我正在尝试按照以下方式创建一个表单(我知道这不是有效的HTML,但它希望说明我尝试这样做的原因和原因):

<form method="post" action="test.php">
    <input type="text" name="teamName">
    <br />Players:
    <grouping name="players[]">
        <input type="text" name="firstName"><br />
        <input type="text" name="lastName"><br />
    </grouping>
    <input type="submit" value="submit">
</form>
Run Code Online (Sandbox Code Playgroud)

通过javascript,我会根据需要多次添加分组元素.提交表单后,我可以访问分组元素中的项目,如下所示:

foreach ($players as $player) {
    $fName = $player->firstName;
    $lName = $player->lastName;
}
Run Code Online (Sandbox Code Playgroud)

也就是说,在我开始之前,我不知道球队中有多少球员,但我知道球员的样子.我希望将这一切保留在一个屏幕上,以便用户可以在一个页面上将玩家添加到他们的团队,我希望能够将这些字段分组添加为一个组.但是,我还希望将分组存储为数组,而不是执行以下操作:

<form method="post" action="test.php">
    <input type="text" name="teamName">
    <br />Players:
    <input type="text" name="firstName[]"><br />
    <input type="text" name="lastName[]"><br />
    <input type="submit" value="submit">
</form>
Run Code Online (Sandbox Code Playgroud)

这意味着我可以遍历分组中的各个元素,但不能通过整个分组.

我有什么想法可以做到这一点?

html forms

2
推荐指数
1
解决办法
1万
查看次数

泛型类型可以用作复合组件属性标记的"类型"吗?

在我看来,复合组件的属性不允许泛型类型.这是一个简单的测试用例:

<cc:attribute name="stringList" type="java.util.List&lt;java.lang.String&gt;" />
Run Code Online (Sandbox Code Playgroud)

我得到的错误是,

java.lang.ClassNotFoundException: java.util.List<java.lang.String>
Run Code Online (Sandbox Code Playgroud)

(如果我用<和>替换<和>,我会收到错误,因为它不是有效的XHTML.)

我知道该类型的通用部分将在运行时被删除,但我希望在这里使用泛型只是为了清楚地阅读代码.那可能吗?

java generics jsf composite-component jsf-2

5
推荐指数
1
解决办法
1486
查看次数